Commit 02b105b7 by 谢中龙

修改bug

parent 03ca4cea
...@@ -56,6 +56,7 @@ wxService.page({ ...@@ -56,6 +56,7 @@ wxService.page({
isAuthorization: false isAuthorization: false
}, () => { }, () => {
const option = this.options || {} const option = this.options || {}
const { scene } = option const { scene } = option
if (scene) { if (scene) {
let idParam = decodeURIComponent(scene).split('&')[0] let idParam = decodeURIComponent(scene).split('&')[0]
......
// pages/userCenter.js // pages/userCenter.js
const wxService = require('../../../../utils/wxService') const wxService = require('../../../../utils/wxService')
const utils = require('../../../../utils/util')
wxService.page({ wxService.page({
/** /**
* 页面的初始数据 * 页面的初始数据
...@@ -8,6 +8,7 @@ wxService.page({ ...@@ -8,6 +8,7 @@ wxService.page({
data: { data: {
query: '', query: '',
integralCouponList: [], // 积分兑换优惠券列表 integralCouponList: [], // 积分兑换优惠券列表
userHasBaseInfo : false,
}, },
/** /**
...@@ -16,6 +17,67 @@ wxService.page({ ...@@ -16,6 +17,67 @@ wxService.page({
onLoad: function (options) { onLoad: function (options) {
wx.hideShareMenu(); wx.hideShareMenu();
this.initIntegralCouponList(); 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({ ...@@ -49,6 +111,26 @@ wxService.page({
}, },
//立即兑换优惠券 //立即兑换优惠券
exchange(e) { 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({ wx.showLoading({
title: '领取中..', title: '领取中..',
}); });
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
</view> </view>
</view> </view>
<view class='coupon-btn positionRe'> <view class='coupon-btn positionRe'>
<button wx:if="{{!currentHasUserInfo}}" <button wx:if="{{!userHasBaseInfo}}"
bindgetuserinfo="_getUserInfo" bindgetuserinfo="_getUserInfo"
open-type='getUserInfo' open-type='getUserInfo'
class="clear-btn positionAbs"></button> class="clear-btn positionAbs"></button>
......
// subPackage/page/pages/couponCenterInfo/couponCenterInfo.js // subPackage/page/pages/couponCenterInfo/couponCenterInfo.js
const wxService = require('../../../../utils/wxService') const wxService = require('../../../../utils/wxService')
const utils = require('../../../../utils/util')
wxService.page({ wxService.page({
/** /**
...@@ -7,7 +8,9 @@ wxService.page({ ...@@ -7,7 +8,9 @@ wxService.page({
*/ */
data: { data: {
activityId : null, activityId : null,
activityInfo : {} activityInfo : {},
userHasBaseInfo : false,
isLoading : true,
}, },
/** /**
...@@ -17,6 +20,7 @@ wxService.page({ ...@@ -17,6 +20,7 @@ wxService.page({
let id = options.id; let id = options.id;
this.data.activityId = id; this.data.activityId = id;
this.getACtivityInfo(); this.getACtivityInfo();
this.userHasLogin();
}, },
/** /**
...@@ -26,6 +30,66 @@ wxService.page({ ...@@ -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(){ getACtivityInfo(){
wxService.post(`/coupon/couponCenterActivity/buyer/getDetail?id=${this.data.activityId}`).then(res => { wxService.post(`/coupon/couponCenterActivity/buyer/getDetail?id=${this.data.activityId}`).then(res => {
...@@ -37,8 +101,14 @@ wxService.page({ ...@@ -37,8 +101,14 @@ wxService.page({
obj.hasExpDate = arr.filter(item => item.type == 1).length > 0 ; obj.hasExpDate = arr.filter(item => item.type == 1).length > 0 ;
this.data.activityInfo = obj; this.data.activityInfo = obj;
this.setData({ this.setData({
activityInfo: this.data.activityInfo activityInfo: this.data.activityInfo,
}); });
// 定时器为了防止触点那边没有正常返回用户就点击了
setTimeout(() => {
this.setData({
isLoading : false,
})
},1000);
} }
} }
}) })
...@@ -46,9 +116,34 @@ wxService.page({ ...@@ -46,9 +116,34 @@ wxService.page({
//领取优惠券 //领取优惠券
onTapGetCoupon(){ 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({ wx.showLoading({
title: '领取中..', title: '领取中..',
}); });
let id = this.data.activityId; let id = this.data.activityId;
wxService.post(`/coupon/couponCenterActivity/buyer/coupon/draw?id=${id}`).then(res => { wxService.post(`/coupon/couponCenterActivity/buyer/coupon/draw?id=${id}`).then(res => {
wx.hideLoading(); wx.hideLoading();
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<view class="coupon-info-con"> <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="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"> <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' /> <image wx:else src='https://img3.bigaka.com/prd/3001/202003/20200331/3001649f2f08-3b4e-4b5b-97c1-30cdf646651c.png' />
</view> </view>
<view class="rg-coupon-info"> <view class="rg-coupon-info">
...@@ -28,12 +28,12 @@ ...@@ -28,12 +28,12 @@
</view> </view>
<!-- 按钮 --> <!-- 按钮 -->
<view class="get-btn positionRe"> <view class="get-btn positionRe {{isLoading ? 'btn-disabled' : ''}}">
<button wx:if="{{!currentHasUserInfo}}" <button wx:if="{{!userHasBaseInfo}}"
bindgetuserinfo="_getUserInfo" bindgetuserinfo="_getUserInfo"
open-type='getUserInfo' open-type='getUserInfo'
class="clear-btn positionAbs">立即领取</button> class="clear-btn positionAbs">{{isLoading ? '数据加载中...' : '立即领取'}}</button>
<view wx:else class="view-btn" bindtap="onTapGetCoupon">立即领取</view> <view wx:else class="view-btn " bindtap="onTapGetCoupon">{{isLoading ? '数据加载中...' : '立即领取'}}</view>
</view> </view>
</view> </view>
...@@ -31,7 +31,7 @@ view{ ...@@ -31,7 +31,7 @@ view{
top: 0; top: 0;
width: 170rpx; width: 170rpx;
height: 100%; height: 100%;
padding: 15rpx; padding: 10rpx;
} }
.coupon-info-bg .lf-coupon-Bg image{ .coupon-info-bg .lf-coupon-Bg image{
...@@ -44,12 +44,14 @@ view{ ...@@ -44,12 +44,14 @@ view{
height: 100%; height: 100%;
padding: 15rpx; padding: 15rpx;
font-size: 24rpx; font-size: 24rpx;
display: flex;
flex-direction: column;
justify-content: space-around;
} }
.coupon-title{ .coupon-title{
font-size: 28rpx; font-size: 28rpx;
color: #333333; color: #333333;
margin-bottom: 8rpx;
font-weight: 550; font-weight: 550;
text-overflow: ellipsis; text-overflow: ellipsis;
display: -webkit-box; display: -webkit-box;
...@@ -58,10 +60,13 @@ view{ ...@@ -58,10 +60,13 @@ view{
overflow: hidden; overflow: hidden;
} }
.btn-disabled{
opacity: 0.7;
}
.coupon-date{ .coupon-date{
font-size: 22rpx; font-size: 22rpx;
color: #999999; color: #999999;
margin-bottom: 5rpx;
} }
.exp-intro{ .exp-intro{
......
...@@ -21,15 +21,15 @@ wxService.page({ ...@@ -21,15 +21,15 @@ wxService.page({
onLoad: function (options) { onLoad: function (options) {
this.data.id = options.id; this.data.id = options.id;
wx.hideShareMenu(); wx.hideShareMenu();
this.userHasLogin();
this.getValueCardActivityInfo(); this.getValueCardActivityInfo();
}, },
/** /**
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow: function () { 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