Commit aae0598d57bc7eba3a68243fee498a1e36382275

Authored by yvan.ni
1 parent 7a3b8f7f

确认订单页

Showing 1 changed file with 56 additions and 28 deletions
pages/cart/cart2/cart2.js
... ... @@ -165,8 +165,23 @@ Page({
165 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 187 var jishi= setInterval(function () {
... ... @@ -597,7 +612,7 @@ Page({
597 612 };
598 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 616 //因为搭配购买也是再这里计算,搭配购的is_b_now==1
602 617 if(th.data.is_b_now==0) {
603 618 //此时物流的选择方式要用th.data.cartlist;
... ... @@ -639,13 +654,12 @@ Page({
639 654 is_bz: item_map.is_bz
640 655 }
641 656 }).then(res => {
642   - if (res.data.code == 0) {
  657 + if (res.data.code == 0 && res.data.data.condition) {
643 658 var get_data = res.data.data;
644 659 item_map.is_bz = get_data.is_bz; //是不是倍增
645   - item_map.is_xz_yh = get_data.is_xz_yh; //是不是优惠
646 660 item_map.bs = get_data.bs; //是不是倍数
647 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 663 item_map.s_intValue = get_data.intValue;
650 664 item_map.s_coupon_id = get_data.coupon_id;
651 665 item_map.s_coupon_num = get_data.coupon_num;
... ... @@ -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 696 if(item_map.prom_price && item_map.price-item_map.prom_price){
679 697 if(cart_item.prom_pt_json){
... ... @@ -681,7 +699,10 @@ Page({
681 699 }else{
682 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 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 763 if(!th.data.isget_by_quan[pickid]){
743 764 //--判断要不要显示包邮券,调用接口,因为有for循环---
744 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 767 }).then(res=>{
747 768 if(res.data.code==0 && res.data.data.total>0){
748 769 //此时要循环判断包邮的地区,不包邮商品是不是符合
... ... @@ -808,6 +829,8 @@ Page({
808 829 for(var j=0;j<item.length;j++){
809 830 //如果都包邮,都没必要等级数量了
810 831 if(th.data.is_quan_by[pickid]) continue;
  832 + //如果是优惠活动是包邮,就不用计算包邮的费用了
  833 + if(item[j].is_past) continue;
811 834 //是不是不包邮的商品
812 835 var is_good_no_by=0;
813 836 if(no_ex_good){
... ... @@ -815,13 +838,11 @@ Page({
815 838 }
816 839 //如果达到全场包邮的条件,同时,没有地区不包邮,或者商品不包邮
817 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 841 continue;
820 842 }
821 843  
822 844 //--如果是包邮券使用的情况下,如果商品是包邮的,那么就不进行计算--
823 845 if(th.data.using_quan[pickid] && th.data.using_quan[pickid].isby==1 && !is_good_no_by){
824   - var i=1;
825 846 continue;
826 847 }
827 848  
... ... @@ -1029,7 +1050,7 @@ Page({
1029 1050  
1030 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 1055 if(!th.data.isget_by_quan[th.data.bn_pick]){
1035 1056 var condition=allpice-cut_price;
... ... @@ -1349,7 +1370,7 @@ Page({
1349 1370 }
1350 1371 if(th.data.formData.give_coupon_id>0){
1351 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 1375 if(th.data.formData.give_lb_id>0){
1355 1376 order_prom_list.give_lb_id=th.data.formData.give_lb_id;
... ... @@ -2417,7 +2438,7 @@ Page({
2417 2438 storeId: oo.stoid,
2418 2439 userId: app.globalData.user_id,
2419 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 2442 pageSize: 100
2422 2443 },
2423 2444 success: function (res) {
... ... @@ -2470,9 +2491,10 @@ Page({
2470 2491 //立即购买获取优惠活动的内容
2471 2492 buy_now_prom_goods:function (prom_id,arr,func) {
2472 2493 var price=arr.shop_price*arr.goods_num;
  2494 + var prom=null;
2473 2495 getApp().request.promiseGet("/api/weshop/promgoods/get/"+os.stoid+"/"+prom_id,{}).then(res=>{
2474 2496 if(res.data.code==0){
2475   - var prom=res.data.data;
  2497 + prom=res.data.data;
2476 2498 return getApp().request.promiseGet("/api/weshop/goods/getDiscount", {
2477 2499 data: {
2478 2500 price: price,
... ... @@ -2488,24 +2510,27 @@ Page({
2488 2510 }).then(res=>{
2489 2511 if(res.data.code==0){
2490 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 2515 arr.bs=get_data.bs; //是不是倍数
2494 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 2518 arr.s_intValue=get_data.intValue;
2497 2519 arr.s_coupon_id=get_data.coupon_id;
2498 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 2534 arr.s_libao=get_data.libao;
2510 2535 arr.s_lb_num=get_data.lb_num;
2511 2536 }
... ... @@ -2550,6 +2575,7 @@ Page({
2550 2575 ob.price=item.goods_price*item.goods_num;
2551 2576 ob.goods_num=item.goods_num;
2552 2577 ob.is_bz=prom.is_bz;
  2578 + ob.is_xz_yh=prom.is_xz_yh;
2553 2579 map[pickid][item.prom_id]=ob;
2554 2580 }
2555 2581 }else{
... ... @@ -2562,6 +2588,7 @@ Page({
2562 2588 ob.price=item.goods_price*item.goods_num;
2563 2589 ob.goods_num=item.goods_num;
2564 2590 ob.is_bz=prom.is_bz;
  2591 + ob.is_xz_yh=prom.is_xz_yh;
2565 2592 var obj={};
2566 2593 obj[item.prom_id]=ob;
2567 2594 map[pickid]=obj;
... ... @@ -2572,8 +2599,9 @@ Page({
2572 2599 //计算立即购买赠品的物流费用
2573 2600 get_now_gift_goods_wuliu:function (code, o_shipping_price, user_addr, gift_freight_free,allpice, rs,shipping_price,no_by_data) {
2574 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 2603 var gift_shipping_price=0;
  2604 + var th=this;
2577 2605 switch (good['exp_sum_type']) {
2578 2606 case 1:
2579 2607 //统一运费
... ... @@ -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 2628 if(th.check_by_goods(no_by_data.goods_list)){
2601 2629 gift_freight_free=0;
2602 2630 th.data.is_no_by[th.data.bn_pick]=1;
... ...