Commit 724d1a398bfc4b315657183ccf8c6585b138d0c7

Authored by 泉州测试
1 parent d0c80654

fix修改商品页面限购

packageA/pages/goodsInfo/goodsInfo.js
... ... @@ -447,7 +447,7 @@ Page({
447 447 sto_sele_name: e.pickup_name,
448 448 sto_sele_id: e.pickup_id,
449 449 sto_sele_distr: e.distr_type,
450   - sto_sele_keyid:e.keyid,
  450 + sto_sele_keyid:e.keyid,
451 451 })
452 452 }
453 453 }
... ... @@ -562,6 +562,9 @@ Page({
562 562 // <---- 秒杀
563 563  
564 564  
  565 +
  566 +
  567 +
565 568  
566 569  
567 570  
... ... @@ -826,21 +829,7 @@ Page({
826 829 });
827 830 },
828 831  
829   - //获取redis中的数量
830   - async getactLen(func) {
831   - var r_num = 0,
832   - prom_type = this.data.prom_type,
833   - prom_id = this.data.prom_id;
834   - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, {
835   - 1: 1
836   - }).then(res => {
837   - var em = res;
838   - if (em.data.code == 0) {
839   - r_num = em.data.data;
840   - }
841   - })
842   - func(r_num);
843   - },
  832 +
