From 3388c6f268039255235813c10e81ec4abca52dfe Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Fri, 26 May 2023 16:37:30 +0800 Subject: [PATCH] 同城配送在切换的时候,对物流的影响~~ --- packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js | 185 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------- packageC/pages/presell/cart/cart2.js | 208 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------- packageE/pages/cart/cart2_inte/cart2_inte.js | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------- pages/cart/cart2_pt/cart2_pt.js | 202 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------- 4 files changed, 406 insertions(+), 383 deletions(-) diff --git a/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js b/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js index 73e19d9..793680d 100644 --- a/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js +++ b/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js @@ -782,113 +782,122 @@ Page({ //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- - if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && (th.data.kt_type != + if (th.data.user_addr != null && th.data.bn_exp_type == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { - var user_addr = th.data.user_addr; - var req_d = { - province: user_addr.province, city: user_addr.city, district: user_addr.district, - wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid - } - - //-- 判断包邮 -- - var back_data = null; - if(!ord_prom || ord_prom.is_post_temp) { - if (th.data.act.is_post_temp ) { - await getApp().request.promisePost("/api/weshop/order/areaFreight", { - is_json: 1, data: req_d - }).then(rs => { - if (rs.data.code == 0) back_data = rs.data.data; - }); - } - } + if(good.is_free_shipping){ + var wl_txt = "formData.shipping_price"; + th.setData({ + [wl_txt]: 0, + }) - var gd_arr_list = []; - gd_arr_list.push(good); - var cut_good_weight = 0; - for (let i in gd_arr_list) { - let item = gd_arr_list[i]; + }else{ - if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { + var user_addr = th.data.user_addr; + var req_d = { + province: user_addr.province, city: user_addr.city, district: user_addr.district, + wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid + } - if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { - if (goods_weight < 0) goods_weight = 0; - goods_weight += item['weight'] * item['buynum']; - cut_good_weight += item['weight'] * item['buynum']; - } - if (back_data.weight_free > 0) { - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; + //-- 判断包邮 -- + var back_data = null; + if(!ord_prom || ord_prom.is_post_temp) { + if (th.data.act.is_post_temp ) { + await getApp().request.promisePost("/api/weshop/order/areaFreight", { + is_json: 1, data: req_d + }).then(rs => { + if (rs.data.code == 0) back_data = rs.data.data; + }); } - continue; } - switch (item['exp_sum_type']) { - case 1: - //统一运费 - o_shipping_price += item['uniform_exp_sum']; - break; - case 2: - if (goods_weight < 0) goods_weight = 0; - //累积商品重量 每种商品的重量 * 数量 - goods_weight += item['weight'] * item['buynum']; + var gd_arr_list = []; + gd_arr_list.push(good); + var cut_good_weight = 0; + for (let i in gd_arr_list) { + let item = gd_arr_list[i]; - if (back_data && back_data.is_by_all && !back_data.no_free_goods) { + if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { + + if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { + if (goods_weight < 0) goods_weight = 0; + goods_weight += item['weight'] * item['buynum']; cut_good_weight += item['weight'] * item['buynum']; - if (back_data.weight_free > 0) { - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; - } } - break; - case 3: - if (goods_piece < 0) goods_piece = 0; - //累积商品数量 - goods_piece += item['buynum']; - break; + if (back_data.weight_free > 0) { + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; + } + continue; + } + + switch (item['exp_sum_type']) { + case 1: + //统一运费 + o_shipping_price += item['uniform_exp_sum']; + break; + case 2: + if (goods_weight < 0) goods_weight = 0; + //累积商品重量 每种商品的重量 * 数量 + goods_weight += item['weight'] * item['buynum']; + + if (back_data && back_data.is_by_all && !back_data.no_free_goods) { + cut_good_weight += item['weight'] * item['buynum']; + if (back_data.weight_free > 0) { + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; + } + } + break; + case 3: + if (goods_piece < 0) goods_piece = 0; + //累积商品数量 + goods_piece += item['buynum']; + break; + } } - } - //如果是正值的时候 - if (out_of_weight >= 0) out_of_weight = -cut_good_weight; - else out_of_weight = -back_data.weight_free * 1000; - - var code = th.data.wu_arr[th.data.index].code; - var shipping_price = 0; - // ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - // goods_piece, th.data.user_addr, back_data,rs); - - var w_data = { - store_id: os.stoid, code: code, - o_shipping_price: o_shipping_price, - goods_weight: goods_weight, - out_of_weight: out_of_weight, goods_piece: goods_piece, - user_addr_province: th.data.user_addr.province, - user_addr_city: th.data.user_addr.city, - user_addr_district: th.data.user_addr.district, - is_by_all: back_data && back_data.is_by_all ? 1 : 0, - no_free_goods: back_data && back_data.no_free_goods && back_data.no_free_goods.length > 0 ? 1 : 0, - } + //如果是正值的时候 + if (out_of_weight >= 0) out_of_weight = -cut_good_weight; + else out_of_weight = -back_data.weight_free * 1000; + + var code = th.data.wu_arr[th.data.index].code; + var shipping_price = 0; + // ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + // goods_piece, th.data.user_addr, back_data,rs); + + var w_data = { + store_id: os.stoid, code: code, + o_shipping_price: o_shipping_price, + goods_weight: goods_weight, + out_of_weight: out_of_weight, goods_piece: goods_piece, + user_addr_province: th.data.user_addr.province, + user_addr_city: th.data.user_addr.city, + user_addr_district: th.data.user_addr.district, + is_by_all: back_data && back_data.is_by_all ? 1 : 0, + no_free_goods: back_data && back_data.no_free_goods && back_data.no_free_goods.length > 0 ? 1 : 0, + } - var is_ok = 0; - await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', { data: w_data, is_json: 1 }).then(res => { - if (res.data.code == 0) { - shipping_price = res.data.data; is_ok = 1; + var is_ok = 0; + await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', { data: w_data, is_json: 1 }).then(res => { + if (res.data.code == 0) { + shipping_price = res.data.data; is_ok = 1; + } + }) + if (!is_ok) { + wx.hideLoading(); + wx.showToast({ + title: "计算物流错误", icon: 'none', duration: 2000 + }) + return false; } - }) - if (!is_ok) { - wx.hideLoading(); - wx.showToast({ - title: "计算物流错误", icon: 'none', duration: 2000 + + shipping_price = parseFloat(shipping_price).toFixed(2); + var wl_txt = "formData.shipping_price"; + th.setData({ + [wl_txt]: shipping_price, }) - return false; } - shipping_price = parseFloat(shipping_price).toFixed(2); - var wl_txt = "formData.shipping_price"; - th.setData({ - [wl_txt]: shipping_price, - }) - } else if (th.data.bn_exp_type == 1) { var wl_txt = "formData.shipping_price"; th.setData({ diff --git a/packageC/pages/presell/cart/cart2.js b/packageC/pages/presell/cart/cart2.js index 88ccb11..bd07a8e 100644 --- a/packageC/pages/presell/cart/cart2.js +++ b/packageC/pages/presell/cart/cart2.js @@ -703,9 +703,6 @@ Page({ allpice = good.offline_price * good.buynum; } - - - var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; var out_of_weight = null; //超出多少重量 @@ -758,7 +755,7 @@ Page({ } //-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮---------- - if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && good.is_past != 1) { + if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_past != 1) { //看是不是有调用过包邮券 if (!th.data.isget_by_quan[th.data.bn_pick] && good.is_xz_yh != 1) { var condition = allpice - cut_price - quan_price; @@ -791,118 +788,127 @@ Page({ } var shipping_price =0; - //-- 在没有使用包邮券的时候 -- - if(!quan_no || !th.data.using_quan[bn_pick].isby) { - - var gd_arr_list = []; - gd_arr_list.push(good); - if (th.data.buy_now_gift_goods) { - gd_arr_list = [...gd_arr_list, ...th.data.buy_now_gift_goods]; - } + if(good.is_free_shipping == 0 ) { + //-- 在没有使用包邮券的时候 -- + if (!quan_no || !th.data.using_quan[bn_pick].isby) { + + var gd_arr_list = []; + gd_arr_list.push(good); + if (th.data.buy_now_gift_goods) { + gd_arr_list = [...gd_arr_list, ...th.data.buy_now_gift_goods]; + } - var user_addr=th.data.user_addr; - var req_d = { - province: user_addr.province, city: user_addr.city, district: user_addr.district, - wuliu: parseFloat(parseFloat(allpice) - cut_price - quan_price).toFixed(2), store_id: os.stoid - } - var back_data = null; - - if(!ord_prom || ord_prom.is_post_temp) { - if (th.data.act.is_post_temp){ - await getApp().request.promisePost("/api/weshop/order/areaFreight", { - is_json: 1, data: req_d - }).then(rs => { - if (rs.data.code == 0) back_data = rs.data.data; - }); + var user_addr = th.data.user_addr; + var req_d = { + province: user_addr.province, + city: user_addr.city, + district: user_addr.district, + wuliu: parseFloat(parseFloat(allpice) - cut_price - quan_price).toFixed(2), + store_id: os.stoid + } + var back_data = null; + + if (!ord_prom || ord_prom.is_post_temp) { + if (th.data.act.is_post_temp) { + await getApp().request.promisePost("/api/weshop/order/areaFreight", { + is_json: 1, data: req_d + }).then(rs => { + if (rs.data.code == 0) back_data = rs.data.data; + }); + } } - } - var cut_good_weight = 0; - for (let i in gd_arr_list) { - let item = gd_arr_list[i]; - - if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { + var cut_good_weight = 0; + for (let i in gd_arr_list) { + let item = gd_arr_list[i]; - if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { - if (goods_weight < 0) goods_weight = 0; - cut_good_weight += item['weight'] * item['buynum']; - goods_weight += item['weight'] * item['buynum']; + if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { + if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { + if (goods_weight < 0) goods_weight = 0; + cut_good_weight += item['weight'] * item['buynum']; + goods_weight += item['weight'] * item['buynum']; + + } + if (back_data.weight_free > 0) { + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; + } + continue; } - if (back_data.weight_free > 0) { - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; - } - continue; - } - switch (item['exp_sum_type']) { - case 1: - //统一运费 - o_shipping_price += item['uniform_exp_sum']; - break; - case 2: - if (goods_weight < 0) goods_weight = 0; - //累积商品重量 每种商品的重量 * 数量 - goods_weight += item['weight'] * item['buynum']; - - if (back_data && back_data.is_by_all && !back_data.no_free_goods) { - cut_good_weight += item['weight'] * item['buynum']; - if (back_data.weight_free > 0) { - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; + switch (item['exp_sum_type']) { + case 1: + //统一运费 + o_shipping_price += item['uniform_exp_sum']; + break; + case 2: + if (goods_weight < 0) goods_weight = 0; + //累积商品重量 每种商品的重量 * 数量 + goods_weight += item['weight'] * item['buynum']; + + if (back_data && back_data.is_by_all && !back_data.no_free_goods) { + cut_good_weight += item['weight'] * item['buynum']; + if (back_data.weight_free > 0) { + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; + } } - } - break; - case 3: - if (goods_piece < 0) goods_piece = 0; - //累积商品数量 - goods_piece += item['buynum']; - break; + break; + case 3: + if (goods_piece < 0) goods_piece = 0; + //累积商品数量 + goods_piece += item['buynum']; + break; + } } - } - - //如果是正值的时候 - if (out_of_weight >= 0) out_of_weight = -cut_good_weight; - else out_of_weight = -back_data.weight_free * 1000; - - - var code = ""; - if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code; - - //--------------开始计算物流------------------ - var shipping_price =0; - // ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - // goods_piece, th.data.user_addr, back_data, rs); - var w_data={ - store_id:os.stoid, code:code, - o_shipping_price:o_shipping_price, - goods_weight:goods_weight, - out_of_weight:out_of_weight,goods_piece:goods_piece, - user_addr_province:th.data.user_addr.province, - user_addr_city:th.data.user_addr.city, - user_addr_district:th.data.user_addr.district, - is_by_all:back_data && back_data.is_by_all?1:0, - no_free_goods:back_data && back_data.no_free_goods && back_data.no_free_goods.length>0?1:0, - } - var is_ok=0; - await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', {data:w_data,is_json:1}).then(res=>{ - if(res.data.code==0){ - shipping_price=res.data.data; is_ok=1; + //如果是正值的时候 + if (out_of_weight >= 0) out_of_weight = -cut_good_weight; + else out_of_weight = -back_data.weight_free * 1000; + + + var code = ""; + if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code; + + //--------------开始计算物流------------------ + var shipping_price = 0; + // ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + // goods_piece, th.data.user_addr, back_data, rs); + var w_data = { + store_id: os.stoid, code: code, + o_shipping_price: o_shipping_price, + goods_weight: goods_weight, + out_of_weight: out_of_weight, goods_piece: goods_piece, + user_addr_province: th.data.user_addr.province, + user_addr_city: th.data.user_addr.city, + user_addr_district: th.data.user_addr.district, + is_by_all: back_data && back_data.is_by_all ? 1 : 0, + no_free_goods: back_data && back_data.no_free_goods && back_data.no_free_goods.length > 0 ? 1 : 0, } - }) - if(!is_ok){ - wx.hideLoading(); - wx.showToast({ - title: "计算物流错误", icon: 'none',duration: 2000 + + var is_ok = 0; + await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', { + data: w_data, + is_json: 1 + }).then(res => { + if (res.data.code == 0) { + shipping_price = res.data.data; + is_ok = 1; + } }) - //th.setData({ show_submit:0 }); + if (!is_ok) { + wx.hideLoading(); + wx.showToast({ + title: "计算物流错误", icon: 'none', duration: 2000 + }) + //th.setData({ show_submit:0 }); - return false; - } + return false; + } - if (shipping_price <= 0) { - th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券 + if (shipping_price <= 0) { + th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券 + } } } diff --git a/packageE/pages/cart/cart2_inte/cart2_inte.js b/packageE/pages/cart/cart2_inte/cart2_inte.js index 683327e..776e968 100644 --- a/packageE/pages/cart/cart2_inte/cart2_inte.js +++ b/packageE/pages/cart/cart2_inte/cart2_inte.js @@ -679,122 +679,126 @@ Page({ } } - - //to.getwuliuprice(async function (rs) { - var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; var out_of_weight = null; //超出多少重量 //-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮---------- - 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) { - - var user_addr=th.data.user_addr; - var req_d = { - province: user_addr.province, city: user_addr.city, district: user_addr.district, - wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid - } - var back_data = null; - //判断是不是包邮模板,bn_is_post_temp 和 订单优惠的包邮模板一起控制 - if (th.data.bn_is_post_temp && (!ord_prom || is_ord_prom_post)) { - await getApp().request.promisePost("/api/weshop/order/areaFreight", { - is_json: 1, data: req_d - }).then(rs => { - if (rs.data.code == 0) back_data = rs.data.data; - }); - } + if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_past != 1 && !th.data.inv_is_post) { + + if(good.is_free_shipping){ + var wl_txt = "formData.shipping_price"; + th.setData({ [wl_txt]: 0 }) + }else{ + var user_addr=th.data.user_addr; + var req_d = { + province: user_addr.province, city: user_addr.city, district: user_addr.district, + wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid + } + var back_data = null; + //判断是不是包邮模板,bn_is_post_temp 和 订单优惠的包邮模板一起控制 + if (th.data.bn_is_post_temp && (!ord_prom || is_ord_prom_post)) { + await getApp().request.promisePost("/api/weshop/order/areaFreight", { + is_json: 1, data: req_d + }).then(rs => { + if (rs.data.code == 0) back_data = rs.data.data; + }); + } - var gd_arr_list = []; - gd_arr_list.push(good); - var cut_good_weight = 0; - for (let i in gd_arr_list) { - let item = gd_arr_list[i]; + var gd_arr_list = []; + gd_arr_list.push(good); + var cut_good_weight = 0; + for (let i in gd_arr_list) { + let item = gd_arr_list[i]; - if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1) ) { + if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1) ) { - if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { - if (goods_weight < 0) goods_weight = 0; - goods_weight += item['weight'] * item['buynum']; - cut_good_weight += item['weight'] * item['buynum']; - } - if (back_data.weight_free > 0) { - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; + if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { + if (goods_weight < 0) goods_weight = 0; + goods_weight += item['weight'] * item['buynum']; + cut_good_weight += item['weight'] * item['buynum']; + } + if (back_data.weight_free > 0) { + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; + } + continue; } - continue; - } - - switch (item['exp_sum_type']) { - case 1: - //统一运费 - o_shipping_price += item['uniform_exp_sum']; - break; - case 2: - if (goods_weight < 0) goods_weight = 0; - //累积商品重量 每种商品的重量 * 数量 - goods_weight += item['weight'] * item['buynum']; - if (back_data && back_data.is_by_all && !back_data.no_free_goods) { - cut_good_weight += item['weight'] * item['buynum']; - if (back_data.weight_free > 0) { - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; + switch (item['exp_sum_type']) { + case 1: + //统一运费 + o_shipping_price += item['uniform_exp_sum']; + break; + case 2: + if (goods_weight < 0) goods_weight = 0; + //累积商品重量 每种商品的重量 * 数量 + goods_weight += item['weight'] * item['buynum']; + + if (back_data && back_data.is_by_all && !back_data.no_free_goods) { + cut_good_weight += item['weight'] * item['buynum']; + if (back_data.weight_free > 0) { + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; + } } - } - break; - case 3: - if (goods_piece < 0) goods_piece = 0; - //累积商品数量 - goods_piece += item['buynum']; - break; + break; + case 3: + if (goods_piece < 0) goods_piece = 0; + //累积商品数量 + goods_piece += item['buynum']; + break; + } } - } - - //如果是正值的时候 - if (out_of_weight >= 0) out_of_weight = -cut_good_weight; - else out_of_weight = -back_data.weight_free * 1000; - - var code = ""; - if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code; - //--------------开始计算物流------------------ - var shipping_price=0; - // var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - // goods_piece, th.data.user_addr, back_data, rs); - - var w_data={ - store_id:os.stoid, code:code, - o_shipping_price:o_shipping_price, - goods_weight:goods_weight, - out_of_weight:out_of_weight,goods_piece:goods_piece, - user_addr_province:th.data.user_addr.province, - user_addr_city:th.data.user_addr.city, - user_addr_district:th.data.user_addr.district, - is_by_all:back_data && back_data.is_by_all?1:0, - no_free_goods:back_data && back_data.no_free_goods && back_data.no_free_goods.length>0?1:0, - } - var is_ok=0; - await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', {data:w_data,is_json:1}).then(res=>{ - if(res.data.code==0){ - shipping_price=res.data.data; is_ok=1; + //如果是正值的时候 + if (out_of_weight >= 0) out_of_weight = -cut_good_weight; + else out_of_weight = -back_data.weight_free * 1000; + + var code = ""; + if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code; + //--------------开始计算物流------------------ + var shipping_price=0; + // var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + // goods_piece, th.data.user_addr, back_data, rs); + + var w_data={ + store_id:os.stoid, code:code, + o_shipping_price:o_shipping_price, + goods_weight:goods_weight, + out_of_weight:out_of_weight,goods_piece:goods_piece, + user_addr_province:th.data.user_addr.province, + user_addr_city:th.data.user_addr.city, + user_addr_district:th.data.user_addr.district, + is_by_all:back_data && back_data.is_by_all?1:0, + no_free_goods:back_data && back_data.no_free_goods && back_data.no_free_goods.length>0?1:0, } - }) - if(!is_ok){ - wx.hideLoading(); - wx.showToast({ - title: "计算物流错误", icon: 'none',duration: 2000 + var is_ok=0; + await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', {data:w_data,is_json:1}).then(res=>{ + if(res.data.code==0){ + shipping_price=res.data.data; is_ok=1; + } }) - return false; - } + if(!is_ok){ + wx.hideLoading(); + wx.showToast({ + title: "计算物流错误", icon: 'none',duration: 2000 + }) + return false; + } - if (shipping_price <= 0) { - th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券 + + if (shipping_price <= 0) { + th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券 + } + + shipping_price = parseFloat(shipping_price).toFixed(2); + var wl_txt = "formData.shipping_price"; + th.setData({ [wl_txt]: shipping_price, }) } - shipping_price = parseFloat(shipping_price).toFixed(2); - var wl_txt = "formData.shipping_price"; - th.setData({ [wl_txt]: shipping_price, }) + } else if(th.data.bn_exp_type == 1 ) { var wl_txt = "formData.shipping_price"; diff --git a/pages/cart/cart2_pt/cart2_pt.js b/pages/cart/cart2_pt/cart2_pt.js index cbc7a44..bb906d7 100644 --- a/pages/cart/cart2_pt/cart2_pt.js +++ b/pages/cart/cart2_pt/cart2_pt.js @@ -701,117 +701,121 @@ Page({ } //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- - 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)) { - - var user_addr = th.data.user_addr; - var req_d = { - province: user_addr.province, city: user_addr.city, district: user_addr.district, - wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid - } - var back_data = null; - - if(!ord_prom || ord_prom.is_post_temp) { - if (th.data.bn_is_post_temp || th.data.bn_goods.is_normal == 1) { - await getApp().request.promisePost("/api/weshop/order/areaFreight", { - is_json: 1, data: req_d - }).then(rs => { - if (rs.data.code == 0) back_data = rs.data.data; - }); - } - } - - var gd_arr_list = []; - gd_arr_list.push(good); - var cut_good_weight = 0; - for (let i in gd_arr_list) { - let item = gd_arr_list[i]; + if (th.data.user_addr != null && th.data.bn_exp_type == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { + + if(good.is_free_shipping){ + var wl_txt = "formData.shipping_price"; + th.setData({ [wl_txt]: 0 }) + }else{ + var user_addr = th.data.user_addr; + var req_d = { + province: user_addr.province, city: user_addr.city, district: user_addr.district, + wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid + } + var back_data = null; + + if(!ord_prom || ord_prom.is_post_temp) { + if (th.data.bn_is_post_temp || th.data.bn_goods.is_normal == 1) { + await getApp().request.promisePost("/api/weshop/order/areaFreight", { + is_json: 1, data: req_d + }).then(rs => { + if (rs.data.code == 0) back_data = rs.data.data; + }); + } + } - if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { + var gd_arr_list = []; + gd_arr_list.push(good); + var cut_good_weight = 0; + for (let i in gd_arr_list) { + let item = gd_arr_list[i]; - if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { - if (goods_weight < 0) goods_weight = 0; - cut_good_weight += item['weight'] * item['buynum']; - goods_weight += item['weight'] * item['buynum']; - } - if (back_data.weight_free > 0) { - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; - } - continue; - } + if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { - switch (item['exp_sum_type']) { - case 1: - //统一运费 - o_shipping_price += item['uniform_exp_sum']; - break; - case 2: - if (goods_weight < 0) goods_weight = 0; - //累积商品重量 每种商品的重量 * 数量 - goods_weight += item['weight'] * item['buynum']; - - if (back_data && back_data.is_by_all && !back_data.no_free_goods) { - cut_good_weight += item['weight'] * item['buynum']; - if (back_data.weight_free > 0) { - out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; - } - } - break; - case 3: - if (goods_piece < 0) goods_piece = 0; - //累积商品数量 - goods_piece += item['buynum']; - break; - } - } + if (item['exp_sum_type'] == 2 && back_data.weight_free > 0) { + if (goods_weight < 0) goods_weight = 0; + cut_good_weight += item['weight'] * item['buynum']; + goods_weight += item['weight'] * item['buynum']; + } + if (back_data.weight_free > 0) { + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; + } + continue; + } - //如果是正值的时候 - if (out_of_weight >= 0) out_of_weight = -cut_good_weight; - else out_of_weight = -back_data.weight_free * 1000; + switch (item['exp_sum_type']) { + case 1: + //统一运费 + o_shipping_price += item['uniform_exp_sum']; + break; + case 2: + if (goods_weight < 0) goods_weight = 0; + //累积商品重量 每种商品的重量 * 数量 + goods_weight += item['weight'] * item['buynum']; + + if (back_data && back_data.is_by_all && !back_data.no_free_goods) { + cut_good_weight += item['weight'] * item['buynum']; + if (back_data.weight_free > 0) { + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; + } + } + break; + case 3: + if (goods_piece < 0) goods_piece = 0; + //累积商品数量 + goods_piece += item['buynum']; + break; + } + } + //如果是正值的时候 + if (out_of_weight >= 0) out_of_weight = -cut_good_weight; + else out_of_weight = -back_data.weight_free * 1000; - var code = th.data.wu_arr[th.data.index].code; - //--------------开始计算物流------------------ - var shipping_price = 0; - // var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - // goods_piece, th.data.user_addr, back_data, rs); + var code = th.data.wu_arr[th.data.index].code; - var w_data = { - store_id: os.stoid, code: code, - o_shipping_price: o_shipping_price, - goods_weight: goods_weight, - out_of_weight: out_of_weight, goods_piece: goods_piece, - user_addr_province: th.data.user_addr.province, - user_addr_city: th.data.user_addr.city, - user_addr_district: th.data.user_addr.district, - is_by_all: back_data && back_data.is_by_all ? 1 : 0, - no_free_goods: back_data && back_data.no_free_goods && back_data.no_free_goods.length > 0 ? 1 : 0, - } + //--------------开始计算物流------------------ + var shipping_price = 0; + // var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + // goods_piece, th.data.user_addr, back_data, rs); - var is_ok = 0; - await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', { - data: w_data, - is_json: 1 - }).then(res => { - if (res.data.code == 0) { - shipping_price = res.data.data; - is_ok = 1; - } - }) - if (!is_ok) { - wx.hideLoading(); - wx.showToast({ - title: "计算物流错误", icon: 'none', duration: 2000 - }) - //th.setData({ show_submit:0 }); + var w_data = { + store_id: os.stoid, code: code, + o_shipping_price: o_shipping_price, + goods_weight: goods_weight, + out_of_weight: out_of_weight, goods_piece: goods_piece, + user_addr_province: th.data.user_addr.province, + user_addr_city: th.data.user_addr.city, + user_addr_district: th.data.user_addr.district, + is_by_all: back_data && back_data.is_by_all ? 1 : 0, + no_free_goods: back_data && back_data.no_free_goods && back_data.no_free_goods.length > 0 ? 1 : 0, + } - return false; - } + var is_ok = 0; + await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', { + data: w_data, + is_json: 1 + }).then(res => { + if (res.data.code == 0) { + shipping_price = res.data.data; + is_ok = 1; + } + }) + if (!is_ok) { + wx.hideLoading(); + wx.showToast({ + title: "计算物流错误", icon: 'none', duration: 2000 + }) + //th.setData({ show_submit:0 }); - shipping_price = parseFloat(shipping_price).toFixed(2); - var wl_txt = "formData.shipping_price"; - th.setData({ [wl_txt]: shipping_price, }) + return false; + } + shipping_price = parseFloat(shipping_price).toFixed(2); + var wl_txt = "formData.shipping_price"; + th.setData({ [wl_txt]: shipping_price, }) + } } else if (th.data.bn_exp_type == 1) { var wl_txt = "formData.shipping_price"; th.setData({ [wl_txt]: 0, }) -- libgit2 0.21.4