Commit e28c9b0b0198e4359578abaf3cf1fba829cf42a9
1 parent
400d2ce2
购物车,收货地址 一开始没有,新增收货地址之后,价格要有物流费用
Showing
2 changed files
with
39 additions
and
8 deletions
pages/cart/cart2/cart2.js
@@ -170,10 +170,12 @@ Page({ | @@ -170,10 +170,12 @@ Page({ | ||
170 | th.setData({user_addr: ie }); | 170 | th.setData({user_addr: ie }); |
171 | if (th.data.is_b_now == 1) { | 171 | if (th.data.is_b_now == 1) { |
172 | if(th.data.bn_goods) { | 172 | if(th.data.bn_goods) { |
173 | + th.setData({add_back:1}); | ||
173 | th.calculatePrice2(); | 174 | th.calculatePrice2(); |
174 | } | 175 | } |
175 | }else{ | 176 | }else{ |
176 | if (th.data.cartlist){ | 177 | if (th.data.cartlist){ |
178 | + th.setData({add_back:1}); | ||
177 | th.calculatePrice(); | 179 | th.calculatePrice(); |
178 | } | 180 | } |
179 | } | 181 | } |
@@ -441,7 +443,10 @@ Page({ | @@ -441,7 +443,10 @@ Page({ | ||
441 | var ie = { | 443 | var ie = { |
442 | pickup_id: pcid, pname: pikname, goods: narr, exp_type: e_t, wind: m_wind, distr_t: dis_t,card_cut_price:0, | 444 | pickup_id: pcid, pname: pikname, goods: narr, exp_type: e_t, wind: m_wind, distr_t: dis_t,card_cut_price:0, |
443 | goods_price: 0, shipping_price: 0, user_money: 0, total_amount: 0, order_amount: 0, user_note:0}; | 445 | goods_price: 0, shipping_price: 0, user_money: 0, total_amount: 0, order_amount: 0, user_note:0}; |
444 | - | 446 | + |
447 | + if(!th.data.add_back){ | ||
448 | + ie.exp_type= et; | ||
449 | + } | ||
445 | //-- 把等级卡会优惠多少钱装进去 -- | 450 | //-- 把等级卡会优惠多少钱装进去 -- |
446 | if(item.cut_price) ie.card_cut_price+=item.cut_price; | 451 | if(item.cut_price) ie.card_cut_price+=item.cut_price; |
447 | arr.push(ie); | 452 | arr.push(ie); |
@@ -573,10 +578,13 @@ Page({ | @@ -573,10 +578,13 @@ Page({ | ||
573 | } | 578 | } |
574 | 579 | ||
575 | th.setData({ | 580 | th.setData({ |
576 | - bn_goods: data, bn_pickname: gg.pick_name, bn_exp_type: et,index:m_wind, | 581 | + bn_goods: data, bn_pickname: gg.pick_name,index:m_wind, |
577 | bn_pick: gg.pick_id, bn_t_exp_t: distr_t | 582 | bn_pick: gg.pick_id, bn_t_exp_t: distr_t |
578 | }); | 583 | }); |
579 | - | 584 | + |
585 | + if(!th.data.add_back){ | ||
586 | + th.setData({ bn_exp_type: et }) | ||
587 | + } | ||
580 | //计算价格 | 588 | //计算价格 |
581 | th.calculatePrice2(); | 589 | th.calculatePrice2(); |
582 | //获取优惠券 | 590 | //获取优惠券 |
@@ -606,9 +614,13 @@ Page({ | @@ -606,9 +614,13 @@ Page({ | ||
606 | th.data.old_cartlist=cart_arr; | 614 | th.data.old_cartlist=cart_arr; |
607 | } | 615 | } |
608 | th.setData({ | 616 | th.setData({ |
609 | - bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et,index:m_wind, | 617 | + bn_goods: t.data.data, bn_pickname: gg.pick_name,index:m_wind, |
610 | bn_pick: gg.pick_id, bn_t_exp_t: distr_t | 618 | bn_pick: gg.pick_id, bn_t_exp_t: distr_t |
611 | }); | 619 | }); |
620 | + | ||
621 | + if(!th.data.add_back){ | ||
622 | + th.setData({ bn_exp_type: et }) | ||
623 | + } | ||
612 | 624 | ||
613 | //--搭配促销也是按照购物车的方式来计算优惠券-- | 625 | //--搭配促销也是按照购物车的方式来计算优惠券-- |
614 | if(gg.prom_type==5){ | 626 | if(gg.prom_type==5){ |
@@ -648,6 +660,11 @@ Page({ | @@ -648,6 +660,11 @@ Page({ | ||
648 | bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et,index:m_wind, | 660 | bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et,index:m_wind, |
649 | bn_pick: gg.pick_id, bn_t_exp_t: distr_t | 661 | bn_pick: gg.pick_id, bn_t_exp_t: distr_t |
650 | }); | 662 | }); |
663 | + | ||
664 | + if(!th.data.add_back){ | ||
665 | + th.setData({ bn_exp_type: et }) | ||
666 | + } | ||
667 | + | ||
651 | //计算价格 | 668 | //计算价格 |
652 | th.calculatePrice2(); | 669 | th.calculatePrice2(); |
653 | //获取优惠券 | 670 | //获取优惠券 |
pages/cart/cart2_pt/cart2_pt.js
@@ -203,9 +203,13 @@ Page({ | @@ -203,9 +203,13 @@ Page({ | ||
203 | } | 203 | } |
204 | 204 | ||
205 | th.setData({ | 205 | th.setData({ |
206 | - bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et, | 206 | + bn_goods: t.data.data, bn_pickname: gg.pick_name, |
207 | bn_pick: gg.pick_id, bn_t_exp_t: distr_t, is_normal:1 | 207 | bn_pick: gg.pick_id, bn_t_exp_t: distr_t, is_normal:1 |
208 | - }); | 208 | + }); |
209 | + if(!th.data.add_back){ | ||
210 | + th.setData({ bn_exp_type: et }) | ||
211 | + } | ||
212 | + | ||
209 | th.calculatePrice2(); | 213 | th.calculatePrice2(); |
210 | }else{ | 214 | }else{ |
211 | 215 | ||
@@ -238,9 +242,13 @@ Page({ | @@ -238,9 +242,13 @@ Page({ | ||
238 | t.data.data.is_normal=1; | 242 | t.data.data.is_normal=1; |
239 | } | 243 | } |
240 | th.setData({ | 244 | th.setData({ |
241 | - bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et, | 245 | + bn_goods: t.data.data, bn_pickname: gg.pick_name, |
242 | bn_pick: gg.pick_id, bn_t_exp_t: distr_t | 246 | bn_pick: gg.pick_id, bn_t_exp_t: distr_t |
243 | }); | 247 | }); |
248 | + | ||
249 | + if(!th.data.add_back){ | ||
250 | + th.setData({ bn_exp_type: et }) | ||
251 | + } | ||
244 | //计算价格 | 252 | //计算价格 |
245 | th.calculatePrice2(); | 253 | th.calculatePrice2(); |
246 | } | 254 | } |
@@ -259,7 +267,12 @@ Page({ | @@ -259,7 +267,12 @@ Page({ | ||
259 | }) | 267 | }) |
260 | }else{ | 268 | }else{ |
261 | this.getuser_addr(function(ie){ | 269 | this.getuser_addr(function(ie){ |
262 | - th.setData({user_addr: ie }); | 270 | + //更换地址回来要重新调用计算价钱的接口 |
271 | + th.setData({user_addr: ie }); | ||
272 | + if(!th.data.user_addr || th.data.user_addr.address_id!=ie.address_id){ | ||
273 | + th.setData({add_back:1}); | ||
274 | + th.calculatePrice2(); | ||
275 | + } | ||
263 | }) | 276 | }) |
264 | //--更新默认地址--,看一下是不是跳到地址页面 | 277 | //--更新默认地址--,看一下是不是跳到地址页面 |
265 | if(!getApp().globalData.is_cart2_old){ | 278 | if(!getApp().globalData.is_cart2_old){ |
@@ -269,6 +282,7 @@ Page({ | @@ -269,6 +282,7 @@ Page({ | ||
269 | } | 282 | } |
270 | } | 283 | } |
271 | 284 | ||
285 | + | ||
272 | //先获取是否有关闭使用优惠券 | 286 | //先获取是否有关闭使用优惠券 |
273 | getApp().getConfig2(function (ee) { | 287 | getApp().getConfig2(function (ee) { |
274 | var json_d = JSON.parse(ee.switch_list); | 288 | var json_d = JSON.parse(ee.switch_list); |