Commit 71c72a34fd9da96641892fb64ec0f240f936633d
1 parent
06ae20d2
fix服务卡商品页限购处理
Showing
1 changed file
with
14 additions
and
8 deletions
packageA/pages/goodsInfo/goodsInfo.js
... | ... | @@ -866,9 +866,15 @@ Page({ |
866 | 866 | |
867 | 867 | // 每人限购数 |
868 | 868 | th.data.sele_g.viplimited = th.data.sele_g.buy_limit; |
869 | - | |
869 | + | |
870 | + //----获取用户活动购买数---- | |
870 | 871 | // 已经付款的单数 |
871 | - var gd_buy_num = !th.data.sele_g.buy_num ? 0 : th.data.sele_g.buy_num; | |
872 | + var gd_buy_num = 0; | |
873 | + await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum?store_id="+os.stoid+"&user_id="+getApp().globalData.user_id+"&card_id="+th.data.options.goods_id+"&prom_type="+th.data.options.prom_type+"&prom_id="+th.data.options.prom_id, { | |
874 | + }).then(res => { | |
875 | + gd_buy_num = !res.data.data.promcardbuynum ? 0 : res.data.data.promcardbuynum; | |
876 | + }); | |
877 | + | |
872 | 878 | |
873 | 879 | // 检查redis库存量 |
874 | 880 | var redisNum = 0; |
... | ... | @@ -889,6 +895,8 @@ Page({ |
889 | 895 | |
890 | 896 | }); |
891 | 897 | |
898 | + | |
899 | + | |
892 | 900 | // 有库存的情况下,走秒杀活动流程 否则 走正常购买流程 |
893 | 901 | // 没有库存,已抢光的情况下,走正常购买流程 |
894 | 902 | if(redisNum > 0 && !this.data.is_normal) { |
... | ... | @@ -897,7 +905,7 @@ Page({ |
897 | 905 | |
898 | 906 | if (t > redisNum) { |
899 | 907 | wx.showToast({ |
900 | - title: '超出活动库存', | |
908 | + title: '超出活动库存' + redisNum, | |
901 | 909 | icon: 'none' |
902 | 910 | }); |
903 | 911 | |
... | ... | @@ -908,9 +916,9 @@ Page({ |
908 | 916 | if (action !="buy") { |
909 | 917 | // 购物车 |
910 | 918 | if (num > redisNum) { |
911 | - th.setData({goodsInputNum: redisNum - cartGoodsNum < 0 ? 0 : redisNum - cartGoodsNum}); | |
919 | + th.setData({goodsInputNum: redisNum}); | |
912 | 920 | } else { |
913 | - th.setData({goodsInputNum: num - cartGoodsNum < 0 ? 0 : num - cartGoodsNum}); | |
921 | + th.setData({goodsInputNum: num}); | |
914 | 922 | } |
915 | 923 | } else { |
916 | 924 | // 立即购买 |
... | ... | @@ -936,10 +944,8 @@ Page({ |
936 | 944 | |
937 | 945 | // 输入的数量 + 购物车同款商品的数量 |
938 | 946 | var maxNum = parseInt(t) + parseInt(cartGoodsNum); |
939 | - | |
940 | 947 | // 是否开启个人限购 |
941 | 948 | if (th.data.sele_g.viplimited > 0) { |
942 | - | |
943 | 949 | if (maxNum + gd_buy_num > th.data.sele_g.buy_limit) { |
944 | 950 | wx.showToast({ |
945 | 951 | title: '超出活动限购数量', |
... | ... | @@ -948,7 +954,7 @@ Page({ |
948 | 954 | |
949 | 955 | // 可购买数量 |
950 | 956 | let num = th.data.sele_g.viplimited - gd_buy_num - cartGoodsNum; |
951 | - th.setData({goodsInputNum: num}); | |
957 | + th.setData({goodsInputNum: num < 0 ? 0 : num}); | |
952 | 958 | return false; |
953 | 959 | } |
954 | 960 | ... | ... |