Commit d0a8f34b18d8a94f8b1cccdcb906b7296c0becf8
1 parent
686b18b9
预售尾款不包邮地区 不i包邮商品优化
Showing
5 changed files
with
134 additions
and
20 deletions
packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart.js
@@ -1891,7 +1891,7 @@ Page({ | @@ -1891,7 +1891,7 @@ Page({ | ||
1891 | 1891 | ||
1892 | 1892 | ||
1893 | //有不包邮区域,且不免运费 | 1893 | //有不包邮区域,且不免运费 |
1894 | - if (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice) - cut_price - quan_price) { | 1894 | + if (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice)) { |
1895 | //-----------获取不包邮区域,不包邮商品------- | 1895 | //-----------获取不包邮区域,不包邮商品------- |
1896 | await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", { | 1896 | await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", { |
1897 | data: { store_id: os.stoid, id: no_ex_id } | 1897 | data: { store_id: os.stoid, id: no_ex_id } |
packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js
@@ -577,7 +577,7 @@ Page({ | @@ -577,7 +577,7 @@ Page({ | ||
577 | } | 577 | } |
578 | var shipping_price = | 578 | var shipping_price = |
579 | th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, | 579 | th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, |
580 | - goods_piece, th.data.user_addr, freight_free, allpice, rs); | 580 | + goods_piece, th.data.user_addr, freight_free, allpice, rs,th.data.bn_pick); |
581 | 581 | ||
582 | shipping_price = parseFloat(shipping_price).toFixed(2); | 582 | shipping_price = parseFloat(shipping_price).toFixed(2); |
583 | var wl_txt = "formData.shipping_price"; | 583 | var wl_txt = "formData.shipping_price"; |
@@ -1075,7 +1075,7 @@ Page({ | @@ -1075,7 +1075,7 @@ Page({ | ||
1075 | 1075 | ||
1076 | //-------------------计算物流--------------- | 1076 | //-------------------计算物流--------------- |
1077 | calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, | 1077 | calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, |
1078 | - goods_piece, user_addr, freight_free, o_price, rs) { | 1078 | + goods_piece, user_addr, freight_free, o_price, rs,pickid) { |
1079 | var price = 0, | 1079 | var price = 0, |
1080 | th = this; | 1080 | th = this; |
1081 | price += parseFloat(o_shipping_price); | 1081 | price += parseFloat(o_shipping_price); |
packageC/pages/presell/cart/cart.js
@@ -1663,7 +1663,7 @@ Page({ | @@ -1663,7 +1663,7 @@ Page({ | ||
1663 | 1663 | ||
1664 | var t_shipping_price = | 1664 | var t_shipping_price = |
1665 | this.calculatewuliu(code, gift_shipping_price, goods_weight, out_of_weight, | 1665 | this.calculatewuliu(code, gift_shipping_price, goods_weight, out_of_weight, |
1666 | - goods_piece, user_addr, gift_freight_free, allpice, rs,th.data.bn_pick); | 1666 | + goods_piece, user_addr, gift_freight_free, allpice, rs, th.data.bn_pick); |
1667 | return t_shipping_price; | 1667 | return t_shipping_price; |
1668 | 1668 | ||
1669 | }, | 1669 | }, |
@@ -1725,14 +1725,25 @@ Page({ | @@ -1725,14 +1725,25 @@ Page({ | ||
1725 | good = th.data.goods, | 1725 | good = th.data.goods, |
1726 | quan_price = 0, | 1726 | quan_price = 0, |
1727 | exp_price = 0; | 1727 | exp_price = 0; |
1728 | - | 1728 | + var no_ex_id = ee.no_ex_id; |
1729 | var quan_no = null; | 1729 | var quan_no = null; |
1730 | var bn_pick = th.data.pickup.pickup_id; | 1730 | var bn_pick = th.data.pickup.pickup_id; |
1731 | var allpice = th.data.all_price; | 1731 | var allpice = th.data.all_price; |
1732 | var out_of_weight = null; //超出多少重量 | 1732 | var out_of_weight = null; //超出多少重量 |
1733 | var freight_free = ee.freight_free; //全场满多少包邮 | 1733 | var freight_free = ee.freight_free; //全场满多少包邮 |
1734 | var weight_free = ee.weight_free; //多少kg内包邮 | 1734 | var weight_free = ee.weight_free; //多少kg内包邮 |
1735 | - | 1735 | + var no_ex_good = null; |
1736 | + var by_qc = {}; | ||
1737 | + if (no_ex_id && freight_free > 0) { | ||
1738 | + //-----------获取不包邮区域,不包邮商品------- | ||
1739 | + await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", { | ||
1740 | + data: { store_id: os.stoid, id: no_ex_id } | ||
1741 | + }).then(res => { | ||
1742 | + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { | ||
1743 | + by_qc = res.data.data[0]; | ||
1744 | + } | ||
1745 | + }) | ||
1746 | + }; | ||
1736 | if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined) | 1747 | if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined) |
1737 | quan_no = th.data.using_quan[bn_pick].coupon_no; | 1748 | quan_no = th.data.using_quan[bn_pick].coupon_no; |
1738 | 1749 | ||
@@ -1824,9 +1835,38 @@ Page({ | @@ -1824,9 +1835,38 @@ Page({ | ||
1824 | } | 1835 | } |
1825 | 1836 | ||
1826 | var code = th.data.wu_arr[th.data.index].code; | 1837 | var code = th.data.wu_arr[th.data.index].code; |
1838 | + th.data.is_no_by[th.data.bn_pick] = 0; | ||
1839 | + var no_by_data = null; | ||
1840 | + //有不包邮区域,且不免运费 | ||
1841 | + if (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice)) { | ||
1842 | + //-----------获取不包邮区域,不包邮商品------- | ||
1843 | + await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", { | ||
1844 | + data: { store_id: os.stoid, id: no_ex_id } | ||
1845 | + }).then(res => { | ||
1846 | + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { | ||
1847 | + no_by_data = res.data.data[0]; | ||
1848 | + //如果有设置不包邮区域的时候 | ||
1849 | + if (res.data.data[0].region_list) { | ||
1850 | + if (th.check_by_area(res.data.data[0].region_list)) { | ||
1851 | + freight_free = 0; | ||
1852 | + // out_of_weight = 0; | ||
1853 | + th.data.is_no_by[th.data.bn_pick] = 1; | ||
1854 | + } | ||
1855 | + } | ||
1856 | + //如果有设置不包邮商品 | ||
1857 | + if (res.data.data[0].goods_list && freight_free) { | ||
1858 | + if (th.check_by_goods(res.data.data[0].goods_list)) { | ||
1859 | + freight_free = 0; | ||
1860 | + // out_of_weight = 0; | ||
1861 | + th.data.is_no_by[th.data.bn_pick] = 1; | ||
1862 | + } | ||
1863 | + } | ||
1864 | + } | ||
1865 | + }) | ||
1866 | + } | ||
1827 | var shipping_price = | 1867 | var shipping_price = |
1828 | th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, | 1868 | th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, |
1829 | - goods_piece, th.data.user_addr, freight_free, allpice, rs); | 1869 | + goods_piece, th.data.user_addr, freight_free, allpice, rs,th.data.bn_pick); |
1830 | exp_price = parseFloat(shipping_price).toFixed(2); | 1870 | exp_price = parseFloat(shipping_price).toFixed(2); |
1831 | } | 1871 | } |
1832 | th.wuliu_next(allpice, quan_price, exp_price); | 1872 | th.wuliu_next(allpice, quan_price, exp_price); |
pages/cart/cart2_pt/cart2_pt.js
@@ -33,7 +33,7 @@ Page({ | @@ -33,7 +33,7 @@ Page({ | ||
33 | couponCode: "",//使用优惠券(多单就用逗号隔开) | 33 | couponCode: "",//使用优惠券(多单就用逗号隔开) |
34 | shipping_price: 0,//物流费用 | 34 | shipping_price: 0,//物流费用 |
35 | }, | 35 | }, |
36 | - | 36 | + is_no_by:{}, |
37 | /*----------------立即购买---------------------*/ | 37 | /*----------------立即购买---------------------*/ |
38 | is_b_now: 0, //0是购物车结算 1立即购买 | 38 | is_b_now: 0, //0是购物车结算 1立即购买 |
39 | bn_goods: null, //立即购买时候的调用商品 | 39 | bn_goods: null, //立即购买时候的调用商品 |
@@ -404,13 +404,26 @@ Page({ | @@ -404,13 +404,26 @@ Page({ | ||
404 | console.log(th.data.formData); | 404 | console.log(th.data.formData); |
405 | 405 | ||
406 | to.getConfig2(function (ee) { | 406 | to.getConfig2(function (ee) { |
407 | - to.getwuliuprice(function (rs) { | 407 | + to.getwuliuprice(async function (rs) { |
408 | console.log('calculatePrice2222'); | 408 | console.log('calculatePrice2222'); |
409 | console.log(rs); | 409 | console.log(rs); |
410 | var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; | 410 | var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; |
411 | var out_of_weight = null; //超出多少重量 | 411 | var out_of_weight = null; //超出多少重量 |
412 | var freight_free = ee.freight_free; //全场满多少包邮 | 412 | var freight_free = ee.freight_free; //全场满多少包邮 |
413 | var weight_free = ee.weight_free; //多少kg内包邮 | 413 | var weight_free = ee.weight_free; //多少kg内包邮 |
414 | + var no_ex_id = ee.no_ex_id; | ||
415 | + var no_ex_good = null; | ||
416 | + var by_qc = {}; | ||
417 | + if (no_ex_id && freight_free > 0) { | ||
418 | + //-----------获取不包邮区域,不包邮商品------- | ||
419 | + await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", { | ||
420 | + data: { store_id: os.stoid, id: no_ex_id } | ||
421 | + }).then(res => { | ||
422 | + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { | ||
423 | + by_qc = res.data.data[0]; | ||
424 | + } | ||
425 | + }) | ||
426 | + }; | ||
414 | //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- | 427 | //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- |
415 | if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { | 428 | if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { |
416 | switch (good['exp_sum_type']) { | 429 | switch (good['exp_sum_type']) { |
@@ -430,14 +443,42 @@ Page({ | @@ -430,14 +443,42 @@ Page({ | ||
430 | //累积商品数量 | 443 | //累积商品数量 |
431 | goods_piece += good['buynum']; break; | 444 | goods_piece += good['buynum']; break; |
432 | } | 445 | } |
433 | - | ||
434 | - console.log(o_shipping_price + ":" + goods_weight + ":" + goods_piece); | 446 | + |
435 | console.log(th.data.wu_arr); | 447 | console.log(th.data.wu_arr); |
436 | var code = th.data.wu_arr[th.data.index].code; | 448 | var code = th.data.wu_arr[th.data.index].code; |
437 | - var freight_free = ee.freight_free; //全场满多少包邮 | 449 | + th.data.is_no_by[th.data.bn_pick] = 0; |
450 | + var no_by_data = null; | ||
451 | + //--全部金额-- | ||
452 | + //有不包邮区域,且不免运费 | ||
453 | + if (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice)) { | ||
454 | + //-----------获取不包邮区域,不包邮商品------- | ||
455 | + await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", { | ||
456 | + data: { store_id: os.stoid, id: no_ex_id } | ||
457 | + }).then(res => { | ||
458 | + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { | ||
459 | + no_by_data = res.data.data[0]; | ||
460 | + //如果有设置不包邮区域的时候 | ||
461 | + if (res.data.data[0].region_list) { | ||
462 | + if (th.check_by_area(res.data.data[0].region_list)) { | ||
463 | + freight_free = 0; | ||
464 | + // out_of_weight = 0; | ||
465 | + th.data.is_no_by[th.data.bn_pick] = 1; | ||
466 | + } | ||
467 | + } | ||
468 | + //如果有设置不包邮商品 | ||
469 | + if (res.data.data[0].goods_list && freight_free) { | ||
470 | + if (th.check_by_goods(res.data.data[0].goods_list)) { | ||
471 | + freight_free = 0; | ||
472 | + // out_of_weight = 0; | ||
473 | + th.data.is_no_by[th.data.bn_pick] = 1; | ||
474 | + } | ||
475 | + } | ||
476 | + } | ||
477 | + }) | ||
478 | + } | ||
438 | var shipping_price = | 479 | var shipping_price = |
439 | th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, | 480 | th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, |
440 | - goods_piece, th.data.user_addr, freight_free, allpice, rs); | 481 | + goods_piece, th.data.user_addr, freight_free, allpice, rs,th.data.bn_pick); |
441 | 482 | ||
442 | shipping_price = parseFloat(shipping_price).toFixed(2); | 483 | shipping_price = parseFloat(shipping_price).toFixed(2); |
443 | var wl_txt = "formData.shipping_price"; | 484 | var wl_txt = "formData.shipping_price"; |
@@ -728,6 +769,39 @@ Page({ | @@ -728,6 +769,39 @@ Page({ | ||
728 | url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a) | 769 | url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a) |
729 | }); | 770 | }); |
730 | }, | 771 | }, |
772 | + //检查区域是不是包邮 | ||
773 | + check_area: function (arr) { | ||
774 | + var user_addr = this.data.user_addr; | ||
775 | + if (!user_addr) return 0; | ||
776 | + for (var i in arr) { | ||
777 | + var item = arr[i]; | ||
778 | + if (user_addr.twon == item || user_addr.district == item | ||
779 | + || user_addr.city == item || user_addr.province == item) { | ||
780 | + return 0; | ||
781 | + } | ||
782 | + } | ||
783 | + return 1; | ||
784 | + }, | ||
785 | + | ||
786 | + //检查立即购买的商品是不是不包邮 | ||
787 | + check_good: function (arr, goods_id) { | ||
788 | + if (!goods_id) goods_id = this.data.goods.goods_id; | ||
789 | + for (var i in arr) { | ||
790 | + var item = arr[i]; | ||
791 | + if (goods_id == item) return 0; | ||
792 | + } | ||
793 | + return 1; | ||
794 | + }, | ||
795 | + check_by_area: function (region_list) { | ||
796 | + var arr = region_list.split(","); | ||
797 | + var check = this.check_area(arr); | ||
798 | + return !check; | ||
799 | + }, | ||
800 | + check_by_goods: function (goods_list, goods_id) { | ||
801 | + var arr = goods_list.split(","); | ||
802 | + var check = this.check_good(arr, goods_id); | ||
803 | + return !check; | ||
804 | + }, | ||
731 | enterAddressPage: function () { | 805 | enterAddressPage: function () { |
732 | getApp().globalData.is_cart_old = 1; | 806 | getApp().globalData.is_cart_old = 1; |
733 | this.data.enterAddressPage = !0, wx.navigateTo({ | 807 | this.data.enterAddressPage = !0, wx.navigateTo({ |
@@ -808,15 +882,15 @@ Page({ | @@ -808,15 +882,15 @@ Page({ | ||
808 | } | 882 | } |
809 | } | 883 | } |
810 | //------超出重量---------- | 884 | //------超出重量---------- |
811 | - if (out_of_weight < 0 && o_price >= freight_free) { | 885 | + if (out_of_weight < 0 && o_price >= freight_free && !th.data.is_no_by[pickid]) { |
812 | fw_price = parseFloat(item['money']); | 886 | fw_price = parseFloat(item['money']); |
813 | var out_of_weight = Math.abs(out_of_weight); | 887 | var out_of_weight = Math.abs(out_of_weight); |
814 | if (out_of_weight > item['first_weight']) { | 888 | if (out_of_weight > item['first_weight']) { |
815 | - var fw = out_of_weight - item['first_weight']; | ||
816 | - var n = Math.ceil(fw / item['second_weight']) | ||
817 | - fw_price = fw_price + n * parseFloat(item['add_money']); | 889 | + var fw = out_of_weight - item['first_weight']; |
890 | + var n = Math.ceil(fw / item['second_weight']) | ||
891 | + fw_price = fw_price + n * parseFloat(item['add_money']); | ||
818 | } | 892 | } |
819 | - } | 893 | + } |
820 | //------按件数---------- | 894 | //------按件数---------- |
821 | if (goods_piece > 0) { | 895 | if (goods_piece > 0) { |
822 | fp_price = parseFloat(item['piecemoney']); | 896 | fp_price = parseFloat(item['piecemoney']); |
pages/cart/cart_wk/cart_wk.js
@@ -527,7 +527,7 @@ Page({ | @@ -527,7 +527,7 @@ Page({ | ||
527 | } | 527 | } |
528 | var shipping_price = | 528 | var shipping_price = |
529 | th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, | 529 | th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, |
530 | - goods_piece, th.data.user_addr, freight_free, allpice, rs); | 530 | + goods_piece, th.data.user_addr, freight_free, allpice, rs,th.data.bn_pick); |
531 | var exp_price = parseFloat(shipping_price).toFixed(2); | 531 | var exp_price = parseFloat(shipping_price).toFixed(2); |
532 | allpice = parseFloat(exp_price) + parseFloat(allpice); | 532 | allpice = parseFloat(exp_price) + parseFloat(allpice); |
533 | allpice = allpice.toFixed(2); | 533 | allpice = allpice.toFixed(2); |
@@ -545,7 +545,7 @@ Page({ | @@ -545,7 +545,7 @@ Page({ | ||
545 | 545 | ||
546 | //----------------计算物流--------------- | 546 | //----------------计算物流--------------- |
547 | calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, | 547 | calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, |
548 | - goods_piece, user_addr, freight_free, o_price, rs) { | 548 | + goods_piece, user_addr, freight_free, o_price, rs,pickid) { |
549 | var price = 0, th = this; | 549 | var price = 0, th = this; |
550 | price += parseFloat(o_shipping_price); | 550 | price += parseFloat(o_shipping_price); |
551 | //如果是包邮 | 551 | //如果是包邮 |