Commit 30893ccab728f0153c5f521883a3e8eb3975afce
1 parent
fd282313
服务卡商品详情限购修改
Showing
1 changed file
with
30 additions
and
20 deletions
packageA/pages/goodsInfo/goodsInfo.js
... | ... | @@ -1140,27 +1140,38 @@ Page({ |
1140 | 1140 | if (th.data.sele_g.viplimited > 0 && !th.data.is_normal && th.data.prom_type == 1) { |
1141 | 1141 | var gd_buy_num = th.data.promcardbuynum; |
1142 | 1142 | |
1143 | - if(t > th.data.sele_g.goods_num) { | |
1144 | - wx.showModal({ | |
1145 | - title: '超出活动库存', | |
1146 | - }); | |
1147 | - | |
1148 | - var num = th.data.sele_g.goods_num; | |
1149 | - th.setData({goodsInputNum: num}) | |
1150 | - return false; | |
1143 | + // 如果限购数量>活动库存数量,增加数量时会先超过库存数量,此时应该提示“超出活动库存”; | |
1144 | + // 如果限购数量<=活动库存数量,增加数量时会先超过限购数量,此时应提示“超出活动限购数量” | |
1145 | + if(th.data.sele_g.viplimited > th.data.sele_g.goods_num) { | |
1146 | + | |
1147 | + // 计算还可以购买的数量:库存量 - 已购数 | |
1148 | + var num = th.data.sele_g.goods_num - gd_buy_num; | |
1149 | + if(num < 0) num = 0; | |
1150 | + if(t > num) { | |
1151 | + wx.showModal({ | |
1152 | + title: '超出活动库存', | |
1153 | + }); | |
1154 | + | |
1155 | + th.setData({goodsInputNum: num}) | |
1156 | + return false; | |
1157 | + | |
1158 | + }; | |
1151 | 1159 | |
1160 | + } else { | |
1161 | + if ((t + gd_buy_num> th.data.sele_g.viplimited) && (t<=th.data.sele_g.goods_num)) { | |
1162 | + wx.showModal({ | |
1163 | + title: '超出活动限购数量', | |
1164 | + }); | |
1165 | + | |
1166 | + var num = th.data.sele_g.viplimited - gd_buy_num; | |
1167 | + if (num <= 0) num = 1; | |
1168 | + th.setData({goodsInputNum: num}) | |
1169 | + return false; | |
1170 | + }; | |
1152 | 1171 | }; |
1153 | 1172 | |
1154 | - if ((t + gd_buy_num> th.data.sele_g.viplimited) && (t<=th.data.sele_g.goods_num)) { | |
1155 | - wx.showModal({ | |
1156 | - title: '超出活动限购数量', | |
1157 | - }); | |
1158 | - | |
1159 | - var num = th.data.sele_g.viplimited - gd_buy_num; | |
1160 | - if (num <= 0) num = 1; | |
1161 | - th.setData({goodsInputNum: num}) | |
1162 | - return false; | |
1163 | - } | |
1173 | + | |
1174 | + | |
1164 | 1175 | }; |
1165 | 1176 | |
1166 | 1177 | //--秒杀:判断商品是否超出活动限购-- |
... | ... | @@ -1193,7 +1204,6 @@ Page({ |
1193 | 1204 | } |
1194 | 1205 | |
1195 | 1206 | |
1196 | - | |
1197 | 1207 | th.setData({goodsInputNum: t}); |
1198 | 1208 | |
1199 | 1209 | }); |
... | ... | @@ -3381,7 +3391,7 @@ Page({ |
3381 | 3391 | var user_id = getApp().globalData.user_id; |
3382 | 3392 | if (!user_id) user_id = 0; |
3383 | 3393 | |
3384 | - var url = "/api/weshop/goods/listSkuFlash?store_id=" + os.stoid + "&goods_id=" + this.data.data.goods_id + "&user_id=" + user_id; | |
3394 | + var url = "/api/weshop/goods/listSkuFlash?store_id=" + os.stoid + "&goods_id=" + this.data.options.goods_id + "&user_id=" + user_id; | |
3385 | 3395 | //获取秒杀的多规格 |
3386 | 3396 | await getApp().request.promiseGet(url, {}).then(res => { |
3387 | 3397 | if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { | ... | ... |