-
Status changed to merged
-
mentioned in commit 0d08339816bdad0cdadee48e53c4febbbbd2eb08
Showing
1 changed file
packageA/pages/goodsInfo/goodsInfo.js
@@ -897,7 +897,7 @@ Page({ | @@ -897,7 +897,7 @@ Page({ | ||
897 | canBuyNum = 0; | 897 | canBuyNum = 0; |
898 | }; | 898 | }; |
899 | 899 | ||
900 | - if(limited > res) { | 900 | + if(canBuyNum > res) { |
901 | if(curNum > res) { // t当前增减的数量 | 901 | if(curNum > res) { // t当前增减的数量 |
902 | wx.showModal({ | 902 | wx.showModal({ |
903 | title: '超出活动库存', | 903 | title: '超出活动库存', |
@@ -909,8 +909,8 @@ Page({ | @@ -909,8 +909,8 @@ Page({ | ||
909 | }; | 909 | }; |
910 | }; | 910 | }; |
911 | 911 | ||
912 | - if(limited <= res) { | ||
913 | - if(curNum > limited) { | 912 | + if(canBuyNum <= res) { |
913 | + if(curNum > canBuyNum) { | ||
914 | wx.showModal({ | 914 | wx.showModal({ |
915 | title: '超出限购数量', | 915 | title: '超出限购数量', |
916 | }); | 916 | }); |
@@ -996,13 +996,66 @@ Page({ | @@ -996,13 +996,66 @@ Page({ | ||
996 | store_id: os.stoid, | 996 | store_id: os.stoid, |
997 | user_id: oo.user_id, | 997 | user_id: oo.user_id, |
998 | service_id: th.data.data.id, | 998 | service_id: th.data.data.id, |
999 | - pick_id: th.data.sto_sele_id, | ||
1000 | }, | 999 | }, |
1001 | success: function(re) { | 1000 | success: function(re) { |
1002 | - | ||
1003 | - //-------如果购物车中有相关的数据--------- | 1001 | + //-------如果购物车中有相关的数据--------- |
1004 | if (re.data.data.total > 0) { | 1002 | if (re.data.data.total > 0) { |
1005 | - 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 | + // 以下为当前门店同类商品已经加入到购物车 | ||
1006 | var totalNum = th.data.goodsInputNum + item.goods_num; | 1059 | var totalNum = th.data.goodsInputNum + item.goods_num; |
1007 | 1060 | ||
1008 | // 秒杀购物车购买 修正数量 | 1061 | // 秒杀购物车购买 修正数量 |
@@ -1016,13 +1069,13 @@ Page({ | @@ -1016,13 +1069,13 @@ Page({ | ||
1016 | } | 1069 | } |
1017 | if (totalNum >= redisNums){ | 1070 | if (totalNum >= redisNums){ |
1018 | if (redisNums > snum) { | 1071 | if (redisNums > snum) { |
1019 | - totalNum = snum; | 1072 | + totalNum = snum- cartGoodsNum; |
1020 | } else { | 1073 | } else { |
1021 | - totalNum = redisNums; | 1074 | + totalNum = redisNums- cartGoodsNum; |
1022 | } | 1075 | } |
1023 | } else { | 1076 | } else { |
1024 | if (totalNum > snum) | 1077 | if (totalNum > snum) |
1025 | - totalNum = snum; | 1078 | + totalNum = snum- cartGoodsNum; |
1026 | } | 1079 | } |
1027 | } | 1080 | } |
1028 | 1081 | ||
@@ -1061,7 +1114,6 @@ Page({ | @@ -1061,7 +1114,6 @@ Page({ | ||
1061 | } | 1114 | } |
1062 | }); | 1115 | }); |
1063 | } else { | 1116 | } else { |
1064 | - | ||
1065 | getApp().request.post("/api/weshop/cartService/save", { | 1117 | getApp().request.post("/api/weshop/cartService/save", { |
1066 | data: newd, | 1118 | data: newd, |
1067 | success: function(t) { | 1119 | success: function(t) { |
@@ -3575,6 +3627,17 @@ Page({ | @@ -3575,6 +3627,17 @@ Page({ | ||
3575 | 3627 | ||
3576 | //-- 秒杀的普通购买 -- | 3628 | //-- 秒杀的普通购买 -- |
3577 | openSpecModel_Nor: function () { | 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 | + | ||
3578 | this.data.g_buy_num = new Map(); | 3641 | this.data.g_buy_num = new Map(); |
3579 | var th = this; | 3642 | var th = this; |
3580 | this.setData({open_ind_store: 5, goodsInputNum: 1});//拼团直接给4 | 3643 | this.setData({open_ind_store: 5, goodsInputNum: 1});//拼团直接给4 |