diff --git a/packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart.js b/packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart.js index 7d12053..b72c56d 100644 --- a/packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart.js +++ b/packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart.js @@ -1548,7 +1548,7 @@ Page({ //统一运费 o_shipping_price += item[j]['uniform_exp_sum']; break; - // case 2: //1464行已计算 不必重复计算 注释为:判断是否有设置限制重量包邮 + // case 2: // +'' // if (goods_weight < 0) goods_weight = 0; // //累积商品重量 每种商品的重量 * 数量 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 e4222b5..f33d5da 100644 --- a/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js +++ b/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js @@ -31,6 +31,7 @@ Page({ firstEnter: !0, //页面获取的参数 param: null, + is_no_by: {}, postdata: null, //提交订单的格式 formData: { @@ -73,62 +74,62 @@ Page({ card_name: '', //显示的卡的名称 card_cut_price: null, //减价多少钱 }, - - onLoad: function(t) { - + + onLoad: function (t) { + // console.log('收到的传参', t); wx.setNavigationBarTitle({ - title: '填写订单', + title: '填写订单', }); self = this; this.setData({ is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow, param: t, }); - + var appD = getApp().get_b_now(); this.data.postdata = appD; - - + + // 获取幸运购活动团team_id this.get_teamId({ store_id: oo.stoid, user_id: getApp().globalData.user_id, aid: t.group_id, }); - - - - + + + + //如果期号有值01 // if (appD.qh) { // th.data.qh = appD.qh; // th.data.pt_listno = appD.qh; // } - - + + this.setData({//01 // kt_type: appD.kt_type }); - + // 01 // if (appD.is_pt_tz) th.data.is_pt_tz = appD.is_pt_tz; - + //先获取物流,再获取用户信息,再展示页面 // this.get_wuliu(th.get_info(th.show_page)); }, - - onUnload: function() { + + onUnload: function () { this.setData({ isclose: 1 }) }, //------获取会员信息-----先获取用户信息,在进行下一步--- - get_info: function(func) { + get_info: function (func) { var user_id = t.globalData.user_id; to.auth.get_u(func); }, @@ -137,7 +138,7 @@ Page({ get_wuliu(func) { var th = this; // console.log("getwuliu4545"); - to.getwuliu(function(e) { + to.getwuliu(function (e) { if (th.data.is_default_logistics) { //如果第一个不是开启默认,说明要让用户自己选 if (!e[0].is_default) { @@ -154,7 +155,7 @@ Page({ }, //------获取会员收货地址----- - getuser_addr: function(func) { + getuser_addr: function (func) { if (to.globalData.baddr != null) { var user_addr = to.globalData.baddr; to.globalData.baddr = null; @@ -166,7 +167,7 @@ Page({ store_id: oo.stoid, pageSize: 600 }, - success: function(su) { + success: function (su) { var user_addr = su.data.data.pageData; var item = null; @@ -188,7 +189,7 @@ Page({ } }, //----------------展示页面,是再获取用户信息之后-------------- - show_page: function() { + show_page: function () { var th = this; //th.setData({ userinfo: to.globalData.userInfo}); 会员信息要时时获取 var user = getApp().globalData.userInfo; @@ -196,7 +197,7 @@ Page({ data: { r: Math.random() }, - success: function(e) { + success: function (e) { getApp().globalData.userInfo = e.data.data; th.setData({ @@ -212,11 +213,11 @@ Page({ store_id: oo.stoid, status: 0 }, - success: function(su) { + success: function (su) { if (su.data.code == 0) { var yuer = parseFloat(th.data.userinfo.user_money - (th.data.userinfo.frozen_money > 0 ? th.data.userinfo.frozen_money : 0) - su.data.data.summoney).toFixed( - 2); + 2); if (yuer < 0) yuer = 0; th.setData({ txmon: su.data.data.summoney, @@ -230,13 +231,13 @@ Page({ }, //-----获取立即购买的商品信息---- - get_buy_goods: function() { + get_buy_goods: function () { var th = this, a = getApp().request; var gg = th.data.postdata; //调用商品 a.get("/api/weshop/goods/get/" + oo.stoid + "/" + gg.goods_id, { - success: function(t) { + success: function (t) { var gd = t.data.data; if (!gd) return false; @@ -313,12 +314,12 @@ Page({ th.calculatePrice2(); } - + else { //01 //--阶梯团很特殊,不能用总表来拿价格-- getApp().request.get("/api/weshop/teamlist/get/" + oo.stoid + "/" + gd.prom_id, { - success: function(tt) { + success: function (tt) { if (tt.data.code == 0) { var pt_data = tt.data.data; @@ -363,13 +364,13 @@ Page({ } }); } - + } }); }, //----------子页返回父页触发---------- - onShow: function() { + onShow: function () { var th = this; if (th.data.isclose == 0) { @@ -377,7 +378,7 @@ Page({ url: "/pages/index/index/index" }) } else { - this.getuser_addr(function(ie) { + this.getuser_addr(function (ie) { //更换地址回来要重新调用计算价钱的接口 th.setData({ user_addr: ie @@ -399,7 +400,7 @@ Page({ //先获取是否有关闭使用优惠券 - getApp().getConfig2(function(ee) { + getApp().getConfig2(function (ee) { var json_d = JSON.parse(ee.switch_list); th.data.json_d = json_d; th.data.ispt_goods = json_d.ispt_goods; //是不是平摊到单品的控制参数赋值 @@ -460,40 +461,40 @@ Page({ }, //---------------检查是否有收货地址------------------- - checkAddressList: function() { + checkAddressList: function () { var t = this; return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({ title: "请先填写或选择收货地址~", - success: function(a) { + success: function (a) { a.confirm ? t.enterAddressPage() : wx.navigateBack(); }, - fail: function() { + fail: function () { wx.navigateBack(); } }), !1); }, - showInvoice: function() { + showInvoice: function () { this.setData({ invoiceToggle: !this.data.invoiceToggle }); }, - keyUpChangePay1: function(t) { + keyUpChangePay1: function (t) { this.setData({ payWithUserMoney: !(t.detail.value.length > 0) }); }, - keyUpChangePay2: function(t) { + keyUpChangePay2: function (t) { this.setData({ payWithPoints: !(t.detail.value.length > 0) }); }, - keyUpChangeNum: function(t) { + keyUpChangeNum: function (t) { this.setData({ maxWord: t.detail.value.length }); }, //---------计算立即购买---------- - calculatePrice2: function() { + calculatePrice2: function () { console.log('calculatePrice2'); var th = this, good = this.data.bn_goods; @@ -506,20 +507,20 @@ Page({ }); console.log(th.data.formData); - to.getConfig2(function(ee) { - to.getwuliuprice(function(rs) { + to.getConfig2(function (ee) { + 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 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; //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- 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)) { + 3 || th.data.bn_goods.is_normal == 1)) { switch (good['exp_sum_type']) { case 1: //统一运费 @@ -529,9 +530,9 @@ Page({ if (goods_weight < 0) goods_weight = 0; //累积商品重量 每种商品的重量 * 数量 goods_weight += good['weight'] * good['buynum']; - if(weight_free > 0){ - out_of_weight = (weight_free * 1000 ) - goods_weight; - } + if (weight_free > 0) { + out_of_weight = (weight_free * 1000) - goods_weight; + } break; case 3: if (goods_piece < 0) goods_piece = 0; @@ -542,10 +543,40 @@ Page({ console.log(o_shipping_price + ":" + goods_weight + ":" + goods_piece); console.log(th.data.wu_arr); + th.data.is_no_by[th.data.bn_pick] = 0; + var no_by_data = null; var code = th.data.wu_arr[th.data.index].code; var freight_free = ee.freight_free; //全场满多少包邮 + + //有不包邮区域,且不免运费 + 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, + th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, goods_piece, th.data.user_addr, freight_free, allpice, rs); shipping_price = parseFloat(shipping_price).toFixed(2); @@ -604,7 +635,7 @@ Page({ // 提交订单前弹出确认对话框 submitConfirm(e) { // is_show为0不显示温馨提示,为1显示温馨提示 - if(this.data.param.is_show == 1) { + if (this.data.param.is_show == 1) { wx.showModal({ title: '温馨提示', content: this.data.param.alert, @@ -620,12 +651,12 @@ Page({ } else { this.submitForm(e); }; - + }, //--------------------提交订单----------------------- - submitForm: async function(t) { + submitForm: async function (t) { if (this.data.is_summit_ing == 1) return false; //--提交中退出-- this.data.is_summit_ing = 1; @@ -637,7 +668,7 @@ Page({ //如果不是阶梯团,或者是普通购买,商家选择了物流,以及地址为空的时候 if (th.data.bn_exp_type == 0 && th.data.user_addr == null && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == - 1)) { + 1)) { ff = false; getApp().my_warnning("请选择收货地址", 0, this); this.data.is_summit_ing = 0; @@ -703,8 +734,8 @@ Page({ // if (!th.data.bn_goods.is_normal) { // item.is_zsorder = th.data.kt_type + 1; //开团类型 01 // } - - + + //老会员成为分销下线需要的参数 if (getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader) { //判断一下分享人是不是分享商 @@ -723,7 +754,7 @@ Page({ item.team_qh = th.data.qh; item.pt_listno = th.data.qh; } - + var gg = to.get_b_now(); var goods = { @@ -784,7 +815,7 @@ Page({ header: { 'content-type': 'application/json' }, // 设置请求的 header - success: function(res) { + success: function (res) { wx.hideLoading(); if (res.statusCode == 200) { @@ -801,7 +832,7 @@ Page({ } } var order_amount = 0; - pdata.forEach(function(em, ind) { + pdata.forEach(function (em, ind) { order_amount += em.order_amount; }) //要进行判断,如果是用微信支付,就要跳转到支付界面 @@ -813,23 +844,23 @@ Page({ // order_sn: data.data, // type:1, // }, 1); - util_pay.pay(data.data, function() { - setTimeout(function() { + util_pay.pay(data.data, function () { + setTimeout(function () { // wx.reLaunch({ // //url: "/pages/payment/pay_success/pay_success?type=1&order_sn="+data.data, // url: "/pages/team/team_success/team_success?ordersn=" + data.data, // }) - + wx.redirectTo({ url: "/packageC/pages/luckyGo/luckyGo_details/luckyGo_details?type=1&ordersn=" + data.data + "&group_id=" + th.data.param.group_id + "&goods_id=" + th.data.param.goods_id + "&goods_name=" + th.data.bn_goods.goods_name, }); - + }, 1000) - }, function() { + }, function () { //支付失败 - setTimeout(function() { + setTimeout(function () { //wx.navigateBack({ delta: 1 }) wx.reLaunch({ url: "/pages/user/order_list/order_list", @@ -851,7 +882,7 @@ Page({ //return false; getApp().request.post("/api/weshop/order/pay/createOrder", { data: dd, - success: function(t) { + success: function (t) { // console.log(t); // app.my_warnning("支付成功",1,th); wx.hideLoading(); @@ -866,9 +897,9 @@ Page({ title: '支付成功', icon: 'success', duration: 2000, - success: function() { + success: function () { // 幸运购 - setTimeout(function() { + setTimeout(function () { wx.redirectTo({ url: "/packageC/pages/luckyGo/luckyGo_details/luckyGo_details?type=1&ordersn=" + data.data + "&group_id=" + th.data.param.group_id + "&goods_id=" + th.data.param.goods_id + @@ -905,12 +936,12 @@ Page({ title: t.data.msg, icon: 'none', duration: 2000, - success: function() { + success: function () { // wx.reLaunch({ // url: "/pages/user/order_list/order_list", // }) - + }, }) }; @@ -928,20 +959,20 @@ Page({ console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode); } }, - fail: function() { + fail: function () { th.data.is_summit_ing = 0; //是否提交中 wx.hideLoading(); console.log("index.js wx.request CheckCallUser fail"); }, - complete: function() {} + complete: function () { } }) }, - - - - - - useCoupon: function() { + + + + + + useCoupon: function () { if (this.data.order.couponNum <= 0) { //return t.showWarning("无可用优惠券"); getApp().my_warnning("无可用优惠券", 0, this); @@ -954,11 +985,11 @@ Page({ url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a) }); }, - - - - - enterAddressPage: function() { + + + + + enterAddressPage: function () { getApp().globalData.is_cart_old = 1; this.data.enterAddressPage = !0, wx.navigateTo({ url: "/pages/user/address_list/address_list" @@ -969,7 +1000,7 @@ Page({ //--------立即购买时,选择自提和物流----------- - setexptype_w: function(t) { + setexptype_w: function (t) { var th = this; var ty = t.currentTarget.dataset.t, txt = t.currentTarget.dataset.txt; @@ -1001,7 +1032,7 @@ Page({ //--------立即购买时,选择自提和物流---------- - setexptype: function(t) { + setexptype: function (t) { var th = this; var ty = t.currentTarget.dataset.t; th.setData({ @@ -1019,19 +1050,19 @@ Page({ //--------立即购买时,使用余额-------- - set_bn_useyuer: function() { + set_bn_useyuer: function () { var th = this; th.setData({ bn_use_money: !th.data.bn_use_money }); th.calculatePrice2(); }, - - - - - - set_js_useyuer: function() { + + + + + + set_js_useyuer: function () { var th = this; th.setData({ js_use_money: !th.data.js_use_money @@ -1043,7 +1074,7 @@ Page({ //-------------------计算物流--------------- - calculatewuliu: function(code, o_shipping_price, goods_weight, + calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, goods_piece, user_addr, freight_free, o_price, rs) { var price = 0, th = this; @@ -1077,15 +1108,15 @@ Page({ } } //------超出重量---------- - if(out_of_weight < 0 && o_price >= freight_free){ - 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']); - } - } + 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']); + } + } //------按件数---------- if (goods_piece > 0) { fp_price = parseFloat(item['piecemoney']); @@ -1102,7 +1133,7 @@ Page({ //------------循环获取config----------- - get_wuliu_config: function(region_id, code, rs) { + get_wuliu_config: function (region_id, code, rs) { var item = null, rslist = rs.pageData; for (var i = 0; i < rslist.length; i++) { @@ -1112,12 +1143,42 @@ Page({ } return item; }, - - - - + //检查立即购买的商品是不是不包邮 + check_good: function (arr, goods_id) { + if (!goods_id) goods_id = this.data.bn_goods.goods_id; + for (var i in arr) { + var item = arr[i]; + if (goods_id == item) return 0; + } + return 1; + }, + check_by_goods: function (goods_list, goods_id) { + var arr = goods_list.split(","); + var check = this.check_good(arr, goods_id); + return !check; + }, + + check_by_area: function (region_list) { + var arr = region_list.split(","); + var check = this.check_area(arr); + return !check; + }, + //检查区域是不是包邮 + 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; + }, + //-------循环获取config,code default------- - get_wuliu_default: function(code, rs) { + get_wuliu_default: function (code, rs) { var item = null, rslist = rs.pageData; for (var i = 0; i < rslist.length; i++) { @@ -1134,7 +1195,7 @@ Page({ //----------立即购买,选择物流------------- - bindPickerChange: function(e) { + bindPickerChange: function (e) { var ind = e.detail.value this.setData({ index: ind @@ -1159,24 +1220,24 @@ Page({ - cart_set_err: function(e) { + cart_set_err: function (e) { var txt = e.currentTarget.dataset.err; var ob = {}; ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif"; this.setData(ob); }, - - - + + + // 开启物流的弹窗 - show_wu_arr: function(e) { + show_wu_arr: function (e) { this.setData({ open_express: 1 }); }, - - + + //更新下默认,在onshow里面 update_code() { @@ -1184,7 +1245,7 @@ Page({ m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code; - var uii = setInterval(function() { + var uii = setInterval(function () { if (th.data.wu_arr) { clearInterval(uii); for (var k = 0; k < th.data.wu_arr.length; k++) { @@ -1201,21 +1262,21 @@ Page({ } }, 500) }, - - + + // 关闭物流的弹窗 - close_express: function() { + close_express: function () { this.setData({ open_express: 0 }); }, - - - - + + + + // 选择物流 - click_express_name: function(e) { + click_express_name: function (e) { var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode; var index = e.currentTarget.dataset.idxe; @@ -1231,18 +1292,18 @@ Page({ //点击确定物流 - determine_expres: function(e) { + determine_expres: function (e) { this.setData({ open_express: 0 }); this.calculatePrice2(); }, - - - - + + + + //设置默认物流 - select_default_logistics: function() { + select_default_logistics: function () { var th = this; var is_shipping_code = this.data.is_shipping_code getApp().request.put("/api/weshop/users/update", { @@ -1251,7 +1312,7 @@ Page({ store_id: oo.stoid, def_exp_code: is_shipping_code }, - success: function(rse) { + success: function (rse) { if (rse.data.code == 0) { getApp().globalData.userInfo.def_exp_code = is_shipping_code; th.setData({ @@ -1270,12 +1331,12 @@ Page({ //跳转到购买卡 - buycard: function() { + buycard: function () { getApp().goto("/pages/user/plus/plus"); getApp().globalData.plus_buy_back = 1; }, - - + + // 获取team_id get_teamId(options) { let aid = options.aid; @@ -1283,8 +1344,8 @@ Page({ let user_id = options.user_id; let url = `/api/weshop/prom/luckyActivity/page?store_id=${store_id}&is_end=0&timetype=1&id=${aid}`; getApp().request.get(url, { - success: function(res) { - if(res.data.code == 0) { + success: function (res) { + if (res.data.code == 0) { let team_id = res.data.data.pageData[0]['team_id']; wx.setStorage({ key: 'team_id', @@ -1294,10 +1355,10 @@ Page({ } }); }, - - - - - - + + + + + + }); diff --git a/packageC/pages/presell/cart/cart.js b/packageC/pages/presell/cart/cart.js index 3496e3a..01e447f 100644 --- a/packageC/pages/presell/cart/cart.js +++ b/packageC/pages/presell/cart/cart.js @@ -1648,7 +1648,7 @@ Page({ if (no_by_data && no_by_data.region_list) { if (th.check_by_area(no_by_data.region_list)) { gift_freight_free = 0; - out_of_weight = 0; + // out_of_weight = 0; th.data.is_no_by[bn_pick] = 1; } } @@ -1656,7 +1656,7 @@ Page({ if (no_by_data && no_by_data.goods_list && gift_freight_free) { if (th.check_by_goods(no_by_data.goods_list, good.goods_id)) { gift_freight_free = 0; - out_of_weight = 0; + // out_of_weight = 0; th.data.is_no_by[bn_pick] = 1; } } diff --git a/pages/cart/cart_wk/cart_wk.js b/pages/cart/cart_wk/cart_wk.js index ae5f3ee..c66fbcc 100644 --- a/pages/cart/cart_wk/cart_wk.js +++ b/pages/cart/cart_wk/cart_wk.js @@ -1,6 +1,7 @@ // pages/cart/cart_wk/cart_wk.js var t = getApp(), - oo = t.globalData.setting; + oo = t.globalData.setting, + os=oo; var regeneratorRuntime = require('../../../utils/runtime.js'); Page({ @@ -19,7 +20,7 @@ Page({ /*----------物流选择--------*/ wu_arr: null, index: 0, - is_express:0, + is_express: 0, //申请提现的金额 txmon: 0, yuer: 0, @@ -33,7 +34,7 @@ Page({ //------物流费用------ exp_price: 0, enterAddressPage: 0, //进入地址页面 - + is_no_by: {}, allpice: 0, show_pay_type: 0, @@ -59,7 +60,7 @@ Page({ var json_d = JSON.parse(e.switch_list); th.data.json_d = json_d; var is_default_logistics = json_d.is_default_logistics; - th.setData({is_default_logistics:is_default_logistics}); + th.setData({ is_default_logistics: is_default_logistics }); th.get_wuliu(th.get_info(th.show_page)); }, 1) @@ -97,7 +98,7 @@ Page({ //---------------获取物流--------------- get_wuliu(func) { var th = this, - to = getApp(); + to = getApp(); to.getwuliu(function (e) { //如果第一个不是开启默认,说明要让用户自己选 if (!e[0].is_default) { @@ -243,7 +244,7 @@ Page({ tail_money = parseFloat(tail_money); order.tail_money = tail_money; - if(!goods) return false; + if (!goods) return false; //--判断物流-- if (goods.distr_type) distr_type = goods.distr_type; @@ -415,15 +416,62 @@ Page({ }); }, + //检查区域是不是包邮 + 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; + }, + //----计算物流的钱---- calculate_wuliu() { var to = getApp(), th = this; to.getConfig2(function (ee) { - to.getwuliuprice(function (rs) { - var o_shipping_price = 0,goods_weight = -1,goods_piece = -1,good=th.data.goods; - var out_of_weight=null; //超出多少重量 + to.getwuliuprice(async function (rs) { + var o_shipping_price = 0, goods_weight = -1, goods_piece = -1, good = th.data.goods; + var out_of_weight = null; //超出多少重量 + var no_ex_id = ee.no_ex_id; 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.user_addr != null && th.data.exp_type == 0 && good.is_free_shipping == 0) { switch (good['exp_sum_type']) { @@ -435,8 +483,8 @@ Page({ if (goods_weight < 0) goods_weight = 0; //累积商品重量 每种商品的重量 * 数量 goods_weight += good['weight'] * th.data.order.order_goods['goods_num']; - if(weight_free > 0){ - out_of_weight = (weight_free * 1000 ) - goods_weight; + if (weight_free > 0) { + out_of_weight = (weight_free * 1000) - goods_weight; } break; case 3: @@ -446,10 +494,39 @@ Page({ break; } 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; //--全部金额-- var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.pt_tail_money; + //有不包邮区域,且不免运费 + 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, + th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, goods_piece, th.data.user_addr, freight_free, allpice, rs); var exp_price = parseFloat(shipping_price).toFixed(2); allpice = parseFloat(exp_price) + parseFloat(allpice); @@ -467,12 +544,12 @@ Page({ }, //----------------计算物流--------------- - calculatewuliu: function (code, o_shipping_price, goods_weight,out_of_weight, + calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, goods_piece, user_addr, freight_free, o_price, rs) { var price = 0, th = this; price += parseFloat(o_shipping_price); //如果是包邮 - if (freight_free > 0 && o_price >= freight_free && out_of_weight>=0) { return 0; } + if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) { return 0; } if (user_addr == null) { return 0; } //计算物流的config item; var item = null; @@ -494,14 +571,14 @@ Page({ fw_price = fw_price + n * parseFloat(item['add_money']); } } - //------超出重量---------- - 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']); } } //------按件数----------