diff --git a/packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart.js b/packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart.js index b72c56d..56db163 100644 --- a/packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart.js +++ b/packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart.js @@ -1891,7 +1891,7 @@ Page({ //有不包邮区域,且不免运费 - if (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice) - cut_price - quan_price) { + if (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice)) { //-----------获取不包邮区域,不包邮商品------- await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", { data: { store_id: os.stoid, id: no_ex_id } 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 f33d5da..579e944 100644 --- a/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js +++ b/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js @@ -577,7 +577,7 @@ Page({ } var shipping_price = th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, th.data.user_addr, freight_free, allpice, rs); + goods_piece, th.data.user_addr, freight_free, allpice, rs,th.data.bn_pick); shipping_price = parseFloat(shipping_price).toFixed(2); var wl_txt = "formData.shipping_price"; @@ -1075,7 +1075,7 @@ Page({ //-------------------计算物流--------------- calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, user_addr, freight_free, o_price, rs) { + goods_piece, user_addr, freight_free, o_price, rs,pickid) { var price = 0, th = this; price += parseFloat(o_shipping_price); diff --git a/packageC/pages/presell/cart/cart.js b/packageC/pages/presell/cart/cart.js index 01e447f..009ab7d 100644 --- a/packageC/pages/presell/cart/cart.js +++ b/packageC/pages/presell/cart/cart.js @@ -1663,7 +1663,7 @@ Page({ var t_shipping_price = this.calculatewuliu(code, gift_shipping_price, goods_weight, out_of_weight, - goods_piece, user_addr, gift_freight_free, allpice, rs,th.data.bn_pick); + goods_piece, user_addr, gift_freight_free, allpice, rs, th.data.bn_pick); return t_shipping_price; }, @@ -1725,14 +1725,25 @@ Page({ good = th.data.goods, quan_price = 0, exp_price = 0; - + var no_ex_id = ee.no_ex_id; var quan_no = null; var bn_pick = th.data.pickup.pickup_id; var allpice = th.data.all_price; var out_of_weight = null; //超出多少重量 var freight_free = ee.freight_free; //全场满多少包邮 var weight_free = ee.weight_free; //多少kg内包邮 - + var no_ex_good = null; + var by_qc = {}; + if (no_ex_id && freight_free > 0) { + //-----------获取不包邮区域,不包邮商品------- + await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", { + data: { store_id: os.stoid, id: no_ex_id } + }).then(res => { + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { + by_qc = res.data.data[0]; + } + }) + }; if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined) quan_no = th.data.using_quan[bn_pick].coupon_no; @@ -1824,9 +1835,38 @@ Page({ } var code = th.data.wu_arr[th.data.index].code; + th.data.is_no_by[th.data.bn_pick] = 0; + var no_by_data = null; + //有不包邮区域,且不免运费 + if (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice)) { + //-----------获取不包邮区域,不包邮商品------- + await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", { + data: { store_id: os.stoid, id: no_ex_id } + }).then(res => { + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { + no_by_data = res.data.data[0]; + //如果有设置不包邮区域的时候 + if (res.data.data[0].region_list) { + if (th.check_by_area(res.data.data[0].region_list)) { + freight_free = 0; + // out_of_weight = 0; + th.data.is_no_by[th.data.bn_pick] = 1; + } + } + //如果有设置不包邮商品 + if (res.data.data[0].goods_list && freight_free) { + if (th.check_by_goods(res.data.data[0].goods_list)) { + freight_free = 0; + // out_of_weight = 0; + th.data.is_no_by[th.data.bn_pick] = 1; + } + } + } + }) + } var shipping_price = th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, th.data.user_addr, freight_free, allpice, rs); + goods_piece, th.data.user_addr, freight_free, allpice, rs,th.data.bn_pick); exp_price = parseFloat(shipping_price).toFixed(2); } th.wuliu_next(allpice, quan_price, exp_price); diff --git a/pages/cart/cart2_pt/cart2_pt.js b/pages/cart/cart2_pt/cart2_pt.js index fd3f517..0995f91 100644 --- a/pages/cart/cart2_pt/cart2_pt.js +++ b/pages/cart/cart2_pt/cart2_pt.js @@ -33,7 +33,7 @@ Page({ couponCode: "",//使用优惠券(多单就用逗号隔开) shipping_price: 0,//物流费用 }, - + is_no_by:{}, /*----------------立即购买---------------------*/ is_b_now: 0, //0是购物车结算 1立即购买 bn_goods: null, //立即购买时候的调用商品 @@ -404,13 +404,26 @@ Page({ console.log(th.data.formData); to.getConfig2(function (ee) { - to.getwuliuprice(function (rs) { + to.getwuliuprice(async function (rs) { console.log('calculatePrice2222'); console.log(rs); var o_shipping_price = 0, goods_weight = -1, goods_piece = -1; var out_of_weight = null; //超出多少重量 var freight_free = ee.freight_free; //全场满多少包邮 var weight_free = ee.weight_free; //多少kg内包邮 + var no_ex_id = ee.no_ex_id; + var no_ex_good = null; + var by_qc = {}; + if (no_ex_id && freight_free > 0) { + //-----------获取不包邮区域,不包邮商品------- + await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", { + data: { store_id: os.stoid, id: no_ex_id } + }).then(res => { + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { + by_qc = res.data.data[0]; + } + }) + }; //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- 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)) { switch (good['exp_sum_type']) { @@ -430,14 +443,42 @@ Page({ //累积商品数量 goods_piece += good['buynum']; break; } - - console.log(o_shipping_price + ":" + goods_weight + ":" + goods_piece); + console.log(th.data.wu_arr); var code = th.data.wu_arr[th.data.index].code; - var freight_free = ee.freight_free; //全场满多少包邮 + th.data.is_no_by[th.data.bn_pick] = 0; + var no_by_data = null; + //--全部金额-- + //有不包邮区域,且不免运费 + if (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice)) { + //-----------获取不包邮区域,不包邮商品------- + await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", { + data: { store_id: os.stoid, id: no_ex_id } + }).then(res => { + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { + no_by_data = res.data.data[0]; + //如果有设置不包邮区域的时候 + if (res.data.data[0].region_list) { + if (th.check_by_area(res.data.data[0].region_list)) { + freight_free = 0; + // out_of_weight = 0; + th.data.is_no_by[th.data.bn_pick] = 1; + } + } + //如果有设置不包邮商品 + if (res.data.data[0].goods_list && freight_free) { + if (th.check_by_goods(res.data.data[0].goods_list)) { + freight_free = 0; + // out_of_weight = 0; + th.data.is_no_by[th.data.bn_pick] = 1; + } + } + } + }) + } var shipping_price = th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, th.data.user_addr, freight_free, allpice, rs); + goods_piece, th.data.user_addr, freight_free, allpice, rs,th.data.bn_pick); shipping_price = parseFloat(shipping_price).toFixed(2); var wl_txt = "formData.shipping_price"; @@ -728,6 +769,39 @@ Page({ url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a) }); }, + //检查区域是不是包邮 + check_area: function (arr) { + var user_addr = this.data.user_addr; + if (!user_addr) return 0; + for (var i in arr) { + var item = arr[i]; + if (user_addr.twon == item || user_addr.district == item + || user_addr.city == item || user_addr.province == item) { + return 0; + } + } + return 1; + }, + + //检查立即购买的商品是不是不包邮 + check_good: function (arr, goods_id) { + if (!goods_id) goods_id = this.data.goods.goods_id; + for (var i in arr) { + var item = arr[i]; + if (goods_id == item) return 0; + } + return 1; + }, + check_by_area: function (region_list) { + var arr = region_list.split(","); + var check = this.check_area(arr); + return !check; + }, + check_by_goods: function (goods_list, goods_id) { + var arr = goods_list.split(","); + var check = this.check_good(arr, goods_id); + return !check; + }, enterAddressPage: function () { getApp().globalData.is_cart_old = 1; this.data.enterAddressPage = !0, wx.navigateTo({ @@ -808,15 +882,15 @@ Page({ } } //------超出重量---------- - if (out_of_weight < 0 && o_price >= freight_free) { + if (out_of_weight < 0 && o_price >= freight_free && !th.data.is_no_by[pickid]) { fw_price = parseFloat(item['money']); var out_of_weight = Math.abs(out_of_weight); if (out_of_weight > item['first_weight']) { - var fw = out_of_weight - item['first_weight']; - var n = Math.ceil(fw / item['second_weight']) - fw_price = fw_price + n * parseFloat(item['add_money']); + var fw = out_of_weight - item['first_weight']; + var n = Math.ceil(fw / item['second_weight']) + fw_price = fw_price + n * parseFloat(item['add_money']); } - } + } //------按件数---------- if (goods_piece > 0) { fp_price = parseFloat(item['piecemoney']); diff --git a/pages/cart/cart_wk/cart_wk.js b/pages/cart/cart_wk/cart_wk.js index c66fbcc..3ac786a 100644 --- a/pages/cart/cart_wk/cart_wk.js +++ b/pages/cart/cart_wk/cart_wk.js @@ -527,7 +527,7 @@ Page({ } var shipping_price = th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, th.data.user_addr, freight_free, allpice, rs); + goods_piece, th.data.user_addr, freight_free, allpice, rs,th.data.bn_pick); var exp_price = parseFloat(shipping_price).toFixed(2); allpice = parseFloat(exp_price) + parseFloat(allpice); allpice = allpice.toFixed(2); @@ -545,7 +545,7 @@ Page({ //----------------计算物流--------------- calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, user_addr, freight_free, o_price, rs) { + goods_piece, user_addr, freight_free, o_price, rs,pickid) { var price = 0, th = this; price += parseFloat(o_shipping_price); //如果是包邮