Commit 3388c6f268039255235813c10e81ec4abca52dfe

Authored by yvan.ni
1 parent 21d09ab2

同城配送在切换的时候,对物流的影响~~

packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js
... ... @@ -782,113 +782,122 @@ Page({
782 782  
783 783  
784 784 //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格----------
785   - if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && (th.data.kt_type !=
  785 + if (th.data.user_addr != null && th.data.bn_exp_type == 0 && (th.data.kt_type !=
786 786 3 || th.data.bn_goods.is_normal == 1)) {
787 787  
788   - var user_addr = th.data.user_addr;
789   - var req_d = {
790   - province: user_addr.province, city: user_addr.city, district: user_addr.district,
791   - wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid
792   - }
793   -
794   - //-- 判断包邮 --
795   - var back_data = null;
796   - if(!ord_prom || ord_prom.is_post_temp) {
797   - if (th.data.act.is_post_temp ) {
798   - await getApp().request.promisePost("/api/weshop/order/areaFreight", {
799   - is_json: 1, data: req_d
800   - }).then(rs => {
801   - if (rs.data.code == 0) back_data = rs.data.data;
802   - });
803   - }
804   - }
  788 + if(good.is_free_shipping){
  789 + var wl_txt = "formData.shipping_price";
  790 + th.setData({
  791 + [wl_txt]: 0,
  792 + })
805 793  
806   - var gd_arr_list = [];
807   - gd_arr_list.push(good);
808   - var cut_good_weight = 0;
809   - for (let i in gd_arr_list) {
810   - let item = gd_arr_list[i];
  794 + }else{
811 795  
812   - if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) {
  796 + var user_addr = th.data.user_addr;
  797 + var req_d = {
  798 + province: user_addr.province, city: user_addr.city, district: user_addr.district,
  799 + wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid
  800 + }
813 801  
814   - if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) {
815   - if (goods_weight < 0) goods_weight = 0;
816   - goods_weight += item['weight'] * item['buynum'];
817   - cut_good_weight += item['weight'] * item['buynum'];
818   - }
819   - if (back_data.weight_free > 0) {
820   - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  802 + //-- 判断包邮 --
  803 + var back_data = null;
  804 + if(!ord_prom || ord_prom.is_post_temp) {
  805 + if (th.data.act.is_post_temp ) {
  806 + await getApp().request.promisePost("/api/weshop/order/areaFreight", {
  807 + is_json: 1, data: req_d
  808 + }).then(rs => {
  809 + if (rs.data.code == 0) back_data = rs.data.data;
  810 + });
821 811 }
822   - continue;
823 812 }
824 813  
825   - switch (item['exp_sum_type']) {
826   - case 1:
827   - //统一运费
828   - o_shipping_price += item['uniform_exp_sum'];
829   - break;
830   - case 2:
831   - if (goods_weight < 0) goods_weight = 0;
832   - //累积商品重量 每种商品的重量 * 数量
833   - goods_weight += item['weight'] * item['buynum'];
  814 + var gd_arr_list = [];
  815 + gd_arr_list.push(good);
  816 + var cut_good_weight = 0;
  817 + for (let i in gd_arr_list) {
  818 + let item = gd_arr_list[i];
834 819  
835   - if (back_data && back_data.is_by_all && !back_data.no_free_goods) {
  820 + if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) {
  821 +
  822 + if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) {
  823 + if (goods_weight < 0) goods_weight = 0;
  824 + goods_weight += item['weight'] * item['buynum'];
836 825 cut_good_weight += item['weight'] * item['buynum'];
837   - if (back_data.weight_free > 0) {
838   - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
839   - }
840 826 }
841   - break;
842   - case 3:
843   - if (goods_piece < 0) goods_piece = 0;
844   - //累积商品数量
845   - goods_piece += item['buynum'];
846   - break;
  827 + if (back_data.weight_free > 0) {
  828 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  829 + }
  830 + continue;
  831 + }
  832 +
  833 + switch (item['exp_sum_type']) {
  834 + case 1:
  835 + //统一运费
  836 + o_shipping_price += item['uniform_exp_sum'];
  837 + break;
  838 + case 2:
  839 + if (goods_weight < 0) goods_weight = 0;
  840 + //累积商品重量 每种商品的重量 * 数量
  841 + goods_weight += item['weight'] * item['buynum'];
  842 +
  843 + if (back_data && back_data.is_by_all && !back_data.no_free_goods) {
  844 + cut_good_weight += item['weight'] * item['buynum'];
  845 + if (back_data.weight_free > 0) {
  846 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  847 + }
  848 + }
  849 + break;
  850 + case 3:
  851 + if (goods_piece < 0) goods_piece = 0;
  852 + //累积商品数量
  853 + goods_piece += item['buynum'];
  854 + break;
  855 + }
847 856 }
848   - }
849 857  
850   - //如果是正值的时候
851   - if (out_of_weight >= 0) out_of_weight = -cut_good_weight;
852   - else out_of_weight = -back_data.weight_free * 1000;
853   -
854   - var code = th.data.wu_arr[th.data.index].code;
855   - var shipping_price = 0;
856   - // ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
857   - // goods_piece, th.data.user_addr, back_data,rs);
858   -
859   - var w_data = {
860   - store_id: os.stoid, code: code,
861   - o_shipping_price: o_shipping_price,
862   - goods_weight: goods_weight,
863   - out_of_weight: out_of_weight, goods_piece: goods_piece,
864   - user_addr_province: th.data.user_addr.province,
865   - user_addr_city: th.data.user_addr.city,
866   - user_addr_district: th.data.user_addr.district,
867   - is_by_all: back_data && back_data.is_by_all ? 1 : 0,
868   - no_free_goods: back_data && back_data.no_free_goods && back_data.no_free_goods.length > 0 ? 1 : 0,
869   - }
  858 + //如果是正值的时候
  859 + if (out_of_weight >= 0) out_of_weight = -cut_good_weight;
  860 + else out_of_weight = -back_data.weight_free * 1000;
  861 +
  862 + var code = th.data.wu_arr[th.data.index].code;
  863 + var shipping_price = 0;
  864 + // ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
  865 + // goods_piece, th.data.user_addr, back_data,rs);
  866 +
  867 + var w_data = {
  868 + store_id: os.stoid, code: code,
  869 + o_shipping_price: o_shipping_price,
  870 + goods_weight: goods_weight,
  871 + out_of_weight: out_of_weight, goods_piece: goods_piece,
  872 + user_addr_province: th.data.user_addr.province,
  873 + user_addr_city: th.data.user_addr.city,
  874 + user_addr_district: th.data.user_addr.district,
  875 + is_by_all: back_data && back_data.is_by_all ? 1 : 0,
  876 + no_free_goods: back_data && back_data.no_free_goods && back_data.no_free_goods.length > 0 ? 1 : 0,
  877 + }
870 878  
871   - var is_ok = 0;
872   - await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', { data: w_data, is_json: 1 }).then(res => {
873   - if (res.data.code == 0) {
874   - shipping_price = res.data.data; is_ok = 1;
  879 + var is_ok = 0;
  880 + await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', { data: w_data, is_json: 1 }).then(res => {
  881 + if (res.data.code == 0) {
  882 + shipping_price = res.data.data; is_ok = 1;
  883 + }
  884 + })
  885 + if (!is_ok) {
  886 + wx.hideLoading();
  887 + wx.showToast({
  888 + title: "计算物流错误", icon: 'none', duration: 2000
  889 + })
  890 + return false;
875 891 }
876   - })
877   - if (!is_ok) {
878   - wx.hideLoading();
879   - wx.showToast({
880   - title: "计算物流错误", icon: 'none', duration: 2000
  892 +
  893 + shipping_price = parseFloat(shipping_price).toFixed(2);
  894 + var wl_txt = "formData.shipping_price";
  895 + th.setData({
  896 + [wl_txt]: shipping_price,
881 897 })
882   - return false;
883 898 }
884 899  
885 900  
886   - shipping_price = parseFloat(shipping_price).toFixed(2);
887   - var wl_txt = "formData.shipping_price";
888   - th.setData({
889   - [wl_txt]: shipping_price,
890   - })
891   -
892 901 } else if (th.data.bn_exp_type == 1) {
893 902 var wl_txt = "formData.shipping_price";
894 903 th.setData({
... ...
packageC/pages/presell/cart/cart2.js
... ... @@ -703,9 +703,6 @@ Page({
703 703 allpice = good.offline_price * good.buynum;
704 704 }
705 705  
706   -
707   -
708   -
709 706 var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
710 707 var out_of_weight = null; //超出多少重量
711 708  
... ... @@ -758,7 +755,7 @@ Page({
758 755 }
759 756  
760 757 //-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮----------
761   - if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && good.is_past != 1) {
  758 + if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_past != 1) {
762 759 //看是不是有调用过包邮券
763 760 if (!th.data.isget_by_quan[th.data.bn_pick] && good.is_xz_yh != 1) {
764 761 var condition = allpice - cut_price - quan_price;
... ... @@ -791,118 +788,127 @@ Page({
791 788 }
792 789  
793 790 var shipping_price =0;
794   - //-- 在没有使用包邮券的时候 --
795   - if(!quan_no || !th.data.using_quan[bn_pick].isby) {
796   -
797   - var gd_arr_list = [];
798   - gd_arr_list.push(good);
799   - if (th.data.buy_now_gift_goods) {
800   - gd_arr_list = [...gd_arr_list, ...th.data.buy_now_gift_goods];
801   - }
  791 + if(good.is_free_shipping == 0 ) {
  792 + //-- 在没有使用包邮券的时候 --
  793 + if (!quan_no || !th.data.using_quan[bn_pick].isby) {
  794 +
  795 + var gd_arr_list = [];
  796 + gd_arr_list.push(good);
  797 + if (th.data.buy_now_gift_goods) {
  798 + gd_arr_list = [...gd_arr_list, ...th.data.buy_now_gift_goods];
  799 + }
802 800  
803   - var user_addr=th.data.user_addr;
804   - var req_d = {
805   - province: user_addr.province, city: user_addr.city, district: user_addr.district,
806   - wuliu: parseFloat(parseFloat(allpice) - cut_price - quan_price).toFixed(2), store_id: os.stoid
807   - }
808   - var back_data = null;
809   -
810   - if(!ord_prom || ord_prom.is_post_temp) {
811   - if (th.data.act.is_post_temp){
812   - await getApp().request.promisePost("/api/weshop/order/areaFreight", {
813   - is_json: 1, data: req_d
814   - }).then(rs => {
815   - if (rs.data.code == 0) back_data = rs.data.data;
816   - });
  801 + var user_addr = th.data.user_addr;
  802 + var req_d = {
  803 + province: user_addr.province,
  804 + city: user_addr.city,
  805 + district: user_addr.district,
  806 + wuliu: parseFloat(parseFloat(allpice) - cut_price - quan_price).toFixed(2),
  807 + store_id: os.stoid
  808 + }
  809 + var back_data = null;
  810 +
  811 + if (!ord_prom || ord_prom.is_post_temp) {
  812 + if (th.data.act.is_post_temp) {
  813 + await getApp().request.promisePost("/api/weshop/order/areaFreight", {
  814 + is_json: 1, data: req_d
  815 + }).then(rs => {
  816 + if (rs.data.code == 0) back_data = rs.data.data;
  817 + });
  818 + }
817 819 }
818   - }
819 820  
820   - var cut_good_weight = 0;
821   - for (let i in gd_arr_list) {
822   - let item = gd_arr_list[i];
823   -
824   - if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) {
  821 + var cut_good_weight = 0;
  822 + for (let i in gd_arr_list) {
  823 + let item = gd_arr_list[i];
825 824  
826   - if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) {
827   - if (goods_weight < 0) goods_weight = 0;
828   - cut_good_weight += item['weight'] * item['buynum'];
829   - goods_weight += item['weight'] * item['buynum'];
  825 + if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) {
830 826  
  827 + if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) {
  828 + if (goods_weight < 0) goods_weight = 0;
  829 + cut_good_weight += item['weight'] * item['buynum'];
  830 + goods_weight += item['weight'] * item['buynum'];
  831 +
  832 + }
  833 + if (back_data.weight_free > 0) {
  834 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  835 + }
  836 + continue;
831 837 }
832   - if (back_data.weight_free > 0) {
833   - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
834   - }
835   - continue;
836   - }
837 838  
838   - switch (item['exp_sum_type']) {
839   - case 1:
840   - //统一运费
841   - o_shipping_price += item['uniform_exp_sum'];
842   - break;
843   - case 2:
844   - if (goods_weight < 0) goods_weight = 0;
845   - //累积商品重量 每种商品的重量 * 数量
846   - goods_weight += item['weight'] * item['buynum'];
847   -
848   - if (back_data && back_data.is_by_all && !back_data.no_free_goods) {
849   - cut_good_weight += item['weight'] * item['buynum'];
850   - if (back_data.weight_free > 0) {
851   - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  839 + switch (item['exp_sum_type']) {
  840 + case 1:
  841 + //统一运费
  842 + o_shipping_price += item['uniform_exp_sum'];
  843 + break;
  844 + case 2:
  845 + if (goods_weight < 0) goods_weight = 0;
  846 + //累积商品重量 每种商品的重量 * 数量
  847 + goods_weight += item['weight'] * item['buynum'];
  848 +
  849 + if (back_data && back_data.is_by_all && !back_data.no_free_goods) {
  850 + cut_good_weight += item['weight'] * item['buynum'];
  851 + if (back_data.weight_free > 0) {
  852 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  853 + }
852 854 }
853   - }
854   - break;
855   - case 3:
856   - if (goods_piece < 0) goods_piece = 0;
857   - //累积商品数量
858   - goods_piece += item['buynum'];
859   - break;
  855 + break;
  856 + case 3:
  857 + if (goods_piece < 0) goods_piece = 0;
  858 + //累积商品数量
  859 + goods_piece += item['buynum'];
  860 + break;
  861 + }
860 862 }
861   - }
862   -
863   - //如果是正值的时候
864   - if (out_of_weight >= 0) out_of_weight = -cut_good_weight;
865   - else out_of_weight = -back_data.weight_free * 1000;
866   -
867   -
868   - var code = "";
869   - if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code;
870   -
871   - //--------------开始计算物流------------------
872   - var shipping_price =0;
873   - // ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
874   - // goods_piece, th.data.user_addr, back_data, rs);
875   - var w_data={
876   - store_id:os.stoid, code:code,
877   - o_shipping_price:o_shipping_price,
878   - goods_weight:goods_weight,
879   - out_of_weight:out_of_weight,goods_piece:goods_piece,
880   - user_addr_province:th.data.user_addr.province,
881   - user_addr_city:th.data.user_addr.city,
882   - user_addr_district:th.data.user_addr.district,
883   - is_by_all:back_data && back_data.is_by_all?1:0,
884   - no_free_goods:back_data && back_data.no_free_goods && back_data.no_free_goods.length>0?1:0,
885   - }
886 863  
887   - var is_ok=0;
888   - await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', {data:w_data,is_json:1}).then(res=>{
889   - if(res.data.code==0){
890   - shipping_price=res.data.data; is_ok=1;
  864 + //如果是正值的时候
  865 + if (out_of_weight >= 0) out_of_weight = -cut_good_weight;
  866 + else out_of_weight = -back_data.weight_free * 1000;
  867 +
  868 +
  869 + var code = "";
  870 + if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code;
  871 +
  872 + //--------------开始计算物流------------------
  873 + var shipping_price = 0;
  874 + // ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
  875 + // goods_piece, th.data.user_addr, back_data, rs);
  876 + var w_data = {
  877 + store_id: os.stoid, code: code,
  878 + o_shipping_price: o_shipping_price,
  879 + goods_weight: goods_weight,
  880 + out_of_weight: out_of_weight, goods_piece: goods_piece,
  881 + user_addr_province: th.data.user_addr.province,
  882 + user_addr_city: th.data.user_addr.city,
  883 + user_addr_district: th.data.user_addr.district,
  884 + is_by_all: back_data && back_data.is_by_all ? 1 : 0,
  885 + no_free_goods: back_data && back_data.no_free_goods && back_data.no_free_goods.length > 0 ? 1 : 0,
891 886 }
892   - })
893   - if(!is_ok){
894   - wx.hideLoading();
895   - wx.showToast({
896   - title: "计算物流错误", icon: 'none',duration: 2000
  887 +
  888 + var is_ok = 0;
  889 + await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', {
  890 + data: w_data,
  891 + is_json: 1
  892 + }).then(res => {
  893 + if (res.data.code == 0) {
  894 + shipping_price = res.data.data;
  895 + is_ok = 1;
  896 + }
897 897 })
898   - //th.setData({ show_submit:0 });
  898 + if (!is_ok) {
  899 + wx.hideLoading();
  900 + wx.showToast({
  901 + title: "计算物流错误", icon: 'none', duration: 2000
  902 + })
  903 + //th.setData({ show_submit:0 });
899 904  
900   - return false;
901   - }
  905 + return false;
  906 + }
902 907  
903 908  
904   - if (shipping_price <= 0) {
905   - th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券
  909 + if (shipping_price <= 0) {
  910 + th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券
  911 + }
906 912 }
907 913 }
908 914  
... ...
packageE/pages/cart/cart2_inte/cart2_inte.js
... ... @@ -679,122 +679,126 @@ Page({
679 679 }
680 680 }
681 681  
682   -
683   -
684 682 //to.getwuliuprice(async function (rs) {
685   -
686 683 var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
687 684 var out_of_weight = null; //超出多少重量
688 685  
689 686 //-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮----------
690   - 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) {
691   -
692   - var user_addr=th.data.user_addr;
693   - var req_d = {
694   - province: user_addr.province, city: user_addr.city, district: user_addr.district,
695   - wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid
696   - }
697   - var back_data = null;
698   - //判断是不是包邮模板,bn_is_post_temp 和 订单优惠的包邮模板一起控制
699   - if (th.data.bn_is_post_temp && (!ord_prom || is_ord_prom_post)) {
700   - await getApp().request.promisePost("/api/weshop/order/areaFreight", {
701   - is_json: 1, data: req_d
702   - }).then(rs => {
703   - if (rs.data.code == 0) back_data = rs.data.data;
704   - });
705   - }
  687 + if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_past != 1 && !th.data.inv_is_post) {
  688 +
  689 + if(good.is_free_shipping){
  690 + var wl_txt = "formData.shipping_price";
  691 + th.setData({ [wl_txt]: 0 })
  692 + }else{
  693 + var user_addr=th.data.user_addr;
  694 + var req_d = {
  695 + province: user_addr.province, city: user_addr.city, district: user_addr.district,
  696 + wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid
  697 + }
  698 + var back_data = null;
  699 + //判断是不是包邮模板,bn_is_post_temp 和 订单优惠的包邮模板一起控制
  700 + if (th.data.bn_is_post_temp && (!ord_prom || is_ord_prom_post)) {
  701 + await getApp().request.promisePost("/api/weshop/order/areaFreight", {
  702 + is_json: 1, data: req_d
  703 + }).then(rs => {
  704 + if (rs.data.code == 0) back_data = rs.data.data;
  705 + });
  706 + }
706 707  
707   - var gd_arr_list = [];
708   - gd_arr_list.push(good);
709   - var cut_good_weight = 0;
710   - for (let i in gd_arr_list) {
711   - let item = gd_arr_list[i];
  708 + var gd_arr_list = [];
  709 + gd_arr_list.push(good);
  710 + var cut_good_weight = 0;
  711 + for (let i in gd_arr_list) {
  712 + let item = gd_arr_list[i];
712 713  
713   - if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1) ) {
  714 + if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1) ) {
714 715  
715   - if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) {
716   - if (goods_weight < 0) goods_weight = 0;
717   - goods_weight += item['weight'] * item['buynum'];
718   - cut_good_weight += item['weight'] * item['buynum'];
719   - }
720   - if (back_data.weight_free > 0) {
721   - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  716 + if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) {
  717 + if (goods_weight < 0) goods_weight = 0;
  718 + goods_weight += item['weight'] * item['buynum'];
  719 + cut_good_weight += item['weight'] * item['buynum'];
  720 + }
  721 + if (back_data.weight_free > 0) {
  722 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  723 + }
  724 + continue;
722 725 }
723   - continue;
724   - }
725   -
726   - switch (item['exp_sum_type']) {
727   - case 1:
728   - //统一运费
729   - o_shipping_price += item['uniform_exp_sum'];
730   - break;
731   - case 2:
732   - if (goods_weight < 0) goods_weight = 0;
733   - //累积商品重量 每种商品的重量 * 数量
734   - goods_weight += item['weight'] * item['buynum'];
735 726  
736   - if (back_data && back_data.is_by_all && !back_data.no_free_goods) {
737   - cut_good_weight += item['weight'] * item['buynum'];
738   - if (back_data.weight_free > 0) {
739   - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  727 + switch (item['exp_sum_type']) {
  728 + case 1:
  729 + //统一运费
  730 + o_shipping_price += item['uniform_exp_sum'];
  731 + break;
  732 + case 2:
  733 + if (goods_weight < 0) goods_weight = 0;
  734 + //累积商品重量 每种商品的重量 * 数量
  735 + goods_weight += item['weight'] * item['buynum'];
  736 +
  737 + if (back_data && back_data.is_by_all && !back_data.no_free_goods) {
  738 + cut_good_weight += item['weight'] * item['buynum'];
  739 + if (back_data.weight_free > 0) {
  740 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  741 + }
740 742 }
741   - }
742   - break;
743   - case 3:
744   - if (goods_piece < 0) goods_piece = 0;
745   - //累积商品数量
746   - goods_piece += item['buynum'];
747   - break;
  743 + break;
  744 + case 3:
  745 + if (goods_piece < 0) goods_piece = 0;
  746 + //累积商品数量
  747 + goods_piece += item['buynum'];
  748 + break;
  749 + }
748 750 }
749   - }
750   -
751   - //如果是正值的时候
752   - if (out_of_weight >= 0) out_of_weight = -cut_good_weight;
753   - else out_of_weight = -back_data.weight_free * 1000;
754   -
755   - var code = "";
756   - if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code;
757   - //--------------开始计算物流------------------
758   - var shipping_price=0;
759   - // var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
760   - // goods_piece, th.data.user_addr, back_data, rs);
761   -
762   - var w_data={
763   - store_id:os.stoid, code:code,
764   - o_shipping_price:o_shipping_price,
765   - goods_weight:goods_weight,
766   - out_of_weight:out_of_weight,goods_piece:goods_piece,
767   - user_addr_province:th.data.user_addr.province,
768   - user_addr_city:th.data.user_addr.city,
769   - user_addr_district:th.data.user_addr.district,
770   - is_by_all:back_data && back_data.is_by_all?1:0,
771   - no_free_goods:back_data && back_data.no_free_goods && back_data.no_free_goods.length>0?1:0,
772   - }
773 751  
774   - var is_ok=0;
775   - await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', {data:w_data,is_json:1}).then(res=>{
776   - if(res.data.code==0){
777   - shipping_price=res.data.data; is_ok=1;
  752 + //如果是正值的时候
  753 + if (out_of_weight >= 0) out_of_weight = -cut_good_weight;
  754 + else out_of_weight = -back_data.weight_free * 1000;
  755 +
  756 + var code = "";
  757 + if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code;
  758 + //--------------开始计算物流------------------
  759 + var shipping_price=0;
  760 + // var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
  761 + // goods_piece, th.data.user_addr, back_data, rs);
  762 +
  763 + var w_data={
  764 + store_id:os.stoid, code:code,
  765 + o_shipping_price:o_shipping_price,
  766 + goods_weight:goods_weight,
  767 + out_of_weight:out_of_weight,goods_piece:goods_piece,
  768 + user_addr_province:th.data.user_addr.province,
  769 + user_addr_city:th.data.user_addr.city,
  770 + user_addr_district:th.data.user_addr.district,
  771 + is_by_all:back_data && back_data.is_by_all?1:0,
  772 + no_free_goods:back_data && back_data.no_free_goods && back_data.no_free_goods.length>0?1:0,
778 773 }
779   - })
780 774  
781   - if(!is_ok){
782   - wx.hideLoading();
783   - wx.showToast({
784   - title: "计算物流错误", icon: 'none',duration: 2000
  775 + var is_ok=0;
  776 + await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', {data:w_data,is_json:1}).then(res=>{
  777 + if(res.data.code==0){
  778 + shipping_price=res.data.data; is_ok=1;
  779 + }
785 780 })
786 781  
787   - return false;
788   - }
  782 + if(!is_ok){
  783 + wx.hideLoading();
  784 + wx.showToast({
  785 + title: "计算物流错误", icon: 'none',duration: 2000
  786 + })
789 787  
  788 + return false;
  789 + }
790 790  
791   - if (shipping_price <= 0) {
792   - th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券
  791 +
  792 + if (shipping_price <= 0) {
  793 + th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券
  794 + }
  795 +
  796 + shipping_price = parseFloat(shipping_price).toFixed(2);
  797 + var wl_txt = "formData.shipping_price";
  798 + th.setData({ [wl_txt]: shipping_price, })
793 799 }
794 800  
795   - shipping_price = parseFloat(shipping_price).toFixed(2);
796   - var wl_txt = "formData.shipping_price";
797   - th.setData({ [wl_txt]: shipping_price, })
  801 +
798 802  
799 803 } else if(th.data.bn_exp_type == 1 ) {
800 804 var wl_txt = "formData.shipping_price";
... ...
pages/cart/cart2_pt/cart2_pt.js
... ... @@ -701,117 +701,121 @@ Page({
701 701 }
702 702  
703 703 //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格----------
704   - 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)) {
705   -
706   - var user_addr = th.data.user_addr;
707   - var req_d = {
708   - province: user_addr.province, city: user_addr.city, district: user_addr.district,
709   - wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid
710   - }
711   - var back_data = null;
712   -
713   - if(!ord_prom || ord_prom.is_post_temp) {
714   - if (th.data.bn_is_post_temp || th.data.bn_goods.is_normal == 1) {
715   - await getApp().request.promisePost("/api/weshop/order/areaFreight", {
716   - is_json: 1, data: req_d
717   - }).then(rs => {
718   - if (rs.data.code == 0) back_data = rs.data.data;
719   - });
720   - }
721   - }
722   -
723   - var gd_arr_list = [];
724   - gd_arr_list.push(good);
725   - var cut_good_weight = 0;
726   - for (let i in gd_arr_list) {
727   - let item = gd_arr_list[i];
  704 + if (th.data.user_addr != null && th.data.bn_exp_type == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) {
  705 +
  706 + if(good.is_free_shipping){
  707 + var wl_txt = "formData.shipping_price";
  708 + th.setData({ [wl_txt]: 0 })
  709 + }else{
  710 + var user_addr = th.data.user_addr;
  711 + var req_d = {
  712 + province: user_addr.province, city: user_addr.city, district: user_addr.district,
  713 + wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid
  714 + }
  715 + var back_data = null;
  716 +
  717 + if(!ord_prom || ord_prom.is_post_temp) {
  718 + if (th.data.bn_is_post_temp || th.data.bn_goods.is_normal == 1) {
  719 + await getApp().request.promisePost("/api/weshop/order/areaFreight", {
  720 + is_json: 1, data: req_d
  721 + }).then(rs => {
  722 + if (rs.data.code == 0) back_data = rs.data.data;
  723 + });
  724 + }
  725 + }
728 726  
729   - if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) {
  727 + var gd_arr_list = [];
  728 + gd_arr_list.push(good);
  729 + var cut_good_weight = 0;
  730 + for (let i in gd_arr_list) {
  731 + let item = gd_arr_list[i];
730 732  
731   - if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) {
732   - if (goods_weight < 0) goods_weight = 0;
733   - cut_good_weight += item['weight'] * item['buynum'];
734   - goods_weight += item['weight'] * item['buynum'];
735   - }
736   - if (back_data.weight_free > 0) {
737   - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
738   - }
739   - continue;
740   - }
  733 + if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) {
741 734  
742   - switch (item['exp_sum_type']) {
743   - case 1:
744   - //统一运费
745   - o_shipping_price += item['uniform_exp_sum'];
746   - break;
747   - case 2:
748   - if (goods_weight < 0) goods_weight = 0;
749   - //累积商品重量 每种商品的重量 * 数量
750   - goods_weight += item['weight'] * item['buynum'];
751   -
752   - if (back_data && back_data.is_by_all && !back_data.no_free_goods) {
753   - cut_good_weight += item['weight'] * item['buynum'];
754   - if (back_data.weight_free > 0) {
755   - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
756   - }
757   - }
758   - break;
759   - case 3:
760   - if (goods_piece < 0) goods_piece = 0;
761   - //累积商品数量
762   - goods_piece += item['buynum'];
763   - break;
764   - }
765   - }
  735 + if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) {
  736 + if (goods_weight < 0) goods_weight = 0;
  737 + cut_good_weight += item['weight'] * item['buynum'];
  738 + goods_weight += item['weight'] * item['buynum'];
  739 + }
  740 + if (back_data.weight_free > 0) {
  741 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  742 + }
  743 + continue;
  744 + }
766 745  
767   - //如果是正值的时候
768   - if (out_of_weight >= 0) out_of_weight = -cut_good_weight;
769   - else out_of_weight = -back_data.weight_free * 1000;
  746 + switch (item['exp_sum_type']) {
  747 + case 1:
  748 + //统一运费
  749 + o_shipping_price += item['uniform_exp_sum'];
  750 + break;
  751 + case 2:
  752 + if (goods_weight < 0) goods_weight = 0;
  753 + //累积商品重量 每种商品的重量 * 数量
  754 + goods_weight += item['weight'] * item['buynum'];
  755 +
  756 + if (back_data && back_data.is_by_all && !back_data.no_free_goods) {
  757 + cut_good_weight += item['weight'] * item['buynum'];
  758 + if (back_data.weight_free > 0) {
  759 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  760 + }
  761 + }
  762 + break;
  763 + case 3:
  764 + if (goods_piece < 0) goods_piece = 0;
  765 + //累积商品数量
  766 + goods_piece += item['buynum'];
  767 + break;
  768 + }
  769 + }
770 770  
  771 + //如果是正值的时候
  772 + if (out_of_weight >= 0) out_of_weight = -cut_good_weight;
  773 + else out_of_weight = -back_data.weight_free * 1000;
771 774  
772   - var code = th.data.wu_arr[th.data.index].code;
773 775  
774   - //--------------开始计算物流------------------
775   - var shipping_price = 0;
776   - // var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
777   - // goods_piece, th.data.user_addr, back_data, rs);
  776 + var code = th.data.wu_arr[th.data.index].code;
778 777  
779   - var w_data = {
780   - store_id: os.stoid, code: code,
781   - o_shipping_price: o_shipping_price,
782   - goods_weight: goods_weight,
783   - out_of_weight: out_of_weight, goods_piece: goods_piece,
784   - user_addr_province: th.data.user_addr.province,
785   - user_addr_city: th.data.user_addr.city,
786   - user_addr_district: th.data.user_addr.district,
787   - is_by_all: back_data && back_data.is_by_all ? 1 : 0,
788   - no_free_goods: back_data && back_data.no_free_goods && back_data.no_free_goods.length > 0 ? 1 : 0,
789   - }
  778 + //--------------开始计算物流------------------
  779 + var shipping_price = 0;
  780 + // var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
  781 + // goods_piece, th.data.user_addr, back_data, rs);
790 782  
791   - var is_ok = 0;
792   - await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', {
793   - data: w_data,
794   - is_json: 1
795   - }).then(res => {
796   - if (res.data.code == 0) {
797   - shipping_price = res.data.data;
798   - is_ok = 1;
799   - }
800   - })
801   - if (!is_ok) {
802   - wx.hideLoading();
803   - wx.showToast({
804   - title: "计算物流错误", icon: 'none', duration: 2000
805   - })
806   - //th.setData({ show_submit:0 });
  783 + var w_data = {
  784 + store_id: os.stoid, code: code,
  785 + o_shipping_price: o_shipping_price,
  786 + goods_weight: goods_weight,
  787 + out_of_weight: out_of_weight, goods_piece: goods_piece,
  788 + user_addr_province: th.data.user_addr.province,
  789 + user_addr_city: th.data.user_addr.city,
  790 + user_addr_district: th.data.user_addr.district,
  791 + is_by_all: back_data && back_data.is_by_all ? 1 : 0,
  792 + no_free_goods: back_data && back_data.no_free_goods && back_data.no_free_goods.length > 0 ? 1 : 0,
  793 + }
807 794  
808   - return false;
809   - }
  795 + var is_ok = 0;
  796 + await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', {
  797 + data: w_data,
  798 + is_json: 1
  799 + }).then(res => {
  800 + if (res.data.code == 0) {
  801 + shipping_price = res.data.data;
  802 + is_ok = 1;
  803 + }
  804 + })
  805 + if (!is_ok) {
  806 + wx.hideLoading();
  807 + wx.showToast({
  808 + title: "计算物流错误", icon: 'none', duration: 2000
  809 + })
  810 + //th.setData({ show_submit:0 });
810 811  
811   - shipping_price = parseFloat(shipping_price).toFixed(2);
812   - var wl_txt = "formData.shipping_price";
813   - th.setData({ [wl_txt]: shipping_price, })
  812 + return false;
  813 + }
814 814  
  815 + shipping_price = parseFloat(shipping_price).toFixed(2);
  816 + var wl_txt = "formData.shipping_price";
  817 + th.setData({ [wl_txt]: shipping_price, })
  818 + }
815 819 } else if (th.data.bn_exp_type == 1) {
816 820 var wl_txt = "formData.shipping_price";
817 821 th.setData({ [wl_txt]: 0, })
... ...