Commit 0d7983205ee3bfcca44c5954408ce02846a9b48a

Authored by 泉州测试
1 parent deaf2b25

fix限购数量

packageA/pages/goodsInfo/goodsInfo.js
@@ -866,7 +866,7 @@ Page({ @@ -866,7 +866,7 @@ Page({
866 // if(!this.data.openSpecModal_ind) { 866 // if(!this.data.openSpecModal_ind) {
867 if(this.data.prom_type == 1) { 867 if(this.data.prom_type == 1) {
868 this.data.sele_g.viplimited = this.data.sele_g.buy_limit; 868 this.data.sele_g.viplimited = this.data.sele_g.buy_limit;
869 - 869 +
870 if(!this.data.is_normal) { 870 if(!this.data.is_normal) {
871 // 输入的数量 871 // 输入的数量
872 var t = th.data.goodsInputNum; 872 var t = th.data.goodsInputNum;
@@ -889,30 +889,44 @@ Page({ @@ -889,30 +889,44 @@ Page({
889 return false; 889 return false;
890 } 890 }
891 891
892 - // 获取购物车同类数量 判断是否超库存  
893 - var cartGoodsNum = 0;  
894 - 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,  
895 - { }).then(res => {  
896 - if (res.data.data.pageData.length > 0) {  
897 - const tmpObj = res.data.data.pageData[0];  
898 - cartGoodsNum = tmpObj.goods_num;  
899 - }  
900 -  
901 - }); 892 + // 获取购物车同类数量 判断是否超库存
  893 + var cartGoodsNum = 0;
  894 + 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,
  895 + { }).then(res => {
  896 + if (res.data.data.pageData.length > 0) {
  897 + const tmpObj = res.data.data.pageData[0];
  898 + cartGoodsNum = tmpObj.goods_num;
  899 + }
  900 +
  901 + });
902 902
903 // 跳过<立即购买> 903 // 跳过<立即购买>
904 if(action !="buy"){ 904 if(action !="buy"){
905 905
906 - if (cartGoodsNum >= redisNum) { 906 + var maxNum = parseInt(t) + parseInt(cartGoodsNum);
  907 +
  908 + if (maxNum > redisNum) {
907 wx.showModal({ 909 wx.showModal({
908 title: '超出活动库存', 910 title: '超出活动库存',
909 }); 911 });
910 - th.setData({goodsInputNum: redisNum});  
911 return false; 912 return false;
912 } 913 }
913 914
  915 + // 是否开启限购
  916 + if (th.data.sele_g.viplimited > 0) {
  917 +
  918 + if (maxNum + th.data.sele_g.buy_num > th.data.sele_g.buy_limit) {
  919 + wx.showModal({
  920 + title: '超出活动限购数量',
  921 + });
  922 + return false;
  923 + }
  924 +
  925 + }
  926 +
  927 +
  928 +
914 } 929 }
915 -  
916 930
917 // 每人限购数 931 // 每人限购数
918 th.data.sele_g.viplimited = th.data.sele_g.buy_limit; 932 th.data.sele_g.viplimited = th.data.sele_g.buy_limit;
@@ -935,6 +949,9 @@ Page({ @@ -935,6 +949,9 @@ Page({
935 949
936 950
937 }; 951 };
  952 +
  953 +
  954 +
938 }; 955 };
939 }; 956 };
940 957
@@ -1147,7 +1164,7 @@ Page({ @@ -1147,7 +1164,7 @@ Page({
1147 if (t > redis_num) { 1164 if (t > redis_num) {
1148 wx.showModal({ 1165 wx.showModal({
1149 // title: '超出商品活动库存', 1166 // title: '超出商品活动库存',
1150 - title: '来晚了,已被抢光~', 1167 + title: '超出活动库存',
1151 }); 1168 });
1152 th.setData({goodsInputNum: redis_num}) 1169 th.setData({goodsInputNum: redis_num})
1153 return false; 1170 return false;