Commit 71c72a34fd9da96641892fb64ec0f240f936633d

Authored by 泉州测试
1 parent 06ae20d2

fix服务卡商品页限购处理

packageA/pages/goodsInfo/goodsInfo.js
@@ -866,9 +866,15 @@ Page({ @@ -866,9 +866,15 @@ Page({
866 866
867 // 每人限购数 867 // 每人限购数
868 th.data.sele_g.viplimited = th.data.sele_g.buy_limit; 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 // 检查redis库存量 879 // 检查redis库存量
874 var redisNum = 0; 880 var redisNum = 0;
@@ -889,6 +895,8 @@ Page({ @@ -889,6 +895,8 @@ Page({
889 895
890 }); 896 });
891 897
  898 +
  899 +
892 // 有库存的情况下,走秒杀活动流程 否则 走正常购买流程 900 // 有库存的情况下,走秒杀活动流程 否则 走正常购买流程
893 // 没有库存,已抢光的情况下,走正常购买流程 901 // 没有库存,已抢光的情况下,走正常购买流程
894 if(redisNum > 0 && !this.data.is_normal) { 902 if(redisNum > 0 && !this.data.is_normal) {
@@ -897,7 +905,7 @@ Page({ @@ -897,7 +905,7 @@ Page({
897 905
898 if (t > redisNum) { 906 if (t > redisNum) {
899 wx.showToast({ 907 wx.showToast({
900 - title: '超出活动库存', 908 + title: '超出活动库存' + redisNum,
901 icon: 'none' 909 icon: 'none'
902 }); 910 });
903 911
@@ -908,9 +916,9 @@ Page({ @@ -908,9 +916,9 @@ Page({
908 if (action !="buy") { 916 if (action !="buy") {
909 // 购物车 917 // 购物车
910 if (num > redisNum) { 918 if (num > redisNum) {
911 - th.setData({goodsInputNum: redisNum - cartGoodsNum < 0 ? 0 : redisNum - cartGoodsNum}); 919 + th.setData({goodsInputNum: redisNum});
912 } else { 920 } else {
913 - th.setData({goodsInputNum: num - cartGoodsNum < 0 ? 0 : num - cartGoodsNum}); 921 + th.setData({goodsInputNum: num});
914 } 922 }
915 } else { 923 } else {
916 // 立即购买 924 // 立即购买
@@ -936,10 +944,8 @@ Page({ @@ -936,10 +944,8 @@ Page({
936 944
937 // 输入的数量 + 购物车同款商品的数量 945 // 输入的数量 + 购物车同款商品的数量
938 var maxNum = parseInt(t) + parseInt(cartGoodsNum); 946 var maxNum = parseInt(t) + parseInt(cartGoodsNum);
939 -  
940 // 是否开启个人限购 947 // 是否开启个人限购
941 if (th.data.sele_g.viplimited > 0) { 948 if (th.data.sele_g.viplimited > 0) {
942 -  
943 if (maxNum + gd_buy_num > th.data.sele_g.buy_limit) { 949 if (maxNum + gd_buy_num > th.data.sele_g.buy_limit) {
944 wx.showToast({ 950 wx.showToast({
945 title: '超出活动限购数量', 951 title: '超出活动限购数量',
@@ -948,7 +954,7 @@ Page({ @@ -948,7 +954,7 @@ Page({
948 954
949 // 可购买数量 955 // 可购买数量
950 let num = th.data.sele_g.viplimited - gd_buy_num - cartGoodsNum; 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 return false; 958 return false;
953 } 959 }
954 960