From cc556a5850563208d576f157ed86489285570936 Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Wed, 5 May 2021 13:50:17 +0800 Subject: [PATCH] 1. 日志报警的修复 2. 立即购买的赠品的运费计算优化 --- app.js | 16 ++++++++++++---- pages/cart/cart/cart.js | 2 +- pages/cart/cart2/cart2.js | 31 ++++++++++++++++++++++--------- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/app.js b/app.js index 818b5d6..7468cd6 100644 --- a/app.js +++ b/app.js @@ -209,8 +209,13 @@ App({ } }, //----------------获取配置参数-------------------- - getConfig: function(t, o) { - var e = this; if(this.globalData.config==undefined) this.globalData.config=null; + getConfig: function(t, o) { + var e = this; + if(!e.globalData.setting.stoid){ + t(null); + return false; + } + if(this.globalData.config==undefined) this.globalData.config=null; this.globalData.config ? "function" == typeof t && t(this.globalData.config) : e.request.get("/api/weshop/store/get/" + e.globalData.setting.stoid, { success: function(o) { console.log('getConfig'); @@ -220,10 +225,13 @@ App({ } }); }, - //----------------获取配置参数-------------------- - getConfig2: function (t, o) { + getConfig2: function (t, o) { var e = this; + if(!e.globalData.setting.stoid) { + t(null); + return false; + } this.globalData.config2 && !o ? "function" == typeof t && t(this.globalData.config2) : a.get("/api/weshop/storeconfig/get/" + e.globalData.setting.stoid, { success: function (o) { diff --git a/pages/cart/cart/cart.js b/pages/cart/cart/cart.js index 6d5ebe1..9b49260 100644 --- a/pages/cart/cart/cart.js +++ b/pages/cart/cart/cart.js @@ -783,7 +783,7 @@ Page({ isShowLoading: 0, success: function(res_d) { - if(res_d.data.code==0){ + if(res_d.data.code==0 && res_d.data.data){ if (t.goods_num > store_count) { wx.showModal({ title: '提示', diff --git a/pages/cart/cart2/cart2.js b/pages/cart/cart2/cart2.js index fbedc65..bb1c73e 100644 --- a/pages/cart/cart2/cart2.js +++ b/pages/cart/cart2/cart2.js @@ -671,7 +671,7 @@ Page({ ob.buynum=num; ob.weight=data.gift_weight; //商品的重量 ob.exp_sum_type=data.gift_exp_sum_type; //商品的物流计算方式 - ob.uniform_exp_sum=data.uniform_exp_sum //统一运费的金额 + ob.uniform_exp_sum=data.gift_uniform_exp_sum //统一运费的金额 th.setData({buy_now_gift_goods:ob}); } @@ -1541,7 +1541,8 @@ Page({ //如果有赠品的时候,也要计算赠品的物流费用 if(th.data.buy_now_gift_goods){ - shipping_price=th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free, parseFloat(allpice)-cut_price-quan_price, rs,shipping_price,no_by_data); + shipping_price=th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free, + parseFloat(allpice)-cut_price-quan_price, rs,shipping_price,no_by_data,goods_weight,goods_piece); } if(shipping_price<=0){ @@ -3161,7 +3162,7 @@ Page({ arr.gift_original_img = get_data.goodsinfo.original_img; arr.gift_weight = get_data.goodsinfo.weight; arr.gift_exp_sum_type = get_data.goodsinfo.exp_sum_type; - arr.uniform_exp_sum = get_data.goodsinfo.uniform_exp_sum; + arr.gift_uniform_exp_sum = get_data.goodsinfo.uniform_exp_sum; arr.gift_limit_num = get_data.limit_num; arr.gift_storecount = get_data.gift_storecount; } @@ -3239,7 +3240,7 @@ Page({ }, //计算立即购买赠品的物流费用 - get_now_gift_goods_wuliu:function (code, o_shipping_price, user_addr, gift_freight_free,allpice, rs,shipping_price,no_by_data) { + get_now_gift_goods_wuliu:function (code, o_shipping_price, user_addr, gift_freight_free,allpice, rs,shipping_price,no_by_data,goods_weight1,goods_piece1) { var good=this.data.buy_now_gift_goods; var goods_weight=-1, goods_piece=-1; var gift_shipping_price=0; @@ -3247,17 +3248,28 @@ Page({ switch (good['exp_sum_type']) { case 1: //统一运费 - gift_shipping_price += good['uniform_exp_sum']; break; + gift_shipping_price += good['uniform_exp_sum']; + gift_shipping_price+=o_shipping_price; + break; case 2: if (goods_weight < 0) goods_weight = 0; //累积商品重量 每种商品的重量 * 数量 - goods_weight += good['weight'] * good['buynum'];break; + goods_weight += good['weight'] * good['buynum']; + if(goods_weight1>0){ + goods_weight+=goods_weight1; + } + break; case 3: if (goods_piece < 0) goods_piece = 0; //累积商品数量 - goods_piece += good['buynum']; break; + goods_piece += good['buynum']; + if(goods_piece1){ + goods_piece+=goods_piece1; + } + break; } - + + //如果有设置不包邮区域的时候 if(no_by_data && no_by_data.region_list){ if(th.check_by_area(no_by_data.region_list)){ @@ -3272,10 +3284,11 @@ Page({ //th.data.is_no_by[th.data.bn_pick]=1; } } + var t_shipping_price= this.calculatewuliu(code, gift_shipping_price, goods_weight, goods_piece, user_addr, gift_freight_free, allpice, rs); - return t_shipping_price+shipping_price; + return t_shipping_price; }, -- libgit2 0.21.4