From 397285c57287e6ad2a1ee1a3879192e5ffcc6b4d Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Thu, 25 Nov 2021 09:33:46 +0800 Subject: [PATCH] 拼团和积分购 单独购买按钮和 立即购买按钮再切换的时候, 库存和限购判断的错误修复 --- pages/goods/goodsInfo/g_filter.wxs | 3 ++- pages/goods/goodsInfo/goodsInfo.js | 45 ++++++++++++++++++++++++++++++++++++--------- pages/goods/goodsInfo/goodsInfo.wxml | 9 +++++---- 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/pages/goods/goodsInfo/g_filter.wxs b/pages/goods/goodsInfo/g_filter.wxs index 9b22f57..0809be9 100644 --- a/pages/goods/goodsInfo/g_filter.wxs +++ b/pages/goods/goodsInfo/g_filter.wxs @@ -93,7 +93,8 @@ var g_filters = { //折扣数值处理,小数位数为1时,只显示1位;小数位数为2时,才显示2位; num: function(value) { if(value != 0) { - return parseFloat(value); + var r=value.toFixed(2)+""; + return parseFloat(r); } else { return value.toFixed(0); }; diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index 63a297b..1499bcd 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -1072,8 +1072,6 @@ Page({ } }, - - //-- 加入购物的函数 -- add_cart_func_inte: function (t) { var i = getApp().request; @@ -1169,8 +1167,11 @@ Page({ if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); if (o.store_count < e.data.goodsInputNum) return s.my_warnning("库存不足!", 0, th); - - th.add_cart_next(e, t, a, o, newd); //立即购买下一步 + var i_canbuy=th.data.prom_act.limitqty-th.data.prom_act.buy_num; + if(i_canbuy 0) { + if((th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) && !th.data.is_normal) { if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) { wx.showModal({ title: '提示', @@ -1669,7 +1670,7 @@ Page({ } } - if (th.data.sele_g.prom_type == 1 || th.data.sele_g.prom_type == 6) { + if((th.data.sele_g.prom_type == 1 || th.data.sele_g.prom_type == 6) && !th.data.is_normal) { var redis_num = 0; //------判断活动是否抢光----- await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + @@ -1715,7 +1716,7 @@ Page({ checkCartNum_inte: function (t) { var th = this; this.get_buy_num(this.data.data, async function () { - + ; //--判断商品是否超出限购-- if (th.data.g_buy_num != null && th.data.data.viplimited > 0) { @@ -1764,7 +1765,18 @@ Page({ th.setData({ goodsInputNum: redis_num }) return false; } + } + + //判断积分购库存 + if(!th.data.is_normal && th.data.prom_type==4){ + var i_canbuy=th.data.prom_act.limitqty-th.data.prom_act.buy_num; + if(t>i_canbuy){ + wx.showModal({ + title: '超出商品活动库存', + }); + return false; + } } var e = th.data.sele_g.store_count; @@ -2424,7 +2436,7 @@ Page({ th.setData({ prom_type: goodsinfo.prom_type, prom_price: prom.price, - prom_buy_limit: prom.buy_limit, + prom_buy_limit: prom.buy_limit?prom.buy_limit:(prom.limitvipqty? prom.limitvipqty:0), prom_end_time: prom.end_time, prom_start_time: prom.start_time, prom_st: prom_st, @@ -3606,7 +3618,7 @@ Page({ gd.prom_type= 0; } - if (gd.prom_type == 1 || gd.prom_type == 2 || gd.prom_type == 4 || gd.prom_type == 6) { + if (!th.data.is_normal && ( gd.prom_type == 1 || gd.prom_type == 2 || gd.prom_type == 4 || gd.prom_type == 6)) { //----获取活动购买数---- getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", { data: { @@ -3679,8 +3691,14 @@ Page({ var th = this; var ind = parseInt(e.currentTarget.dataset.it); + //如果是拼单活动的普通购买 if (ind == 1) { + + if(!th.data.is_normal) { + th.data.g_buy_num=new Map(); + } + //如果拼单的sku data是空的,就要先获取一下 if (th.data.sku_g_pt) { th.get_sto(1); @@ -3700,6 +3718,10 @@ Page({ th.check_is_youhui(th.data.gid, 1); } else { + if(th.data.is_normal) { + th.data.g_buy_num=new Map(); + } + //拼单商品从这里进,先判断有没有买过商品, getApp().request.get("/api/weshop/order/page", { data: { @@ -5795,11 +5817,16 @@ Page({ //-- 积分购 -- go_pay_integral: function () { + this.data.g_buy_num = new Map(); this.get_sto(0) this.setData({ openSpecModal_inte: 1, goodsInputNum: 1 }); + + }, //-- 积分购普通购买 -- go_pay_integral_normal: function () { + + this.data.g_buy_num = new Map(); var th = this; if (th.data.sku_g_pt) { this.get_sto(1) diff --git a/pages/goods/goodsInfo/goodsInfo.wxml b/pages/goods/goodsInfo/goodsInfo.wxml index 09c23f6..9290e29 100644 --- a/pages/goods/goodsInfo/goodsInfo.wxml +++ b/pages/goods/goodsInfo/goodsInfo.wxml @@ -435,11 +435,12 @@ {{data.goods_name}} - - + + -- 88888 -- + 销量:{{data.sales_sum}}件 - 折扣:{{data.disc}}折 + 折扣:{{g_filters.num(data.disc)}}折 {{categories3[0].num}}人评价 @@ -587,7 +588,7 @@ - +