Commit d6e9bf9b by 谢中龙

711积分换物库存校验提前

parent f713cd1f
...@@ -46,6 +46,10 @@ wxService.page({ ...@@ -46,6 +46,10 @@ wxService.page({
// this.initIntegralCouponList(); // this.initIntegralCouponList();
//获取会员积分信息 //获取会员积分信息
this.getMemberIntegrateInfo(); this.getMemberIntegrateInfo();
if (wx.getStorageSync('needReloadExchangeList')) {
wx.removeStorageSync('needReloadExchangeList');
this.initIntegralProductList();
}
}, },
//刷新积分请求 //刷新积分请求
refreshPointRequest() { refreshPointRequest() {
...@@ -109,16 +113,49 @@ wxService.page({ ...@@ -109,16 +113,49 @@ wxService.page({
else{ else{
this.data.currentTab = 'goods'; this.data.currentTab = 'goods';
} }
let integralGoodsList = data ? data : [];
integralGoodsList.forEach(item => {
item.canExchange = true;
});
this.setData({ this.setData({
integralGoodsList: data? data : [],
currentTab: this.data.currentTab currentTab: this.data.currentTab
}) });
this.findExchangeNumByIds(integralGoodsList);
} }
} }
}).finally(() => { }).finally(() => {
wx.hideLoading(); wx.hideLoading();
}) })
}, },
//查询指定积分换物活动兑换数量
findExchangeNumByIds(integralGoodsList) {
//获取ids
let ids = integralGoodsList.map(g => {
return g.id;
});
wxService.post(`/member/pointsRedemptionProductSetting/getExchangeCount`, ids).then(res => {
if(res){
let data = res.data.data ? res.data.data : null;
if (data) {
for (let k in data) {
let id = k, value = data[k];
for (let i = 0; i < integralGoodsList.length; i++) {
if (integralGoodsList[i].id == id) {
integralGoodsList[i].canExchange = integralGoodsList[i].stock > value;
}
}
}
}
}
this.setData({
integralGoodsList: integralGoodsList,
});
});
},
// 积分兑换优惠券列表 // 积分兑换优惠券列表
initIntegralCouponList() { initIntegralCouponList() {
wx.showLoading({ wx.showLoading({
...@@ -150,8 +187,15 @@ wxService.page({ ...@@ -150,8 +187,15 @@ wxService.page({
}, },
// 立即兑换物品 // 立即兑换物品
exchangeGoods(e) { exchangeGoods(e) {
const { id, point } = e.currentTarget.dataset; const { id, point, canexchange} = e.currentTarget.dataset;
const { memberId } = wx.getStorageSync('_baseUserInfo') const { memberId } = wx.getStorageSync('_baseUserInfo')
if (!canexchange) {
this.setData({
dialogStockEmpty: true
});
return;
}
//检查是不是可以兑换 //检查是不是可以兑换
wx.showLoading({ wx.showLoading({
title: '检查兑换资格中..', title: '检查兑换资格中..',
......
...@@ -94,6 +94,7 @@ ...@@ -94,6 +94,7 @@
<view class='coupon-btn-click' <view class='coupon-btn-click'
data-id="{{item.id}}" data-id="{{item.id}}"
data-point="{{item.point}}" data-point="{{item.point}}"
data-canexchange="{{item.canExchange}}"
catchtap='exchangeGoods'>立即兑换</view> catchtap='exchangeGoods'>立即兑换</view>
<view class='coupon-btn-num'>{{item.point}}积分</view> <view class='coupon-btn-num'>{{item.point}}积分</view>
</view> </view>
......
...@@ -11,7 +11,8 @@ wxService.page({ ...@@ -11,7 +11,8 @@ wxService.page({
*/ */
data: { data: {
isExchange: false, isExchange: false,
dialogUserLimit: false, dialogUserLimit : false,
dialogStockEmpty : false,
integralMallDetail: {} integralMallDetail: {}
}, },
...@@ -24,10 +25,34 @@ wxService.page({ ...@@ -24,10 +25,34 @@ wxService.page({
this.getIntegralCouponDetail(id) this.getIntegralCouponDetail(id)
}, },
//btn回调
onDialogBtnCallBack(e) {
let pages = getCurrentPages();
let index = pages.length - 1;
for (let i = 0; i < pages.length; i++) {
if (pages[i].route.indexOf('IntegralMallGoods/IntegralMallGoods') > -1) {
index = index - i;
break;
}
}
wx.navigateBack({
delta: index
});
},
//立即兑换 //立即兑换
exchange() { exchange() {
const { memberId } = wx.getStorageSync('_baseUserInfo'); const { memberId } = wx.getStorageSync('_baseUserInfo');
const id = this.data.integralMallDetail.id; const id = this.data.integralMallDetail.id;
if (!this.data.integralMallDetail.canExchange){
this.setData({
dialogStockEmpty : true,
});
return ;
}
//检查是不是可以兑换 //检查是不是可以兑换
wx.showLoading({ wx.showLoading({
title: '检查兑换资格中..', title: '检查兑换资格中..',
...@@ -57,12 +82,34 @@ wxService.page({ ...@@ -57,12 +82,34 @@ wxService.page({
if (result == 0) { if (result == 0) {
wx.hideLoading() wx.hideLoading()
data.desc = JSON.parse(data.desc) data.desc = JSON.parse(data.desc)
data.canExchange = true;
this.setData({ this.setData({
integralMallDetail: data integralMallDetail: data
},() => {
this.findExchangeNumByIds(id);
}); });
} }
}).finally(() => { }).finally(() => {
wx.hideLoading() wx.hideLoading()
}) })
},
//查询指定积分换物活动兑换数量
findExchangeNumByIds(id) {
//获取ids
let ids = [id];
wxService.post(`/member/pointsRedemptionProductSetting/getExchangeCount`, ids).then(res => {
if (res){
let data = res.data.data ? res.data.data : null;
if (data) {
let value = data[id];
this.data.integralMallDetail.canExchange = this.data.integralMallDetail.stock > value;
} }
}
this.setData({
integralMallDetail: this.data.integralMallDetail
});
});
},
}) })
\ No newline at end of file
{ {
"navigationBarTitleText": "积分换物详情", "navigationBarTitleText": "积分换物详情",
"usingComponents": { "usingComponents": {
"dialog-stock-empty": "/component/dialogStockEmpty/dialogStockEmpty",
"dialog-user-limit": "/component/dialogUserLimit/dialogUserLimit" "dialog-user-limit": "/component/dialogUserLimit/dialogUserLimit"
} }
} }
\ No newline at end of file
...@@ -27,3 +27,5 @@ ...@@ -27,3 +27,5 @@
<!--goHome--> <!--goHome-->
<go-home/> <go-home/>
<dialog-user-limit show="{{dialogUserLimit}}"/> <dialog-user-limit show="{{dialogUserLimit}}"/>
<dialog-stock-empty show="{{dialogStockEmpty}}" bind:btnClick="onDialogBtnCallBack"/>
...@@ -128,6 +128,7 @@ wxService.page({ ...@@ -128,6 +128,7 @@ wxService.page({
wx.showToast({ wx.showToast({
title: '兑换成功', title: '兑换成功',
}); });
wx.setStorageSync('needReloadExchangeList', true)
setTimeout(() => { setTimeout(() => {
wx.navigateBack({ wx.navigateBack({
......
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