Commit 38709b6662a3719006dbbc6bb4a9dc3e111e8b02

Authored by 后端研发-苏泰源
2 parents 65635003 80c80e31

Merge branch 'dev' of http://git.vipzhuang.cn/wxd/MShopWeApp into dev

custom-tab-bar/index.js
... ... @@ -12,7 +12,6 @@ Component({
12 12  
13 13 lifetimes: {
14 14 attached: function() {
15   -
16 15 var th=this;
17 16 getApp().promiseGet("/api/weshop/storeDistribut/get/"+os.stoid,{}).then(rs=>{
18 17 var dis=rs.data.data;
... ... @@ -99,7 +98,7 @@ Component({
99 98 //设置自定义页面的列表
100 99 set_list:function(data){
101 100 var itemList = data.data;
102   - itemList = JSON.parse(itemList);
  101 + itemList = JSON.parse(itemList);
103 102 this.setData({
104 103 list:itemList,
105 104 backgroundColor: data.bkcolor,
... ...
packageA/pages/cart2_ser/cart2_ser.js
... ... @@ -477,16 +477,34 @@ Page({
477 477 getApp().showWarning("未找到门店");
478 478 return false;
479 479 }
480   - var goods = {
481   - 'card_id': gg.service_id,
482   - 'itemid': gg.erpItemID,
483   - 'qty': gg.goods_num,
484   - 'price': gg.money,
485   - 'pickup_id': gg.pick_id,
486   - 'pickup_keyid': list[i].keyid,
487   - 'prom_type': gg.prom_type, //促销活动类型
488   - 'prom_id': gg.prom_id, //促销活动id
489   - };
  480 +
  481 +
  482 + if (gg.prom_type == 1 && gg.is_pd_normal == 0) {
  483 + // 秒杀活动购买
  484 + var goods = {
  485 + 'card_id': gg.service_id,
  486 + 'itemid': gg.erpItemID,
  487 + 'qty': gg.goods_num,
  488 + 'price': gg.money,
  489 + 'pickup_id': gg.pick_id,
  490 + 'pickup_keyid': list[i].keyid,
  491 + 'prom_type': gg.prom_type, //促销活动类型
  492 + 'prom_id': gg.prom_id, //促销活动id
  493 + };
  494 + } else {
  495 + // 普通购买
  496 + var goods = {
  497 + 'card_id': gg.service_id,
  498 + 'itemid': gg.erpItemID,
  499 + 'qty': gg.goods_num,
  500 + 'price': gg.money,
  501 + 'pickup_id': gg.pick_id,
  502 + 'pickup_keyid': list[i].keyid,
  503 + };
  504 + }
  505 +
  506 +
  507 +
490 508 //--导购分享过来的id--
491 509 if (gg.guide_id) {
492 510 goods.guide_id = gg.guide_id;
... ...
packageA/pages/details_serviceCard/details_serviceCard.js
... ... @@ -228,7 +228,7 @@ Page({
228 228  
229 229  
230 230 // 再来一单
231   - buy2(t) {
  231 + buy2: async function(t) {
232 232 let details = this.data.details;
233 233 var th = this;
234 234 var ind = 1; // 1:加入购物车
... ... @@ -236,7 +236,7 @@ Page({
236 236 // var action= t.currentTarget.dataset.action;
237 237 var action = 'add'; //
238 238 // if(!ind) ind = t.currentTarget.dataset.openspecmodal_ind;
239   -
  239 + var user_id = getApp().globalData.user_id;
240 240 th.setData({
241 241 open_ind_store: ind
242 242 });
... ... @@ -261,95 +261,172 @@ Page({
261 261 // th.buyNow(newd);
262 262 } else {
263 263  
264   - var newd = {
265   - // service_id: th.data.data.id,
266   - // service_sn:th.data.data.service_sn,
267   - // service_name:th.data.data.goods_name,
268   - // goods_num: th.data.goodsInputNum,
269   - // pick_id: th.data.sto_sele_id,
270   - // user_id:oo.user_id,
271   - // store_id:os.stoid,
272   - // money:th.data.data.shop_price,
273   -
274   - service_id: details.list[0].card_id,
275   - service_sn: details.list[0].service_sn,
276   - service_name: details.list[0].service_name,
277   - goods_num: details.list[0].qty,
278   - pick_id: details.list[0].pickup_id,
279   - user_id: this.data.userInfo.user_id,
280   - store_id: app.globalData.setting.stoid,
281   - money: details.list[0].price,
282   - };
283   - if (getApp().globalData.guide_id) {
284   - newd['guide_id'] = getApp().globalData.guide_id;
285   - newd['guide_type'] = 0;
286   - };
287   - // 秒杀:单独购买的情况下,加入购物车显示的是零售价,否则显示秒杀活动价
288   - if(details.list[0].prom_type == 1) {
289   - newd['prom_type'] = details.list[0].prom_type;
290   - newd['prom_id'] = details.list[0].prom_id;
291   - // if(th.data.openSpecModal_flash_normal) {
292   - // newd['money'] = th.data.data.shop_price;
293   - // newd['is_pd_normal'] = 1;
294   - // } else {
295   - // newd['money'] = th.data.prom_price;
296   - // };
297   - };
298   -
  264 + var len = details.list.length;
  265 + // 底导航购物车红点显示的数量
  266 + var c_num = 0;
  267 + // 多商品
  268 + for (let i = 0; i < len; i++) {
  269 +
  270 + var newd = {
  271 + // service_id: th.data.data.id,
  272 + // service_sn:th.data.data.service_sn,
  273 + // service_name:th.data.data.goods_name,
  274 + // goods_num: th.data.goodsInputNum,
  275 + // pick_id: th.data.sto_sele_id,
  276 + // user_id:oo.user_id,
  277 + // store_id:os.stoid,
  278 + // money:th.data.data.shop_price,
  279 +
  280 + service_id: details.list[i].card_id,
  281 + service_sn: details.list[i].service_sn,
  282 + service_name: details.list[i].service_name,
  283 + goods_num: details.list[i].qty,
  284 + pick_id: details.list[i].pickup_id,
  285 + user_id: user_id,
  286 + store_id: app.globalData.setting.stoid,
  287 + money: details.list[i].price,
  288 + };
  289 + if (getApp().globalData.guide_id) {
  290 + newd['guide_id'] = getApp().globalData.guide_id;
  291 + newd['guide_type'] = 0;
  292 + };
  293 + // 秒杀:单独购买的情况下,加入购物车显示的是零售价,否则显示秒杀活动价
  294 + if(details.list[i].prom_type == 1) {
  295 + newd['prom_type'] = details.list[i].prom_type;
  296 + newd['prom_id'] = details.list[i].prom_id;
  297 + };
299 298  
300   - //----先看会员在购物车中是否加入了该商品-----
301   - app.request.get("/api/weshop/cartService/page", {
302   - data: {
303   - store_id: app.globalData.setting.stoid,
304   - user_id: this.data.userInfo.user_id,
305   - service_id: details.list[0].card_id,
306   - pick_id: details.list[0].pickup_id,
307   - },
308   - success: function(re) {
309   -
310   - //-------如果购物车中有相关的数据---------
311   - if (re.data.data.total > 0) {
312   - var item = re.data.data.pageData[0];
313   - var updata = {
314   - id: item.id,
315   - goods_num: details.list[0].qty + item.goods_num,
316   - money: details.list[0].price,
317   - store_id: app.globalData.setting.stoid,
318   - };
  299 + var prom_id = details.list[i].prom_id > 0 ? details.list[i].prom_id : 0;
  300 + var card_id = details.list[i].card_id;
  301 + var prom_type = details.list[i].prom_type > 0 ? details.list[i].prom_type : 0;
  302 + var is_pd_normal = details.list[i].is_pd_normal;
  303 + // 库存
  304 + var redisNums = 0;
  305 + // 限购数
  306 + var limitNum = 0;
  307 + // 已购买数量
  308 + var boughtNum = 0;
  309 +
  310 + // 秒杀活动中购买
  311 + if (prom_type == 1 && !is_pd_normal) {
  312 +
  313 + // 获取已购数量
  314 + await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum?store_id="+os.stoid+"&user_id="+getApp().globalData.user_id+"&card_id="+card_id+"&prom_type="+prom_type+"&prom_id="+prom_id, {
  315 + }).then(res => {
  316 + boughtNum = !res.data.data.promcardbuynum ? 0 : res.data.data.promcardbuynum;
  317 + });
  318 +
  319 + // 获取库存
  320 + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/1/" + prom_id, {}).then(res => {
  321 + if (res.data.code == 0) {
  322 + redisNums = !res.data.data ? 0 : res.data.data;
  323 + };
  324 + });
319 325  
320   - if (getApp().globalData.guide_id) {
321   - updata['guide_id'] = getApp().globalData.guide_id;
322   - updata['guide_type'] = 1;
323   - }
324   - getApp().request.put("/api/weshop/cartService/update", {
325   - data: updata,
326   - success: function(t) {
327   - // getApp().my_warnning('加入购物车成功', 1, th, 450);
328   - var c_num = th.data.cartGoodsNum + th.data.goodsInputNum;
329   - th.setData({
330   - cartGoodsNum: c_num
  326 + // 获取限购数
  327 + var is_end = 1;
  328 + await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + prom_id, {}).then(res => {
  329 + if (res.data.code == 0) {
  330 + is_end = res.data.data.is_end;
  331 + limitNum = res.data.data.buy_limit;
  332 + }
  333 + });
  334 + // 判断活动是否结束
  335 + if (is_end == 1) {
  336 + wx.showModal({
  337 + title: details.list[i].service_name + '\n\t活动已经结束',
331 338 });
332   - app.goto('/pages/cart/cart/cart');
333   - // th.closeSpecModal();
  339 + return false;
334 340 }
335   - });
336   - } else {
337 341  
338   - getApp().request.post("/api/weshop/cartService/save", {
339   - data: newd,
340   - success: function(t) {
341   - // getApp().my_warnning('加入购物车成功', 1, th, 450);
342   - var c_num = th.data.cartGoodsNum + th.data.goodsInputNum;
343   - th.setData({
344   - cartGoodsNum: c_num
  342 +
  343 + var snum = limitNum - boughtNum;
  344 + if (snum <= 0) {
  345 + wx.showModal({
  346 + title: '超出活动限购数量',
  347 + });
  348 + return false;
  349 + }
  350 +
  351 + }
  352 +
  353 +
  354 + //----先看会员在购物车中是否加入了该商品-----
  355 + app.request.get("/api/weshop/cartService/page", {
  356 + data: {
  357 + store_id: app.globalData.setting.stoid,
  358 + user_id: user_id,
  359 + service_id: details.list[i].card_id,
  360 + pick_id: details.list[i].pickup_id,
  361 + },
  362 + success: function(re) {
  363 + //-------如果购物车中有相关的数据---------
  364 + if (re.data.data.total > 0) {
  365 + var item = re.data.data.pageData[0];
  366 + var totalNum = details.list[i].qty + item.goods_num;
  367 +
  368 + if (prom_type == 1 && !is_pd_normal) {
  369 + // 秒杀购物车购买 修正数量 剩余购买数量
  370 + var snum = limitNum - boughtNum;
  371 +
  372 + if (totalNum >= redisNums){
  373 + if (redisNums > snum) {
  374 + totalNum = snum;
  375 + } else {
  376 + totalNum = redisNums;
  377 + }
  378 + } else {
  379 + if (totalNum > snum)
  380 + totalNum = snum;
  381 + }
  382 + }
  383 +
  384 + var updata = {
  385 + id: item.id,
  386 + goods_num: totalNum,
  387 + money: details.list[i].price,
  388 + store_id: app.globalData.setting.stoid,
  389 + };
  390 +
  391 + if (getApp().globalData.guide_id) {
  392 + updata['guide_id'] = getApp().globalData.guide_id;
  393 + updata['guide_type'] = 1;
  394 + }
  395 +
  396 + getApp().request.put("/api/weshop/cartService/update", {
  397 + data: updata,
  398 + success: function(t) {
  399 + // getApp().my_warnning('加入购物车成功', 1, th, 450);
  400 + c_num += th.data.cartGoodsNum + th.data.goodsInputNum;
  401 + th.setData({
  402 + cartGoodsNum: c_num
  403 + });
  404 +
  405 + // th.closeSpecModal();
  406 + }
  407 + });
  408 +
  409 +
  410 + } else {
  411 +
  412 + getApp().request.post("/api/weshop/cartService/save", {
  413 + data: newd,
  414 + success: function(t) {
  415 + // getApp().my_warnning('加入购物车成功', 1, th, 450);
  416 + c_num += th.data.cartGoodsNum + th.data.goodsInputNum;
  417 + th.setData({
  418 + cartGoodsNum: c_num
  419 + });
  420 +
  421 + // th.closeSpecModal();
  422 + }
345 423 });
346   - app.goto('/pages/cart/cart/cart');
347   - // th.closeSpecModal();
348 424 }
349   - });
350   - }
351   - }
352   - });
  425 + }
  426 + });
  427 +
  428 + }
  429 + app.goto('/pages/cart/cart/cart');
353 430  
354 431 }
355 432 },
... ...
packageA/pages/goodsInfo/goodsInfo.js
... ... @@ -447,7 +447,7 @@ Page({
447 447 sto_sele_name: e.pickup_name,
448 448 sto_sele_id: e.pickup_id,
449 449 sto_sele_distr: e.distr_type,
450   - sto_sele_keyid:e.keyid,
  450 + sto_sele_keyid:e.keyid,
451 451 })
452 452 }
453 453 }
... ... @@ -562,6 +562,9 @@ Page({
562 562 // <---- 秒杀
563 563  
564 564  
  565 +
  566 +
  567 +
565 568  
566 569  
567 570  
... ... @@ -826,21 +829,7 @@ Page({
826 829 });
827 830 },
828 831  
829   - //获取redis中的数量
830   - async getactLen(func) {
831   - var r_num = 0,
832   - prom_type = this.data.prom_type,
833   - prom_id = this.data.prom_id;
834   - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, {
835   - 1: 1
836   - }).then(res => {
837   - var em = res;
838   - if (em.data.code == 0) {
839   - r_num = em.data.data;
840   - }
841   - })
842   - func(r_num);
843   - },
  832 +
844 833  
845 834 //------------加入购物车--------------
846 835 addCart: async function(t) {
... ... @@ -848,8 +837,7 @@ Page({
848 837 var ind = t.currentTarget.dataset.openSpecModal_ind;
849 838 var action= t.currentTarget.dataset.action;
850 839 if(!ind) ind = t.currentTarget.dataset.openspecmodal_ind;
851   - // 活动ID
852   - var prom_id = th.data.prom_id;
  840 +
853 841 th.setData({
854 842 open_ind_store: ind
855 843 });
... ... @@ -859,145 +847,96 @@ Page({
859 847 return false;
860 848 };
861 849  
  850 + // 库存
  851 + var redisNums = 0;
  852 + // 限购数
  853 + var limitNum = 0;
  854 + // 已购买数量
  855 + var boughtNum = 0;
862 856  
863   - if(this.data.prom_type == 1) {
864   -
865   - this.data.sele_g.viplimited = this.data.sele_g.buy_limit;
866   -
867   - // 每人限购数
868   - th.data.sele_g.viplimited = th.data.sele_g.buy_limit;
869   -
870   - // 已经付款的单数
871   - var gd_buy_num = !th.data.sele_g.buy_num ? 0 : th.data.sele_g.buy_num;
872   -
873   - // 检查redis库存量
874   - var redisNum = 0;
875   - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/1/" + prom_id, {}).then(res => {
876   - if (res.data.code == 0) {
877   - redisNum = !res.data.data ? 0 : res.data.data;
878   - };
879   - });
880   -
881   - // 获取购物车同款数量 判断是否超库存
882   - var cartGoodsNum = 0;
883   - await getApp().request.promiseGet("/api/weshop/cartService/page?store_id="+os.stoid+"&user_id="+oo.user_id+"&service_id="+th.data.data.id+"&pick_id="+th.data.sto_sele_id,
884   - { }).then(res => {
885   - if (res.data.data.pageData.length > 0) {
886   - const tmpObj = res.data.data.pageData[0];
887   - cartGoodsNum = !tmpObj.goods_num ? 0 : tmpObj.goods_num;
888   - }
889   -
890   - });
891   -
892   - // 有库存的情况下,走秒杀活动流程 否则 走正常购买流程
893   - // 没有库存,已抢光的情况下,走正常购买流程
894   - if(redisNum > 0 && !this.data.is_normal) {
895   - // 输入的数量
896   - var t = th.data.goodsInputNum;
897   -
898   - if (t > redisNum) {
899   - wx.showToast({
  857 + // 秒杀活动
  858 + if(this.data.prom_type == 1) {
  859 + // 如果是秒杀活动下的单独购买,is_normal为1
  860 + if(this.data.openSpecModal_flash_normal) this.data.is_normal = 1;
  861 +
  862 + if(!this.data.is_normal) {// 秒杀购买
  863 +
  864 + // 获取redis当前可以购买的数量
  865 + // 如果数量为0,设置和显示已抢光
  866 + // 否则,进一步判断是否超出限购或超出库存
  867 + await this.getactLen().then(async function(res) {
  868 + redisNums = res;
  869 + let curNum = th.data.goodsInputNum;
  870 + // res: redis可购买数量
  871 + console.log('当前可以购买的数量:', res);
  872 + if(res <= 0) {
  873 + // 可购买数量<=0, 设置和显示已抢光
  874 + th.setData({
  875 + prom_r_null: 1,
  876 + });
  877 + wx.showModal({
  878 + title: '超出活动库存',
  879 + });
  880 + return false;
  881 + } else {
  882 + // 可购买数量>0
  883 + // 计算自己还可以购买的数量
  884 + // 自己还可购买的数量c = 每人活动限购数量a - 自己已经购买的数量b
  885 + // 如果限购数量a>redis可购买数量d,当增加数量t>d, 提示超出库存
  886 + // 如果限购数量a<=redis可购买数量d, 当增加数量t>a,提示超出限购
  887 + let actInfo = th.data.sele_g;
  888 + await th.get_buy_num2().then(function (data) {
  889 + let limited = actInfo.buy_limit; // 限购数量a
  890 + let promcardbuynum = data.data.data.promcardbuynum;
  891 + let buyedNum = promcardbuynum; // 自己已经购买的数量b
  892 + let canBuyNum = limited - buyedNum; // 自己还可购买的数量c
  893 + limitNum = limited;
  894 + boughtNum = buyedNum;
  895 +
  896 + if(canBuyNum <= 0) {
  897 + canBuyNum = 0;
  898 + };
  899 +
  900 + if(canBuyNum > res) {
  901 + if(curNum > res) { // t当前增减的数量
  902 + wx.showModal({
900 903 title: '超出活动库存',
901   - icon: 'none'
902   - });
903   -
904   - // 开启限购
905   - if (th.data.sele_g.viplimited > 0) {
906   -
907   - let num = th.data.sele_g.viplimited - gd_buy_num;
908   - if (action !="buy") {
909   - // 购物车
910   - if (num > redisNum) {
911   - th.setData({goodsInputNum: redisNum - cartGoodsNum < 0 ? 0 : redisNum - cartGoodsNum});
912   - } else {
913   - th.setData({goodsInputNum: num - cartGoodsNum < 0 ? 0 : num - cartGoodsNum});
914   - }
915   - } else {
916   - // 立即购买
917   - if (num > redisNum) {
918   - th.setData({goodsInputNum: redisNum});
919   - } else {
920   - th.setData({goodsInputNum: num});
921   - }
922   - }
923   -
924   -
925   - } else {
926   - th.setData({goodsInputNum: redisNum});
927   - }
928   -
929   - return false;
930   - }
931   -
  904 + });
  905 + th.setData({
  906 + goodsInputNum: res,
  907 + });
  908 + return false;
  909 + };
  910 + };
932 911  
933   -
934   - // 跳过<立即购买> 购物车
935   - if (action !="buy") {
936   -
937   - // 输入的数量 + 购物车同款商品的数量
938   - var maxNum = parseInt(t) + parseInt(cartGoodsNum);
939   -
940   - // 是否开启个人限购
941   - if (th.data.sele_g.viplimited > 0) {
942   -
943   - if (maxNum + gd_buy_num > th.data.sele_g.buy_limit) {
944   - wx.showToast({
945   - title: '超出活动限购数量',
946   - icon: 'none'
947   - });
948   -
949   - // 可购买数量
950   - let num = th.data.sele_g.viplimited - gd_buy_num - cartGoodsNum;
951   - th.setData({goodsInputNum: num});
952   - return false;
953   - }
954   -
955   - }
956   -
957   - if (maxNum > redisNum) {
958   - wx.showToast({
959   - title: '超出活动库存',
960   - icon: 'none'
  912 + if(canBuyNum <= res) {
  913 + if(curNum > canBuyNum) {
  914 + wx.showModal({
  915 + title: '超出限购数量',
  916 + });
  917 + th.setData({
  918 + goodsInputNum: canBuyNum,
961 919 });
962   - // 可购买数量
963   - let num = redisNum - cartGoodsNum;
964   - th.setData({goodsInputNum: num});
965 920 return false;
966   - }
967   -
968   - } else {
969   - // 以下为立即购买
970   - // 是否开启个人限购
971   - if (th.data.sele_g.viplimited > 0) {
972   -
973   - if (t + gd_buy_num > th.data.sele_g.viplimited) {
974   - wx.showToast({
975   - title: '超出活动限购数量',
976   - icon: 'none'
977   - });
978   -
979   - let num = th.data.sele_g.viplimited - gd_buy_num;
980   - if (num > redisNum) {
981   - th.setData({goodsInputNum: redisNum});
982   - } else {
983   - th.setData({goodsInputNum: num});
984   - }
985   - return false;
986   - }
987   -
988   -
989 921 };
990   -
991   - }
992   -
  922 + };
  923 +
  924 +
  925 + });
  926 +
  927 +
  928 +
993 929 };
  930 + });
  931 +
994 932 };
995 933  
996 934  
  935 + };
997 936  
998 937  
999 938  
1000   - if(action=="buy"){ // 立即购买
  939 + if(action=="buy"){
1001 940 //--------------此时操作的数据------------
1002 941 var newd = {
1003 942 id: th.data.data.id,
... ... @@ -1019,23 +958,10 @@ Page({
1019 958 newd['prom_type'] = 0;
1020 959 newd['prom_price'] = this.data.data.shop_price;
1021 960 };
1022   -
1023   - // 判断是否为0库存的情况
1024   - var tmpRedisNum = 0;
1025   - // 检查redis库存量
1026   - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/1/" + prom_id, {}).then(res => {
1027   - if (res.data.code == 0) {
1028   - tmpRedisNum = res.data.data;
1029   - };
1030   - });
1031   - if(this.data.prom_type == 1 && tmpRedisNum == 0) {
1032   - newd['prom_type'] = 0;
1033   - newd['prom_price'] = this.data.data.shop_price;
1034   - };
1035 961  
1036 962 // console.log('newd++++++++', newd);
1037 963 th.buyNow(newd);
1038   - } else { // 购物车
  964 + } else {
1039 965  
1040 966 var newd = {
1041 967 service_id: th.data.data.id,
... ... @@ -1062,19 +988,7 @@ Page({
1062 988 newd['money'] = th.data.prom_price;
1063 989 };
1064 990 };
1065   -
1066   - // 判断是否为0库存的情况
1067   - var tmpRedisNum = 0;
1068   - // 检查redis库存量
1069   - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/1/" + prom_id, {}).then(res => {
1070   - if (res.data.code == 0) {
1071   - tmpRedisNum = res.data.data;
1072   - };
1073   - });
1074   - if(th.data.options.prom_type == 1 && tmpRedisNum == 0) {
1075   - newd['prom_type'] = 0;
1076   - newd['money'] = th.data.data.shop_price;
1077   - };
  991 +
1078 992  
1079 993 //----先看会员在购物车中是否加入了该商品-----
1080 994 getApp().request.get("/api/weshop/cartService/page", {
... ... @@ -1082,16 +996,92 @@ Page({
1082 996 store_id: os.stoid,
1083 997 user_id: oo.user_id,
1084 998 service_id: th.data.data.id,
1085   - pick_id: th.data.sto_sele_id,
1086 999 },
1087 1000 success: function(re) {
1088   -
1089   - //-------如果购物车中有相关的数据---------
  1001 + //-------如果购物车中有相关的数据---------
1090 1002 if (re.data.data.total > 0) {
1091   - var item = re.data.data.pageData[0];
  1003 + var item = null;
  1004 + // 多门店问题
  1005 + var cartGoodsNum = 0;
  1006 + const tmpObj = re.data.data.pageData;
  1007 + for (let i = 0; i < tmpObj.length; i++) {
  1008 + if (th.data.sto_sele_id != tmpObj[i].pick_id) {
  1009 + cartGoodsNum += parseInt(tmpObj[i].goods_num);
  1010 + } else {
  1011 + item = tmpObj[i];
  1012 + }
  1013 + }
  1014 + // 当前门店同类商品还没加入到购物车 但是有其他门店的同类商品
  1015 + if (th.data.prom_type == 1 && !th.data.is_normal && !item) {
  1016 +
  1017 + // 秒杀购物车购买 修正数量
  1018 + var snum = limitNum - boughtNum;
  1019 + if (snum <= 0) {
  1020 + wx.showModal({
  1021 + title: '超出限购数量',
  1022 + });
  1023 + return false;
  1024 + }
  1025 +
  1026 + var cSnum = snum- cartGoodsNum <= 0 ? 0 : snum- cartGoodsNum;
  1027 + var cRedisNums = redisNums- cartGoodsNum <= 0 ? 0 : redisNums- cartGoodsNum;
  1028 +
  1029 + if (newd['goods_num'] >= redisNums){
  1030 + if (redisNums > snum) {
  1031 + newd['goods_num'] = cSnum;
  1032 + } else {
  1033 + newd['goods_num'] = cRedisNums;
  1034 + }
  1035 + } else {
  1036 + if (newd['goods_num'] > snum) newd['goods_num'] = cSnum;
  1037 + }
  1038 +
  1039 + if (newd['goods_num'] <= 0) {
  1040 + getApp().my_warnning('加入购物车成功', 1, th, 450);
  1041 + th.closeSpecModal();
  1042 + return false;
  1043 + }
  1044 + getApp().request.post("/api/weshop/cartService/save", {
  1045 + data: newd,
  1046 + success: function(t) {
  1047 + getApp().my_warnning('加入购物车成功', 1, th, 450);
  1048 + var c_num = th.data.cartGoodsNum + th.data.goodsInputNum;
  1049 + th.setData({
  1050 + cartGoodsNum: c_num
  1051 + });
  1052 + th.closeSpecModal();
  1053 + }
  1054 + });
  1055 + return false;
  1056 + }
  1057 +
  1058 + // 以下为当前门店同类商品已经加入到购物车
  1059 + var totalNum = th.data.goodsInputNum + item.goods_num;
  1060 +
  1061 + // 秒杀购物车购买 修正数量
  1062 + if (th.data.prom_type == 1 && !th.data.is_normal) {
  1063 + var snum = limitNum - boughtNum;
  1064 + if (snum <= 0) {
  1065 + wx.showModal({
  1066 + title: '超出限购数量',
  1067 + });
  1068 + return false;
  1069 + }
  1070 + if (totalNum >= redisNums){
  1071 + if (redisNums > snum) {
  1072 + totalNum = snum- cartGoodsNum;
  1073 + } else {
  1074 + totalNum = redisNums- cartGoodsNum;
  1075 + }
  1076 + } else {
  1077 + if (totalNum > snum)
  1078 + totalNum = snum- cartGoodsNum;
  1079 + }
  1080 + }
  1081 +
1092 1082 var updata = {
1093 1083 id: item.id,
1094   - goods_num: th.data.goodsInputNum + item.goods_num,
  1084 + goods_num: totalNum,
1095 1085 money: th.data.data.shop_price,
1096 1086 store_id: os.stoid,
1097 1087 };
... ... @@ -1124,7 +1114,6 @@ Page({
1124 1114 }
1125 1115 });
1126 1116 } else {
1127   -
1128 1117 getApp().request.post("/api/weshop/cartService/save", {
1129 1118 data: newd,
1130 1119 success: function(t) {
... ... @@ -1171,142 +1160,121 @@ Page({
1171 1160 },
1172 1161  
1173 1162 //------检查数量是不是超出限购------
1174   - checkCartNum: function(t) {
  1163 + checkCartNum: async function(t) {
  1164 + var th = this;
1175 1165  
1176   - if(this.data.prom_type != 1) {
1177   - this.setData({goodsInputNum: t});
1178   - return false;
  1166 + if(!th.data.def_pick_store) {
  1167 + wx.showModal({title: '请选择门店',});
  1168 + return false;
1179 1169 };
1180 1170  
1181   - var th = this;
1182   -
1183   - // if(this.data.prom_act.is_shop_buy && this.data.options.prom_type != 1) {
1184   -
1185   - if(t == 0) return false;
1186   - // th.setData({goodsInputNum:t});
  1171 + // 非秒杀活动
  1172 + if(this.data.prom_type != 1) {
  1173 + this.setData({
  1174 + goodsInputNum: t,
  1175 + });
  1176 + };
1187 1177  
1188   - // if(this.data.options.prom_type == 1 && !this.data.openSpecModal_flash_normal) {
1189   -
1190   - this.get_buy_num(this.data.sele_g, async function () {
1191   - th.data.sele_g.viplimited = th.data.sele_g.buy_limit;
1192   -
1193   - //--判断商品是否超出限购--
1194   - // if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) {
1195   - // if(!th.data.prom_act.is_shop_buy) {
1196   -
1197   - // if (th.data.sele_g.viplimited > 0) {
1198   - // var gd_buy_num = th.data.sele_g.buy_num;
1199   -
1200   - // if (t + gd_buy_num> th.data.sele_g.viplimited) {
1201   - // wx.showModal({
1202   - // title: '超出商品限购',
1203   - // });
1204   -
1205   - // var num = th.data.sele_g.viplimited - gd_buy_num;
1206   - // if (num <= 0) num = 1;
1207   - // th.setData({goodsInputNum: num})
1208   - // return false;
1209   - // }
1210   - // };
1211   -
1212   -
1213   - // 单独购买
1214   - if(th.data.openSpecModal_flash_normal) th.data.is_normal = 1;
1215   -
1216   - // 秒杀:判断活动是否抢光
1217   - if (th.data.sele_g.prom_type == 1 && !th.data.is_normal) {
1218   - var redis_num = 0;
1219   - //------判断活动是否抢光-----
1220   - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
1221   - os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, {
1222   - 1: 1
1223   - }).then(res => {
1224   - redis_num = res.data.data;
  1178 + // 秒杀活动
  1179 + if(this.data.prom_type == 1) {
  1180 + // 如果是秒杀活动下的单独购买,is_normal为1
  1181 + if(this.data.openSpecModal_flash_normal) this.data.is_normal = 1;
  1182 +
  1183 + if(this.data.is_normal) {// 单独购买
  1184 + this.setData({
  1185 + goodsInputNum: t,
  1186 + });
  1187 + } else {// 秒杀购买
  1188 +
  1189 + // 获取redis当前可以购买的数量
  1190 + // 如果数量为0,设置和显示已抢光
  1191 + // 否则,进一步判断是否超出限购或超出库存
  1192 + await this.getactLen().then(async function(res) {
  1193 + // res: redis可购买数量
  1194 + console.log('当前可以购买的数量:', res);
  1195 + if(res <= 0) {
  1196 + // 可购买数量<=0, 设置和显示已抢光
  1197 + th.setData({
  1198 + prom_r_null: 1,
  1199 + });
  1200 + } else {
  1201 + // 可购买数量>0
  1202 + // 计算自己还可以购买的数量
  1203 + // 自己还可购买的数量c = 每人活动限购数量a - 自己已经购买的数量b
  1204 + // 如果限购数量a>redis可购买数量d,当增加数量t>d, 提示超出库存
  1205 + // 如果限购数量a<=redis可购买数量d, 当增加数量t>a,提示超出限购
  1206 + let actInfo = th.data.sele_g;
  1207 + await th.get_buy_num2().then(function (data) {
  1208 + let limited = actInfo.buy_limit; // 限购数量a
  1209 + let promcardbuynum = data.data.data.promcardbuynum;
  1210 + let buyedNum = promcardbuynum; // 自己已经购买的数量b
  1211 + let canBuyNum = limited - buyedNum; // 自己还可购买的数量c
  1212 +
  1213 + if(canBuyNum <= 0) {
  1214 + canBuyNum = 0;
  1215 + };
  1216 +
  1217 + if(limited > res) {
  1218 + if(t > res) { // t当前增减的数量
  1219 + wx.showModal({
  1220 + title: '超出活动库存',
1225 1221 });
1226   -
1227   - if (t > redis_num) {
1228   - wx.showToast({
1229   - // title: '超出商品活动库存',
1230   - title: '超出活动库存',
1231   - icon: 'none',
1232   - });
1233   - th.setData({goodsInputNum: redis_num})
1234   - return false;
1235   - }
  1222 + th.setData({
  1223 + goodsInputNum: res,
  1224 + });
  1225 + return false;
1236 1226 };
1237   -
1238   - //--秒杀:判断商品是否超出活动限购--
1239   - if (th.data.sele_g.viplimited > 0 && !th.data.is_normal && th.data.prom_type == 1) {
1240   - var gd_buy_num = th.data.promcardbuynum;
1241   -
1242   - // 如果限购数量>活动库存数量,增加数量时会先超过库存数量,此时应该提示“超出活动库存”;
1243   - // 如果限购数量<=活动库存数量,增加数量时会先超过限购数量,此时应提示“超出活动限购数量”
1244   - if(th.data.sele_g.viplimited > th.data.sele_g.goods_num) {
1245   -
1246   - // 计算还可以购买的数量:库存量 - 已购数
1247   - var num = th.data.sele_g.goods_num - gd_buy_num;
1248   - if(num < 0) num = 0;
1249   - if(t > num) {
1250   - wx.showToast({
1251   - title: '超出活动库存',
1252   - icon: 'none',
1253   - });
1254   -
1255   - th.setData({goodsInputNum: num})
1256   - return false;
1257   -
1258   - };
1259   -
1260   - } else {
1261   - if ((t + gd_buy_num> th.data.sele_g.viplimited) && (t<=th.data.sele_g.goods_num)) {
1262   - wx.showToast({
1263   - title: '超出活动限购数量',
1264   - icon: 'none',
1265   - });
1266   -
1267   - var num = th.data.sele_g.viplimited - gd_buy_num;
1268   - if (num <= 0) num = 1;
1269   - th.setData({goodsInputNum: num})
1270   - return false;
1271   - };
1272   - };
1273   -
1274   -
1275   -
  1227 + };
  1228 +
  1229 + if(limited <= res) {
  1230 + if(t>canBuyNum) {
  1231 + wx.showModal({
  1232 + title: '超出限购数量',
  1233 + });
  1234 + th.setData({
  1235 + goodsInputNum: canBuyNum,
  1236 + });
  1237 + return false;
1276 1238 };
1277   -
1278   - //--秒杀:判断商品是否超出活动限购--
1279   - // if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0 && !th.data.is_normal) {
1280   - // if (t + th.data.prom_buy_num > th.data.prom_buy_limit) {
1281   - // wx.showModal({
1282   - // title: '超出商品活动限购',
1283   - // });
  1239 + };
  1240 +
  1241 + th.setData({
  1242 + goodsInputNum: t,
  1243 + });
  1244 + });
  1245 + };
  1246 + });
1284 1247  
1285   - // var num = th.data.prom_buy_limit - th.data.prom_buy_num;
1286   - // if (num < 0) num = 0;
1287   - // th.setData({goodsInputNum: num})
1288   - // return false;
1289   - // };
1290   - // };
  1248 + }
  1249 +
  1250 +
  1251 + };
  1252 +
  1253 +
  1254 +
  1255 +
  1256 +
  1257 +
1291 1258  
1292 1259  
1293 1260  
1294 1261  
1295 1262  
1296 1263 // var e = th.data.sele_g.goods_num;
1297   - var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4
1298   - if (th.data.sales_rules == 2 && (p_type != 1 && p_type != 4 && p_type != 6 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) {
1299   - if (!th.data.def_pick_store) {
1300   - wx.showModal({title: '请选择门店',});
1301   - return false;
1302   - } else {
1303   - // e = th.data.def_pick_store.CanOutQty;
1304   - }
1305   - }
1306   -
1307   - th.setData({goodsInputNum: t});
  1264 + // var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4
  1265 + // if (th.data.sales_rules == 2 && (p_type != 1 && p_type != 4 && p_type != 6 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) {
  1266 + // if (!th.data.def_pick_store) {
  1267 + // wx.showModal({title: '请选择门店',});
  1268 + // return false;
  1269 + // } else {
  1270 + // e = th.data.def_pick_store.CanOutQty;
  1271 + // }
  1272 + // }
  1273 +
  1274 +
  1275 + // th.setData({goodsInputNum: t});
1308 1276  
1309   - });
  1277 + // });
1310 1278  
1311 1279  
1312 1280 },
... ... @@ -1338,12 +1306,10 @@ Page({
1338 1306 return false;
1339 1307 }
1340 1308  
1341   - var ind = t.currentTarget.dataset.ind;
1342   -
  1309 + var ind = t.currentTarget.dataset.ind;
1343 1310 this.setData({
1344 1311 openSpecModal: !0,
1345   - openSpecModal_ind: ind,
1346   - goodsInputNum: 1,
  1312 + openSpecModal_ind: ind,
1347 1313 });
1348 1314  
1349 1315 },
... ... @@ -3300,19 +3266,18 @@ Page({
3300 3266  
3301 3267  
3302 3268 //获取redis中的数量
3303   - async getactLen(func) {
3304   - var r_num = 0,
3305   - prom_type = this.data.prom_type,
3306   - prom_id = this.data.prom_id;
3307   - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, {
  3269 + async getactLen() {
  3270 + let prom_type = this.data.options.prom_type;
  3271 + let prom_id = this.data.options.prom_id;
  3272 + return await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, {
3308 3273 1: 1
3309 3274 }).then(res => {
3310   - var em = res;
3311   - if (em.data.code == 0) {
3312   - r_num = em.data.data;
3313   - }
  3275 + if (res.data.code == 0) {
  3276 + // 当前可以购买的数量
  3277 + let r_num = res.data.data;
  3278 + return r_num;
  3279 + };
3314 3280 })
3315   - func(r_num);
3316 3281 },
3317 3282  
3318 3283  
... ... @@ -3551,7 +3516,7 @@ Page({
3551 3516 //----获取商品购买数----
3552 3517 if (th.data.prom_type == 1) {
3553 3518 //----获取活动购买数----
3554   - getApp().request.get("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", {
  3519 + getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", {
3555 3520 data: {
3556 3521 store_id: os.stoid,
3557 3522 user_id: user_id,
... ... @@ -3579,6 +3544,49 @@ Page({
3579 3544 },
3580 3545  
3581 3546  
  3547 + get_buy_num2: async function () {
  3548 + // var map = this.data.g_buy_num,
  3549 + var th = this,
  3550 + user_id = getApp().globalData.user_id;
  3551 + // if (user_id == null) {
  3552 + // // map.set(gd.goods_id, 0);
  3553 + // th.setData({
  3554 + // // g_buy_num: map,
  3555 + // prom_buy_num: 0,
  3556 + // });
  3557 + // "function" == typeof func && func();
  3558 + // return false;
  3559 + // }
  3560 +
  3561 +
  3562 + //----获取商品购买数----
  3563 +
  3564 + //----获取活动购买数----
  3565 + return await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", {
  3566 + data: {
  3567 + store_id: os.stoid,
  3568 + user_id: user_id,
  3569 + card_id: th.data.options.goods_id,
  3570 + prom_type: th.data.options.prom_type,
  3571 + prom_id: th.data.options.prom_id
  3572 + },
  3573 + //-----获取-----
  3574 + success: function (tt) {
  3575 + if (tt.data.code == 0) {
  3576 + // map.set(gd.goods_id, g_buy_num);
  3577 + th.setData({
  3578 + // g_buy_num: map,
  3579 + promcardbuynum: tt.data.data.promcardbuynum,
  3580 + cardbuynum: tt.data.data.cardbuynum,
  3581 + });
  3582 + }
  3583 + }
  3584 + });
  3585 +
  3586 +
  3587 + },
  3588 +
  3589 +
3582 3590  
3583 3591  
3584 3592  
... ... @@ -3619,6 +3627,17 @@ Page({
3619 3627  
3620 3628 //-- 秒杀的普通购买 --
3621 3629 openSpecModel_Nor: function () {
  3630 +
  3631 + // 是否授权登陆
  3632 + var user_info = getApp().globalData.userInfo;
  3633 + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
  3634 + wx.navigateTo({
  3635 + url: '/pages/togoin/togoin',
  3636 + })
  3637 + return false;
  3638 + }
  3639 +
  3640 +
3622 3641 this.data.g_buy_num = new Map();
3623 3642 var th = this;
3624 3643 this.setData({open_ind_store: 5, goodsInputNum: 1});//拼团直接给4
... ...
pages/cart/cart/cart.js
... ... @@ -1079,9 +1079,10 @@ Page({
1079 1079 if (a = isNaN(t.detail.value) || t.detail.value < 1 ? 1 : parseInt(t.detail.value)) {
1080 1080 var s = {
1081 1081 goods_num: a,
1082   - goods_id: e.goods_id,
  1082 + goods_id: e.service_id,
1083 1083 id: e.id,
1084 1084 store_id: oo.stoid,
  1085 + is_pd_normal: e.is_pd_normal
1085 1086 };
1086 1087 if(e.prom_type) {
1087 1088 s.prom_type = e.prom_type;
... ... @@ -1102,7 +1103,7 @@ Page({
1102 1103 addNum_ser: function (t) {
1103 1104 if (!this.data.is_load) return false;
1104 1105 if (this.data.up_dating == 1) return false;
1105   - this.data.up_dating = 1;
  1106 + // this.data.up_dating = 1;
1106 1107  
1107 1108 var a = t.currentTarget.dataset.item;
1108 1109 var b = t.currentTarget.dataset.pitems;
... ... @@ -1113,6 +1114,7 @@ Page({
1113 1114 id: a.id,
1114 1115 goods_id: a.service_id,
1115 1116 store_id: oo.stoid,
  1117 + is_pd_normal: a.is_pd_normal
1116 1118 };
1117 1119 if(a.prom_type) {
1118 1120 e.prom_type = a.prom_type;
... ... @@ -1134,7 +1136,7 @@ Page({
1134 1136  
1135 1137 if (!this.data.is_load) return false;
1136 1138 if (this.data.up_dating == 1) return false;
1137   - this.data.up_dating = 1;
  1139 + // this.data.up_dating = 1;
1138 1140  
1139 1141 var a = t.currentTarget.dataset.item;
1140 1142 var b = t.currentTarget.dataset.pitems;
... ... @@ -1150,9 +1152,11 @@ Page({
1150 1152 var e = {
1151 1153 goods_num: a.goods_num - 1,
1152 1154 id: a.id,
1153   - goods_id: a.goods_id,
1154   - store_id: oo.stoid
  1155 + goods_id: a.service_id,
  1156 + store_id: oo.stoid,
  1157 + is_pd_normal: a.is_pd_normal
1155 1158 };
  1159 +
1156 1160 this.postCardList_ser(e, t.currentTarget.dataset.item, t.currentTarget.dataset.pitems);
1157 1161 }
1158 1162 },
... ... @@ -2025,104 +2029,139 @@ Page({
2025 2029 e.setData({
2026 2030 [txt]: t.goods_num
2027 2031 });
2028   -
2029   -
2030   - if(t.prom_type == 1) {
2031   - var txt = "service_data[" + pitem + "].goods[" + item + "].goods_num";
2032   - var redis_num = 0;
2033   -
2034   - //------判断活动是否抢光-----
2035   - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
2036   - t.store_id + "/" + t.prom_type + "/" + t.prom_id, {
2037   - 1: 1
2038   - }).then(res => {
2039   - redis_num = res.data.data;
2040   - });
2041   -
2042   - // 检测库存
2043   - if(redis_num == 0) {
2044   - wx.showToast({
2045   - title: '超出活动库存',
2046   - icon: 'none',
2047   - });
2048   - th.setData({[txt]: redis_num});
2049   - await e.doCheckAll();
2050   - return false;
2051   - };
2052 2032  
2053   - var buylimit = 0
2054   - await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + t.store_id + "/" + getApp().globalData.user_id + "/" + t.prom_id, {
  2033 + // 1.秒杀活动
  2034 + // 2.活动开始
  2035 + if(t.prom_type == 1 && t.is_pd_normal == 0) {
  2036 + var txt = "service_data[" + pitem + "].goods[" + item + "].goods_num";
  2037 + var redis_num = 0;
  2038 +
  2039 + // 获取其他门店,同类商品的数量
  2040 + var cartGoodsNum = 0;
  2041 + await getApp().request.promiseGet("/api/weshop/cartService/page?store_id="+t.store_id+"&user_id="+getApp().globalData.user_id+"&service_id="+t.goods_id,
  2042 + { }).then(res => {
  2043 + if (res.data.data.pageData.length > 0) {
  2044 + const tmpObj = res.data.data.pageData;
  2045 + tmpObj.forEach(v => {
  2046 + if (t.id != v.id) {
  2047 + cartGoodsNum += parseInt(v.goods_num);
  2048 + }
2055 2049  
2056   - }).then(res => {
2057   - if(res.data.code == 0) {
2058   -
2059   - th.data.sele_g = res.data.data;
2060   - th.data.sele_g.viplimited = res.data.data.buy_limit;
2061   - buylimit = !res.data.data.buy_limit ? 0 : res.data.data.buy_limit;
2062   - };
2063 2050 });
  2051 + }
  2052 + });
  2053 + // 当前商品数量包括其他门店
  2054 + var totalNum = 0
  2055 + if (cartGoodsNum > 0) {
  2056 + totalNum = t.goods_num + cartGoodsNum;
  2057 + } else {
  2058 + totalNum = t.goods_num;
  2059 + }
2064 2060  
2065   - //----获取用户活动购买数----
2066   - var gd_buy_num = 0;
2067   - await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum?store_id="+t.store_id+"&user_id="+getApp().globalData.user_id+"&card_id="+t.goods_id+"&prom_type="+t.prom_type+"&prom_id="+t.prom_id, {
2068   - }).then(tt => {
2069   - if (tt.data.code == 0) {
2070   - gd_buy_num = !tt.data.promcardbuynum ? 0 : tt.data.promcardbuynum;
2071   - th.setData({
2072   - promcardbuynum: !tt.data.promcardbuynum ? 0 : tt.data.promcardbuynum,
2073   - cardbuynum: tt.data.data.cardbuynum,
2074   - });
2075   - };
  2061 + //获取当前商品活动库存
  2062 + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
  2063 + t.store_id + "/" + t.prom_type + "/" + t.prom_id, {
  2064 + 1: 1
  2065 + }).then(res => {
  2066 + redis_num = res.data.data;
  2067 + });
  2068 +
  2069 + // 检测库存
  2070 + if(redis_num == 0) {
  2071 + wx.showToast({
  2072 + title: '超出活动库存',
  2073 + icon: 'none',
  2074 + });
  2075 + th.setData({[txt]: redis_num});
  2076 + t.goods_num = redis_num;
  2077 + await th.doCheckAll();
  2078 + await th.update_cart_ser(t, pitem, item);
  2079 + return false;
  2080 + };
  2081 +
  2082 + // 限购数量
  2083 + var buylimit = 0
  2084 + await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + t.store_id + "/" + getApp().globalData.user_id + "/" + t.prom_id, {
  2085 +
  2086 + }).then(res => {
  2087 + if(res.data.code == 0) {
  2088 + th.data.sele_g = res.data.data;
  2089 + th.data.sele_g.viplimited = res.data.data.buy_limit;
  2090 + buylimit = !res.data.data.buy_limit ? 0 : res.data.data.buy_limit;
  2091 + };
  2092 + });
  2093 +
  2094 + //用户已经成功付款购买的数量
  2095 + var gd_buy_num = 0;
  2096 + await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum?store_id="+t.store_id+"&user_id="+getApp().globalData.user_id+"&card_id="+t.card_id+"&prom_type="+t.prom_type+"&prom_id="+t.prom_id, {
  2097 + }).then(tt => {
  2098 + if (tt.data.code == 0) {
  2099 + gd_buy_num = !tt.data.data.promcardbuynum ? 0 : tt.data.data.promcardbuynum;
  2100 + th.setData({
  2101 + promcardbuynum: !tt.data.data.promcardbuynum ? 0 : tt.data.data.promcardbuynum,
  2102 + cardbuynum: tt.data.data.cardbuynum,
2076 2103 });
  2104 + };
  2105 + });
2077 2106  
2078   -
2079   -
  2107 + // 剩余购买数
  2108 + let num = buylimit - gd_buy_num;
2080 2109  
2081   - if(t.goods_num > redis_num) {
2082   - wx.showToast({
2083   - title: '超出活动库存',
2084   - icon: 'none',
2085   - });
2086   - // 开启限购
2087   - if (buylimit > 0) {
2088   - let num = buylimit - gd_buy_num;
2089   - if (num > redis_num) {
2090   - th.setData({[txt]: redis_num});
2091   - } else {
2092   - th.setData({[txt]: num});
2093   - }
2094   - } else {
2095   - th.setData({[txt]: redis_num});
2096   - }
  2110 + if(totalNum > redis_num) {
  2111 + wx.showToast({
  2112 + title: '超出活动库存',
  2113 + icon: 'none',
  2114 + });
  2115 + // 开启限购
  2116 + if (buylimit > 0) {
  2117 + if (num > redis_num) {
  2118 + th.setData({[txt]: redis_num-cartGoodsNum});
  2119 + t.goods_num = redis_num-cartGoodsNum;
  2120 + await th.doCheckAll();
  2121 + await th.update_cart_ser(t, pitem, item);
  2122 + } else {
  2123 + th.setData({[txt]: num - cartGoodsNum});
  2124 + t.goods_num = num - cartGoodsNum;
  2125 + await th.doCheckAll();
  2126 + await th.update_cart_ser(t, pitem, item);
  2127 + }
  2128 + } else {
  2129 + th.setData({[txt]: redis_num - cartGoodsNum});
  2130 + t.goods_num = redis_num - cartGoodsNum;
  2131 + await th.doCheckAll();
  2132 + await th.update_cart_ser(t, pitem, item);
  2133 + }
2097 2134  
2098   - await e.doCheckAll();
2099   - return false;
2100   - };
  2135 + return false;
  2136 + };
2101 2137  
  2138 +
  2139 + //--秒杀:判断商品是否超出活动限购--
  2140 + if (buylimit > 0) {
  2141 +
  2142 + // 如果限购数量<=活动库存数量,增加数量时会先超过限购数量,此时应提示“超出活动限购数量”
  2143 + if(totalNum > num) {
  2144 + // 计算还可以购买的数量:库存量 - 已购数
  2145 + wx.showToast({
  2146 + title: '超出活动限购',
  2147 + icon: 'none',
  2148 + });
  2149 + if (num <= 0) num = 1;
  2150 + th.setData({[txt]: num - cartGoodsNum});
  2151 + t.goods_num = num - cartGoodsNum;
  2152 + await th.doCheckAll();
  2153 + await th.update_cart_ser(t, pitem, item);
  2154 + return false;
  2155 + };
2102 2156  
2103   - //--秒杀:判断商品是否超出活动限购--
2104   - if (buylimit > 0) {
2105   -
2106   - // 如果限购数量<=活动库存数量,增加数量时会先超过限购数量,此时应提示“超出活动限购数量”
2107   - if(t.goods_num + gd_buy_num > buylimit) {
2108   - // 计算还可以购买的数量:库存量 - 已购数
2109   - wx.showToast({
2110   - title: '超出活动限购',
2111   - icon: 'none',
2112   - });
2113   - let num = buylimit - gd_buy_num;
2114   - if (num <= 0) num = 1;
2115   - th.setData({[txt]: num});
2116   - await e.doCheckAll();
2117   - return false;
2118   - };
2119   -
2120   - }
2121   -
2122   -
2123   - }
2124   - await e.doCheckAll();
2125   - await e.update_cart_ser(t, pitem, item);
  2157 + }
  2158 +
  2159 +
  2160 + }
  2161 +
  2162 +
  2163 + await e.doCheckAll();
  2164 + await e.update_cart_ser(t, pitem, item);
2126 2165  
2127 2166  
2128 2167 },
... ... @@ -2336,7 +2375,6 @@ Page({
2336 2375 update_cart_ser: function (t, pitem, item) {
2337 2376 var e = this;
2338 2377  
2339   - console.log('t===>', t);
2340 2378 getApp().request.put("/api/weshop/cartService/update", {
2341 2379 data: t,
2342 2380 success: async function (ee) {
... ...
pages/cart/cart2/cart2.js
... ... @@ -3855,15 +3855,20 @@ Page({
3855 3855 if (prom_pt_json) {
3856 3856 for (let oj in prom_pt_json) {
3857 3857 let item_j = prom_pt_json[oj];
3858   -
3859 3858 //要对一下阶梯优惠促销的功能
3860 3859 if (item_j.ladder_prom_id) {
3861   -
3862 3860 //看一下要不要限制使用优惠券
3863 3861 if (th.data.ladder_map[item_j.ladder_prom_id] && th.data.ladder_map[item_j.ladder_prom_id].is_usecoupon) {
3864 3862 continue;
3865 3863 }
3866   -
  3864 + cut_price += parseFloat(item_j.dis);
  3865 + }
  3866 + //要对一下组合购促销的功能
  3867 + if (item_j.zhprom_id) {
  3868 + //看一下要不要限制使用优惠券
  3869 + if (th.data.zhhe_act_map[item_j.zhprom_id] && th.data.zhhe_act_map[item_j.zhprom_id].is_xz_yh) {
  3870 + continue;
  3871 + }
3867 3872 cut_price += parseFloat(item_j.dis);
3868 3873 }
3869 3874 }
... ...
pages/goods/goodsInfo/goodsInfo.wxml
... ... @@ -490,61 +490,8 @@
490 490 </view>
491 491 </view>
492 492 </block>
493   - <!-- 门店收货地址 -->
494   - <view class="xc-address_frame bdt16 flex-vertical xc-ash {{def_pick_store!=null?'sn_height':'on_height'}}">
495   - <view class="address_frame" bindtap="choice_store" data-ind="0">
496   - <view class="flex-vertical-between ">
497   - <view class="flex-vertical select_store_height">
498   - <image class="stores-img" src="{{iurl}}/miniapp/images/stores.png"></image>
499   - <view class="fs30" style="color:black;">选择门店</view>
500   - </view>
501   - <view class="red_bb fs26">更多门店<text class="bg_jj"></text></view>
502   - </view>
503   - <view wx:if="{{def_pick_store && def_pick_store.pickup_name}}">
504   - <view class="flex-space-between address ai_end pdv10">
505   - <view>
506   - <text class="fs30 xc-black3 shop_name bold">{{def_pick_store.pickup_name}}</text>
507   - </view>
508   - <view class="distance fs24" wx:if="{{def_pick_store.distance!=null}}">
509   - 距离:{{def_pick_store.distance>1000?filters.toFix(def_pick_store.distance/1000,2)+"km":filters.toFix(def_pick_store.distance,0)+"m"}}
510   - </view>
511   - </view>
512   - <view class="no_store" wx:if="{{only_pk && !only_pk.length}}">(库存不足)</view>
513   - <block wx:else>
514   - <view class="no_store" wx:if="{{def_pickpu_list && !def_pickpu_list.length}}">
515   - (库存不足)
516   - </view>
517   - <block wx:else>
518   - <view class="no_store" wx:if="{{def_pick_store && def_pick_store.is_no_dis}}">
519   - (配送不匹配)
520   - </view>
521   - <view class="no_store" wx:elif="{{def_pick_store && !def_pick_store.CanOutQty && sales_rules==2 && prom_type==0}}">
522   - (库存不足)
523   - </view>
524   - </block>
525   - </block>
526   - <view class="fs24 xc-ash-9f">地址:{{def_pick_store.fulladdress}}</view>
527   - </view>
528   - </view>
529   - </view>
530   - <!-- 许程 7.24暂时注释 -->
531   - <view class="bdt16" wx:if="{{prom_type!=1&& prom_type!=1 && prom_act.kttype!=3&&prom_act.kttype!=2&&prom_act.kttype!=1 && is_closecoupon!=1}}">
532   - <view class="cx-frame flex" style="position: relative" wx:if="{{fir_quan.length>0}}">
533   - <view class="cx-sizs fs30">领券</view>
534   - <view class="flex ai_c f1 pdh20">
535   - <view class="xc-coupon-fram" wx:for="{{fir_quan}}" wx:key="id">
536   - <view class="circle xc-circular xc-one"></view>
537   - <view class="xc-coupon t-c four-level-word">
538   - 满{{item.condition}}减{{item.money}}
539   - </view>
540   - <view class="circle xc-circular xc-two"></view>
541   - </view>
542   - </view>
543   - <view data-coupon="1" bindtap="switchCoupon" class="cx-obtain-coupon wsize">
544   - <text class="bg_jj"></text>
545   - </view>
546   - </view>
547   - </view>
  493 +
  494 +
548 495 <!-- 要判断是不是有促销活动 -->
549 496 <block wx:if="{{prom_goods}}">
550 497 <view class="cx-frame flex" style="position: relative; height: auto" hidden="{{prom_type==4 || prom_type==6}}">
... ... @@ -601,7 +548,6 @@
601 548 </view>
602 549 </block>
603 550  
604   -
605 551 <!-- 要判断是不是有订单优惠 -->
606 552 <block wx:if="{{order_prom}}">
607 553 <view class="cx-frame flex" style="position: relative; height: auto">
... ... @@ -664,7 +610,61 @@
664 610 </view>
665 611 </block>
666 612 </block>
667   -
  613 + <!-- 许程 7.24暂时注释 -->
  614 + <view class="bdt16" wx:if="{{prom_type!=1&& prom_type!=1 && prom_act.kttype!=3&&prom_act.kttype!=2&&prom_act.kttype!=1 && is_closecoupon!=1}}">
  615 + <view class="cx-frame flex" style="position: relative" wx:if="{{fir_quan.length>0}}">
  616 + <view class="cx-sizs fs30">领券</view>
  617 + <view class="flex ai_c f1 pdh20">
  618 + <view class="xc-coupon-fram" wx:for="{{fir_quan}}" wx:key="id">
  619 + <view class="circle xc-circular xc-one"></view>
  620 + <view class="xc-coupon t-c four-level-word">
  621 + 满{{item.condition}}减{{item.money}}
  622 + </view>
  623 + <view class="circle xc-circular xc-two"></view>
  624 + </view>
  625 + </view>
  626 + <view data-coupon="1" bindtap="switchCoupon" class="cx-obtain-coupon wsize">
  627 + <text class="bg_jj"></text>
  628 + </view>
  629 + </view>
  630 + </view>
  631 + <!-- 门店收货地址 -->
  632 + <view class="xc-address_frame bdt16 flex-vertical xc-ash {{def_pick_store!=null?'sn_height':'on_height'}}">
  633 + <view class="address_frame" bindtap="choice_store" data-ind="0">
  634 + <view class="flex-vertical-between ">
  635 + <view class="flex-vertical select_store_height">
  636 + <image class="stores-img" src="{{iurl}}/miniapp/images/stores.png"></image>
  637 + <view class="fs30" style="color:black;">选择门店</view>
  638 + </view>
  639 + <view class="red_bb fs26">更多门店<text class="bg_jj"></text></view>
  640 + </view>
  641 + <view wx:if="{{def_pick_store && def_pick_store.pickup_name}}">
  642 + <view class="flex-space-between address ai_end pdv10">
  643 + <view>
  644 + <text class="fs30 xc-black3 shop_name bold">{{def_pick_store.pickup_name}}</text>
  645 + </view>
  646 + <view class="distance fs24" wx:if="{{def_pick_store.distance!=null}}">
  647 + 距离:{{def_pick_store.distance>1000?filters.toFix(def_pick_store.distance/1000,2)+"km":filters.toFix(def_pick_store.distance,0)+"m"}}
  648 + </view>
  649 + </view>
  650 + <view class="no_store" wx:if="{{only_pk && !only_pk.length}}">(库存不足)</view>
  651 + <block wx:else>
  652 + <view class="no_store" wx:if="{{def_pickpu_list && !def_pickpu_list.length}}">
  653 + (库存不足)
  654 + </view>
  655 + <block wx:else>
  656 + <view class="no_store" wx:if="{{def_pick_store && def_pick_store.is_no_dis}}">
  657 + (配送不匹配)
  658 + </view>
  659 + <view class="no_store" wx:elif="{{def_pick_store && !def_pick_store.CanOutQty && sales_rules==2 && prom_type==0}}">
  660 + (库存不足)
  661 + </view>
  662 + </block>
  663 + </block>
  664 + <view class="fs24 xc-ash-9f">地址:{{def_pick_store.fulladdress}}</view>
  665 + </view>
  666 + </view>
  667 + </view>
668 668 <!-- 保障服务 -->
669 669 <view class="bz_view flex bdt16 ai_c" wx:if="{{bconfig.service_bz}}">
670 670 <image class="bzfu_img" src="{{iurl}}/miniapp/images/bzfu_w.png"></image>
... ... @@ -676,7 +676,6 @@
676 676 </view>
677 677 </view>
678 678 </view>
679   -
680 679 <!-- - 搭配促销 -- -->
681 680 <view class="dp_cx_view" wx:if="{{collocationGoods}}">
682 681 <view class="bb_view">
... ...
pages/goods/search/g_filter.wxs
1 1 var g_filters = {
2   - //-- 判断是不是有等级价 --
3   - is_has_rank:function(rank_switch,item){
4   - if(!rank_switch) return false;
5   - if(item.cardprice1 || item.cardprice2 || item.cardprice3) {return true}
6   - return false;
7   - },
8   -
9   - //-- 判断,不是等级会员时候,要显示的最低等级价和名称 --
10   - get_card_price:function(goods,all_card,type){
11   - var price1=parseFloat(goods['cardprice1']);
12   - var price2=parseFloat(goods['cardprice2']);
13   - var price3=parseFloat(goods['cardprice3']);
14   - if(!all_card){
15   - if(type==0) return 0;
16   - return "";
17   - }
18   -
19   - var arr=[];
20   - var min_price= 0;
21   - var min_name="";
22   -
23   - var min_price=null;
24   - var min_name=null;
25   - //---设置对应的价格名字----
26   - for(var i=0;i<3;i++) {
27   - var vl=all_card[i];
28   - if(!vl) continue;
29   - if(vl['CorrPrice']=="Price1" && price1>0)
30   - {
31   - if(min_price==null) {
32   - min_price=price1;min_name=vl['CardName'];
33   - }
34   - else if(price1<min_price) {
35   - min_price=price1;min_name=vl['CardName'];
36   - }
37   - }
38   - if(vl['CorrPrice']=="Price2" && price2>0)
39   - {
40   - if(min_price==null) {
41   - min_price=price2;min_name=vl['CardName'];
42   - }
43   - else if(price2<min_price) {
44   - min_price=price2;min_name=vl['CardName'];
45   - }
46   - }
47   -
48   - if(vl['CorrPrice']=="Price3" && price3>0)
49   - {
50   - if(min_price==null) {
51   - min_price=price3;min_name=vl['CardName'];
52   - }
53   - else if(price3<min_price) {
54   - min_price=price3;min_name=vl['CardName'];
55   - }
56   - }
57   -
58   - }
59   - if(min_price==null){
60   - if(type==0) return 0;
61   - return "";
62   - }
63   -
64   - //if(type==0) return arr.length;
65   - //--进行排序,升序---
66   - /*---
67   - arr.sort(function(a,b){
68   - if (a.price < b.price) {
69   - return -1;
70   - } else if (a.fee == b.fee) {
71   - return 0;
72   - } else {
73   - return 1;
74   - }
75   - })--*/
76   - //-- 获取最下价钱,和相应的卡的名称 --
77   - //min_price=min.price;
78   - //min_name=min.name;
79   - if(type==0) return min_price.toFixed(2);
80   - if(min_name.length>7 ) min_name=min_name.substring(0, 8);
81   - return min_name;
82   - },
  2 + //-- 判断是不是有等级价 --
  3 + is_has_rank: function (rank_switch, item) {
  4 + if (!rank_switch) return false;
  5 + if (item.cardprice1 || item.cardprice2 || item.cardprice3) { return true }
  6 + return false;
  7 + },
83 8  
  9 + //-- 判断,不是等级会员时候,要显示的最低等级价和名称 --
  10 + get_card_price: function (goods, all_card, type) {
  11 + var price1 = parseFloat(goods['cardprice1']);
  12 + var price2 = parseFloat(goods['cardprice2']);
  13 + var price3 = parseFloat(goods['cardprice3']);
  14 + if (!all_card) {
  15 + if (type == 0) return 0;
  16 + return "";
  17 + }
84 18  
85   - get_goods_url:function(item){
  19 + var arr = [];
  20 + var min_price = 0;
  21 + var min_name = "";
86 22  
87   - var url1="/pages/goods/goodsInfo/goodsInfo?goods_id="+item.goods_id
88   - // 预售活动
89   - if(item.prom_type==8){
90   - url1="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id="+item.goods_id+"&prom_id="+item.prom_id
91   - }
92   - // 如果是幸运购活动商品
93   - if(item.prom_type == 9){
94   - url1 = "/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo?goods_id=" + item.goods_id + "&group_id=" + item.prom_id
95   - }
96   -
97   - if(item.prom_type==1 && item.prom_id>0){
98   - url1="/pages/goods/goodsInfo/goodsInfo?goods_id="+item.goods_id+"&prom_id="+item.prom_id+"&prom_type=1";
99   - }
100   - return url1;
101   - }
  23 + var min_price = null;
  24 + var min_name = null;
  25 + //---设置对应的价格名字----
  26 + for (var i = 0; i < 3; i++) {
  27 + var vl = all_card[i];
  28 + if (!vl) continue;
  29 + if (vl['CorrPrice'] == "Price1" && price1 > 0) {
  30 + if (min_price == null) {
  31 + min_price = price1; min_name = vl['CardName'];
  32 + }
  33 + else if (price1 < min_price) {
  34 + min_price = price1; min_name = vl['CardName'];
  35 + }
  36 + }
  37 + if (vl['CorrPrice'] == "Price2" && price2 > 0) {
  38 + if (min_price == null) {
  39 + min_price = price2; min_name = vl['CardName'];
  40 + }
  41 + else if (price2 < min_price) {
  42 + min_price = price2; min_name = vl['CardName'];
  43 + }
  44 + }
  45 +
  46 + if (vl['CorrPrice'] == "Price3" && price3 > 0) {
  47 + if (min_price == null) {
  48 + min_price = price3; min_name = vl['CardName'];
  49 + }
  50 + else if (price3 < min_price) {
  51 + min_price = price3; min_name = vl['CardName'];
  52 + }
  53 + }
  54 +
  55 + }
  56 + if (min_price == null) {
  57 + if (type == 0) return 0;
  58 + return "";
  59 + }
  60 +
  61 + //if(type==0) return arr.length;
  62 + //--进行排序,升序---
  63 + /*---
  64 + arr.sort(function(a,b){
  65 + if (a.price < b.price) {
  66 + return -1;
  67 + } else if (a.fee == b.fee) {
  68 + return 0;
  69 + } else {
  70 + return 1;
  71 + }
  72 + })--*/
  73 + //-- 获取最下价钱,和相应的卡的名称 --
  74 + //min_price=min.price;
  75 + //min_name=min.name;
  76 + if (type == 0) return min_price.toFixed(2);
  77 + if (min_name.length > 7) min_name = min_name.substring(0, 8);
  78 + return min_name;
  79 + },
  80 +
  81 +
  82 + get_goods_url: function (item) {
  83 +
  84 + var url1 = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + item.goods_id
  85 + // 预售活动
  86 + if (item.prom_type == 8) {
  87 + url1 = "/packageC/pages/presell/goodsInfo/goodsInfo?goods_id=" + item.goods_id + "&prom_id=" + item.prom_id
  88 + }
  89 + // 如果是幸运购活动商品
  90 + if (item.prom_type == 9) {
  91 + url1 = "/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo?goods_id=" + item.goods_id + "&group_id=" + item.prom_id
  92 + }
  93 +
  94 + if (item.prom_type == 1 && item.prom_id > 0) {
  95 + url1 = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + item.goods_id + "&prom_id=" + item.prom_id + "&prom_type=1";
  96 + }
  97 + return url1;
  98 + }
102 99 }
103 100  
104 101 module.exports = {
105   - is_has_rank:g_filters.is_has_rank,
106   - get_card_price:g_filters.get_card_price,
107   - get_goods_url:g_filters.get_goods_url
  102 + is_has_rank: g_filters.is_has_rank,
  103 + get_card_price: g_filters.get_card_price,
  104 + get_goods_url: g_filters.get_goods_url
108 105 }
109 106 \ No newline at end of file
... ...
pages/index/index/index.js
... ... @@ -525,7 +525,6 @@ Page({
525 525 backgroundColor: temp_data.top_color, // 必写项
526 526 })
527 527 }
528   -
529 528 }
530 529 })
531 530  
... ...
pages/user/address_list/address_list.js
... ... @@ -56,10 +56,8 @@ Page({
56 56 var arr1 = e.data.addresses;
57 57 var arr2 = t.data.data.pageData;
58 58 var arr3 = [...arr1, ...arr2];
59   -
60 59 var ismore = 0;
61 60 if (arr3.length == t.data.data.total) ismore = 1
62   -
63 61 e.setData({
64 62 addresses: arr3, total: t.data.data.total, ismore: ismore,
65 63 is_address_read:1
... ...
pages/user/address_list/address_list.wxml
... ... @@ -32,7 +32,7 @@
32 32 <view class="address-box">
33 33  
34 34 <!-- 单个收货地址框架 -->
35   - <view class="address-user" wx:for="{{addresses}}" wx:key="{{index}}">
  35 + <view class="address-user" wx:for="{{addresses}}" wx:key="index">
36 36 <!-- 选择icon
37 37 <view class="icon">
38 38 <icon type="success" color="red" size="33rpx" wx:if="{{item.is_pickup==1}}" bindtap="add_is_pickup" data-icon="{{index}}"></icon>
... ...
pages/user/order_list/order_list.js
... ... @@ -2224,35 +2224,176 @@ Page({
2224 2224 },
2225 2225  
2226 2226 // 卡项订单 - 立即支付
2227   - pay(e) {
  2227 + pay: async function(e) {
2228 2228 let index = e.currentTarget.dataset.index;
2229 2229 let item = this.data.cardList[index];
2230 2230 let order_sn = item.order_sn;
2231 2231 let order_id = item.order_id;
2232 2232 let store_id = app.globalData.setting.stoid;
2233   - // console.log('go1!!!!!!!!!!!!!!!!!!!!!!!!!',index,item,order_sn,store_id);
  2233 + let user_id = oo.user_id;
  2234 + let flag = true;
  2235 +
  2236 +
  2237 + // 如果是普通购买或单独购买,不用判断
  2238 + // 如果是秒杀购买:1、判断活动是否变化;2、是否超出限购
  2239 +
  2240 + let list = item.list;
  2241 + for(const it of list) {
  2242 + if(it.prom_type == 1) {
  2243 + let act_details = null;
  2244 + let redis_num = 0;
  2245 + let promcardbuynum = 0;
  2246 + let qty = it.qty;
  2247 +
  2248 +
  2249 + await getApp().request.promiseGet('/api/ms/flash_sale/getNew/' + store_id + '/' + user_id + '/' + it.prom_id, {}).then(res => {
  2250 + console.log('11111111====>>>');
  2251 + if(res.data.code == 0) {
  2252 + console.log('当前的秒杀活动信息:', res.data.data);
  2253 + act_details = res.data.data;
  2254 + if(act_details.is_end == 1) {
  2255 + wx.showModal({
  2256 + title: '提示',
  2257 + content: '活动已结束,无法支付,请取消订单!',
  2258 + showCancel: false,
  2259 + });
  2260 + flag = false;
  2261 + return false;
  2262 + };
  2263 + if(act_details.id != it.prom_id) {
  2264 + wx.showModal({
  2265 + title: '提示',
  2266 + content: '活动发生了变化,无法支付,请取消订单,重新购买!',
  2267 + showCancel: false,
  2268 + });
  2269 + flag = false;
  2270 + return false;
  2271 + };
  2272 + };
  2273 + });
  2274 +
  2275 + await getApp().request.promiseGet('/api/weshop/activitylist/getActLen/' + store_id + '/' + it.prom_type + '/' + it.prom_id, {
  2276 + 1: 1
  2277 + }).then(res => {
  2278 + console.log('222222222====>>>');
  2279 + if (res.data.code == 0) {
  2280 + // 当前可以购买的数量
  2281 + console.log('redis当前可以购买的数量:', res.data.data);
  2282 + redis_num = res.data.data;
  2283 + // if(redis_num <=0) {
  2284 + // wx.showModal({
  2285 + // title: '提示',
  2286 + // content: '活动库存不足,无法支付,请取消订单!',
  2287 + // showCancel: false,
  2288 + // });
  2289 + // // flag = false;
  2290 + // return true;
  2291 + // };
  2292 + };
  2293 + });
  2294 +
  2295 + await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", {
  2296 + data: {
  2297 + store_id: store_id,
  2298 + user_id: user_id,
  2299 + card_id: it.card_id,
  2300 + prom_type: it.prom_type,
  2301 + prom_id: it.prom_id,
  2302 + }
  2303 + }).then(res => {
  2304 + console.log('333333333====>>>');
  2305 + if (res.data.code == 0) {
  2306 + console.log('已经购买的数量:', res.data.data);
  2307 + promcardbuynum = res.data.data.promcardbuynum;
  2308 +
  2309 +
  2310 + let limited = act_details.buy_limit; // 限购数量a
  2311 + let buyedNum = promcardbuynum; // 自己已经购买的数量b
  2312 + let canBuyNum = limited - buyedNum; // 自己还可购买的数量c
  2313 +
  2314 +
  2315 + if(canBuyNum <= 0) {
  2316 + wx.showModal({
  2317 + title: '提示',
  2318 + content: '您已超出活动限购数量,无法支付,请取消订单!',
  2319 + showCancel: false,
  2320 + });
  2321 + flag = false;
  2322 + return false;
  2323 + };
  2324 +
  2325 + if(limited > redis_num) {
  2326 + if(canBuyNum <= redis_num) {
  2327 + if(qty > canBuyNum) {
  2328 + wx.showModal({
  2329 + title: '提示',
  2330 + content: '您已超出活动限购数量,无法支付,请取消订单!',
  2331 + showCancel: false,
  2332 + });
  2333 + flag = false;
  2334 + return false;
  2335 + };
  2336 +
  2337 + };
  2338 +
  2339 + if(canBuyNum > redis_num) {
  2340 + if(qty > redis_num) {
  2341 + wx.showModal({
  2342 + title: '提示',
  2343 + content: '活动库存不足,无法支付,请取消订单!',
  2344 + showCancel: false,
  2345 + });
  2346 + flag = false;
  2347 + return false;
  2348 + };
  2349 +
  2350 + };
  2351 + };
  2352 +
  2353 + if(limited <= redis_num) {
  2354 + if(qty > canBuyNum) {
  2355 + wx.showModal({
  2356 + title: '提示',
  2357 + content: '您已超出活动限购数量,无法支付,请取消订单!',
  2358 + showCancel: false,
  2359 + });
  2360 + flag = false;
  2361 + return false;
  2362 + };
  2363 + };
  2364 + };
  2365 + });
  2366 +
  2367 + };
  2368 +
  2369 + };
  2370 +
2234 2371  
2235   - app.request.post('/api/weshop/order/pay/createRechargeOrder', {
2236   - data: {
2237   - parentSn: order_sn,
2238   - store_id: store_id,
2239   - },
  2372 + if(flag) {
  2373 + await app.request.promisePost('/api/weshop/order/pay/createRechargeOrder', {
  2374 + data: {
  2375 + parentSn: order_sn,
  2376 + store_id: store_id,
  2377 + },
  2378 + }).then(res => {
  2379 + // success: function(res) {
  2380 + var n = res.data.data;
  2381 + self.weixinPay(n, function() {
  2382 + app.showWarning('支付成功');
  2383 +
  2384 + }, function() {
  2385 + app.showWarning('支付失败');
  2386 + // setTimeout(function() {
  2387 + // wx.reLaunch({
  2388 + // url: '/packageA/pages/cardList/cardList',
  2389 + // })
  2390 + // }, 1000)
  2391 + });
  2392 + // }
  2393 + });
  2394 + };
  2395 +
2240 2396  
2241   - success: function(res) {
2242   - var n = res.data.data;
2243   - self.weixinPay(n, function() {
2244   - app.showWarning('支付成功');
2245   -
2246   - }, function() {
2247   - app.showWarning('支付失败');
2248   - // setTimeout(function() {
2249   - // wx.reLaunch({
2250   - // url: '/packageA/pages/cardList/cardList',
2251   - // })
2252   - // }, 1000)
2253   - });
2254   - }
2255   - })
2256 2397 },
2257 2398  
2258 2399 //------调起支付框--------
... ...