From dfbb5336669e3e94d9e6e68ea1db735f3e6ff753 Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Mon, 30 Oct 2023 17:50:15 +0800 Subject: [PATCH] 商品的多规格的bug优化, 金额和价格的错误~~ --- packageC/pages/luckyGo/luckyGo_goodsInfo/buy_pt.wxml | 4 ++-- packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js | 46 +++++++++++++++++++++++++++++++++++++--------- pages/goods/goodsInfo/buy_com_pop.wxml | 8 ++++---- pages/goods/goodsInfo/buy_pt.wxml | 6 +++--- pages/goods/goodsInfo/goodsInfo.js | 59 ++++++++++++++++++++++++++++++++++++++++++++--------------- pages/goods/goodsInfo/goodsInfo.wxml | 8 ++++---- 6 files changed, 94 insertions(+), 37 deletions(-) diff --git a/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_pt.wxml b/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_pt.wxml index a07ac33..aba0c02 100644 --- a/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_pt.wxml +++ b/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_pt.wxml @@ -204,7 +204,7 @@ 库存不足 - 立即购买 + 立即购买 @@ -221,7 +221,7 @@ 配送不匹配 - 确定 + 确定 diff --git a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js index 853fc10..ca144a0 100644 --- a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js +++ b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js @@ -3025,6 +3025,13 @@ Page({ //-----------选择属性的按钮事件---------- sele_spec: function (e) { + + //防止重复点击 + if(this.data.sp_seleing){ + return false; + } + this.setData({sp_seleing:1}) + var that = this, ee = this, th = this; var gid = e.currentTarget.dataset.gid; var nor = e.currentTarget.dataset.nor; @@ -3056,13 +3063,21 @@ Page({ }); - that.check_is_youhui(gid, that.data.is_normal); + this.get_sto(that.data.is_normal,()=>{ + that.sele_spec_next(gid,item) + }); + + + }, - this.get_sto(that.data.is_normal); - //默认门店要拿下门店库存 - if (!getApp().is_virtual(item) && !item.whsle_id && that.data.sales_rules >= 2 && that.data.def_pick_store) { + sele_spec_next(gid,item){ + var that = this; + that.check_is_youhui(gid, that.data.is_normal); + + //默认门店要拿下门店库存 + if (!getApp().is_virtual(item) && !item.whsle_id && that.data.sales_rules >= 2 && that.data.def_pick_store) { var lock = 0, plist = null; // //先读取门店的lock,采用链式写法,少用await // getApp().request.promiseGet("/api/weshop/order/ware/lock/page", { @@ -3099,8 +3114,8 @@ Page({ } + that.sele_spec_chech_activity(); - this.sele_spec_chech_activity(); }, //选择了不同的规格的时候要判断是不是有活动正在进行中 @@ -3155,7 +3170,8 @@ Page({ prom_start_time: prom.start_time, prom_st: prom_st, prom_act: prom, - prom_id: prom.id + prom_id: prom.id, + sp_seleing:0 }) //却换图片 @@ -3196,13 +3212,14 @@ Page({ prom_end_time: null, prom_start_time: null, prom_st: null, + sp_seleing:0 }) }, //---------拿出门店分类和门店------------ - get_sto(e) { + get_sto(e,func) { var th = this, that = this; var is_normal = e; @@ -3253,9 +3270,9 @@ Page({ getApp().request.promiseGet("/api/weshop/pickup/list", { data: dd, }).then(res => { - var e = res; + var e = res; - if (e.data.code == 0 && e.data.data && e.data.data.pageData && e.data.data.pageData.length > 0) { + if (e.data.code == 0 && e.data.data && e.data.data.pageData && e.data.data.pageData.length > 0) { //-- 如果有指定门店的时候 -- if(th.data.sele_g.pickup_ids && th.data.is_normal){ @@ -3346,7 +3363,13 @@ Page({ th.deal_pickup(e); //--普通门店排版-- }, 800) } + + if(func) func(); + } + },err=>{ + ut.m_toast('网络繁忙,请稍后重试'); + wx.hideLoading(); }) }, 200) @@ -4692,6 +4715,11 @@ Page({ //-----------------拼单生成方法--------------------- addCart_pt: function () { + //如果是切换规格的时候,让商品不能提交到确认订单的页面,否则活动会出错,金额也不对 + if(this.data.sp_seleing){ + return false; + } + if (this.data.is_normal == 0) { //看一下有没有起购数,如果有起购数,要计算起购数 // var qnum = parseFloat(th.data.prom_act.minbuynum); diff --git a/pages/goods/goodsInfo/buy_com_pop.wxml b/pages/goods/goodsInfo/buy_com_pop.wxml index 0018476..eb86ef4 100644 --- a/pages/goods/goodsInfo/buy_com_pop.wxml +++ b/pages/goods/goodsInfo/buy_com_pop.wxml @@ -153,10 +153,10 @@ - 加入购物车 - 立即购买 @@ -172,10 +172,10 @@ - 加入购物车 - 立即购买 diff --git a/pages/goods/goodsInfo/buy_pt.wxml b/pages/goods/goodsInfo/buy_pt.wxml index 6046921..8d0de58 100644 --- a/pages/goods/goodsInfo/buy_pt.wxml +++ b/pages/goods/goodsInfo/buy_pt.wxml @@ -195,7 +195,7 @@ - 立即购买 + 立即购买 @@ -206,7 +206,7 @@ - 立即购买 + 立即购买 @@ -226,7 +226,7 @@ 该店不可售 - 确定 + 确定 diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index 113eafc..9514ddb 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -1392,6 +1392,10 @@ Page({ //------------加入购物车-------------- addCart: function (t) { + //如果是切换规格的时候,让商品不能提交到确认订单的页面,否则活动会出错,金额也不对 + if(this.data.sp_seleing){ + return false; + } var th = this; var ind = t.currentTarget.dataset.openSpecModal_ind; @@ -3279,6 +3283,12 @@ Page({ //-----------选择属性的按钮事件---------- sele_spec: function (e) { + if(this.data.sp_seleing){ + return false; + } + + this.setData({sp_seleing:1}) + var that = this; var th = this; @@ -3365,22 +3375,27 @@ Page({ }); - if (nor) { that.set_sele_g(sku_g) - that.get_sto(1); + that.get_sto(1,()=>{ + that.sele_spec_next(that,item,gid,nor); + }); } - else that.get_sto(); + else that.get_sto(null,()=>{ + that.sele_spec_next(that,item,gid,nor); + }); + }, + //-- 选择规格下一步 -- + sele_spec_next(that,item,gid,nor){ if (!item.whsle_id && ([1, 2, 4, 6].indexOf(item.prom_type) == -1 || this.data.is_normal == 1)) that.check_is_youhui(gid, that.data.is_normal, 1); - //默认门店要拿下门店库存 if (that.data.sales_rules >= 2 && that.data.def_pick_store && !that.data.sele_g.whsle_id && [1, 2, 4, 6].indexOf(item.prom_type) == -1) { var lock = 0, - plist = null; + plist = null; that.check_CanOutQty(that.data.sele_g, that.data.def_pick_store, function (CanOutQty) { that.data.def_pick_store.CanOutQty = CanOutQty; @@ -3391,18 +3406,18 @@ Page({ }) } - this.sele_spec_chech_activity(nor); + that.sele_spec_chech_activity(nor); //如果是秒杀,拼团等互动,就不重新算界面 if ([1, 2, 4, 6, 8, 9].indexOf(this.data.base_nor_prom_type) > -1) { return false; } - this.check_has_flash(gid); + that.check_has_flash(gid); var url = '/api/weshop/activitylist/listGoodActInfo2New'; var req_d = { "store_id": os.stoid, - "goods_id": this.data.gid, + "goods_id": that.data.gid, "user_id": user_id, } getApp().request.get(url, { @@ -3421,7 +3436,7 @@ Page({ if (arr3 && arr3.length > 0) { //获取活动信息 var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + - arr3[0].act_id + "/" + getApp().globalData.user_id; + arr3[0].act_id + "/" + getApp().globalData.user_id; getApp().request.get(url, { success: function (e) { if (e.data.code == 0 && e.data.data) { @@ -3450,9 +3465,7 @@ Page({ //选择了不同的规格的时候要判断是不是有活动正在进行中 async sele_spec_chech_activity(nor) { //---如果是活动的时候--- - var prom = null, - goodsinfo = this.data.sele_g, - th = this; + var prom = null,goodsinfo = this.data.sele_g,th = this; //如果是普通购买的时候,要返回原先 if (goodsinfo.goods_id == this.data.base_nor_goods_id) { @@ -3537,7 +3550,8 @@ Page({ prom_start_time: prom.start_time, prom_st: prom_st, prom_act: prom, - prom_id: prom.id + prom_id: prom.id, + sp_seleing:0 }) var pro_null=null; @@ -3581,7 +3595,10 @@ Page({ } } - if (nor) return false; + if (nor){ + th.setData({ sp_seleing:0 }) + return false; + } //---设置普通商品--- th.setData({ @@ -3591,13 +3608,14 @@ Page({ prom_end_time: null, prom_start_time: null, prom_st: null, + sp_seleing:0 }) }, //---------拿出门店分类和门店------------ - get_sto(e) { + get_sto(e,func) { console.log('get_sto') var th = this, that = this; @@ -3791,12 +3809,16 @@ Page({ th.deal_pickup(e); //--普通门店排版-- }, 800) } + if(func) func(); }else{ wx.hideLoading(); } } else { wx.hideLoading(); } + },err=>{ + ut.m_toast('网络繁忙,请稍后重试'); + wx.hideLoading(); }) }, 200) @@ -3807,6 +3829,7 @@ Page({ keyword: e.detail.value }) }, + //搜索门店 searchfn() { let choice_sort_store = this.data.choice_sort_store @@ -5338,6 +5361,12 @@ Page({ //-----------------拼单生成方法--------------------- addCart_pt: function () { + + //如果是切换规格的时候,让商品不能提交到确认订单的页面,否则活动会出错,金额也不对 + if(this.data.sp_seleing){ + return false; + } + var th = this; if (this.data.is_normal == 0) { //看一下有没有起购数,如果有起购数,要计算起购数 diff --git a/pages/goods/goodsInfo/goodsInfo.wxml b/pages/goods/goodsInfo/goodsInfo.wxml index 6262f2e..11c657e 100644 --- a/pages/goods/goodsInfo/goodsInfo.wxml +++ b/pages/goods/goodsInfo/goodsInfo.wxml @@ -1465,10 +1465,10 @@ - + 加入购物车 - + {{sele_g.offline_price?"券后购买":"立即购买"}} @@ -1487,10 +1487,10 @@ - + 加入购物车 - + {{sele_g.offline_price?"券后购买":"立即购买"}} -- libgit2 0.21.4