Commit d372f4b3e24bba63ed63f965fa4b7f402f4a56ef
1 parent
555b4f3a
服务卡商品详情获取购买数量修改
Showing
1 changed file
with
182 additions
and
173 deletions
packageA/pages/goodsInfo/goodsInfo.js
... | ... | @@ -893,7 +893,7 @@ Page({ |
893 | 893 | |
894 | 894 | if (t + gd_buy_num > th.data.sele_g.viplimited) { |
895 | 895 | wx.showModal({ |
896 | - title: '超出商品限购', | |
896 | + title: '超出活动限购数量', | |
897 | 897 | }); |
898 | 898 | |
899 | 899 | let num = th.data.sele_g.viplimited - gd_buy_num; |
... | ... | @@ -1067,122 +1067,106 @@ Page({ |
1067 | 1067 | // th.setData({goodsInputNum:t}); |
1068 | 1068 | |
1069 | 1069 | // if(this.data.options.prom_type == 1 && !this.data.openSpecModal_flash_normal) { |
1070 | - | |
1071 | - this.get_buy_num(this.data.sele_g, async function () { | |
1072 | - th.data.sele_g.viplimited = th.data.sele_g.buy_limit; | |
1073 | - | |
1074 | - //--判断商品是否超出限购-- | |
1075 | - // if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { | |
1076 | - // if(!th.data.prom_act.is_shop_buy) { | |
1077 | - | |
1078 | - // if (th.data.sele_g.viplimited > 0) { | |
1079 | - // var gd_buy_num = th.data.sele_g.buy_num; | |
1070 | + | |
1071 | + this.get_buy_num(this.data.sele_g, async function () { | |
1072 | + th.data.sele_g.viplimited = th.data.sele_g.buy_limit; | |
1080 | 1073 | |
1081 | - // if (t + gd_buy_num> th.data.sele_g.viplimited) { | |
1082 | - // wx.showModal({ | |
1083 | - // title: '超出商品限购', | |
1084 | - // }); | |
1074 | + //--判断商品是否超出限购-- | |
1075 | + // if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { | |
1076 | + // if(!th.data.prom_act.is_shop_buy) { | |
1077 | + | |
1078 | + // if (th.data.sele_g.viplimited > 0) { | |
1079 | + // var gd_buy_num = th.data.sele_g.buy_num; | |
1080 | + | |
1081 | + // if (t + gd_buy_num> th.data.sele_g.viplimited) { | |
1082 | + // wx.showModal({ | |
1083 | + // title: '超出商品限购', | |
1084 | + // }); | |
1085 | + | |
1086 | + // var num = th.data.sele_g.viplimited - gd_buy_num; | |
1087 | + // if (num <= 0) num = 1; | |
1088 | + // th.setData({goodsInputNum: num}) | |
1089 | + // return false; | |
1090 | + // } | |
1091 | + // }; | |
1092 | + | |
1093 | + | |
1094 | + // 单独购买 | |
1095 | + if(th.data.openSpecModal_flash_normal) th.data.is_normal = 1; | |
1085 | 1096 | |
1086 | - // var num = th.data.sele_g.viplimited - gd_buy_num; | |
1087 | - // if (num <= 0) num = 1; | |
1088 | - // th.setData({goodsInputNum: num}) | |
1089 | - // return false; | |
1090 | - // } | |
1091 | - // }; | |
1097 | + // 秒杀:判断活动是否抢光 | |
1098 | + if (th.data.sele_g.prom_type == 1 && !th.data.is_normal) { | |
1099 | + var redis_num = 0; | |
1100 | + //------判断活动是否抢光----- | |
1101 | + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + | |
1102 | + os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, { | |
1103 | + 1: 1 | |
1104 | + }).then(res => { | |
1105 | + redis_num = res.data.data; | |
1106 | + }); | |
1107 | + | |
1108 | + if (t > redis_num) { | |
1109 | + wx.showModal({ | |
1110 | + // title: '超出商品活动库存', | |
1111 | + title: '来晚了,已被抢光~', | |
1112 | + }); | |
1113 | + th.setData({goodsInputNum: redis_num}) | |
1114 | + return false; | |
1115 | + } | |
1116 | + }; | |
1092 | 1117 | |
1093 | - | |
1094 | - // 单独购买 | |
1095 | - if(th.data.openSpecModal_flash_normal) th.data.is_normal = 1; | |
1096 | - | |
1097 | - // 秒杀:判断活动是否抢光 | |
1098 | - if (th.data.sele_g.prom_type == 1 && !th.data.is_normal) { | |
1099 | - var redis_num = 0; | |
1100 | - //------判断活动是否抢光----- | |
1101 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + | |
1102 | - os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, { | |
1103 | - 1: 1 | |
1104 | - }).then(res => { | |
1105 | - redis_num = res.data.data; | |
1106 | - }); | |
1107 | - | |
1108 | - if (t > redis_num) { | |
1109 | - wx.showModal({ | |
1110 | - // title: '超出商品活动库存', | |
1111 | - title: '来晚了,已被抢光~', | |
1112 | - }); | |
1113 | - th.setData({goodsInputNum: redis_num}) | |
1114 | - return false; | |
1115 | - } | |
1116 | - }; | |
1117 | - | |
1118 | - //--秒杀:判断商品是否超出活动限购-- | |
1119 | - if (th.data.sele_g.viplimited > 0 && !th.data.is_normal && th.data.prom_type == 1) { | |
1120 | - var gd_buy_num = th.data.sele_g.buy_num; | |
1118 | + //--秒杀:判断商品是否超出活动限购-- | |
1119 | + if (th.data.sele_g.viplimited > 0 && !th.data.is_normal && th.data.prom_type == 1) { | |
1120 | + var gd_buy_num = th.data.promcardbuynum; | |
1121 | + | |
1122 | + if (t + gd_buy_num> th.data.sele_g.viplimited) { | |
1123 | + wx.showModal({ | |
1124 | + title: '超出活动限购数量', | |
1125 | + }); | |
1126 | + | |
1127 | + var num = th.data.sele_g.viplimited - gd_buy_num; | |
1128 | + if (num <= 0) num = 1; | |
1129 | + th.setData({goodsInputNum: num}) | |
1130 | + return false; | |
1131 | + } | |
1132 | + }; | |
1121 | 1133 | |
1122 | - if (t + gd_buy_num> th.data.sele_g.viplimited) { | |
1123 | - wx.showModal({ | |
1124 | - title: '超出商品活动限购', | |
1125 | - }); | |
1126 | - | |
1127 | - var num = th.data.sele_g.viplimited - gd_buy_num; | |
1128 | - if (num <= 0) num = 1; | |
1129 | - th.setData({goodsInputNum: num}) | |
1130 | - return false; | |
1131 | - } | |
1132 | - }; | |
1133 | - | |
1134 | - //--秒杀:判断商品是否超出活动限购-- | |
1135 | - // if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0 && !th.data.is_normal) { | |
1136 | - // if (t + th.data.prom_buy_num > th.data.prom_buy_limit) { | |
1137 | - // wx.showModal({ | |
1138 | - // title: '超出商品活动限购', | |
1139 | - // }); | |
1140 | - | |
1141 | - // var num = th.data.prom_buy_limit - th.data.prom_buy_num; | |
1142 | - // if (num < 0) num = 0; | |
1143 | - // th.setData({goodsInputNum: num}) | |
1144 | - // return false; | |
1145 | - // }; | |
1146 | - // }; | |
1147 | - | |
1148 | - | |
1149 | - | |
1150 | - | |
1151 | - | |
1152 | - // var e = th.data.sele_g.goods_num; | |
1153 | - var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4 | |
1154 | - 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)) { | |
1155 | - if (!th.data.def_pick_store) { | |
1156 | - wx.showModal({title: '请选择门店',}); | |
1157 | - return false; | |
1158 | - } else { | |
1159 | - // e = th.data.def_pick_store.CanOutQty; | |
1160 | - } | |
1161 | - } | |
1162 | - | |
1163 | - // 单独购买时 | |
1164 | - if(th.data.openSpecModal_flash_normal && th.data.prom_type == 1) { | |
1165 | - // if (!e) e = 0; | |
1166 | - // //库存不足,不增加 | |
1167 | - // if (e < t) { | |
1168 | - // wx.showModal({title: '购买数量不能超出库存',}); | |
1169 | - // if (e < 0) e = 0; | |
1170 | - // th.setData({goodsInputNum: e}); | |
1171 | - // return false; | |
1172 | - // }; | |
1173 | - // t > e || 0 == e ? t = e : t < 1 && (t = 1); | |
1174 | - }; | |
1175 | - | |
1176 | - th.setData({goodsInputNum: t}); | |
1134 | + //--秒杀:判断商品是否超出活动限购-- | |
1135 | + // if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0 && !th.data.is_normal) { | |
1136 | + // if (t + th.data.prom_buy_num > th.data.prom_buy_limit) { | |
1137 | + // wx.showModal({ | |
1138 | + // title: '超出商品活动限购', | |
1139 | + // }); | |
1140 | + | |
1141 | + // var num = th.data.prom_buy_limit - th.data.prom_buy_num; | |
1142 | + // if (num < 0) num = 0; | |
1143 | + // th.setData({goodsInputNum: num}) | |
1144 | + // return false; | |
1145 | + // }; | |
1146 | + // }; | |
1147 | + | |
1148 | + | |
1149 | + | |
1150 | + | |
1151 | + | |
1152 | + // var e = th.data.sele_g.goods_num; | |
1153 | + var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4 | |
1154 | + 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)) { | |
1155 | + if (!th.data.def_pick_store) { | |
1156 | + wx.showModal({title: '请选择门店',}); | |
1157 | + return false; | |
1158 | + } else { | |
1159 | + // e = th.data.def_pick_store.CanOutQty; | |
1160 | + } | |
1161 | + } | |
1162 | + | |
1163 | + | |
1164 | + | |
1165 | + th.setData({goodsInputNum: t}); | |
1166 | + | |
1167 | + }); | |
1168 | + | |
1177 | 1169 | |
1178 | - }) | |
1179 | - | |
1180 | - // }; | |
1181 | - | |
1182 | - | |
1183 | - | |
1184 | - | |
1185 | - | |
1186 | 1170 | }, |
1187 | 1171 | |
1188 | 1172 | |
... | ... | @@ -3297,7 +3281,7 @@ Page({ |
3297 | 3281 | //如果是进行中的话 |
3298 | 3282 | if (endTime1 < newTime) { |
3299 | 3283 | //-- 获取秒杀活动的多少规格 -- |
3300 | - ee.get_more_flahs(function (list) { | |
3284 | + ee.get_more_flash(function (list) { | |
3301 | 3285 | if (list && list.length > 1) { |
3302 | 3286 | |
3303 | 3287 | var n_item = list[0]; |
... | ... | @@ -3364,7 +3348,7 @@ Page({ |
3364 | 3348 | |
3365 | 3349 | |
3366 | 3350 | //获取更多秒杀 |
3367 | - get_more_flahs: async function (func) { | |
3351 | + get_more_flash: async function (func) { | |
3368 | 3352 | var f_more = false; |
3369 | 3353 | var user_id = getApp().globalData.user_id; |
3370 | 3354 | if (!user_id) user_id = 0; |
... | ... | @@ -3425,64 +3409,89 @@ Page({ |
3425 | 3409 | // "function" == typeof func && func(); |
3426 | 3410 | // } else { |
3427 | 3411 | //----获取商品购买数---- |
3428 | - getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", { | |
3429 | - data: { | |
3430 | - store_id: os.stoid, | |
3431 | - user_id: user_id, | |
3432 | - goods_id: gd.goods_id, | |
3433 | - }, | |
3434 | - success: function (t) { | |
3435 | - if (t.data.code == 0) { | |
3436 | - // var g_buy_num = t.data.data.goodsbuynum; | |
3437 | - | |
3438 | - //如果是秒杀的时候 | |
3439 | - // if (th.data.prom_type == 0 && gd.prom_type == 1) { | |
3440 | - // gd.prom_type = 0; | |
3441 | - // } | |
3442 | - // //如果全场优惠,商品做了秒杀 | |
3443 | - // if (th.data.prom_type == 3 && gd.prom_type == 1) { | |
3444 | - // gd.prom_type = 0; | |
3445 | - // } | |
3446 | - // //如果全场阶梯优惠,商品做了秒杀 | |
3447 | - // if (th.data.prom_type == 10 && gd.prom_type == 1) { | |
3448 | - // gd.prom_type = 0; | |
3449 | - // } | |
3450 | - | |
3451 | - | |
3452 | - if (th.data.prom_type == 1) { | |
3453 | - //----获取活动购买数---- | |
3454 | - getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", { | |
3455 | - data: { | |
3456 | - store_id: os.stoid, | |
3457 | - user_id: user_id, | |
3458 | - goods_id: th.data.options.goods_id, | |
3459 | - prom_type: th.data.options.prom_type, | |
3460 | - prom_id: th.data.options.prom_id | |
3461 | - }, | |
3462 | - //-----获取----- | |
3463 | - success: function (tt) { | |
3464 | - if (tt.data.code == 0) { | |
3465 | - // map.set(gd.goods_id, g_buy_num); | |
3466 | - th.setData({ | |
3467 | - // g_buy_num: map, | |
3468 | - prom_buy_num: tt.data.data.goodsbuynum, | |
3469 | - goodsbuynum: t.data.data.goodsbuynum, | |
3470 | - }); | |
3471 | - "function" == typeof func && func(); | |
3472 | - } | |
3473 | - } | |
3474 | - }); | |
3475 | - } else { | |
3476 | - // map.set(gd.goods_id, g_buy_num); | |
3477 | - // th.setData({ | |
3478 | - // g_buy_num: map | |
3479 | - // }); | |
3480 | - "function" == typeof func && func(); | |
3481 | - }; | |
3482 | - } | |
3483 | - }, | |
3412 | + if (th.data.prom_type == 1) { | |
3413 | + //----获取活动购买数---- | |
3414 | + getApp().request.get("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", { | |
3415 | + data: { | |
3416 | + store_id: os.stoid, | |
3417 | + user_id: user_id, | |
3418 | + card_id: th.data.options.goods_id, | |
3419 | + prom_type: th.data.options.prom_type, | |
3420 | + prom_id: th.data.options.prom_id | |
3421 | + }, | |
3422 | + //-----获取----- | |
3423 | + success: function (tt) { | |
3424 | + if (tt.data.code == 0) { | |
3425 | + // map.set(gd.goods_id, g_buy_num); | |
3426 | + th.setData({ | |
3427 | + // g_buy_num: map, | |
3428 | + promcardbuynum: tt.data.data.promcardbuynum, | |
3429 | + cardbuynum: tt.data.data.cardbuynum, | |
3430 | + }); | |
3431 | + "function" == typeof func && func(); | |
3432 | + } | |
3433 | + } | |
3434 | + }); | |
3435 | + } else { | |
3436 | + "function" == typeof func && func(); | |
3437 | + }; | |
3438 | + | |
3439 | + // getApp().request.get("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", { | |
3440 | + // data: { | |
3441 | + // store_id: os.stoid, | |
3442 | + // user_id: user_id, | |
3443 | + // card_id: gd.goods_id, | |
3444 | + // prom_type: th.data.options.prom_type, | |
3445 | + // prom_id: th.data.options.prom_id, | |
3446 | + // }, | |
3447 | + // success: function (t) { | |
3448 | + // if (t.data.code == 0) { | |
3449 | + // // var g_buy_num = t.data.data.goodsbuynum; | |
3450 | + | |
3451 | + // //如果是秒杀的时候 | |
3452 | + // // if (th.data.prom_type == 0 && gd.prom_type == 1) { | |
3453 | + // // gd.prom_type = 0; | |
3454 | + // // } | |
3455 | + // // //如果全场优惠,商品做了秒杀 | |
3456 | + // // if (th.data.prom_type == 3 && gd.prom_type == 1) { | |
3457 | + // // gd.prom_type = 0; | |
3458 | + // // } | |
3459 | + // // //如果全场阶梯优惠,商品做了秒杀 | |
3460 | + // // if (th.data.prom_type == 10 && gd.prom_type == 1) { | |
3461 | + // // gd.prom_type = 0; | |
3462 | + // // } | |
3463 | + | |
3464 | + | |
3465 | + // if (th.data.prom_type == 1) { | |
3466 | + // //----获取活动购买数---- | |
3467 | + // getApp().request.get("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", { | |
3468 | + // data: { | |
3469 | + // store_id: os.stoid, | |
3470 | + // user_id: user_id, | |
3471 | + // card_id: th.data.options.goods_id, | |
3472 | + // prom_type: th.data.options.prom_type, | |
3473 | + // prom_id: th.data.options.prom_id | |
3474 | + // }, | |
3475 | + // //-----获取----- | |
3476 | + // success: function (tt) { | |
3477 | + // if (tt.data.code == 0) { | |
3478 | + // // map.set(gd.goods_id, g_buy_num); | |
3479 | + // th.setData({ | |
3480 | + // // g_buy_num: map, | |
3481 | + // promcardbuynum: tt.data.data.promcardbuynum, | |
3482 | + // cardbuynum: t.data.data.cardbuynum, | |
3483 | + // }); | |
3484 | + // "function" == typeof func && func(); | |
3485 | + // } | |
3486 | + // } | |
3487 | + // }); | |
3488 | + // } else { | |
3489 | + // "function" == typeof func && func(); | |
3490 | + // }; | |
3491 | + // } | |
3492 | + // }, | |
3484 | 3493 | |
3485 | - }); | |
3494 | + // }); | |
3486 | 3495 | // } |
3487 | 3496 | }, |
3488 | 3497 | |
... | ... | @@ -3621,7 +3630,7 @@ Page({ |
3621 | 3630 | if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { |
3622 | 3631 | wx.showModal({ |
3623 | 3632 | title: '提示', |
3624 | - content: '超出商品限购' | |
3633 | + content: '超出活动限购数量' | |
3625 | 3634 | }); |
3626 | 3635 | return false; |
3627 | 3636 | } |
... | ... | @@ -3631,7 +3640,7 @@ Page({ |
3631 | 3640 | if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) { |
3632 | 3641 | wx.showModal({ |
3633 | 3642 | title: '提示', |
3634 | - content: '超出商品活动限购' | |
3643 | + content: '超出活动限购数量' | |
3635 | 3644 | }); |
3636 | 3645 | return false; |
3637 | 3646 | } | ... | ... |