From e28c9b0b0198e4359578abaf3cf1fba829cf42a9 Mon Sep 17 00:00:00 2001 From: yvan.ni <765199919@qq.com> Date: Mon, 12 Oct 2020 15:01:37 +0800 Subject: [PATCH] 购物车,收货地址 一开始没有,新增收货地址之后,价格要有物流费用 --- pages/cart/cart2/cart2.js | 25 +++++++++++++++++++++---- pages/cart/cart2_pt/cart2_pt.js | 22 ++++++++++++++++++---- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/pages/cart/cart2/cart2.js b/pages/cart/cart2/cart2.js index 7a5ede7..a0ff763 100644 --- a/pages/cart/cart2/cart2.js +++ b/pages/cart/cart2/cart2.js @@ -170,10 +170,12 @@ Page({ th.setData({user_addr: ie }); if (th.data.is_b_now == 1) { if(th.data.bn_goods) { + th.setData({add_back:1}); th.calculatePrice2(); } }else{ if (th.data.cartlist){ + th.setData({add_back:1}); th.calculatePrice(); } } @@ -441,7 +443,10 @@ Page({ var ie = { pickup_id: pcid, pname: pikname, goods: narr, exp_type: e_t, wind: m_wind, distr_t: dis_t,card_cut_price:0, goods_price: 0, shipping_price: 0, user_money: 0, total_amount: 0, order_amount: 0, user_note:0}; - + + if(!th.data.add_back){ + ie.exp_type= et; + } //-- 把等级卡会优惠多少钱装进去 -- if(item.cut_price) ie.card_cut_price+=item.cut_price; arr.push(ie); @@ -573,10 +578,13 @@ Page({ } th.setData({ - bn_goods: data, bn_pickname: gg.pick_name, bn_exp_type: et,index:m_wind, + bn_goods: data, bn_pickname: gg.pick_name,index:m_wind, bn_pick: gg.pick_id, bn_t_exp_t: distr_t }); - + + if(!th.data.add_back){ + th.setData({ bn_exp_type: et }) + } //计算价格 th.calculatePrice2(); //获取优惠券 @@ -606,9 +614,13 @@ Page({ th.data.old_cartlist=cart_arr; } th.setData({ - bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et,index:m_wind, + bn_goods: t.data.data, bn_pickname: gg.pick_name,index:m_wind, bn_pick: gg.pick_id, bn_t_exp_t: distr_t }); + + if(!th.data.add_back){ + th.setData({ bn_exp_type: et }) + } //--搭配促销也是按照购物车的方式来计算优惠券-- if(gg.prom_type==5){ @@ -648,6 +660,11 @@ Page({ bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et,index:m_wind, bn_pick: gg.pick_id, bn_t_exp_t: distr_t }); + + if(!th.data.add_back){ + th.setData({ bn_exp_type: et }) + } + //计算价格 th.calculatePrice2(); //获取优惠券 diff --git a/pages/cart/cart2_pt/cart2_pt.js b/pages/cart/cart2_pt/cart2_pt.js index fbc44f5..985c22f 100644 --- a/pages/cart/cart2_pt/cart2_pt.js +++ b/pages/cart/cart2_pt/cart2_pt.js @@ -203,9 +203,13 @@ Page({ } th.setData({ - bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et, + bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_pick: gg.pick_id, bn_t_exp_t: distr_t, is_normal:1 - }); + }); + if(!th.data.add_back){ + th.setData({ bn_exp_type: et }) + } + th.calculatePrice2(); }else{ @@ -238,9 +242,13 @@ Page({ t.data.data.is_normal=1; } th.setData({ - bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et, + bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_pick: gg.pick_id, bn_t_exp_t: distr_t }); + + if(!th.data.add_back){ + th.setData({ bn_exp_type: et }) + } //计算价格 th.calculatePrice2(); } @@ -259,7 +267,12 @@ Page({ }) }else{ this.getuser_addr(function(ie){ - th.setData({user_addr: ie }); + //更换地址回来要重新调用计算价钱的接口 + th.setData({user_addr: ie }); + if(!th.data.user_addr || th.data.user_addr.address_id!=ie.address_id){ + th.setData({add_back:1}); + th.calculatePrice2(); + } }) //--更新默认地址--,看一下是不是跳到地址页面 if(!getApp().globalData.is_cart2_old){ @@ -269,6 +282,7 @@ Page({ } } + //先获取是否有关闭使用优惠券 getApp().getConfig2(function (ee) { var json_d = JSON.parse(ee.switch_list); -- libgit2 0.21.4