Commit a549f91af7c5f600be01d9197707dc68efb5135a
Merge branch 'dev_jfg' into dev
Showing
2 changed files
with
300 additions
and
203 deletions
pages/cart/cart2_inte/cart2_inte.js
| ... | ... | @@ -42,6 +42,9 @@ Page({ |
| 42 | 42 | bn_pickname: "", //选择的门店名称 |
| 43 | 43 | bn_t_exp_t: 0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流 |
| 44 | 44 | |
| 45 | + bn_is_order_yh: 1, //是不是订单优惠 | |
| 46 | + bn_is_post_temp: 1, //是不是进行计算包邮模板 | |
| 47 | + | |
| 45 | 48 | bn_plus_cut_price: 0, //显示等级卡会优惠多少钱 |
| 46 | 49 | /*------------------------*/ |
| 47 | 50 | user_addr: null,//物流 |
| ... | ... | @@ -538,6 +541,19 @@ Page({ |
| 538 | 541 | } |
| 539 | 542 | |
| 540 | 543 | |
| 544 | + if (inte_data.is_order_yh) { | |
| 545 | + th.data.bn_is_order_yh = 1; | |
| 546 | + } else { | |
| 547 | + th.data.bn_is_order_yh = 0; | |
| 548 | + } | |
| 549 | + | |
| 550 | + if (inte_data.is_post_temp) { | |
| 551 | + th.data.bn_is_post_temp = 1; | |
| 552 | + } else { | |
| 553 | + th.data.bn_is_post_temp = 0; | |
| 554 | + } | |
| 555 | + | |
| 556 | + | |
| 541 | 557 | |
| 542 | 558 | th.setData({ |
| 543 | 559 | bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et, index: m_wind, |
| ... | ... | @@ -594,6 +610,7 @@ Page({ |
| 594 | 610 | |
| 595 | 611 | |
| 596 | 612 | //---------计算立即购买---------- |
| 613 | + //---------计算立即购买---------- | |
| 597 | 614 | calculatePrice2:async function () { |
| 598 | 615 | var th = this, good = this.data.bn_goods; |
| 599 | 616 | |
| ... | ... | @@ -608,6 +625,7 @@ Page({ |
| 608 | 625 | cut_price = allpice - good.prom_price; |
| 609 | 626 | } |
| 610 | 627 | allpice = parseFloat(allpice).toFixed(2); |
| 628 | + | |
| 611 | 629 | var txt = "formData.all_price"; |
| 612 | 630 | th.setData({ [txt]: allpice, }); |
| 613 | 631 | if (cut_price) { |
| ... | ... | @@ -615,132 +633,198 @@ Page({ |
| 615 | 633 | th.setData({ [c_txt]: cut_price, }); |
| 616 | 634 | } |
| 617 | 635 | |
| 618 | - //to.getwuliuprice(async function (rs) { | |
| 619 | 636 | |
| 620 | - var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; | |
| 621 | - var out_of_weight = null; //超出多少重量 | |
| 637 | + //-- 把订单优惠的判断提前,bn_is_order_yh是确定要不要订单优惠的控制 -- | |
| 638 | + var condition = parseFloat(allpice-cut_price).toFixed(2); | |
| 639 | + var ord_prom = null; | |
| 640 | + var is_ord_prom_post = 0; | |
| 622 | 641 | |
| 623 | - //-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮---------- | |
| 624 | - if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && good.is_past != 1 && !th.data.inv_is_post) { | |
| 642 | + if (condition > 0 && th.data.bn_is_order_yh && !th.data.bn_goods.whsle_id) { | |
| 643 | + await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { | |
| 644 | + data: { store_id: os.stoid, orderAmount: condition, user_id: getApp().globalData.user_id } | |
| 645 | + }).then(res => { | |
| 646 | + if (res.data.code == 0) { | |
| 647 | + var data = res.data.data; | |
| 648 | + ord_prom = data; | |
| 649 | + } | |
| 650 | + }) | |
| 651 | + if (ord_prom && ord_prom.is_post_temp) { | |
| 652 | + is_ord_prom_post = 1; | |
| 653 | + } | |
| 654 | + } | |
| 625 | 655 | |
| 626 | - var user_addr=th.data.user_addr; | |
| 627 | - var req_d = { | |
| 628 | - province: user_addr.province, city: user_addr.city, district: user_addr.district, | |
| 629 | - wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid | |
| 630 | - } | |
| 631 | - var back_data = null; | |
| 632 | - await getApp().request.promisePost("/api/weshop/order/areaFreight", { | |
| 633 | - is_json: 1, data: req_d | |
| 634 | - }).then(rs => { | |
| 635 | - if (rs.data.code == 0) back_data = rs.data.data; | |
| 636 | - }); | |
| 637 | 656 | |
| 638 | - var gd_arr_list = []; | |
| 639 | - gd_arr_list.push(good); | |
| 640 | - var cut_good_weight = 0; | |
| 641 | - for (let i in gd_arr_list) { | |
| 642 | - let item = gd_arr_list[i]; | |
| 643 | - | |
| 644 | - if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1) ) { | |
| 645 | - | |
| 646 | - if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { | |
| 647 | - if (goods_weight < 0) goods_weight = 0; | |
| 648 | - goods_weight += item['weight'] * item['buynum']; | |
| 649 | - cut_good_weight += item['weight'] * item['buynum']; | |
| 650 | - } | |
| 651 | - if (back_data.weight_free > 0) { | |
| 652 | - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; | |
| 653 | - } | |
| 654 | - continue; | |
| 655 | - } | |
| 656 | 657 | |
| 657 | - switch (item['exp_sum_type']) { | |
| 658 | - case 1: | |
| 659 | - //统一运费 | |
| 660 | - o_shipping_price += item['uniform_exp_sum']; | |
| 661 | - break; | |
| 662 | - case 2: | |
| 663 | - if (goods_weight < 0) goods_weight = 0; | |
| 664 | - //累积商品重量 每种商品的重量 * 数量 | |
| 665 | - goods_weight += item['weight'] * item['buynum']; | |
| 666 | - | |
| 667 | - if (back_data && back_data.is_by_all && !back_data.no_free_goods) { | |
| 668 | - cut_good_weight += item['weight'] * item['buynum']; | |
| 669 | - if (back_data.weight_free > 0) { | |
| 670 | - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; | |
| 671 | - } | |
| 672 | - } | |
| 673 | - break; | |
| 674 | - case 3: | |
| 675 | - if (goods_piece < 0) goods_piece = 0; | |
| 676 | - //累积商品数量 | |
| 677 | - goods_piece += item['buynum']; | |
| 678 | - break; | |
| 679 | - } | |
| 680 | - } | |
| 658 | + //to.getwuliuprice(async function (rs) { | |
| 681 | 659 | |
| 682 | - //如果是正值的时候 | |
| 683 | - if (out_of_weight >= 0) out_of_weight = -cut_good_weight; | |
| 684 | - else out_of_weight = -back_data.weight_free * 1000; | |
| 685 | - | |
| 686 | - var code = ""; | |
| 687 | - if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code; | |
| 688 | - //--------------开始计算物流------------------ | |
| 689 | - var shipping_price=0; | |
| 690 | - // var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, | |
| 691 | - // goods_piece, th.data.user_addr, back_data, rs); | |
| 692 | - | |
| 693 | - var w_data={ | |
| 694 | - store_id:os.stoid, code:code, | |
| 695 | - o_shipping_price:o_shipping_price, | |
| 696 | - goods_weight:goods_weight, | |
| 697 | - out_of_weight:out_of_weight,goods_piece:goods_piece, | |
| 698 | - user_addr_province:th.data.user_addr.province, | |
| 699 | - user_addr_city:th.data.user_addr.city, | |
| 700 | - user_addr_district:th.data.user_addr.district, | |
| 701 | - is_by_all:back_data && back_data.is_by_all?1:0, | |
| 702 | - no_free_goods:back_data && back_data.no_free_goods && back_data.no_free_goods.length>0?1:0, | |
| 703 | - } | |
| 660 | + var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; | |
| 661 | + var out_of_weight = null; //超出多少重量 | |
| 704 | 662 | |
| 705 | - var is_ok=0; | |
| 706 | - await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', {data:w_data,is_json:1}).then(res=>{ | |
| 707 | - if(res.data.code==0){ | |
| 708 | - shipping_price=res.data.data; is_ok=1; | |
| 709 | - } | |
| 710 | - }) | |
| 663 | + //-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮---------- | |
| 664 | + if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && good.is_past != 1 && !th.data.inv_is_post) { | |
| 711 | 665 | |
| 712 | - if(!is_ok){ | |
| 713 | - wx.hideLoading(); | |
| 714 | - wx.showToast({ | |
| 715 | - title: "计算物流错误", icon: 'none',duration: 2000 | |
| 716 | - }) | |
| 666 | + var user_addr=th.data.user_addr; | |
| 667 | + var req_d = { | |
| 668 | + province: user_addr.province, city: user_addr.city, district: user_addr.district, | |
| 669 | + wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid | |
| 670 | + } | |
| 671 | + var back_data = null; | |
| 672 | + //判断是不是包邮模板,bn_is_post_temp 和 订单优惠的包邮模板一起控制 | |
| 673 | + if (th.data.bn_is_post_temp && (!ord_prom || is_ord_prom_post)) { | |
| 674 | + await getApp().request.promisePost("/api/weshop/order/areaFreight", { | |
| 675 | + is_json: 1, data: req_d | |
| 676 | + }).then(rs => { | |
| 677 | + if (rs.data.code == 0) back_data = rs.data.data; | |
| 678 | + }); | |
| 679 | + } | |
| 717 | 680 | |
| 718 | - return false; | |
| 719 | - } | |
| 681 | + var gd_arr_list = []; | |
| 682 | + gd_arr_list.push(good); | |
| 683 | + var cut_good_weight = 0; | |
| 684 | + for (let i in gd_arr_list) { | |
| 685 | + let item = gd_arr_list[i]; | |
| 720 | 686 | |
| 687 | + if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1) ) { | |
| 721 | 688 | |
| 722 | - if (shipping_price <= 0) { | |
| 723 | - th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券 | |
| 689 | + if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { | |
| 690 | + if (goods_weight < 0) goods_weight = 0; | |
| 691 | + goods_weight += item['weight'] * item['buynum']; | |
| 692 | + cut_good_weight += item['weight'] * item['buynum']; | |
| 693 | + } | |
| 694 | + if (back_data.weight_free > 0) { | |
| 695 | + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; | |
| 696 | + } | |
| 697 | + continue; | |
| 698 | + } | |
| 699 | + | |
| 700 | + switch (item['exp_sum_type']) { | |
| 701 | + case 1: | |
| 702 | + //统一运费 | |
| 703 | + o_shipping_price += item['uniform_exp_sum']; | |
| 704 | + break; | |
| 705 | + case 2: | |
| 706 | + if (goods_weight < 0) goods_weight = 0; | |
| 707 | + //累积商品重量 每种商品的重量 * 数量 | |
| 708 | + goods_weight += item['weight'] * item['buynum']; | |
| 709 | + | |
| 710 | + if (back_data && back_data.is_by_all && !back_data.no_free_goods) { | |
| 711 | + cut_good_weight += item['weight'] * item['buynum']; | |
| 712 | + if (back_data.weight_free > 0) { | |
| 713 | + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; | |
| 714 | + } | |
| 724 | 715 | } |
| 716 | + break; | |
| 717 | + case 3: | |
| 718 | + if (goods_piece < 0) goods_piece = 0; | |
| 719 | + //累积商品数量 | |
| 720 | + goods_piece += item['buynum']; | |
| 721 | + break; | |
| 722 | + } | |
| 723 | + } | |
| 725 | 724 | |
| 726 | - shipping_price = parseFloat(shipping_price).toFixed(2); | |
| 727 | - var wl_txt = "formData.shipping_price"; | |
| 728 | - th.setData({ [wl_txt]: shipping_price, }) | |
| 725 | + //如果是正值的时候 | |
| 726 | + if (out_of_weight >= 0) out_of_weight = -cut_good_weight; | |
| 727 | + else out_of_weight = -back_data.weight_free * 1000; | |
| 728 | + | |
| 729 | + var code = ""; | |
| 730 | + if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code; | |
| 731 | + //--------------开始计算物流------------------ | |
| 732 | + var shipping_price=0; | |
| 733 | + // var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, | |
| 734 | + // goods_piece, th.data.user_addr, back_data, rs); | |
| 735 | + | |
| 736 | + var w_data={ | |
| 737 | + store_id:os.stoid, code:code, | |
| 738 | + o_shipping_price:o_shipping_price, | |
| 739 | + goods_weight:goods_weight, | |
| 740 | + out_of_weight:out_of_weight,goods_piece:goods_piece, | |
| 741 | + user_addr_province:th.data.user_addr.province, | |
| 742 | + user_addr_city:th.data.user_addr.city, | |
| 743 | + user_addr_district:th.data.user_addr.district, | |
| 744 | + is_by_all:back_data && back_data.is_by_all?1:0, | |
| 745 | + no_free_goods:back_data && back_data.no_free_goods && back_data.no_free_goods.length>0?1:0, | |
| 746 | + } | |
| 729 | 747 | |
| 730 | - } else if(th.data.bn_exp_type == 1 ) { | |
| 731 | - var wl_txt = "formData.shipping_price"; | |
| 732 | - th.setData({ [wl_txt]: 0, }) | |
| 748 | + var is_ok=0; | |
| 749 | + await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', {data:w_data,is_json:1}).then(res=>{ | |
| 750 | + if(res.data.code==0){ | |
| 751 | + shipping_price=res.data.data; is_ok=1; | |
| 733 | 752 | } |
| 734 | - //---如果有选择优惠券的情况下--- | |
| 735 | - var quan_price = 0, bn_pick = th.data.bn_pick; | |
| 736 | - | |
| 737 | - //-----------------支付价,优惠券不减物流----------------- | |
| 738 | - var total_m = (parseFloat(allpice)).toFixed(2); | |
| 739 | - var order_m = (parseFloat(allpice - cut_price) - quan_price).toFixed(2); | |
| 740 | - var coupon_price = quan_price; //优惠券优惠了多少钱 | |
| 741 | - if (order_m < 0) { | |
| 742 | - order_m = 0; coupon_price = parseFloat(order_m).toFixed(2); | |
| 753 | + }) | |
| 754 | + | |
| 755 | + if(!is_ok){ | |
| 756 | + wx.hideLoading(); | |
| 757 | + wx.showToast({ | |
| 758 | + title: "计算物流错误", icon: 'none',duration: 2000 | |
| 759 | + }) | |
| 760 | + | |
| 761 | + return false; | |
| 762 | + } | |
| 763 | + | |
| 764 | + | |
| 765 | + if (shipping_price <= 0) { | |
| 766 | + th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券 | |
| 767 | + } | |
| 768 | + | |
| 769 | + shipping_price = parseFloat(shipping_price).toFixed(2); | |
| 770 | + var wl_txt = "formData.shipping_price"; | |
| 771 | + th.setData({ [wl_txt]: shipping_price, }) | |
| 772 | + | |
| 773 | + } else if(th.data.bn_exp_type == 1 ) { | |
| 774 | + var wl_txt = "formData.shipping_price"; | |
| 775 | + th.setData({ [wl_txt]: 0, }) | |
| 776 | + } | |
| 777 | + //---如果有选择优惠券的情况下--- | |
| 778 | + var quan_price = 0, bn_pick = th.data.bn_pick; | |
| 779 | + | |
| 780 | + //-----------------支付价,优惠券不减物流----------------- | |
| 781 | + var total_m = (parseFloat(allpice)).toFixed(2); | |
| 782 | + var order_m = (parseFloat(allpice - cut_price) - quan_price).toFixed(2); | |
| 783 | + var coupon_price = quan_price; //优惠券优惠了多少钱 | |
| 784 | + if (order_m < 0) { | |
| 785 | + order_m = 0; coupon_price = parseFloat(order_m).toFixed(2); | |
| 786 | + } | |
| 787 | + | |
| 788 | + //--看一下有没有订单优惠-- | |
| 789 | + var o_condition = parseFloat(order_m); | |
| 790 | + if (th.data.bn_goods.whsle_id > 0) { | |
| 791 | + o_condition = 0; | |
| 792 | + } | |
| 793 | + | |
| 794 | + var order_prom_amount = 0; | |
| 795 | + var order_prom_id = 0; | |
| 796 | + if (ord_prom && o_condition > 0) { | |
| 797 | + //么有使用券,或者活动没有限制使用优惠券 | |
| 798 | + if (coupon_price <= 0 || !ord_prom.is_xz_yh) { | |
| 799 | + order_prom_id = ord_prom['id']; | |
| 800 | + switch (ord_prom['type']) { | |
| 801 | + case 0: | |
| 802 | + order_m = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折 | |
| 803 | + order_prom_amount = (o_condition - order_m).toFixed(2); | |
| 804 | + break; | |
| 805 | + case 1: | |
| 806 | + //-- 如果有优惠促销倍减的时候 -- | |
| 807 | + var bs = 1; | |
| 808 | + if (ord_prom.is_bz) { | |
| 809 | + bs = Math.floor(o_condition / ord_prom.money); | |
| 810 | + } | |
| 811 | + | |
| 812 | + order_m = o_condition - bs * ord_prom['expression'];//满额优惠金额 | |
| 813 | + order_prom_amount = ord_prom['expression']; | |
| 814 | + break; | |
| 743 | 815 | } |
| 816 | + } | |
| 817 | + } | |
| 818 | + //--订单优惠的显示-- | |
| 819 | + var order_prom_txt1 = "formData.order_prom_id"; | |
| 820 | + var order_prom_txt2 = "formData.order_prom_amount"; | |
| 821 | + if (order_prom_id > 0) { | |
| 822 | + th.setData({ [order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount }) | |
| 823 | + } else { | |
| 824 | + th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) | |
| 825 | + } | |
| 826 | + | |
| 827 | + | |
| 744 | 828 | |
| 745 | 829 | //预存金额使用参与计算 |
| 746 | 830 | if (th.data.udata && th.data.udata.Balance > 0 && order_m * 1 > 0) { |
| ... | ... | @@ -772,7 +856,7 @@ Page({ |
| 772 | 856 | order_amount: order_m, |
| 773 | 857 | goods: [{ |
| 774 | 858 | goods_sn: th.data.bn_goods.goods_sn, |
| 775 | - goods_price: th.data.bn_goods.shop_price || th.data.bn_goods.goods_price, | |
| 859 | + goods_price: th.data.bn_goods.shop_price || th.data.bn_goods.goods_price, | |
| 776 | 860 | goods_num: th.data.bn_goods.buynum || th.data.bn_goods.goods_num, |
| 777 | 861 | }], |
| 778 | 862 | sto: { |
| ... | ... | @@ -841,107 +925,107 @@ Page({ |
| 841 | 925 | }) |
| 842 | 926 | } |
| 843 | 927 | |
| 844 | - //判断是否同城配送,而且没有调用过 | |
| 845 | - if(th.data.bn_exp_type==2 && th.data.user_addr) { | |
| 846 | - | |
| 847 | - var lon=0;var lat=0; | |
| 848 | - //-- 获取距离 -- | |
| 849 | - await getApp().request.promisePost("/api/weshop/order/sameCityExp/getGeocoder", { | |
| 850 | - is_json: 1, data: {address:th.data.user_addr.more_address+th.data.user_addr.address} | |
| 851 | - }).then(res=>{ | |
| 852 | - if(res.data.code==0){ | |
| 853 | - var data= JSON.parse(res.data.data); | |
| 854 | - if(data.status==0){ | |
| 855 | - lon=data.result.location.lng; | |
| 856 | - lat=data.result.location.lat; | |
| 857 | - } | |
| 858 | - } | |
| 859 | - }) | |
| 860 | - | |
| 861 | - | |
| 862 | - var gd_w = good['weight'] * good['buynum']; | |
| 863 | - //-- 获取距离 -- | |
| 864 | - var req_data = { | |
| 865 | - store_id: os.stoid, | |
| 866 | - order_amount: order_m, | |
| 867 | - lon: lon, lat: lat, | |
| 868 | - pickup_id: bn_pick, | |
| 869 | - goods_weight: gd_w | |
| 870 | - } | |
| 871 | - | |
| 872 | - var is_next=1; | |
| 873 | - //获取同城配送参数 | |
| 874 | - await getApp().request.promisePost("/api/weshop/order/sameCityExp/getMoney", { | |
| 875 | - is_json: 1, | |
| 876 | - data: req_data | |
| 877 | - }).then(res => { | |
| 878 | - if (res.data.code == 0) { | |
| 879 | - var wl_txt = "formData.shipping_price"; | |
| 880 | - th.setData({ [wl_txt]: res.data.data, }) | |
| 881 | - }else{ | |
| 882 | - is_next=0; | |
| 883 | - wx.showToast({ | |
| 884 | - title: res.data.msg, icon: 'none', duration: 2000 | |
| 885 | - }) | |
| 886 | - } | |
| 887 | - }) | |
| 888 | - if(!is_next) return false | |
| 889 | - } | |
| 890 | - | |
| 891 | - | |
| 892 | - | |
| 893 | - //--看一下有没有订单优惠--0 | |
| 894 | - total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price); | |
| 895 | - order_m = parseFloat(order_m) + parseFloat(th.data.formData.shipping_price); | |
| 896 | - var atxt = "formData.total_amount"; | |
| 897 | - th.setData({ [atxt]: total_m, }) | |
| 898 | - | |
| 899 | - var txt = "formData.user_money"; | |
| 900 | - var txt2 = "formData.order_amount"; | |
| 901 | - var txt4 = "formData.integral"; | |
| 902 | - | |
| 903 | - | |
| 904 | - //-- 最后的金额小于佣金 -- | |
| 905 | - if(parseFloat(order_m)<parseFloat(th.data.bn_goods.use_commission)){ | |
| 906 | - | |
| 907 | - if(th.data.bn_use_commission){ | |
| 908 | - wx.showToast({ | |
| 909 | - title: '应付金额小于本单佣金,不可使用!', | |
| 910 | - icon: 'none', | |
| 911 | - duration: 2000 | |
| 912 | - }) | |
| 928 | + //判断是否同城配送,而且没有调用过 | |
| 929 | + if(th.data.bn_exp_type==2 && th.data.user_addr) { | |
| 930 | + | |
| 931 | + var lon=0;var lat=0; | |
| 932 | + //-- 获取距离 -- | |
| 933 | + await getApp().request.promisePost("/api/weshop/order/sameCityExp/getGeocoder", { | |
| 934 | + is_json: 1, data: {address:th.data.user_addr.more_address+th.data.user_addr.address} | |
| 935 | + }).then(res=>{ | |
| 936 | + if(res.data.code==0){ | |
| 937 | + var data= JSON.parse(res.data.data); | |
| 938 | + if(data.status==0){ | |
| 939 | + lon=data.result.location.lng; | |
| 940 | + lat=data.result.location.lat; | |
| 913 | 941 | } |
| 942 | + } | |
| 943 | + }) | |
| 914 | 944 | |
| 915 | - th.setData({ | |
| 916 | - cart_use_commission:0 | |
| 917 | - }); | |
| 918 | 945 | |
| 946 | + var gd_w = good['weight'] * good['buynum']; | |
| 947 | + //-- 获取距离 -- | |
| 948 | + var req_data = { | |
| 949 | + store_id: os.stoid, | |
| 950 | + order_amount: order_m, | |
| 951 | + lon: lon, lat: lat, | |
| 952 | + pickup_id: bn_pick, | |
| 953 | + goods_weight: gd_w | |
| 919 | 954 | } |
| 920 | 955 | |
| 956 | + var is_next=1; | |
| 957 | + //获取同城配送参数 | |
| 958 | + await getApp().request.promisePost("/api/weshop/order/sameCityExp/getMoney", { | |
| 959 | + is_json: 1, | |
| 960 | + data: req_data | |
| 961 | + }).then(res => { | |
| 962 | + if (res.data.code == 0) { | |
| 963 | + var wl_txt = "formData.shipping_price"; | |
| 964 | + th.setData({ [wl_txt]: res.data.data, }) | |
| 965 | + }else{ | |
| 966 | + is_next=0; | |
| 967 | + wx.showToast({ | |
| 968 | + title: res.data.msg, icon: 'none', duration: 2000 | |
| 969 | + }) | |
| 970 | + } | |
| 971 | + }) | |
| 972 | + if(!is_next) return false | |
| 973 | + } | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + //--看一下有没有订单优惠--0 | |
| 978 | + total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price); | |
| 979 | + order_m = parseFloat(order_m) + parseFloat(th.data.formData.shipping_price); | |
| 980 | + var atxt = "formData.total_amount"; | |
| 981 | + th.setData({ [atxt]: total_m, }) | |
| 982 | + | |
| 983 | + var txt = "formData.user_money"; | |
| 984 | + var txt2 = "formData.order_amount"; | |
| 985 | + var txt4 = "formData.integral"; | |
| 986 | + | |
| 987 | + | |
| 988 | + //-- 最后的金额小于佣金 -- | |
| 989 | + if(parseFloat(order_m)<parseFloat(th.data.bn_goods.use_commission)){ | |
| 921 | 990 | |
| 922 | - var txt5 = "formData.use_commission"; | |
| 923 | 991 | if(th.data.bn_use_commission){ |
| 924 | - order_m=(parseFloat(order_m)- parseFloat(th.data.bn_goods.use_commission)).toFixed(2); | |
| 925 | - th.setData({[txt5]:th.data.bn_goods.use_commission}) | |
| 992 | + wx.showToast({ | |
| 993 | + title: '应付金额小于本单佣金,不可使用!', | |
| 994 | + icon: 'none', | |
| 995 | + duration: 2000 | |
| 996 | + }) | |
| 926 | 997 | } |
| 927 | 998 | |
| 928 | - var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money); | |
| 929 | - //--------------如果使用余额--------------------- | |
| 930 | - if (th.data.bn_use_money == 1) { | |
| 931 | - if (amoney > parseFloat(order_m)) { | |
| 932 | - order_m = parseFloat(order_m).toFixed(2); | |
| 933 | - th.setData({ [txt]: order_m, [txt2]: 0, [txt4]: all_integral, show_submit: 1,submit:0 }) | |
| 934 | - } else { | |
| 935 | - order_m = parseFloat(order_m - amoney); | |
| 936 | - order_m = order_m.toFixed(2); | |
| 937 | - th.setData({ [txt]: amoney, [txt2]: order_m, [txt4]: all_integral, show_submit: 1,submit:0 }) | |
| 938 | - } | |
| 939 | - } else { | |
| 940 | - th.setData({ [txt]: 0, [txt2]: order_m, [txt4]: all_integral, show_submit: 1,submit:0}) | |
| 941 | - } | |
| 942 | - wx.hideLoading(); | |
| 999 | + th.setData({ | |
| 1000 | + cart_use_commission:0 | |
| 1001 | + }); | |
| 1002 | + | |
| 1003 | + } | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + var txt5 = "formData.use_commission"; | |
| 1007 | + if(th.data.bn_use_commission){ | |
| 1008 | + order_m=(parseFloat(order_m)- parseFloat(th.data.bn_goods.use_commission)).toFixed(2); | |
| 1009 | + th.setData({[txt5]:th.data.bn_goods.use_commission}) | |
| 1010 | + } | |
| 943 | 1011 | |
| 944 | - //}); | |
| 1012 | + var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money); | |
| 1013 | + //--------------如果使用余额--------------------- | |
| 1014 | + if (th.data.bn_use_money == 1) { | |
| 1015 | + if (amoney > parseFloat(order_m)) { | |
| 1016 | + order_m = parseFloat(order_m).toFixed(2); | |
| 1017 | + th.setData({ [txt]: order_m, [txt2]: 0, [txt4]: all_integral, show_submit: 1,submit:0 }) | |
| 1018 | + } else { | |
| 1019 | + order_m = parseFloat(order_m - amoney); | |
| 1020 | + order_m = order_m.toFixed(2); | |
| 1021 | + th.setData({ [txt]: amoney, [txt2]: order_m, [txt4]: all_integral, show_submit: 1,submit:0 }) | |
| 1022 | + } | |
| 1023 | + } else { | |
| 1024 | + th.setData({ [txt]: 0, [txt2]: order_m, [txt4]: all_integral, show_submit: 1,submit:0}) | |
| 1025 | + } | |
| 1026 | + wx.hideLoading(); | |
| 1027 | + | |
| 1028 | + //}); | |
| 945 | 1029 | |
| 946 | 1030 | }, |
| 947 | 1031 | |
| ... | ... | @@ -1027,6 +1111,13 @@ Page({ |
| 1027 | 1111 | if(th.data.bn_use_commission){ |
| 1028 | 1112 | item.use_commission=th.data.bn_goods.use_commission; |
| 1029 | 1113 | } |
| 1114 | + var order_prom_list = {}; | |
| 1115 | + //--判断有没有优惠活动-- | |
| 1116 | + if (th.data.formData.order_prom_amount > 0) { | |
| 1117 | + order_prom_list.order_prom_id = th.data.formData.order_prom_id; | |
| 1118 | + order_prom_list.order_prom_amount = th.data.formData.order_prom_amount; | |
| 1119 | + } | |
| 1120 | + item.order_prom_list = order_prom_list; | |
| 1030 | 1121 | |
| 1031 | 1122 | |
| 1032 | 1123 | //获取立即购买的商品的信息 | ... | ... |
pages/cart/cart2_inte/cart2_inte.wxml
| ... | ... | @@ -65,7 +65,7 @@ |
| 65 | 65 | <view class="goods-img"> |
| 66 | 66 | <image class="wh100 bdr14" src="{{bn_goods.original_img}}" binderror='cart_set_err' data-err="bn_goods.original_img"></image> |
| 67 | 67 | </view> |
| 68 | - <navigator class="order-cont" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{bn_goods.goods_id}}"> | |
| 68 | + <navigator class="order-cont" url="/pages/goods/goodsInfo/goodsInfo?goods_id={{bn_goods.goods_id}}&prom_type={{bn_goods.prom_type}}&prom_id={{bn_goods.prom_id}}"> | |
| 69 | 69 | <view class="goods-name ellipsis-2">{{bn_goods.goods_name}}</view> |
| 70 | 70 | <!-- 商品属性 --> |
| 71 | 71 | <view class="flex-vertical fs28 xc-ash color-gray n_guige"> |
| ... | ... | @@ -174,6 +174,12 @@ |
| 174 | 174 | <view>配送费用</view> |
| 175 | 175 | <view class="co-red">¥ {{formData.shipping_price}}元</view> |
| 176 | 176 | </view> |
| 177 | + | |
| 178 | + <!-- 订单优惠优惠金额 --> | |
| 179 | + <view class="item" wx:if="{{formData.order_prom_amount>0}}"> | |
| 180 | + <view>订单优惠</view> | |
| 181 | + <view class="co-red">- ¥ {{filters.toFix(formData.order_prom_amount,2)}}元</view> | |
| 182 | + </view> | |
| 177 | 183 | <!-- 使用预存优惠金额 --> |
| 178 | 184 | <view class="item" wx:if="{{formData.prestore>0}}"> |
| 179 | 185 | <view>使用预存</view> | ... | ... |