Commit aae0598d57bc7eba3a68243fee498a1e36382275
1 parent
7a3b8f7f
确认订单页
Showing
1 changed file
with
56 additions
and
28 deletions
pages/cart/cart2/cart2.js
| @@ -165,8 +165,23 @@ Page({ | @@ -165,8 +165,23 @@ Page({ | ||
| 165 | th.data.isget_by_quan={}; | 165 | th.data.isget_by_quan={}; |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | - th.setData({user_addr: ie }); | ||
| 169 | - var going=0; | 168 | + //更换地址回来要重新调用计算价钱的接口 |
| 169 | + if(!th.data.user_addr || th.data.user_addr.address_id!=ie.address_id){ | ||
| 170 | + if (th.data.is_b_now == 1) { | ||
| 171 | + if(th.data.bn_goods) { | ||
| 172 | + th.calculatePrice2(); | ||
| 173 | + } | ||
| 174 | + }else{ | ||
| 175 | + if (th.data.cartlist){ | ||
| 176 | + th.calculatePrice(); | ||
| 177 | + } | ||
| 178 | + } | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + th.setData({user_addr: ie }); | ||
| 182 | + var going=0; | ||
| 183 | + | ||
| 184 | + | ||
| 170 | //使用计时器,避免空现象 | 185 | //使用计时器,避免空现象 |
| 171 | /*--- | 186 | /*--- |
| 172 | var jishi= setInterval(function () { | 187 | var jishi= setInterval(function () { |
| @@ -597,7 +612,7 @@ Page({ | @@ -597,7 +612,7 @@ Page({ | ||
| 597 | }; | 612 | }; |
| 598 | var c_arr=JSON.parse(JSON.stringify(th.data.old_cartlist)); | 613 | var c_arr=JSON.parse(JSON.stringify(th.data.old_cartlist)); |
| 599 | //---循环购物车--- | 614 | //---循环购物车--- |
| 600 | - for(var i=0;i<c_arr.length;i++){ | 615 | + for(var i in c_arr){ |
| 601 | //因为搭配购买也是再这里计算,搭配购的is_b_now==1 | 616 | //因为搭配购买也是再这里计算,搭配购的is_b_now==1 |
| 602 | if(th.data.is_b_now==0) { | 617 | if(th.data.is_b_now==0) { |
| 603 | //此时物流的选择方式要用th.data.cartlist; | 618 | //此时物流的选择方式要用th.data.cartlist; |
| @@ -639,13 +654,12 @@ Page({ | @@ -639,13 +654,12 @@ Page({ | ||
| 639 | is_bz: item_map.is_bz | 654 | is_bz: item_map.is_bz |
| 640 | } | 655 | } |
| 641 | }).then(res => { | 656 | }).then(res => { |
| 642 | - if (res.data.code == 0) { | 657 | + if (res.data.code == 0 && res.data.data.condition) { |
| 643 | var get_data = res.data.data; | 658 | var get_data = res.data.data; |
| 644 | item_map.is_bz = get_data.is_bz; //是不是倍增 | 659 | item_map.is_bz = get_data.is_bz; //是不是倍增 |
| 645 | - item_map.is_xz_yh = get_data.is_xz_yh; //是不是优惠 | ||
| 646 | item_map.bs = get_data.bs; //是不是倍数 | 660 | item_map.bs = get_data.bs; //是不是倍数 |
| 647 | item_map.is_past = get_data.is_past; //是不是包邮 | 661 | item_map.is_past = get_data.is_past; //是不是包邮 |
| 648 | - item_map.prom_price = get_data.price?get_data.price:0; | 662 | + item_map.prom_price = get_data.price?get_data.price:item_map.price; |
| 649 | item_map.s_intValue = get_data.intValue; | 663 | item_map.s_intValue = get_data.intValue; |
| 650 | item_map.s_coupon_id = get_data.coupon_id; | 664 | item_map.s_coupon_id = get_data.coupon_id; |
| 651 | item_map.s_coupon_num = get_data.coupon_num; | 665 | item_map.s_coupon_num = get_data.coupon_num; |
| @@ -674,6 +688,10 @@ Page({ | @@ -674,6 +688,10 @@ Page({ | ||
| 674 | } | 688 | } |
| 675 | } | 689 | } |
| 676 | 690 | ||
| 691 | + var q_conditin=0; | ||
| 692 | + //判断包邮券的钱 | ||
| 693 | + q_conditin=o_price; | ||
| 694 | + if(!item_map.is_xz_yh) q_conditin=o_price-item_map.price; | ||
| 677 | //--看有没有减价-- | 695 | //--看有没有减价-- |
| 678 | if(item_map.prom_price && item_map.price-item_map.prom_price){ | 696 | if(item_map.prom_price && item_map.price-item_map.prom_price){ |
| 679 | if(cart_item.prom_pt_json){ | 697 | if(cart_item.prom_pt_json){ |
| @@ -681,7 +699,10 @@ Page({ | @@ -681,7 +699,10 @@ Page({ | ||
| 681 | }else{ | 699 | }else{ |
| 682 | cart_item.prom_pt_json=[{"prom_id":item_map.prom_id,"dis":item_map.price-item_map.prom_price,"ispt":0}]; | 700 | cart_item.prom_pt_json=[{"prom_id":item_map.prom_id,"dis":item_map.price-item_map.prom_price,"ispt":0}]; |
| 683 | } | 701 | } |
| 702 | + | ||
| 684 | o_price-=(item_map.price-item_map.prom_price); | 703 | o_price-=(item_map.price-item_map.prom_price); |
| 704 | + //如果有限制使用优惠券,就要减掉参与的活动商品的钱 | ||
| 705 | + if(!item_map.is_xz_yh) q_conditin=o_price; | ||
| 685 | } | 706 | } |
| 686 | 707 | ||
| 687 | //--优惠多少钱-- | 708 | //--优惠多少钱-- |
| @@ -742,7 +763,7 @@ Page({ | @@ -742,7 +763,7 @@ Page({ | ||
| 742 | if(!th.data.isget_by_quan[pickid]){ | 763 | if(!th.data.isget_by_quan[pickid]){ |
| 743 | //--判断要不要显示包邮券,调用接口,因为有for循环--- | 764 | //--判断要不要显示包邮券,调用接口,因为有for循环--- |
| 744 | await getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea",{ | 765 | await getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea",{ |
| 745 | - data:{store_id:os.stoid,isuse:0,condition:o_price,user_id:getApp().globalData.user_id,pageSize:2000} | 766 | + data:{store_id:os.stoid,isuse:0,condition:q_conditin,user_id:getApp().globalData.user_id,pageSize:2000} |
| 746 | }).then(res=>{ | 767 | }).then(res=>{ |
| 747 | if(res.data.code==0 && res.data.data.total>0){ | 768 | if(res.data.code==0 && res.data.data.total>0){ |
| 748 | //此时要循环判断包邮的地区,不包邮商品是不是符合 | 769 | //此时要循环判断包邮的地区,不包邮商品是不是符合 |
| @@ -808,6 +829,8 @@ Page({ | @@ -808,6 +829,8 @@ Page({ | ||
| 808 | for(var j=0;j<item.length;j++){ | 829 | for(var j=0;j<item.length;j++){ |
| 809 | //如果都包邮,都没必要等级数量了 | 830 | //如果都包邮,都没必要等级数量了 |
| 810 | if(th.data.is_quan_by[pickid]) continue; | 831 | if(th.data.is_quan_by[pickid]) continue; |
| 832 | + //如果是优惠活动是包邮,就不用计算包邮的费用了 | ||
| 833 | + if(item[j].is_past) continue; | ||
| 811 | //是不是不包邮的商品 | 834 | //是不是不包邮的商品 |
| 812 | var is_good_no_by=0; | 835 | var is_good_no_by=0; |
| 813 | if(no_ex_good){ | 836 | if(no_ex_good){ |
| @@ -815,13 +838,11 @@ Page({ | @@ -815,13 +838,11 @@ Page({ | ||
| 815 | } | 838 | } |
| 816 | //如果达到全场包邮的条件,同时,没有地区不包邮,或者商品不包邮 | 839 | //如果达到全场包邮的条件,同时,没有地区不包邮,或者商品不包邮 |
| 817 | if(o_price>=freight_free && freight_free>0 && !is_good_no_by && th.data.is_no_by[pickid]!=1){ | 840 | if(o_price>=freight_free && freight_free>0 && !is_good_no_by && th.data.is_no_by[pickid]!=1){ |
| 818 | - var i=1; | ||
| 819 | continue; | 841 | continue; |
| 820 | } | 842 | } |
| 821 | 843 | ||
| 822 | //--如果是包邮券使用的情况下,如果商品是包邮的,那么就不进行计算-- | 844 | //--如果是包邮券使用的情况下,如果商品是包邮的,那么就不进行计算-- |
| 823 | if(th.data.using_quan[pickid] && th.data.using_quan[pickid].isby==1 && !is_good_no_by){ | 845 | if(th.data.using_quan[pickid] && th.data.using_quan[pickid].isby==1 && !is_good_no_by){ |
| 824 | - var i=1; | ||
| 825 | continue; | 846 | continue; |
| 826 | } | 847 | } |
| 827 | 848 | ||
| @@ -1029,7 +1050,7 @@ Page({ | @@ -1029,7 +1050,7 @@ Page({ | ||
| 1029 | 1050 | ||
| 1030 | var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; | 1051 | var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; |
| 1031 | //-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮---------- | 1052 | //-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮---------- |
| 1032 | - if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && good.is_past!=1){ | 1053 | + if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && good.is_past!=1 && good.is_xz_yh!=1){ |
| 1033 | //看是不是有调用过包邮券 | 1054 | //看是不是有调用过包邮券 |
| 1034 | if(!th.data.isget_by_quan[th.data.bn_pick]){ | 1055 | if(!th.data.isget_by_quan[th.data.bn_pick]){ |
| 1035 | var condition=allpice-cut_price; | 1056 | var condition=allpice-cut_price; |
| @@ -1349,7 +1370,7 @@ Page({ | @@ -1349,7 +1370,7 @@ Page({ | ||
| 1349 | } | 1370 | } |
| 1350 | if(th.data.formData.give_coupon_id>0){ | 1371 | if(th.data.formData.give_coupon_id>0){ |
| 1351 | order_prom_list.give_coupon_id=th.data.formData.give_coupon_id; | 1372 | order_prom_list.give_coupon_id=th.data.formData.give_coupon_id; |
| 1352 | - order_prom_list.give_coupon_id=th.data.formData.g_coupon_num; | 1373 | + order_prom_list.g_coupon_num=th.data.formData.g_coupon_num; |
| 1353 | } | 1374 | } |
| 1354 | if(th.data.formData.give_lb_id>0){ | 1375 | if(th.data.formData.give_lb_id>0){ |
| 1355 | order_prom_list.give_lb_id=th.data.formData.give_lb_id; | 1376 | order_prom_list.give_lb_id=th.data.formData.give_lb_id; |
| @@ -2417,7 +2438,7 @@ Page({ | @@ -2417,7 +2438,7 @@ Page({ | ||
| 2417 | storeId: oo.stoid, | 2438 | storeId: oo.stoid, |
| 2418 | userId: app.globalData.user_id, | 2439 | userId: app.globalData.user_id, |
| 2419 | BuySum: th.data.ckeck_quan_price, | 2440 | BuySum: th.data.ckeck_quan_price, |
| 2420 | - WareIds: th.data.check_quan_ware_list, | 2441 | + WareIds: encodeURIComponent(th.data.check_quan_ware_list), |
| 2421 | pageSize: 100 | 2442 | pageSize: 100 |
| 2422 | }, | 2443 | }, |
| 2423 | success: function (res) { | 2444 | success: function (res) { |
| @@ -2470,9 +2491,10 @@ Page({ | @@ -2470,9 +2491,10 @@ Page({ | ||
| 2470 | //立即购买获取优惠活动的内容 | 2491 | //立即购买获取优惠活动的内容 |
| 2471 | buy_now_prom_goods:function (prom_id,arr,func) { | 2492 | buy_now_prom_goods:function (prom_id,arr,func) { |
| 2472 | var price=arr.shop_price*arr.goods_num; | 2493 | var price=arr.shop_price*arr.goods_num; |
| 2494 | + var prom=null; | ||
| 2473 | getApp().request.promiseGet("/api/weshop/promgoods/get/"+os.stoid+"/"+prom_id,{}).then(res=>{ | 2495 | getApp().request.promiseGet("/api/weshop/promgoods/get/"+os.stoid+"/"+prom_id,{}).then(res=>{ |
| 2474 | if(res.data.code==0){ | 2496 | if(res.data.code==0){ |
| 2475 | - var prom=res.data.data; | 2497 | + prom=res.data.data; |
| 2476 | return getApp().request.promiseGet("/api/weshop/goods/getDiscount", { | 2498 | return getApp().request.promiseGet("/api/weshop/goods/getDiscount", { |
| 2477 | data: { | 2499 | data: { |
| 2478 | price: price, | 2500 | price: price, |
| @@ -2488,24 +2510,27 @@ Page({ | @@ -2488,24 +2510,27 @@ Page({ | ||
| 2488 | }).then(res=>{ | 2510 | }).then(res=>{ |
| 2489 | if(res.data.code==0){ | 2511 | if(res.data.code==0){ |
| 2490 | var get_data=res.data.data; | 2512 | var get_data=res.data.data; |
| 2491 | - arr.is_bz=get_data.is_bz; //是不是倍增 | ||
| 2492 | - arr.is_xz_yh=get_data.is_xz_yh; //是不是优惠 | 2513 | + arr.is_bz=prom.is_bz; //是不是倍增 |
| 2514 | + arr.is_xz_yh=prom.is_xz_yh; //是不是优惠 | ||
| 2493 | arr.bs=get_data.bs; //是不是倍数 | 2515 | arr.bs=get_data.bs; //是不是倍数 |
| 2494 | arr.is_past=get_data.is_past; //是不是包邮 | 2516 | arr.is_past=get_data.is_past; //是不是包邮 |
| 2495 | - arr.prom_price=get_data.price; | 2517 | + arr.prom_price=get_data.price?get_data.price:price; |
| 2496 | arr.s_intValue=get_data.intValue; | 2518 | arr.s_intValue=get_data.intValue; |
| 2497 | arr.s_coupon_id=get_data.coupon_id; | 2519 | arr.s_coupon_id=get_data.coupon_id; |
| 2498 | arr.s_coupon_num=get_data.coupon_num; | 2520 | arr.s_coupon_num=get_data.coupon_num; |
| 2499 | - arr.gift_id=get_data.gift_id; | ||
| 2500 | - arr.gift_goods_id=get_data.goods_id; | ||
| 2501 | - arr.gift_goods_name=get_data.goods_name; | ||
| 2502 | - arr.gift_goods_color=get_data.goodsinfo.goods_color; | ||
| 2503 | - arr.gift_goods_spec=get_data.goodsinfo.goods_spec; | ||
| 2504 | - arr.gift_original_img=get_data.goodsinfo.original_img; | ||
| 2505 | - arr.gift_weight=get_data.goodsinfo.weight; | ||
| 2506 | - arr.gift_exp_sum_type=get_data.goodsinfo.exp_sum_type; | ||
| 2507 | - arr.gift_limit_num=get_data.limit_num; | ||
| 2508 | - arr.gift_storecount=get_data.gift_storecount; | 2521 | + //-- 看是不是有赠品 -- |
| 2522 | + if(get_data.gift_id) { | ||
| 2523 | + arr.gift_id = get_data.gift_id; | ||
| 2524 | + arr.gift_goods_id = get_data.goods_id; | ||
| 2525 | + arr.gift_goods_name = get_data.goods_name; | ||
| 2526 | + arr.gift_goods_color = get_data.goodsinfo.goods_color; | ||
| 2527 | + arr.gift_goods_spec = get_data.goodsinfo.goods_spec; | ||
| 2528 | + arr.gift_original_img = get_data.goodsinfo.original_img; | ||
| 2529 | + arr.gift_weight = get_data.goodsinfo.weight; | ||
| 2530 | + arr.gift_exp_sum_type = get_data.goodsinfo.exp_sum_type; | ||
| 2531 | + arr.gift_limit_num = get_data.limit_num; | ||
| 2532 | + arr.gift_storecount = get_data.gift_storecount; | ||
| 2533 | + } | ||
| 2509 | arr.s_libao=get_data.libao; | 2534 | arr.s_libao=get_data.libao; |
| 2510 | arr.s_lb_num=get_data.lb_num; | 2535 | arr.s_lb_num=get_data.lb_num; |
| 2511 | } | 2536 | } |
| @@ -2550,6 +2575,7 @@ Page({ | @@ -2550,6 +2575,7 @@ Page({ | ||
| 2550 | ob.price=item.goods_price*item.goods_num; | 2575 | ob.price=item.goods_price*item.goods_num; |
| 2551 | ob.goods_num=item.goods_num; | 2576 | ob.goods_num=item.goods_num; |
| 2552 | ob.is_bz=prom.is_bz; | 2577 | ob.is_bz=prom.is_bz; |
| 2578 | + ob.is_xz_yh=prom.is_xz_yh; | ||
| 2553 | map[pickid][item.prom_id]=ob; | 2579 | map[pickid][item.prom_id]=ob; |
| 2554 | } | 2580 | } |
| 2555 | }else{ | 2581 | }else{ |
| @@ -2562,6 +2588,7 @@ Page({ | @@ -2562,6 +2588,7 @@ Page({ | ||
| 2562 | ob.price=item.goods_price*item.goods_num; | 2588 | ob.price=item.goods_price*item.goods_num; |
| 2563 | ob.goods_num=item.goods_num; | 2589 | ob.goods_num=item.goods_num; |
| 2564 | ob.is_bz=prom.is_bz; | 2590 | ob.is_bz=prom.is_bz; |
| 2591 | + ob.is_xz_yh=prom.is_xz_yh; | ||
| 2565 | var obj={}; | 2592 | var obj={}; |
| 2566 | obj[item.prom_id]=ob; | 2593 | obj[item.prom_id]=ob; |
| 2567 | map[pickid]=obj; | 2594 | map[pickid]=obj; |
| @@ -2572,8 +2599,9 @@ Page({ | @@ -2572,8 +2599,9 @@ Page({ | ||
| 2572 | //计算立即购买赠品的物流费用 | 2599 | //计算立即购买赠品的物流费用 |
| 2573 | get_now_gift_goods_wuliu:function (code, o_shipping_price, user_addr, gift_freight_free,allpice, rs,shipping_price,no_by_data) { | 2600 | get_now_gift_goods_wuliu:function (code, o_shipping_price, user_addr, gift_freight_free,allpice, rs,shipping_price,no_by_data) { |
| 2574 | var good=this.data.buy_now_gift_goods; | 2601 | var good=this.data.buy_now_gift_goods; |
| 2575 | - var goods_weight=-1, goods_piece=-1; | 2602 | + var goods_weight=-1, goods_piece=-1; |
| 2576 | var gift_shipping_price=0; | 2603 | var gift_shipping_price=0; |
| 2604 | + var th=this; | ||
| 2577 | switch (good['exp_sum_type']) { | 2605 | switch (good['exp_sum_type']) { |
| 2578 | case 1: | 2606 | case 1: |
| 2579 | //统一运费 | 2607 | //统一运费 |
| @@ -2596,7 +2624,7 @@ Page({ | @@ -2596,7 +2624,7 @@ Page({ | ||
| 2596 | } | 2624 | } |
| 2597 | } | 2625 | } |
| 2598 | //如果有设置不包邮商品 | 2626 | //如果有设置不包邮商品 |
| 2599 | - if(no_by_data && no_by_data.goods_list && freight_free){ | 2627 | + if(no_by_data && no_by_data.goods_list && gift_freight_free){ |
| 2600 | if(th.check_by_goods(no_by_data.goods_list)){ | 2628 | if(th.check_by_goods(no_by_data.goods_list)){ |
| 2601 | gift_freight_free=0; | 2629 | gift_freight_free=0; |
| 2602 | th.data.is_no_by[th.data.bn_pick]=1; | 2630 | th.data.is_no_by[th.data.bn_pick]=1; |