Commit 02b105b7 by 谢中龙

修改bug

parent 03ca4cea
......@@ -56,6 +56,7 @@ wxService.page({
isAuthorization: false
}, () => {
const option = this.options || {}
const { scene } = option
if (scene) {
let idParam = decodeURIComponent(scene).split('&')[0]
......
// pages/userCenter.js
const wxService = require('../../../../utils/wxService')
const utils = require('../../../../utils/util')
wxService.page({
/**
* 页面的初始数据
......@@ -8,6 +8,7 @@ wxService.page({
data: {
query: '',
integralCouponList: [], // 积分兑换优惠券列表
userHasBaseInfo : false,
},
/**
......@@ -16,6 +17,67 @@ wxService.page({
onLoad: function (options) {
wx.hideShareMenu();
this.initIntegralCouponList();
this.userHasLogin();
},
//授权
_getUserInfo(res = {}) {
const userInfo = res.detail || {}
if (res.detail.userInfo) {
utils.getUserInfoByBtn(userInfo).then((data = {}) => {
const { token } = data
wx.setStorageSync('_accreditUserInfo', userInfo)
if (token) {
wx.setStorageSync('token', token)
} else {
wx.setStorageSync('token', '')
}
wx.setStorageSync('_baseUserInfo', data)
const baseUserInfo = wx.getStorageSync('_baseUserInfo')
// 获取当前会员是否是体验者
const { member } = baseUserInfo
const curMemberTrial = member && member.trial || false
wx.setStorageSync('isExperiencer', curMemberTrial)
this.setUserInfo()
}).catch(err => {
if (err) {
wx.showToast({
title: `会员系统异常请稍后重试!`,
icon: 'none'
})
}
})
}
},
//获取当前用户是否登录
userHasLogin(){
const baseUserInfo = wx.getStorageSync('_baseUserInfo');
if(baseUserInfo){
this.setData({
userHasBaseInfo : true
})
}
else{
this.setData({
userHasBaseInfo: false
})
}
},
setUserInfo() {
// 判断有无开卡
const userInfo = wx.getStorageSync('_baseUserInfo')
// 新用户去激活领卡
if (userInfo && userInfo.member && !userInfo.member.mobile && !userInfo.member.cardNoWeixin) {
wxService.openCard()
return false
}
// 跳转
setTimeout(() => {
this.initIntegralCouponList();
this.userHasLogin();
}, 200)
},
// 获取优惠券活动列表
......@@ -49,6 +111,26 @@ wxService.page({
},
//立即兑换优惠券
exchange(e) {
const { member } = wx.getStorageSync('_baseUserInfo');
if(!member){
wx.showToast({
title: '请先去登录',
icon : 'none'
})
return ;
}
//判断是否开卡
if(!member.cardNoWeixin){
wx.showToast({
title: '请先开卡后购买',
icon : 'none'
});
wxService.openCard()
return ;
}
wx.showLoading({
title: '领取中..',
});
......
......@@ -23,7 +23,7 @@
</view>
</view>
<view class='coupon-btn positionRe'>
<button wx:if="{{!currentHasUserInfo}}"
<button wx:if="{{!userHasBaseInfo}}"
bindgetuserinfo="_getUserInfo"
open-type='getUserInfo'
class="clear-btn positionAbs"></button>
......
// subPackage/page/pages/couponCenterInfo/couponCenterInfo.js
const wxService = require('../../../../utils/wxService')
const utils = require('../../../../utils/util')
wxService.page({
/**
......@@ -7,7 +8,9 @@ wxService.page({
*/
data: {
activityId : null,
activityInfo : {}
activityInfo : {},
userHasBaseInfo : false,
isLoading : true,
},
/**
......@@ -17,6 +20,7 @@ wxService.page({
let id = options.id;
this.data.activityId = id;
this.getACtivityInfo();
this.userHasLogin();
},
/**
......@@ -26,6 +30,66 @@ wxService.page({
},
//授权
_getUserInfo(res = {}) {
const userInfo = res.detail || {}
if (res.detail.userInfo) {
utils.getUserInfoByBtn(userInfo).then((data = {}) => {
const { token } = data
wx.setStorageSync('_accreditUserInfo', userInfo)
if (token) {
wx.setStorageSync('token', token)
} else {
wx.setStorageSync('token', '')
}
wx.setStorageSync('_baseUserInfo', data)
const baseUserInfo = wx.getStorageSync('_baseUserInfo')
// 获取当前会员是否是体验者
const { member } = baseUserInfo
const curMemberTrial = member && member.trial || false
wx.setStorageSync('isExperiencer', curMemberTrial)
this.setUserInfo()
}).catch(err => {
if (err) {
wx.showToast({
title: `会员系统异常请稍后重试!`,
icon: 'none'
})
}
})
}
},
//获取当前用户是否登录
userHasLogin(){
const baseUserInfo = wx.getStorageSync('_baseUserInfo');
if(baseUserInfo){
this.setData({
userHasBaseInfo : true
})
}
else{
this.setData({
userHasBaseInfo: false
})
}
},
setUserInfo() {
// 判断有无开卡
const userInfo = wx.getStorageSync('_baseUserInfo')
// 新用户去激活领卡
if (userInfo && userInfo.member && !userInfo.member.mobile && !userInfo.member.cardNoWeixin) {
wxService.openCard()
return false
}
// 跳转
setTimeout(() => {
this.getACtivityInfo();
this.userHasLogin();
}, 200)
},
//获取活动详情
getACtivityInfo(){
wxService.post(`/coupon/couponCenterActivity/buyer/getDetail?id=${this.data.activityId}`).then(res => {
......@@ -37,8 +101,14 @@ wxService.page({
obj.hasExpDate = arr.filter(item => item.type == 1).length > 0 ;
this.data.activityInfo = obj;
this.setData({
activityInfo: this.data.activityInfo
activityInfo: this.data.activityInfo,
});
// 定时器为了防止触点那边没有正常返回用户就点击了
setTimeout(() => {
this.setData({
isLoading : false,
})
},1000);
}
}
})
......@@ -46,9 +116,34 @@ wxService.page({
//领取优惠券
onTapGetCoupon(){
if(this.data.isLoading){
return ;
}
const { member } = wx.getStorageSync('_baseUserInfo');
if(!member){
wx.showToast({
title: '请先去登录',
icon : 'none'
})
return ;
}
//判断是否开卡
if(!member.cardNoWeixin){
wx.showToast({
title: '请先开卡后购买',
icon : 'none'
});
wxService.openCard()
return ;
}
wx.showLoading({
title: '领取中..',
});
let id = this.data.activityId;
wxService.post(`/coupon/couponCenterActivity/buyer/coupon/draw?id=${id}`).then(res => {
wx.hideLoading();
......
......@@ -2,7 +2,7 @@
<view class="coupon-info-con">
<view class="coupon-info-bg" style="background-image:url('https://img3.bigaka.com/prd/3001/202003/20200331/3001df30305c-f4fe-4c35-bd73-5d87d4882f7a.png')">
<view class="lf-coupon-Bg">
<image wx:if="{{activityInfo.listPicture}}" mode="aspectFit" src="{{activityInfo.listPicture}}"></image>
<image wx:if="{{activityInfo.listPicture}}" mode="aspectFill" src="{{activityInfo.listPicture}}"></image>
<image wx:else src='https://img3.bigaka.com/prd/3001/202003/20200331/3001649f2f08-3b4e-4b5b-97c1-30cdf646651c.png' />
</view>
<view class="rg-coupon-info">
......@@ -28,12 +28,12 @@
</view>
<!-- 按钮 -->
<view class="get-btn positionRe">
<button wx:if="{{!currentHasUserInfo}}"
<view class="get-btn positionRe {{isLoading ? 'btn-disabled' : ''}}">
<button wx:if="{{!userHasBaseInfo}}"
bindgetuserinfo="_getUserInfo"
open-type='getUserInfo'
class="clear-btn positionAbs">立即领取</button>
<view wx:else class="view-btn" bindtap="onTapGetCoupon">立即领取</view>
class="clear-btn positionAbs">{{isLoading ? '数据加载中...' : '立即领取'}}</button>
<view wx:else class="view-btn " bindtap="onTapGetCoupon">{{isLoading ? '数据加载中...' : '立即领取'}}</view>
</view>
</view>
......@@ -31,7 +31,7 @@ view{
top: 0;
width: 170rpx;
height: 100%;
padding: 15rpx;
padding: 10rpx;
}
.coupon-info-bg .lf-coupon-Bg image{
......@@ -44,12 +44,14 @@ view{
height: 100%;
padding: 15rpx;
font-size: 24rpx;
display: flex;
flex-direction: column;
justify-content: space-around;
}
.coupon-title{
font-size: 28rpx;
color: #333333;
margin-bottom: 8rpx;
font-weight: 550;
text-overflow: ellipsis;
display: -webkit-box;
......@@ -58,10 +60,13 @@ view{
overflow: hidden;
}
.btn-disabled{
opacity: 0.7;
}
.coupon-date{
font-size: 22rpx;
color: #999999;
margin-bottom: 5rpx;
}
.exp-intro{
......
......@@ -21,7 +21,7 @@ wxService.page({
onLoad: function (options) {
this.data.id = options.id;
wx.hideShareMenu();
this.userHasLogin();
this.getValueCardActivityInfo();
},
......@@ -29,7 +29,7 @@ wxService.page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.userHasLogin();
},
//获取当前用户是否登录
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment