diff --git a/packageA/pages/goodsInfo/goodsInfo.js b/packageA/pages/goodsInfo/goodsInfo.js index ff7fbf6..314e8aa 100644 --- a/packageA/pages/goodsInfo/goodsInfo.js +++ b/packageA/pages/goodsInfo/goodsInfo.js @@ -865,23 +865,21 @@ Page({ // if(!this.data.openSpecModal_ind) { if(this.data.prom_type == 1) { + this.data.sele_g.viplimited = this.data.sele_g.buy_limit; - if(!this.data.is_normal) { + // 检查redis库存量 + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/1/" + prom_id, {}).then(res => { + if (res.data.code == 0) { + redisNum = res.data.data; + }; + }); + + if(redisNum > 0 && !this.data.is_normal) { // 输入的数量 var t = th.data.goodsInputNum; - // 检查redis库存量 - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + - os.stoid + "/1/" + prom_id, - {} - ).then(res => { - if (res.data.code == 0) { - redisNum = res.data.data; - }; - }); - - if (redisNum > 0 && t > redisNum) { + if (t > redisNum) { wx.showModal({ title: '超出活动库存', }); @@ -901,7 +899,7 @@ Page({ }); // 跳过<立即购买> 购物车 - if(action !="buy"){ + if (action !="buy") { // 输入的数量 + 购物车同款商品的数量 var maxNum = parseInt(t) + parseInt(cartGoodsNum); @@ -918,41 +916,47 @@ Page({ } - if (redisNum > 0 && maxNum > redisNum) { + if (maxNum > redisNum) { wx.showModal({ title: '超出活动库存', }); return false; } - } + } else { + // 以下为立即购买 + // 每人限购数 + th.data.sele_g.viplimited = th.data.sele_g.buy_limit; + // 已经付款的单数 + var gd_buy_num = th.data.sele_g.buy_num; - // 以下为立即购买 - // 每人限购数 - th.data.sele_g.viplimited = th.data.sele_g.buy_limit; + // 是否超出活动库存 + if (t + gd_buy_num > redisNum) { + wx.showModal({ + title: '超出活动库存', + }); + return false; + } - // 是否开启个人限购 - if (th.data.sele_g.viplimited > 0) { - // 已经付款的单数 - var gd_buy_num = th.data.sele_g.buy_num; + // 是否开启个人限购 + if (th.data.sele_g.viplimited > 0) { - if (t + gd_buy_num > th.data.sele_g.viplimited) { - wx.showModal({ - title: '超出活动限购数量', - }); - - let num = th.data.sele_g.viplimited - gd_buy_num; - if (num <= 0) num = 1; - th.setData({goodsInputNum: num}); - return false; + if (t + gd_buy_num > th.data.sele_g.viplimited) { + wx.showModal({ + title: '超出活动限购数量', + }); + + let num = th.data.sele_g.viplimited - gd_buy_num; + if (num <= 0) num = 1; + th.setData({goodsInputNum: num}); + return false; + } + + + }; } - }; - - - - }; };