From d372f4b3e24bba63ed63f965fa4b7f402f4a56ef Mon Sep 17 00:00:00 2001 From: taiwan Date: Tue, 15 Mar 2022 09:58:28 +0800 Subject: [PATCH] 服务卡商品详情获取购买数量修改 --- packageA/pages/goodsInfo/goodsInfo.js | 355 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1 file changed, 182 insertions(+), 173 deletions(-) diff --git a/packageA/pages/goodsInfo/goodsInfo.js b/packageA/pages/goodsInfo/goodsInfo.js index d68a1a0..ccc3613 100644 --- a/packageA/pages/goodsInfo/goodsInfo.js +++ b/packageA/pages/goodsInfo/goodsInfo.js @@ -893,7 +893,7 @@ Page({ if (t + gd_buy_num > th.data.sele_g.viplimited) { wx.showModal({ - title: '超出商品限购', + title: '超出活动限购数量', }); let num = th.data.sele_g.viplimited - gd_buy_num; @@ -1067,122 +1067,106 @@ Page({ // th.setData({goodsInputNum:t}); // if(this.data.options.prom_type == 1 && !this.data.openSpecModal_flash_normal) { - - this.get_buy_num(this.data.sele_g, async function () { - th.data.sele_g.viplimited = th.data.sele_g.buy_limit; - - //--判断商品是否超出限购-- - // if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { - // if(!th.data.prom_act.is_shop_buy) { - - // if (th.data.sele_g.viplimited > 0) { - // var gd_buy_num = th.data.sele_g.buy_num; + + this.get_buy_num(this.data.sele_g, async function () { + th.data.sele_g.viplimited = th.data.sele_g.buy_limit; - // if (t + gd_buy_num> th.data.sele_g.viplimited) { - // wx.showModal({ - // title: '超出商品限购', - // }); + //--判断商品是否超出限购-- + // if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { + // if(!th.data.prom_act.is_shop_buy) { + + // if (th.data.sele_g.viplimited > 0) { + // var gd_buy_num = th.data.sele_g.buy_num; + + // if (t + gd_buy_num> th.data.sele_g.viplimited) { + // wx.showModal({ + // title: '超出商品限购', + // }); + + // var num = th.data.sele_g.viplimited - gd_buy_num; + // if (num <= 0) num = 1; + // th.setData({goodsInputNum: num}) + // return false; + // } + // }; + + + // 单独购买 + if(th.data.openSpecModal_flash_normal) th.data.is_normal = 1; - // var num = th.data.sele_g.viplimited - gd_buy_num; - // if (num <= 0) num = 1; - // th.setData({goodsInputNum: num}) - // return false; - // } - // }; + // 秒杀:判断活动是否抢光 + if (th.data.sele_g.prom_type == 1 && !th.data.is_normal) { + var redis_num = 0; + //------判断活动是否抢光----- + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + + os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, { + 1: 1 + }).then(res => { + redis_num = res.data.data; + }); + + if (t > redis_num) { + wx.showModal({ + // title: '超出商品活动库存', + title: '来晚了,已被抢光~', + }); + th.setData({goodsInputNum: redis_num}) + return false; + } + }; - - // 单独购买 - if(th.data.openSpecModal_flash_normal) th.data.is_normal = 1; - - // 秒杀:判断活动是否抢光 - if (th.data.sele_g.prom_type == 1 && !th.data.is_normal) { - var redis_num = 0; - //------判断活动是否抢光----- - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + - os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, { - 1: 1 - }).then(res => { - redis_num = res.data.data; - }); - - if (t > redis_num) { - wx.showModal({ - // title: '超出商品活动库存', - title: '来晚了,已被抢光~', - }); - th.setData({goodsInputNum: redis_num}) - return false; - } - }; - - //--秒杀:判断商品是否超出活动限购-- - if (th.data.sele_g.viplimited > 0 && !th.data.is_normal && th.data.prom_type == 1) { - var gd_buy_num = th.data.sele_g.buy_num; + //--秒杀:判断商品是否超出活动限购-- + if (th.data.sele_g.viplimited > 0 && !th.data.is_normal && th.data.prom_type == 1) { + var gd_buy_num = th.data.promcardbuynum; + + if (t + gd_buy_num> th.data.sele_g.viplimited) { + wx.showModal({ + title: '超出活动限购数量', + }); + + var num = th.data.sele_g.viplimited - gd_buy_num; + if (num <= 0) num = 1; + th.setData({goodsInputNum: num}) + return false; + } + }; - if (t + gd_buy_num> th.data.sele_g.viplimited) { - wx.showModal({ - title: '超出商品活动限购', - }); - - var num = th.data.sele_g.viplimited - gd_buy_num; - if (num <= 0) num = 1; - th.setData({goodsInputNum: num}) - return false; - } - }; - - //--秒杀:判断商品是否超出活动限购-- - // if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0 && !th.data.is_normal) { - // if (t + th.data.prom_buy_num > th.data.prom_buy_limit) { - // wx.showModal({ - // title: '超出商品活动限购', - // }); - - // var num = th.data.prom_buy_limit - th.data.prom_buy_num; - // if (num < 0) num = 0; - // th.setData({goodsInputNum: num}) - // return false; - // }; - // }; - - - - - - // var e = th.data.sele_g.goods_num; - var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4 - 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)) { - if (!th.data.def_pick_store) { - wx.showModal({title: '请选择门店',}); - return false; - } else { - // e = th.data.def_pick_store.CanOutQty; - } - } - - // 单独购买时 - if(th.data.openSpecModal_flash_normal && th.data.prom_type == 1) { - // if (!e) e = 0; - // //库存不足,不增加 - // if (e < t) { - // wx.showModal({title: '购买数量不能超出库存',}); - // if (e < 0) e = 0; - // th.setData({goodsInputNum: e}); - // return false; - // }; - // t > e || 0 == e ? t = e : t < 1 && (t = 1); - }; - - th.setData({goodsInputNum: t}); + //--秒杀:判断商品是否超出活动限购-- + // if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0 && !th.data.is_normal) { + // if (t + th.data.prom_buy_num > th.data.prom_buy_limit) { + // wx.showModal({ + // title: '超出商品活动限购', + // }); + + // var num = th.data.prom_buy_limit - th.data.prom_buy_num; + // if (num < 0) num = 0; + // th.setData({goodsInputNum: num}) + // return false; + // }; + // }; + + + + + + // var e = th.data.sele_g.goods_num; + var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4 + 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)) { + if (!th.data.def_pick_store) { + wx.showModal({title: '请选择门店',}); + return false; + } else { + // e = th.data.def_pick_store.CanOutQty; + } + } + + + + th.setData({goodsInputNum: t}); + + }); + - }) - - // }; - - - - - }, @@ -3297,7 +3281,7 @@ Page({ //如果是进行中的话 if (endTime1 < newTime) { //-- 获取秒杀活动的多少规格 -- - ee.get_more_flahs(function (list) { + ee.get_more_flash(function (list) { if (list && list.length > 1) { var n_item = list[0]; @@ -3364,7 +3348,7 @@ Page({ //获取更多秒杀 - get_more_flahs: async function (func) { + get_more_flash: async function (func) { var f_more = false; var user_id = getApp().globalData.user_id; if (!user_id) user_id = 0; @@ -3425,64 +3409,89 @@ Page({ // "function" == typeof func && func(); // } else { //----获取商品购买数---- - getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", { - data: { - store_id: os.stoid, - user_id: user_id, - goods_id: gd.goods_id, - }, - success: function (t) { - if (t.data.code == 0) { - // var g_buy_num = t.data.data.goodsbuynum; - - //如果是秒杀的时候 - // if (th.data.prom_type == 0 && gd.prom_type == 1) { - // gd.prom_type = 0; - // } - // //如果全场优惠,商品做了秒杀 - // if (th.data.prom_type == 3 && gd.prom_type == 1) { - // gd.prom_type = 0; - // } - // //如果全场阶梯优惠,商品做了秒杀 - // if (th.data.prom_type == 10 && gd.prom_type == 1) { - // gd.prom_type = 0; - // } - - - if (th.data.prom_type == 1) { - //----获取活动购买数---- - getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", { - data: { - store_id: os.stoid, - user_id: user_id, - goods_id: th.data.options.goods_id, - prom_type: th.data.options.prom_type, - prom_id: th.data.options.prom_id - }, - //-----获取----- - success: function (tt) { - if (tt.data.code == 0) { - // map.set(gd.goods_id, g_buy_num); - th.setData({ - // g_buy_num: map, - prom_buy_num: tt.data.data.goodsbuynum, - goodsbuynum: t.data.data.goodsbuynum, - }); - "function" == typeof func && func(); - } - } - }); - } else { - // map.set(gd.goods_id, g_buy_num); - // th.setData({ - // g_buy_num: map - // }); - "function" == typeof func && func(); - }; - } - }, + if (th.data.prom_type == 1) { + //----获取活动购买数---- + getApp().request.get("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", { + data: { + store_id: os.stoid, + user_id: user_id, + card_id: th.data.options.goods_id, + prom_type: th.data.options.prom_type, + prom_id: th.data.options.prom_id + }, + //-----获取----- + success: function (tt) { + if (tt.data.code == 0) { + // map.set(gd.goods_id, g_buy_num); + th.setData({ + // g_buy_num: map, + promcardbuynum: tt.data.data.promcardbuynum, + cardbuynum: tt.data.data.cardbuynum, + }); + "function" == typeof func && func(); + } + } + }); + } else { + "function" == typeof func && func(); + }; + + // getApp().request.get("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", { + // data: { + // store_id: os.stoid, + // user_id: user_id, + // card_id: gd.goods_id, + // prom_type: th.data.options.prom_type, + // prom_id: th.data.options.prom_id, + // }, + // success: function (t) { + // if (t.data.code == 0) { + // // var g_buy_num = t.data.data.goodsbuynum; + + // //如果是秒杀的时候 + // // if (th.data.prom_type == 0 && gd.prom_type == 1) { + // // gd.prom_type = 0; + // // } + // // //如果全场优惠,商品做了秒杀 + // // if (th.data.prom_type == 3 && gd.prom_type == 1) { + // // gd.prom_type = 0; + // // } + // // //如果全场阶梯优惠,商品做了秒杀 + // // if (th.data.prom_type == 10 && gd.prom_type == 1) { + // // gd.prom_type = 0; + // // } + + + // if (th.data.prom_type == 1) { + // //----获取活动购买数---- + // getApp().request.get("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", { + // data: { + // store_id: os.stoid, + // user_id: user_id, + // card_id: th.data.options.goods_id, + // prom_type: th.data.options.prom_type, + // prom_id: th.data.options.prom_id + // }, + // //-----获取----- + // success: function (tt) { + // if (tt.data.code == 0) { + // // map.set(gd.goods_id, g_buy_num); + // th.setData({ + // // g_buy_num: map, + // promcardbuynum: tt.data.data.promcardbuynum, + // cardbuynum: t.data.data.cardbuynum, + // }); + // "function" == typeof func && func(); + // } + // } + // }); + // } else { + // "function" == typeof func && func(); + // }; + // } + // }, - }); + // }); // } }, @@ -3621,7 +3630,7 @@ Page({ if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { wx.showModal({ title: '提示', - content: '超出商品限购' + content: '超出活动限购数量' }); return false; } @@ -3631,7 +3640,7 @@ Page({ if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) { wx.showModal({ title: '提示', - content: '超出商品活动限购' + content: '超出活动限购数量' }); return false; } -- libgit2 0.21.4