Commit 0d7983205ee3bfcca44c5954408ce02846a9b48a

Authored by 泉州测试
1 parent deaf2b25

fix限购数量

packageA/pages/goodsInfo/goodsInfo.js
... ... @@ -866,7 +866,7 @@ Page({
866 866 // if(!this.data.openSpecModal_ind) {
867 867 if(this.data.prom_type == 1) {
868 868 this.data.sele_g.viplimited = this.data.sele_g.buy_limit;
869   -
  869 +
870 870 if(!this.data.is_normal) {
871 871 // 输入的数量
872 872 var t = th.data.goodsInputNum;
... ... @@ -889,30 +889,44 @@ Page({
889 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 904 if(action !="buy"){
905 905  
906   - if (cartGoodsNum >= redisNum) {
  906 + var maxNum = parseInt(t) + parseInt(cartGoodsNum);
  907 +
  908 + if (maxNum > redisNum) {
907 909 wx.showModal({
908 910 title: '超出活动库存',
909 911 });
910   - th.setData({goodsInputNum: redisNum});
911 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 932 th.data.sele_g.viplimited = th.data.sele_g.buy_limit;
... ... @@ -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 1164 if (t > redis_num) {
1148 1165 wx.showModal({
1149 1166 // title: '超出商品活动库存',
1150   - title: '来晚了,已被抢光~',
  1167 + title: '超出活动库存',
1151 1168 });
1152 1169 th.setData({goodsInputNum: redis_num})
1153 1170 return false;
... ...