Commit d0c80654e66fc2d62c236c0349ddf2ce54f3b543

Authored by 泉州测试
1 parent ec5b07d3

fix提示框

packageA/pages/goodsInfo/goodsInfo.js
@@ -877,10 +877,21 @@ Page({ @@ -877,10 +877,21 @@ Page({
877 var redisNum = 0; 877 var redisNum = 0;
878 await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/1/" + prom_id, {}).then(res => { 878 await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/1/" + prom_id, {}).then(res => {
879 if (res.data.code == 0) { 879 if (res.data.code == 0) {
880 - redisNum = res.data.data; 880 + redisNum = !res.data.data ? 0 : res.data.data;
881 }; 881 };
882 }); 882 });
883 883
  884 + // 获取购物车同款数量 判断是否超库存
  885 + var cartGoodsNum = 0;
  886 + 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,
  887 + { }).then(res => {
  888 + if (res.data.data.pageData.length > 0) {
  889 + const tmpObj = res.data.data.pageData[0];
  890 + cartGoodsNum = !tmpObj.goods_num ? 0 : tmpObj.goods_num;
  891 + }
  892 +
  893 + });
  894 +
884 // 有库存的情况下,走秒杀活动流程 否则 走正常购买流程 895 // 有库存的情况下,走秒杀活动流程 否则 走正常购买流程
885 // 没有库存,已抢光的情况下,走正常购买流程 896 // 没有库存,已抢光的情况下,走正常购买流程
886 if(redisNum > 0 && !this.data.is_normal) { 897 if(redisNum > 0 && !this.data.is_normal) {
@@ -888,36 +899,40 @@ Page({ @@ -888,36 +899,40 @@ Page({
888 var t = th.data.goodsInputNum; 899 var t = th.data.goodsInputNum;
889 900
890 if (t > redisNum) { 901 if (t > redisNum) {
891 - wx.showModal({ 902 + wx.showToast({
892 title: '超出活动库存', 903 title: '超出活动库存',
  904 + icon: 'none'
893 }); 905 });
894 906
895 // 开启限购 907 // 开启限购
896 if (th.data.sele_g.viplimited > 0) { 908 if (th.data.sele_g.viplimited > 0) {
  909 +
897 let num = th.data.sele_g.viplimited - gd_buy_num; 910 let num = th.data.sele_g.viplimited - gd_buy_num;
898 - if (num > redisNum) {  
899 - th.setData({goodsInputNum: redisNum}); 911 + if (action !="buy") {
  912 + // 购物车
  913 + if (num > redisNum) {
  914 + th.setData({goodsInputNum: redisNum - cartGoodsNum});
  915 + } else {
  916 + th.setData({goodsInputNum: num - cartGoodsNum});
  917 + }
900 } else { 918 } else {
901 - th.setData({goodsInputNum: num}); 919 + // 立即购买
  920 + if (num > redisNum) {
  921 + th.setData({goodsInputNum: redisNum});
  922 + } else {
  923 + th.setData({goodsInputNum: num});
  924 + }
902 } 925 }
  926 +
  927 +
903 } else { 928 } else {
904 th.setData({goodsInputNum: redisNum}); 929 th.setData({goodsInputNum: redisNum});
905 } 930 }
906 931
907 -  
908 return false; 932 return false;
909 } 933 }
910 934
911 - // 获取购物车同款数量 判断是否超库存  
912 - var cartGoodsNum = 0;  
913 - 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,  
914 - { }).then(res => {  
915 - if (res.data.data.pageData.length > 0) {  
916 - const tmpObj = res.data.data.pageData[0];  
917 - cartGoodsNum = !tmpObj.goods_num ? 0 : tmpObj.goods_num;  
918 - }  
919 -  
920 - }); 935 +
921 936
922 // 跳过<立即购买> 购物车 937 // 跳过<立即购买> 购物车
923 if (action !="buy") { 938 if (action !="buy") {
@@ -929,8 +944,9 @@ Page({ @@ -929,8 +944,9 @@ Page({
929 if (th.data.sele_g.viplimited > 0) { 944 if (th.data.sele_g.viplimited > 0) {
930 945
931 if (maxNum + gd_buy_num > th.data.sele_g.buy_limit) { 946 if (maxNum + gd_buy_num > th.data.sele_g.buy_limit) {
932 - wx.showModal({ 947 + wx.showToast({
933 title: '超出活动限购数量', 948 title: '超出活动限购数量',
  949 + icon: 'none'
934 }); 950 });
935 951
936 // 可购买数量 952 // 可购买数量
@@ -942,8 +958,9 @@ Page({ @@ -942,8 +958,9 @@ Page({
942 } 958 }
943 959
944 if (maxNum > redisNum) { 960 if (maxNum > redisNum) {
945 - wx.showModal({ 961 + wx.showToast({
946 title: '超出活动库存', 962 title: '超出活动库存',
  963 + icon: 'none'
947 }); 964 });
948 // 可购买数量 965 // 可购买数量
949 let num = redisNum - cartGoodsNum; 966 let num = redisNum - cartGoodsNum;
@@ -952,14 +969,14 @@ Page({ @@ -952,14 +969,14 @@ Page({
952 } 969 }
953 970
954 } else { 971 } else {
955 -  
956 // 以下为立即购买 972 // 以下为立即购买
957 // 是否开启个人限购 973 // 是否开启个人限购
958 if (th.data.sele_g.viplimited > 0) { 974 if (th.data.sele_g.viplimited > 0) {
959 975
960 if (t + gd_buy_num > th.data.sele_g.viplimited) { 976 if (t + gd_buy_num > th.data.sele_g.viplimited) {
961 - wx.showModal({ 977 + wx.showToast({
962 title: '超出活动限购数量', 978 title: '超出活动限购数量',
  979 + icon: 'none'
963 }); 980 });
964 981
965 let num = th.data.sele_g.viplimited - gd_buy_num; 982 let num = th.data.sele_g.viplimited - gd_buy_num;
@@ -973,6 +990,7 @@ Page({ @@ -973,6 +990,7 @@ Page({
973 990
974 991
975 }; 992 };
  993 +
976 } 994 }
977 995
978 }; 996 };
@@ -1210,9 +1228,10 @@ Page({ @@ -1210,9 +1228,10 @@ Page({
1210 }); 1228 });
1211 1229
1212 if (t > redis_num) { 1230 if (t > redis_num) {
1213 - wx.showModal({ 1231 + wx.showToast({
1214 // title: '超出商品活动库存', 1232 // title: '超出商品活动库存',
1215 title: '超出活动库存', 1233 title: '超出活动库存',
  1234 + icon: 'none',
1216 }); 1235 });
1217 th.setData({goodsInputNum: redis_num}) 1236 th.setData({goodsInputNum: redis_num})
1218 return false; 1237 return false;
@@ -1231,8 +1250,9 @@ Page({ @@ -1231,8 +1250,9 @@ Page({
1231 var num = th.data.sele_g.goods_num - gd_buy_num; 1250 var num = th.data.sele_g.goods_num - gd_buy_num;
1232 if(num < 0) num = 0; 1251 if(num < 0) num = 0;
1233 if(t > num) { 1252 if(t > num) {
1234 - wx.showModal({ 1253 + wx.showToast({
1235 title: '超出活动库存', 1254 title: '超出活动库存',
  1255 + icon: 'none',
1236 }); 1256 });
1237 1257
1238 th.setData({goodsInputNum: num}) 1258 th.setData({goodsInputNum: num})
@@ -1242,8 +1262,9 @@ Page({ @@ -1242,8 +1262,9 @@ Page({
1242 1262
1243 } else { 1263 } else {
1244 if ((t + gd_buy_num> th.data.sele_g.viplimited) && (t<=th.data.sele_g.goods_num)) { 1264 if ((t + gd_buy_num> th.data.sele_g.viplimited) && (t<=th.data.sele_g.goods_num)) {
1245 - wx.showModal({ 1265 + wx.showToast({
1246 title: '超出活动限购数量', 1266 title: '超出活动限购数量',
  1267 + icon: 'none',
1247 }); 1268 });
1248 1269
1249 var num = th.data.sele_g.viplimited - gd_buy_num; 1270 var num = th.data.sele_g.viplimited - gd_buy_num;
@@ -1285,7 +1306,6 @@ Page({ @@ -1285,7 +1306,6 @@ Page({
1285 // e = th.data.def_pick_store.CanOutQty; 1306 // e = th.data.def_pick_store.CanOutQty;
1286 } 1307 }
1287 } 1308 }
1288 -  
1289 1309
1290 th.setData({goodsInputNum: t}); 1310 th.setData({goodsInputNum: t});
1291 1311
@@ -1321,10 +1341,12 @@ Page({ @@ -1321,10 +1341,12 @@ Page({
1321 return false; 1341 return false;
1322 } 1342 }
1323 1343
1324 - var ind = t.currentTarget.dataset.ind; 1344 + var ind = t.currentTarget.dataset.ind;
  1345 +
1325 this.setData({ 1346 this.setData({
1326 openSpecModal: !0, 1347 openSpecModal: !0,
1327 - openSpecModal_ind: ind, 1348 + openSpecModal_ind: ind,
  1349 + goodsInputNum: 1,
1328 }); 1350 });
1329 1351
1330 }, 1352 },