844 833  
845 834 //------------加入购物车--------------
846 835 addCart: async function(t) {
... ... @@ -848,11 +837,7 @@ Page({
848 837 var ind = t.currentTarget.dataset.openSpecModal_ind;
849 838 var action= t.currentTarget.dataset.action;
850 839 if(!ind) ind = t.currentTarget.dataset.openspecmodal_ind;
851   - // 活动ID
852   - var prom_id = th.data.prom_id;
853   -
854   -
855   -
  840 +
856 841 th.setData({
857 842 open_ind_store: ind
858 843 });
... ... @@ -863,144 +848,98 @@ Page({
863 848 };
864 849  
865 850  
866   - if(this.data.prom_type == 1) {
867   -
868   - this.data.sele_g.viplimited = this.data.sele_g.buy_limit;
869   -
870   - // 每人限购数
871   - th.data.sele_g.viplimited = th.data.sele_g.buy_limit;
872   -
873   - // 已经付款的单数
874   - var gd_buy_num = !th.data.sele_g.buy_num ? 0 : th.data.sele_g.buy_num;
875   -
876   - // 检查redis库存量
877   - var redisNum = 0;
878   - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/1/" + prom_id, {}).then(res => {
879   - if (res.data.code == 0) {
880   - redisNum = !res.data.data ? 0 : res.data.data;
881   - };
882   - });
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   -
895   - // 有库存的情况下,走秒杀活动流程 否则 走正常购买流程
896   - // 没有库存,已抢光的情况下,走正常购买流程
897   - if(redisNum > 0 && !this.data.is_normal) {
898   - // 输入的数量
899   - var t = th.data.goodsInputNum;
900   -
901   - if (t > redisNum) {
902   - wx.showToast({
  851 + // 秒杀活动
  852 + if(this.data.prom_type == 1) {
  853 + // 如果是秒杀活动下的单独购买,is_normal为1
  854 + if(this.data.openSpecModal_flash_normal) this.data.is_normal = 1;
  855 +
  856 + if(!this.data.is_normal) {// 秒杀购买
  857 +
  858 + // 获取redis当前可以购买的数量
  859 + // 如果数量为0,设置和显示已抢光
  860 + // 否则,进一步判断是否超出限购或超出库存
  861 + await this.getactLen().then(async function(res) {
  862 + let curNum = th.data.goodsInputNum;
  863 + // res: redis可购买数量
  864 + console.log('当前可以购买的数量:', res);
  865 + if(res <= 0) {
  866 + // 可购买数量<=0, 设置和显示已抢光
  867 + th.setData({
  868 + prom_r_null: 1,
  869 + });
  870 + wx.showModal({
  871 + title: '超出活动库存',
  872 + });
  873 + return false;
  874 + } else {
  875 + // 可购买数量>0
  876 + // 计算自己还可以购买的数量
  877 + // 自己还可购买的数量c = 每人活动限购数量a - 自己已经购买的数量b
  878 + // 如果限购数量a>redis可购买数量d,当增加数量t>d, 提示超出库存
  879 + // 如果限购数量a<=redis可购买数量d, 当增加数量t>a,提示超出限购
  880 + let actInfo = th.data.sele_g;
  881 + await th.get_buy_num2().then(function (data) {
  882 + let limited = actInfo.buy_limit; // 限购数量a
  883 + let promcardbuynum = data.data.data.promcardbuynum;
  884 + let buyedNum = promcardbuynum; // 自己已经购买的数量b
  885 + let canBuyNum = limited - buyedNum; // 自己还可购买的数量c
  886 +
  887 + if(canBuyNum <= 0) {
  888 + canBuyNum = 0;
  889 + };
  890 +
  891 + if(limited > res) {
  892 + if(curNum > res) { // t当前增减的数量
  893 + wx.showModal({
903 894 title: '超出活动库存',
904   - icon: 'none'
905   - });
906   -
907   - // 开启限购
908   - if (th.data.sele_g.viplimited > 0) {
909   -
910   - let num = th.data.sele_g.viplimited - gd_buy_num;
911   - if (action !="buy") {
912   - // 购物车
913   - if (num > redisNum) {
914   - th.setData({goodsInputNum: redisNum - cartGoodsNum});
915   - } else {
916   - th.setData({goodsInputNum: num - cartGoodsNum});
917   - }
918   - } else {
919   - // 立即购买
920   - if (num > redisNum) {
921   - th.setData({goodsInputNum: redisNum});
922   - } else {
923   - th.setData({goodsInputNum: num});
924   - }
925   - }
926   -
927   -
928   - } else {
929   - th.setData({goodsInputNum: redisNum});
930   - }
931   -
932   - return false;
933   - }
934   -
  895 + });
  896 + th.setData({
  897 + goodsInputNum: res,
  898 + });
  899 + return false;
  900 + };
  901 + };
935 902  
936   -
937   - // 跳过<立即购买> 购物车
938   - if (action !="buy") {
939   -
940   - // 输入的数量 + 购物车同款商品的数量
941   - var maxNum = parseInt(t) + parseInt(cartGoodsNum);
942   -
943   - // 是否开启个人限购
944   - if (th.data.sele_g.viplimited > 0) {
945   -
946   - if (maxNum + gd_buy_num > th.data.sele_g.buy_limit) {
947   - wx.showToast({
948   - title: '超出活动限购数量',
949   - icon: 'none'
950   - });
951   -
952   - // 可购买数量
953   - let num = th.data.sele_g.viplimited - gd_buy_num - cartGoodsNum;
954   - th.setData({goodsInputNum: num});
955   - return false;
956   - }
957   -
958   - }
959   -
960   - if (maxNum > redisNum) {
961   - wx.showToast({
962   - title: '超出活动库存',
963   - icon: 'none'
  903 + if(limited <= res) {
  904 + if(curNum > limited) {
  905 + wx.showModal({
  906 + title: '超出限购数量',
  907 + });
  908 + th.setData({
  909 + goodsInputNum: canBuyNum,
964 910 });
965   - // 可购买数量
966   - let num = redisNum - cartGoodsNum;
967   - th.setData({goodsInputNum: num});
968 911 return false;
969   - }
970   -
971   - } else {
972   - // 以下为立即购买
973   - // 是否开启个人限购
974   - if (th.data.sele_g.viplimited > 0) {
975   -
976   - if (t + gd_buy_num > th.data.sele_g.viplimited) {
977   - wx.showToast({
978   - title: '超出活动限购数量',
979   - icon: 'none'
980   - });
981   -
982   - let num = th.data.sele_g.viplimited - gd_buy_num;
983   - if (num > redisNum) {
984   - th.setData({goodsInputNum: redisNum});
985   - } else {
986   - th.setData({goodsInputNum: num});
987   - }
988   - return false;
989   - }
990   -
991   -
992 912 };
993   -
994   - }
995   -
  913 + };
  914 +
  915 +
  916 + });
  917 +
  918 +
  919 +
996 920 };
  921 + });
  922 +
997 923 };
998 924  
999 925  
  926 + };
  927 +
  928 +
  929 +
  930 +
  931 +
  932 +
  933 +
  934 +
  935 +
  936 +
  937 +
  938 +
1000 939  
1001 940  
1002 941  
1003   - if(action=="buy"){ // 立即购买
  942 + if(action=="buy"){
1004 943 //--------------此时操作的数据------------
1005 944 var newd = {
1006 945 id: th.data.data.id,
... ... @@ -1022,23 +961,13 @@ Page({
1022 961 newd['prom_type'] = 0;
1023 962 newd['prom_price'] = this.data.data.shop_price;
1024 963 };
1025   -
1026   - // 判断是否为0库存的情况
1027   - var tmpRedisNum = 0;
1028   - // 检查redis库存量
1029   - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/1/" + prom_id, {}).then(res => {
1030   - if (res.data.code == 0) {
1031   - tmpRedisNum = res.data.data;
1032   - };
1033   - });
1034   - if(this.data.prom_type == 1 && tmpRedisNum == 0) {
1035   - newd['prom_type'] = 0;
1036   - newd['prom_price'] = this.data.data.shop_price;
1037   - };
1038 964  
1039 965 // console.log('newd++++++++', newd);
1040 966 th.buyNow(newd);
1041   - } else { // 购物车
  967 + } else {
  968 +
  969 +
  970 +
1042 971  
1043 972 var newd = {
1044 973 service_id: th.data.data.id,
... ... @@ -1065,19 +994,7 @@ Page({
1065 994 newd['money'] = th.data.prom_price;
1066 995 };
1067 996 };
1068   -
1069   - // 判断是否为0库存的情况
1070   - var tmpRedisNum = 0;
1071   - // 检查redis库存量
1072   - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/1/" + prom_id, {}).then(res => {
1073   - if (res.data.code == 0) {
1074   - tmpRedisNum = res.data.data;
1075   - };
1076   - });
1077   - if(th.data.options.prom_type == 1 && tmpRedisNum == 0) {
1078   - newd['prom_type'] = 0;
1079   - newd['money'] = th.data.data.shop_price;
1080   - };
  997 +
1081 998  
1082 999 //----先看会员在购物车中是否加入了该商品-----
1083 1000 getApp().request.get("/api/weshop/cartService/page", {
... ... @@ -1174,142 +1091,121 @@ Page({
1174 1091 },
1175 1092  
1176 1093 //------检查数量是不是超出限购------
1177   - checkCartNum: function(t) {
  1094 + checkCartNum: async function(t) {
  1095 + var th = this;
1178 1096  
1179   - if(this.data.prom_type != 1) {
1180   - this.setData({goodsInputNum: t});
1181   - return false;
  1097 + if(!th.data.def_pick_store) {
  1098 + wx.showModal({title: '请选择门店',});
  1099 + return false;
1182 1100 };
1183 1101  
1184   - var th = this;
1185   -
1186   - // if(this.data.prom_act.is_shop_buy && this.data.options.prom_type != 1) {
1187   -
1188   - if(t == 0) return false;
1189   - // th.setData({goodsInputNum:t});
  1102 + // 非秒杀活动
  1103 + if(this.data.prom_type != 1) {
  1104 + this.setData({
  1105 + goodsInputNum: t,
  1106 + });
  1107 + };
1190 1108  
1191   - // if(this.data.options.prom_type == 1 && !this.data.openSpecModal_flash_normal) {
1192   -
1193   - this.get_buy_num(this.data.sele_g, async function () {
1194   - th.data.sele_g.viplimited = th.data.sele_g.buy_limit;
1195   -
1196   - //--判断商品是否超出限购--
1197   - // if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) {
1198   - // if(!th.data.prom_act.is_shop_buy) {
1199   -
1200   - // if (th.data.sele_g.viplimited > 0) {
1201   - // var gd_buy_num = th.data.sele_g.buy_num;
1202   -
1203   - // if (t + gd_buy_num> th.data.sele_g.viplimited) {
1204   - // wx.showModal({
1205   - // title: '超出商品限购',
1206   - // });
1207   -
1208   - // var num = th.data.sele_g.viplimited - gd_buy_num;
1209   - // if (num <= 0) num = 1;
1210   - // th.setData({goodsInputNum: num})
1211   - // return false;
1212   - // }
1213   - // };
1214   -
1215   -
1216   - // 单独购买
1217   - if(th.data.openSpecModal_flash_normal) th.data.is_normal = 1;
1218   -
1219   - // 秒杀:判断活动是否抢光
1220   - if (th.data.sele_g.prom_type == 1 && !th.data.is_normal) {
1221   - var redis_num = 0;
1222   - //------判断活动是否抢光-----
1223   - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
1224   - os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, {
1225   - 1: 1
1226   - }).then(res => {
1227   - redis_num = res.data.data;
  1109 + // 秒杀活动
  1110 + if(this.data.prom_type == 1) {
  1111 + // 如果是秒杀活动下的单独购买,is_normal为1
  1112 + if(this.data.openSpecModal_flash_normal) this.data.is_normal = 1;
  1113 +
  1114 + if(this.data.is_normal) {// 单独购买
  1115 + this.setData({
  1116 + goodsInputNum: t,
  1117 + });
  1118 + } else {// 秒杀购买
  1119 +
  1120 + // 获取redis当前可以购买的数量
  1121 + // 如果数量为0,设置和显示已抢光
  1122 + // 否则,进一步判断是否超出限购或超出库存
  1123 + await this.getactLen().then(async function(res) {
  1124 + // res: redis可购买数量
  1125 + console.log('当前可以购买的数量:', res);
  1126 + if(res <= 0) {
  1127 + // 可购买数量<=0, 设置和显示已抢光
  1128 + th.setData({
  1129 + prom_r_null: 1,
  1130 + });
  1131 + } else {
  1132 + // 可购买数量>0
  1133 + // 计算自己还可以购买的数量
  1134 + // 自己还可购买的数量c = 每人活动限购数量a - 自己已经购买的数量b
  1135 + // 如果限购数量a>redis可购买数量d,当增加数量t>d, 提示超出库存
  1136 + // 如果限购数量a<=redis可购买数量d, 当增加数量t>a,提示超出限购
  1137 + let actInfo = th.data.sele_g;
  1138 + await th.get_buy_num2().then(function (data) {
  1139 + let limited = actInfo.buy_limit; // 限购数量a
  1140 + let promcardbuynum = data.data.data.promcardbuynum;
  1141 + let buyedNum = promcardbuynum; // 自己已经购买的数量b
  1142 + let canBuyNum = limited - buyedNum; // 自己还可购买的数量c
  1143 +
  1144 + if(canBuyNum <= 0) {
  1145 + canBuyNum = 0;
  1146 + };
  1147 +
  1148 + if(limited > res) {
  1149 + if(t > res) { // t当前增减的数量
  1150 + wx.showModal({
  1151 + title: '超出活动库存',
1228 1152 });
1229   -
1230   - if (t > redis_num) {
1231   - wx.showToast({
1232   - // title: '超出商品活动库存',
1233   - title: '超出活动库存',
1234   - icon: 'none',
1235   - });
1236   - th.setData({goodsInputNum: redis_num})
1237   - return false;
1238   - }
  1153 + th.setData({
  1154 + goodsInputNum: res,
  1155 + });
  1156 + return false;
1239 1157 };
1240   -
1241   - //--秒杀:判断商品是否超出活动限购--
1242   - if (th.data.sele_g.viplimited > 0 && !th.data.is_normal && th.data.prom_type == 1) {
1243   - var gd_buy_num = th.data.promcardbuynum;
1244   -
1245   - // 如果限购数量>活动库存数量,增加数量时会先超过库存数量,此时应该提示“超出活动库存”;
1246   - // 如果限购数量<=活动库存数量,增加数量时会先超过限购数量,此时应提示“超出活动限购数量”
1247   - if(th.data.sele_g.viplimited > th.data.sele_g.goods_num) {
1248   -
1249   - // 计算还可以购买的数量:库存量 - 已购数
1250   - var num = th.data.sele_g.goods_num - gd_buy_num;
1251   - if(num < 0) num = 0;
1252   - if(t > num) {
1253   - wx.showToast({
1254   - title: '超出活动库存',
1255   - icon: 'none',
1256   - });
1257   -
1258   - th.setData({goodsInputNum: num})
1259   - return false;
1260   -
1261   - };
1262   -
1263   - } else {
1264   - if ((t + gd_buy_num> th.data.sele_g.viplimited) && (t<=th.data.sele_g.goods_num)) {
1265   - wx.showToast({
1266   - title: '超出活动限购数量',
1267   - icon: 'none',
1268   - });
1269   -
1270   - var num = th.data.sele_g.viplimited - gd_buy_num;
1271   - if (num <= 0) num = 1;
1272   - th.setData({goodsInputNum: num})
1273   - return false;
1274   - };
1275   - };
1276   -
1277   -
1278   -
  1158 + };
  1159 +
  1160 + if(limited <= res) {
  1161 + if(t>limited) {
  1162 + wx.showModal({
  1163 + title: '超出限购数量',
  1164 + });
  1165 + th.setData({
  1166 + goodsInputNum: canBuyNum,
  1167 + });
  1168 + return false;
1279 1169 };
1280   -
1281   - //--秒杀:判断商品是否超出活动限购--
1282   - // if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0 && !th.data.is_normal) {
1283   - // if (t + th.data.prom_buy_num > th.data.prom_buy_limit) {
1284   - // wx.showModal({
1285   - // title: '超出商品活动限购',
1286   - // });
  1170 + };
  1171 +
  1172 + th.setData({
  1173 + goodsInputNum: t,
  1174 + });
  1175 + });
  1176 + };
  1177 + });
1287 1178  
1288   - // var num = th.data.prom_buy_limit - th.data.prom_buy_num;
1289   - // if (num < 0) num = 0;
1290   - // th.setData({goodsInputNum: num})
1291   - // return false;
1292   - // };
1293   - // };
  1179 + }
  1180 +
  1181 +
  1182 + };
  1183 +
  1184 +
  1185 +
  1186 +
  1187 +
  1188 +
1294 1189  
1295 1190  
1296 1191  
1297 1192  
1298 1193  
1299 1194 // var e = th.data.sele_g.goods_num;
1300   - var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4
1301   - if (th.data.sales_rules == 2 && (p_type != 1 && p_type != 4 && p_type != 6 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) {
1302   - if (!th.data.def_pick_store) {
1303   - wx.showModal({title: '请选择门店',});
1304   - return false;
1305   - } else {
1306   - // e = th.data.def_pick_store.CanOutQty;
1307   - }
1308   - }
1309   -
1310   - th.setData({goodsInputNum: t});
  1195 + // var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4
  1196 + // if (th.data.sales_rules == 2 && (p_type != 1 && p_type != 4 && p_type != 6 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) {
  1197 + // if (!th.data.def_pick_store) {
  1198 + // wx.showModal({title: '请选择门店',});
  1199 + // return false;
  1200 + // } else {
  1201 + // e = th.data.def_pick_store.CanOutQty;
  1202 + // }
  1203 + // }
  1204 +
  1205 +
  1206 + // th.setData({goodsInputNum: t});
1311 1207  
1312   - });
  1208 + // });
1313 1209  
1314 1210  
1315 1211 },
... ... @@ -1341,12 +1237,10 @@ Page({
1341 1237 return false;
1342 1238 }
1343 1239  
1344   - var ind = t.currentTarget.dataset.ind;
1345   -
  1240 + var ind = t.currentTarget.dataset.ind;
1346 1241 this.setData({
1347 1242 openSpecModal: !0,
1348   - openSpecModal_ind: ind,
1349   - goodsInputNum: 1,
  1243 + openSpecModal_ind: ind,
1350 1244 });
1351 1245  
1352 1246 },
... ... @@ -3303,19 +3197,18 @@ Page({
3303 3197  
3304 3198  
3305 3199 //获取redis中的数量
3306   - async getactLen(func) {
3307   - var r_num = 0,
3308   - prom_type = this.data.prom_type,
3309   - prom_id = this.data.prom_id;
3310   - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, {
  3200 + async getactLen() {
  3201 + let prom_type = this.data.options.prom_type;
  3202 + let prom_id = this.data.options.prom_id;
  3203 + return await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, {
3311 3204 1: 1
3312 3205 }).then(res => {
3313   - var em = res;
3314   - if (em.data.code == 0) {
3315   - r_num = em.data.data;
3316   - }
  3206 + if (res.data.code == 0) {
  3207 + // 当前可以购买的数量
  3208 + let r_num = res.data.data;
  3209 + return r_num;
  3210 + };
3317 3211 })
3318   - func(r_num);
3319 3212 },
3320 3213  
3321 3214  
... ... @@ -3554,7 +3447,7 @@ Page({
3554 3447 //----获取商品购买数----
3555 3448 if (th.data.prom_type == 1) {
3556 3449 //----获取活动购买数----
3557   - getApp().request.get("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", {
  3450 + getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", {
3558 3451 data: {
3559 3452 store_id: os.stoid,
3560 3453 user_id: user_id,
... ... @@ -3582,6 +3475,49 @@ Page({
3582 3475 },
3583 3476  
3584 3477  
  3478 + get_buy_num2: async function () {
  3479 + // var map = this.data.g_buy_num,
  3480 + var th = this,
  3481 + user_id = getApp().globalData.user_id;
  3482 + // if (user_id == null) {
  3483 + // // map.set(gd.goods_id, 0);
  3484 + // th.setData({
  3485 + // // g_buy_num: map,
  3486 + // prom_buy_num: 0,
  3487 + // });
  3488 + // "function" == typeof func && func();
  3489 + // return false;
  3490 + // }
  3491 +
  3492 +
  3493 + //----获取商品购买数----
  3494 +
  3495 + //----获取活动购买数----
  3496 + return await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", {
  3497 + data: {
  3498 + store_id: os.stoid,
  3499 + user_id: user_id,
  3500 + card_id: th.data.options.goods_id,
  3501 + prom_type: th.data.options.prom_type,
  3502 + prom_id: th.data.options.prom_id
  3503 + },
  3504 + //-----获取-----
  3505 + success: function (tt) {
  3506 + if (tt.data.code == 0) {
  3507 + // map.set(gd.goods_id, g_buy_num);
  3508 + th.setData({
  3509 + // g_buy_num: map,
  3510 + promcardbuynum: tt.data.data.promcardbuynum,
  3511 + cardbuynum: tt.data.data.cardbuynum,
  3512 + });
  3513 + }
  3514 + }
  3515 + });
  3516 +
  3517 +
  3518 + },
  3519 +
  3520 +
3585 3521  
3586 3522  
3587 3523  
... ...
pages/cart/cart/cart.js
... ... @@ -2063,17 +2063,20 @@ Page({
2063 2063 });
2064 2064  
2065 2065 //----获取用户活动购买数----
  2066 + var gd_buy_num = 0;
2066 2067 await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum?store_id="+t.store_id+"&user_id="+getApp().globalData.user_id+"&card_id="+t.goods_id+"&prom_type="+t.prom_type+"&prom_id="+t.prom_id, {
2067 2068 }).then(tt => {
2068 2069 if (tt.data.code == 0) {
  2070 + gd_buy_num = !tt.data.promcardbuynum ? 0 : tt.data.promcardbuynum;
2069 2071 th.setData({
2070   - promcardbuynum: !th.data.promcardbuynum ? 0 : th.data.promcardbuynum,
  2072 + promcardbuynum: !tt.data.promcardbuynum ? 0 : tt.data.promcardbuynum,
2071 2073 cardbuynum: tt.data.data.cardbuynum,
2072 2074 });
2073 2075 };
2074 2076 });
2075 2077  
2076   - var gd_buy_num = !th.data.promcardbuynum ? 0 : th.data.promcardbuynum;
  2078 +
  2079 +
2077 2080  
2078 2081 if(t.goods_num > redis_num) {
2079 2082 wx.showToast({
... ... @@ -2197,7 +2200,7 @@ Page({
2197 2200 // 计算还可以购买的数量:库存量 - 已购数
2198 2201 wx.showToast({
2199 2202 title: '超出活动限购',
2200   - icon: 'none',
  2203 + icon: 'none',
2201 2204 });
2202 2205 th.setData({[txt]: buylimit});
2203 2206  
... ... @@ -2634,9 +2637,12 @@ Page({
2634 2637 }
2635 2638 });
2636 2639 } else {
  2640 +
2637 2641 //-- 开始服务卡的购物车购买 --
2638 2642 for (var i = 0; i < this.data.service_data.length; i++) {
2639 2643 var i_arr = this.data.service_data[i].goods;
  2644 + console.log(i_arr)
  2645 +
2640 2646 for (var j = 0; j < i_arr.length; j++) {
2641 2647 await rq.promisePut("/api/weshop/cartService/update", {
2642 2648 data: {
... ...