From 65dadb7be0210d8047f475356129c0f299bfc72e Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Thu, 12 May 2022 09:33:02 +0800 Subject: [PATCH] 1、虚拟成团 2、运费阶梯 3、 区域价格的时候,门店控制 --- components/diy_store_select/diy_store_select.js | 32 +++++++++++++++++++++++++++----- components/diy_store_select/diy_store_select.wxml | 8 ++++++-- packageA/pages/goodsInfo/buy_flash_normal.wxml | 2 +- packageA/pages/goodsInfo/goodsInfo.js | 39 +++++++++++++++++++++++++-------------- packageA/pages/goodsInfo/goodsInfo.wxml | 6 +++--- packageA/pages/prom_list/prom_list.js | 8 ++++++++ packageA/pages/prom_list/prom_list.wxml | 2 +- packageB/pages/zuhegou/index/index.js | 3 +-- packageB/pages/zuhegou/index/index.wxml | 2 +- packageB/pages/zuhegou/preindex/index.js | 2 +- packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js | 131 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------- packageC/pages/luckyGo/luckyGo_goodsInfo/buy_integral.wxml | 2 +- packageC/pages/luckyGo/luckyGo_goodsInfo/buy_integral_normal.wxml | 2 +- packageC/pages/luckyGo/luckyGo_goodsInfo/buy_pt.wxml | 2 +- packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js | 20 +++++++++++++++----- packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxml | 4 ++-- packageC/pages/presell/cart/cart.js | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------ packageC/pages/presell/cart/cart2.js | 270 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- packageC/pages/presell/cart/cart2_pre.js | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------- packageC/pages/presell/goodsInfo/goodsInfo.js | 7 +++++++ packageC/pages/presell/goodsInfo/goodsInfo.wxml | 4 ++-- packageC/pages/presell/pregoodsInfo/goodsInfo.js | 8 ++++++++ packageC/pages/presell/pregoodsInfo/goodsInfo.wxml | 4 ++-- pages/cart/cart2/cart2.js | 588 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- pages/cart/cart2_inte/cart2_inte.js | 203 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------ pages/cart/cart2_pt/cart2_pt.js | 207 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------- pages/cart/cart_wk/cart_wk.js | 210 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------- pages/giftpack/buygiftpack/giftpackbuy.js | 15 +++++++++++++++ pages/giftpack/giftpacklist/giftpacklist.js | 15 +++++++++++++++ pages/giftpack/public/buy_com.js | 3 +++ pages/goods/goodsInfo/buy_flash_normal.wxml | 2 +- pages/goods/goodsInfo/buy_integral.wxml | 2 +- pages/goods/goodsInfo/buy_integral_normal.wxml | 2 +- pages/goods/goodsInfo/buy_pt.wxml | 2 +- pages/goods/goodsInfo/goodsInfo.js | 18 +++++++++++++++++- pages/goods/goodsInfo/goodsInfo.wxml | 8 ++++---- pages/team/team_ping/team_ping.js | 26 ++++++++++++++++++++++++-- pages/team/team_ping/team_ping.wxml | 9 ++++++++- pages/team/team_show/team_show.js | 13 +++++++++++-- pages/team/team_show/team_show.wxml | 2 +- pages/team/team_success/team_success.js | 27 ++++++++++++++++++++++++++- pages/team/team_success/team_success.wxml | 17 +++++++++++++---- 42 files changed, 940 insertions(+), 1205 deletions(-) diff --git a/components/diy_store_select/diy_store_select.js b/components/diy_store_select/diy_store_select.js index 9bf3500..822ec53 100644 --- a/components/diy_store_select/diy_store_select.js +++ b/components/diy_store_select/diy_store_select.js @@ -43,7 +43,7 @@ Component({ } //获取顶部的门店 - getApp().get_user_store(function(){ + getApp().get_user_store(function(e){ wx.getLocation({ type: 'gcj02', success: function(res) { @@ -59,6 +59,14 @@ Component({ }) }) + + + getApp().getConfig2(function (e) { + var json_d = JSON.parse(e.switch_list); + if(json_d.is_pricing_open_store){ + th.setData({ no_select:1 }) + } + },1) }, @@ -101,10 +109,24 @@ Component({ }); return false; } - var th=this; - this.get_top_sto(function(){ - th.setData({store:1}); - }); + var th=this; + + if(this.data.no_select && getApp().globalData.pk_store ){ + return false; + } + + //获取属性 + getApp().getConfig2(function (e) { + var json_d = JSON.parse(e.switch_list); + if(getApp().globalData.pk_store && json_d.is_pricing_open_store){ + return false; + } + th.get_top_sto(function(){ + th.setData({store:1}); + }); + }) + + }, //选择更多门店 more_store: function() { diff --git a/components/diy_store_select/diy_store_select.wxml b/components/diy_store_select/diy_store_select.wxml index 2bcffc1..0f3bc71 100644 --- a/components/diy_store_select/diy_store_select.wxml +++ b/components/diy_store_select/diy_store_select.wxml @@ -3,12 +3,16 @@ - {{top_store?top_store.pickup_name+'[切换]':'请选择门店'}} + + {{top_store?top_store.pickup_name:'请选择门店'}} + {{top_store?top_store.pickup_name+'[切换]':'请选择门店'}} - {{top_store?top_store.pickup_name+'[切换]':'请选择门店'}} + + {{top_store?top_store.pickup_name:'请选择门店'}} + {{top_store?top_store.pickup_name+'[切换]':'请选择门店'}} diff --git a/packageA/pages/goodsInfo/buy_flash_normal.wxml b/packageA/pages/goodsInfo/buy_flash_normal.wxml index f7ec6ee..72e8a72 100644 --- a/packageA/pages/goodsInfo/buy_flash_normal.wxml +++ b/packageA/pages/goodsInfo/buy_flash_normal.wxml @@ -44,7 +44,7 @@ 选择门店 - 更多门店 + (库存不足) diff --git a/packageA/pages/goodsInfo/goodsInfo.js b/packageA/pages/goodsInfo/goodsInfo.js index 9b20287..73e58cb 100644 --- a/packageA/pages/goodsInfo/goodsInfo.js +++ b/packageA/pages/goodsInfo/goodsInfo.js @@ -357,6 +357,9 @@ Page({ th.data.fir_def_store={}; //赋值空对象 return false; } + + th.setData({has_def:1}) + var ee=JSON.parse(JSON.stringify(e)); //--定时器推迟一下-- setTimeout(function () { @@ -1287,9 +1290,7 @@ Page({ }, openSpecModel: function(t) { - var th=this; - var open_store = t.currentTarget.dataset.ind; - + var th=this; var open_store = t.currentTarget.dataset.ind; if(getApp().is_sp_hao() && open_store==1){ wx.showToast({ title: "视频号商品不允许加入购物车", @@ -1300,20 +1301,22 @@ Page({ } + //--先判断会员状态-- + var user_info = getApp().globalData.userInfo; + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { + wx.navigateTo({ + url: '/pages/togoin/togoin', + }) + return false; + } + this.setData({ store: 0, choice_sort_store: 0, sort_store: 0, open_ind_store: open_store, }) - //--先判断会员状态-- - var user_info = getApp().globalData.userInfo; - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { - wx.navigateTo({ - url: '/pages/togoin/togoin', - }) - return false; - } + var ind = t.currentTarget.dataset.ind; this.setData({ @@ -2445,6 +2448,11 @@ Page({ var ind=ee.currentTarget.dataset.ind; var bconfig = th.data.bconfig; + + //如果开启了,则不在选择门店 + if(this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){ + return false; + } if(!th.data.only_pk && !th.data.def_pickpu_list){ getApp().confirmBox("门店库存不足", null, 25000, !1); return false; @@ -3455,7 +3463,10 @@ Page({ let prom_type = e.currentTarget.dataset.promtype; let prom_id = e.currentTarget.dataset.promid; let goods_id = this.data.data.goods_id; - let url = `/packageA/pages/goodsInfo/goodsInfo?goods_id=${goods_id}&prom_type=${prom_type}&prom_id=${prom_id}`;s + let url = `/packageA/pages/goodsInfo/goodsInfo?goods_id=${goods_id}&prom_type=${prom_type}&prom_id=${prom_id}`; + if(prom_type==6){ + url = `/packageA/pages/serviceCard_pd/goodsInfo/goodsInfo?goods_id=${goods_id}&prom_type=${prom_type}&prom_id=${prom_id}`; + } getApp().goto(url); }, @@ -3636,6 +3647,7 @@ Page({ //-- 秒杀的普通购买 -- openSpecModel_Nor: function () { + var th=this; // 是否授权登陆 var user_info = getApp().globalData.userInfo; @@ -3646,8 +3658,7 @@ Page({ return false; } - - this.data.g_buy_num = new Map(); + this.data.g_buy_num = new Map(); var th = this; this.setData({open_ind_store: 5, goodsInputNum: 1});//拼团直接给4 diff --git a/packageA/pages/goodsInfo/goodsInfo.wxml b/packageA/pages/goodsInfo/goodsInfo.wxml index cd90b2d..d0d01ac 100644 --- a/packageA/pages/goodsInfo/goodsInfo.wxml +++ b/packageA/pages/goodsInfo/goodsInfo.wxml @@ -155,7 +155,7 @@ 选择门店 - 更多门店 + @@ -189,6 +189,7 @@ 秒杀{{index+1}} + 拼单{{index+1}} diff --git a/packageB/pages/zuhegou/preindex/index.js b/packageB/pages/zuhegou/preindex/index.js index faf319d..1c773d1 100644 --- a/packageB/pages/zuhegou/preindex/index.js +++ b/packageB/pages/zuhegou/preindex/index.js @@ -260,7 +260,7 @@ Page({ return false; } - + th.setData({has_def:1}) var ee = JSON.parse(JSON.stringify(e)); var appd = getApp().globalData; 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 0eb3a1d..ed69f2c 100644 --- a/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js +++ b/packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js @@ -3,6 +3,7 @@ var t = getApp(), a = t.request, e = require("../../../../utils/common.js"), s = require("../../../../utils/util.js"), + ut=s, o = require("../../../../utils/md5.js"), to = getApp(); var oo = t.globalData.setting, @@ -499,7 +500,7 @@ Page({ var th = this, good = this.data.bn_goods; //-----------计算商品总价-------------- - var allpice = good.shop_price * good.buynum; + var allpice = th.data.param.goods_price; allpice = parseFloat(allpice).toFixed(2); var txt = "formData.all_price"; th.setData({ @@ -507,77 +508,81 @@ Page({ }); console.log(th.data.formData); - to.getConfig2(function (ee) { - to.getwuliuprice(async function (rs) { - console.log('calculatePrice2222'); - console.log(rs); + + to.getwuliuprice(async function (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; + //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- 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']) { - case 1: - //统一运费 - o_shipping_price += good['uniform_exp_sum']; - break; - case 2: - 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; - } - break; - case 3: - if (goods_piece < 0) goods_piece = 0; - //累积商品数量 - goods_piece += good['buynum']; - break; - } - 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 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; + 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 (back_data && back_data['is_by_all'] && !back_data.no_free_goods) { + continue; + } + if (back_data && back_data['is_by_all'] && back_data.no_free_goods.indexOf(item.goods_id) == -1) { + if (item['exp_sum_type'] == 2) { + 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; + } + + 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 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, out_of_weight, - goods_piece, th.data.user_addr, freight_free, allpice, rs,th.data.bn_pick); + ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + goods_piece, th.data.user_addr, back_data,rs); shipping_price = parseFloat(shipping_price).toFixed(2); var wl_txt = "formData.shipping_price"; @@ -628,7 +633,7 @@ Page({ } }); - }); + }, diff --git a/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_integral.wxml b/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_integral.wxml index 5d268cb..383f797 100644 --- a/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_integral.wxml +++ b/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_integral.wxml @@ -40,7 +40,7 @@ 选择门店 - + diff --git a/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_integral_normal.wxml b/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_integral_normal.wxml index 836bfd7..24db585 100644 --- a/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_integral_normal.wxml +++ b/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_integral_normal.wxml @@ -42,7 +42,7 @@ 选择门店 - + diff --git a/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_pt.wxml b/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_pt.wxml index a35df7b..cb614be 100644 --- a/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_pt.wxml +++ b/packageC/pages/luckyGo/luckyGo_goodsInfo/buy_pt.wxml @@ -64,7 +64,7 @@ 选择门店 - + diff --git a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js index 4811e5b..9055067 100644 --- a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js +++ b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js @@ -474,6 +474,8 @@ Page({ th.data.fir_def_store = {}; //赋值空对象 return false; } + + th.setData({has_def:1}) var ee = JSON.parse(JSON.stringify(e)); //--定时器推迟一下-- setTimeout(function () { @@ -1825,7 +1827,9 @@ Page({ // console.log('11111111111111111111111111======》'); // getApp().goto("/packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart?is_bnow=1&goods_id=" + e.goods_id); - getApp().goto("/packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart?is_bnow=1&group_id=" + th.data.group_id + "&goods_id=" + e.goods_id + "&alert=" + th.data.luckGoInfo.lc_alert); + //getApp().goto("/packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart?is_bnow=1&group_id=" + th.data.group_id + "&goods_id=" + e.goods_id + "&alert=" + th.data.luckGoInfo.lc_alert); + + getApp().goto("/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id) }) } else { @@ -2064,8 +2068,6 @@ Page({ return false; } - - if (th.data.more_flash && open_store == 1) { th.setData({ is_pop_more: 1 }); } else { @@ -3877,6 +3879,8 @@ Page({ // ind == 1 为普通购买 openSpecModel_pt: function (e) { + + this.setData({ open_ind_store: 9, goodsInputNum: 1 }); // 判断是否有待支付订单 var aid = this.data.group_id; @@ -3919,7 +3923,6 @@ Page({ var th = this; var ind = parseInt(e.currentTarget.dataset.ind); - console.log('当前ind========>>>>', ind); //ind == 1是普通购买 if (ind == 1) { @@ -5433,7 +5436,13 @@ Page({ var ind = ee.currentTarget.dataset.ind; var bconfig = th.data.bconfig; - if (!th.data.only_pk && !th.data.def_pickpu_list) { + //如果开启了,则不在选择门店 + if(this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){ + return false; + } + + + if (!th.data.only_pk && !th.data.def_pickpu_list) { getApp().confirmBox("门店库存不足", null, 25000, !1); return false; } @@ -5449,6 +5458,7 @@ Page({ } + if (bconfig && bconfig.is_sort_storage) { wx.getLocation({ type: 'gcj02', diff --git a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxml b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxml index c34f037..c009fa0 100644 --- a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxml +++ b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxml @@ -406,7 +406,7 @@ 选择门店 - 更多门店 + @@ -1115,7 +1115,7 @@ 选择门店 - 更多门店 + (库存不足) diff --git a/packageC/pages/presell/cart/cart.js b/packageC/pages/presell/cart/cart.js index 075e249..6c7eb10 100644 --- a/packageC/pages/presell/cart/cart.js +++ b/packageC/pages/presell/cart/cart.js @@ -1,3 +1,4 @@ +//这个页面是付尾款 var t = getApp(), app = t, a = t.request, e = require("../../../../utils/common.js"), s = require("../../../../utils/util.js"), ut = s, o = require("../../../../utils/md5.js"), to = getApp(); var oo = t.globalData.setting, os = oo; @@ -1717,33 +1718,21 @@ Page({ //----计算物流的钱---- calculate_wuliu() { var to = getApp(), th = this; - to.getConfig2(function (ee) { - to.getwuliuprice(async function (rs) { + to.getwuliuprice(async function (rs) { var o_shipping_price = 0, goods_weight = -1, goods_piece = -1, 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]; - } - }) - }; + + good.buynum=th.data.order.order_goods.goods_num; + 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; @@ -1814,59 +1803,74 @@ Page({ if (quan_no && th.data.using_quan[bn_pick].isby == 1) { exp_price = 0; } else { - switch (good['exp_sum_type']) { - case 1: - //统一运费 - o_shipping_price += good['uniform_exp_sum']; - break; - case 2: - 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; - } - break; - case 3: - if (goods_piece < 0) goods_piece = 0; - //累积商品数量 - goods_piece += th.data.order.order_goods['goods_num']; - break; + 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; + 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 (back_data && back_data['is_by_all'] && !back_data.no_free_goods) { + continue; + } + if (back_data && back_data['is_by_all'] && back_data.no_free_goods.indexOf(item.goods_id) == -1) { + if (item['exp_sum_type'] == 2) { + 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; + } - 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; + 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; + } } - var shipping_price = - th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, th.data.user_addr, freight_free, allpice, rs,th.data.bn_pick); + + //如果是正值的时候 + 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; + th.data.is_no_by[th.data.bn_pick] = 0; + + //--------------开始计算物流------------------ + var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + goods_piece, th.data.user_addr, back_data, rs); + exp_price = parseFloat(shipping_price).toFixed(2); } th.wuliu_next(allpice, quan_price, exp_price); @@ -1874,7 +1878,6 @@ Page({ th.wuliu_next(allpice, quan_price, exp_price); } }); - }); }, //相同的东西统一在一起 wuliu_next(allpice, quan_price, exp_price) { diff --git a/packageC/pages/presell/cart/cart2.js b/packageC/pages/presell/cart/cart2.js index 9116ed3..a7df533 100644 --- a/packageC/pages/presell/cart/cart2.js +++ b/packageC/pages/presell/cart/cart2.js @@ -1,3 +1,4 @@ +//预售全款 var t = getApp(), app = t, a = t.request, e = require("../../../../utils/common.js"), s = require("../../../../utils/util.js"), ut = s, to = getApp(); var oo = t.globalData.setting, os = oo; @@ -613,9 +614,7 @@ Page({ 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 quan_price = 0, bn_pick = th.data.bn_pick; var quan_no = null; @@ -673,83 +672,91 @@ Page({ }) } - switch (good['exp_sum_type']) { - case 1: - //统一运费 - o_shipping_price += good['uniform_exp_sum']; - break; - case 2: - 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; - } - break; - case 3: - if (goods_piece < 0) goods_piece = 0; - //累积商品数量 - goods_piece += good['buynum']; - break; - } - - 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; + //-- 在没有使用包邮券的时候 -- + if(!quan_no || !th.data.using_quan[bn_pick].isby) { - th.data.is_no_by[th.data.bn_pick] = 0; + 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 no_by_data = null; - var gift_freight_free = freight_free; + 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; + 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 (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice) - cut_price - quan_price) { - //-----------获取不包邮区域,不包邮商品------- - 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; - // weight_free=-1; - th.data.is_no_by[th.data.bn_pick] = 1; - } + 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) { + continue; + } + if (back_data && back_data['is_by_all'] && back_data.no_free_goods.indexOf(item.goods_id) == -1) { + if (item['exp_sum_type'] == 2) { + cut_good_weight += item['weight'] * item['buynum']; } - //如果有设置不包邮商品 - 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; - // weight_free=-1; - th.data.is_no_by[th.data.bn_pick] = 1; - } + if (back_data.weight_free > 0) { + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; } + continue; } - }) - } - th.data.is_by[th.data.bn_pick] = 0; - //--------------开始计算物流------------------ - var shipping_price = - th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, th.data.user_addr, freight_free, parseFloat(allpice) - cut_price - quan_price, rs,th.data.bn_pick); + 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; - //如果有赠品的时候,也要计算赠品的物流费用 - if (th.data.buy_now_gift_goods) { - shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free, out_of_weight, gift_weight_free, - parseFloat(allpice) - cut_price - quan_price, rs, shipping_price, no_by_data, goods_weight, goods_piece,th.data.bn_pick); - } - if (shipping_price <= 0) { - th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券 + 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 = + ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + goods_piece, th.data.user_addr, back_data, rs); + + + 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, }) + th.setData({[wl_txt]: shipping_price,}) } else { var wl_txt = "formData.shipping_price"; @@ -1682,79 +1689,6 @@ Page({ th.setData({ js_use_money: !th.data.js_use_money }); th.calculatePrice(); }, - //-------------------计算物流--------------- - calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, user_addr, freight_free, o_price, rs,pickid) { - 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 (user_addr == null) { - return 0; - } - //计算物流的config item; - var item = null; - //先根据 镇 县 区找计算的config - item = th.get_wuliu_config(user_addr.district, code, rs); - if (item == null) item = th.get_wuliu_config(user_addr.city, code, rs); - if (item == null) item = th.get_wuliu_config(user_addr.province, code, rs); - if (item == null) item = th.get_wuliu_default(code, rs); - if (item == null) return o_shipping_price; - var fw_price = 0, fp_price = 0; - item = item.config; - if (item == null) return o_shipping_price; - //------按重量---------- - if (goods_weight >= 0 && item['money']) { - fw_price = parseFloat(item['money']); - if (goods_weight > item['first_weight']) { - var fw = goods_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); - var n = Math.ceil(out_of_weight / item['second_weight']) - fw_price = fw_price + n * parseFloat(item['add_money']); - } - //------按件数---------- - if (goods_piece > 0 && item['piecemoney']) { - fp_price = parseFloat(item['piecemoney']); - if (goods_piece > item['first_piece']) { - var fp = goods_piece - item['first_piece']; - var m = Math.ceil(fp / item['second_piece']) - fp_price = fp_price + m * parseFloat(item['add_piecemoney']); - } - } - var rspice = parseFloat(price + fw_price + fp_price); - return rspice; - }, - - //------------循环获取config----------- - get_wuliu_config: function (region_id, code, rs) { - var item = null, rslist = rs.pageData; - for (var i = 0; i < rslist.length; i++) { - if (rslist[i].code == code && rslist[i].region_id == region_id) { - item = rslist[i]; - } - } - return item; - }, - //-------循环获取config,code default------- - get_wuliu_default: function (code, rs) { - var item = null, rslist = rs.pageData; - for (var i = 0; i < rslist.length; i++) { - if (rslist[i].shipping_code == code && rslist[i].is_default == 1) { - item = rslist[i]; - } - } - return item; - }, //----------立即购买,选择物流------------- bindPickerChange: function (e) { @@ -2552,62 +2486,6 @@ Page({ } }, - //计算立即购买赠品的物流费用 - get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free, gift_weight_free, out_of_weight, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1,pickid) { - var good = this.data.buy_now_gift_goods; - var goods_weight = -1, goods_piece = -1; - var gift_shipping_price = 0; - var th = this; - switch (good['exp_sum_type']) { - case 1: - //统一运费 - gift_shipping_price += good['uniform_exp_sum']; - gift_shipping_price += o_shipping_price; - break; - case 2: - if (goods_weight < 0) goods_weight = 0; - //累积商品重量 每种商品的重量 * 数量 - goods_weight += good['weight'] * good['buynum']; - if (goods_weight1 > 0) { - out_of_weight = gift_weight_free - goods_weight; - //不能调换位置 下面goods_weight会变大 - goods_weight += goods_weight1; - } - break; - case 3: - if (goods_piece < 0) goods_piece = 0; - //累积商品数量 - goods_piece += good['buynum']; - if (goods_piece1) { - goods_piece += goods_piece1; - } - break; - } - - - //如果有设置不包邮区域的时候 - 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; - th.data.is_no_by[th.data.bn_pick] = 1; - } - } - //如果有设置不包邮商品 - 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; - th.data.is_no_by[th.data.bn_pick]=1; - } - } - - 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); - return t_shipping_price; - - }, //从优惠的映射中拿出商品从表的item item_map_get_goods: function (goods_id, map) { diff --git a/packageC/pages/presell/cart/cart2_pre.js b/packageC/pages/presell/cart/cart2_pre.js index a4eb6ea..750209c 100644 --- a/packageC/pages/presell/cart/cart2_pre.js +++ b/packageC/pages/presell/cart/cart2_pre.js @@ -1,3 +1,4 @@ +//预付定金 var t = getApp(), app = t, a = t.request, ut = require("../../../../utils/util.js"); var os = t.globalData.setting; var regeneratorRuntime = require('../../../../utils/runtime.js'); @@ -340,34 +341,74 @@ Page({ th.setData({ [txt]: allpice, }); console.log(th.data.formData); - app.getConfig2(function (ee) { - app.getwuliuprice(function (rs) { + app.getwuliuprice(async function (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; + //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- 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']) { - case 1: - //统一运费 - o_shipping_price += good['uniform_exp_sum']; break; - case 2: - 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; + + 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; + 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 = data[i]; + if (back_data && back_data['is_by_all'] && !back_data.no_free_goods) { + continue; + } + if (back_data && back_data['is_by_all'] && back_data.no_free_goods.indexOf(item.goods_id) == -1) { + if (item['exp_sum_type'] == 2) { + cut_good_weight += item['weight'] * item['buynum']; } - break; - case 3: - if (goods_piece < 0) goods_piece = 0; - //累积商品数量 - goods_piece += good['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 = th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, @@ -405,7 +446,7 @@ Page({ } }); - }); + }, // -- 支付的下一步 -- diff --git a/packageC/pages/presell/goodsInfo/goodsInfo.js b/packageC/pages/presell/goodsInfo/goodsInfo.js index 5e8acda..a9b679a 100644 --- a/packageC/pages/presell/goodsInfo/goodsInfo.js +++ b/packageC/pages/presell/goodsInfo/goodsInfo.js @@ -679,6 +679,8 @@ Page({ th.data.fir_def_store = {}; //赋值空对象 return false; } + th.setData({has_def:1}) + var ee = JSON.parse(JSON.stringify(e)); if (th.data.fir_goods) var g_distr_type = th.data.fir_goods.distr_type; @@ -3206,6 +3208,11 @@ Page({ var ind = ee.currentTarget.dataset.ind; var bconfig = th.data.bconfig; + //如果开启了,则不在选择门店 + if(this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){ + return false; + } + if (!th.data.only_pk && !th.data.def_pickpu_list) { getApp().confirmBox("门店库存不足", null, 25000, !1); return false; diff --git a/packageC/pages/presell/goodsInfo/goodsInfo.wxml b/packageC/pages/presell/goodsInfo/goodsInfo.wxml index e8ffc06..f31fa6a 100644 --- a/packageC/pages/presell/goodsInfo/goodsInfo.wxml +++ b/packageC/pages/presell/goodsInfo/goodsInfo.wxml @@ -154,7 +154,7 @@ 选择门店 - 更多门店 + @@ -602,7 +602,7 @@ 选择门店 - 更多门店 + (库存不足) diff --git a/packageC/pages/presell/pregoodsInfo/goodsInfo.js b/packageC/pages/presell/pregoodsInfo/goodsInfo.js index 1e25130..40c8888 100644 --- a/packageC/pages/presell/pregoodsInfo/goodsInfo.js +++ b/packageC/pages/presell/pregoodsInfo/goodsInfo.js @@ -675,6 +675,9 @@ Page({ th.data.fir_def_store = {}; //赋值空对象 return false; } + + th.setData({has_def:1}) + var ee = JSON.parse(JSON.stringify(e)); if (th.data.fir_goods) var g_distr_type = th.data.fir_goods.distr_type; @@ -3174,6 +3177,11 @@ Page({ var ind = ee.currentTarget.dataset.ind; var bconfig = th.data.bconfig; + //如果开启了,则不在选择门店 + if(this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){ + return false; + } + if (!th.data.only_pk && !th.data.def_pickpu_list) { getApp().confirmBox("门店库存不足", null, 25000, !1); return false; diff --git a/packageC/pages/presell/pregoodsInfo/goodsInfo.wxml b/packageC/pages/presell/pregoodsInfo/goodsInfo.wxml index a80ff81..94b19bb 100644 --- a/packageC/pages/presell/pregoodsInfo/goodsInfo.wxml +++ b/packageC/pages/presell/pregoodsInfo/goodsInfo.wxml @@ -154,7 +154,7 @@ 选择门店 - 更多门店 + @@ -596,7 +596,7 @@ 选择门店 - 更多门店 + (库存不足) diff --git a/pages/cart/cart2/cart2.js b/pages/cart/cart2/cart2.js index 47c4498..a3ae08d 100644 --- a/pages/cart/cart2/cart2.js +++ b/pages/cart/cart2/cart2.js @@ -1457,8 +1457,7 @@ Page({ //-------------------计算订单价格------------------- calculatePrice: function (t, s) { var th = this; - to.getConfig2(function (ee) { - to.getwuliuprice(async function (rs) { + to.getwuliuprice(async function (rs) { wx.showLoading({ title: "处理中." }) //是不是区域包邮 th.data.is_area_by = 0; @@ -1480,24 +1479,7 @@ Page({ var all_order_prom = 0; //所有的订单优惠 var umoney = th.data.userinfo.user_money - th.data.txmon - (th.data.userinfo.frozen_money ? th.data.userinfo.frozen_money : 0); - var freight_free = ee.freight_free; //全场满多少包邮 - var free1 = 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 = {}; var out_of_weight = 0; //超出多少重量 - 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]; - } - }) - }; var c_arr = JSON.parse(JSON.stringify(th.data.old_cartlist)); if (th.data.cartlist && th.data.cartlist.length > 0) { @@ -1646,84 +1628,8 @@ Page({ th.data.is_no_past = 1; //不包邮标识符 - var no_ex_good_arr = null; - //--有不包邮区域,且不免运费,全场的计算,要减到优惠金额 和券的金额-- - if (no_ex_id && freight_free > 0 && (o_price - quan_price) >= freight_free && cart_item.exp_type == 0 && (by_qc.region_list || by_qc.goods_list)) { - //如果有设置不包邮区域的时候 - if (by_qc.region_list != "" && by_qc.region_list != null && by_qc.region_list != undefined) { - if (th.check_by_area(by_qc.region_list)) { - freight_free = 0; - th.data.is_area_by = 1; - //goods_weight = -1; - //out_of_weight = 0; - th.data.is_no_by[pickid] = 1; - } - } - //如果有设置不包邮区商品 - if (by_qc.goods_list != "" && by_qc.goods_list != undefined && by_qc != null && freight_free > 0) { - freight_free = 0; - //goods_weight = -1; - //out_of_weight = 0; - //th.data.is_no_by[pickid] = 1; - no_ex_good = by_qc.goods_list; - if (no_ex_good) no_ex_good_arr = no_ex_good.split(','); - } - } - - - - var is_in_no_ex_goods_arr = 0; - var by_g_weight = 0; - //--------循环计算商品总物流----------- - for (var jo = 0; jo < item.length; jo++) { - //----------------如果是选择了物流--------------------- - if (cart_item.exp_type == 0 && item[jo].is_free_shipping == 0 && th.data.user_addr != null) { - - //判断是否有设置限制重量包邮,先看商品有没有包邮 - if (!no_ex_good_arr || no_ex_good_arr.indexOf(item[jo].goods_id + '') == -1) { - if (!th.data.is_area_by) th.data.free1 = free1; - //此时是 模板里面没有不包邮商品列表或者是 该商品没有再不包邮商品列表礼包 - if (item[jo]['is_past'] !== 1 && item[jo]['exp_sum_type'] == 2) { - if (goods_weight < 0) goods_weight = 0; - //累积商品重量 每种商品的重量 * 数量 - goods_weight += item[jo]['weight'] * item[jo]['goods_num']; - by_g_weight += item[jo]['weight'] * item[jo]['goods_num']; - - if (free1 > 0) { - if (weight_free > 0) { - out_of_weight = (weight_free * 1000) - by_g_weight; - } else { - out_of_weight = -by_g_weight; - } - } - - } - } - //这个是在不包邮列表礼包 - else if (no_ex_good_arr.indexOf(item[jo].goods_id + '') > -1) { - is_in_no_ex_goods_arr = 1; - if (item[jo]['is_past'] !== 1 && item[jo]['exp_sum_type'] == 2) { - if (goods_weight < 0) goods_weight = 0; - //累积商品重量 每种商品的重量 * 数量 - goods_weight += item[jo]['weight'] * item[jo]['goods_num']; - } - - } - } - } - - if (free1 > 0) { - //当商品没有超出的时候 - if (out_of_weight >= 0) { - out_of_weight = -by_g_weight; - } else { - if (weight_free > 0) out_of_weight = -weight_free * 1000; - } - } - - //所有的商品都不在不包邮商品列表,freight_free为0的时候,以及不是区域包邮 - if (!is_in_no_ex_goods_arr && !freight_free && !th.data.is_area_by) freight_free = free1; - + var back_data = null; + var quan_no_goods_arr=null; //--如果是物流,且选择了地址,就要开始显示包邮券,且包邮券也已经优惠了优惠活动的金额-- if (cart_item.exp_type == 0 && th.data.user_addr != null && !cart_item.is_xz_yh) { //看是不是有调用过包邮券 @@ -1768,104 +1674,117 @@ Page({ } }) } + + var user_addr=th.data.user_addr; + var req_d = { + province: user_addr.province, city: user_addr.city, district: user_addr.district, + wuliu:parseFloat(o_price - quan_price).toFixed(2),store_id: os.stoid + } + 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 (quan_no && th.data.using_quan[pickid].isby == 1) { var quan = th.data.using_quan[pickid]; if (!quan.goods_list) { th.data.is_quan_by[pickid] = 1; //专门给券的判断用的 } else { - th.data.is_quan_by[pickid] = 0; - //看有没有模板的包邮 - if (no_ex_good) { - var arr = no_ex_good.split(","); - var arr2 = quan.goods_list.split(","); - if (ut.isContained(arr, arr2)) { - getApp().my_warnning("全场不包邮商品和包邮券的重复", 0, th); - th.data.using_quan[pickid] = {}; - th.setData({ using_quan: th.data.using_quan }) - return false; - } - var n_arr = ut.mergeArray(arr, arr2); - no_ex_good = n_arr.join(","); - } else { - no_ex_good = quan.goods_list; - } + th.data.is_quan_by[pickid] = 0; + quan_no_goods_arr = quan.goods_list.split(","); + } } else { th.data.is_quan_by[pickid] = 0; //专门给券的判断用的 } - //--------循环计算总价----------- - for (var j = 0; j < item.length; j++) { - //如果都包邮,都没必要等级数量了 - if (th.data.is_quan_by[pickid]) continue; - //如果是优惠活动是包邮,就不用计算包邮的费用了 - if (item[j].is_past) continue; - //是不是不包邮的商品 - var is_good_no_by = 0; - if (no_ex_good) { - is_good_no_by = th.check_by_goods(no_ex_good, item[j].goods_id); + var cut_good_weight=0; + //计算物流价格 + if (cart_item.exp_type == 0 && th.data.user_addr && !th.data.is_quan_by[pickid]) { + + //如果有包邮券的不包邮商品的时候 + if(quan_no_goods_arr) { + if (back_data && back_data.no_free_goods) { + back_data['is_by_all']=1; + var arr3 = back_data.no_free_goods.filter(item => { + return quan_no_goods_arr.includes(item) + }) + back_data.no_free_goods = null; + if (arr3.length) { + back_data.no_free_goods = arr3; + } + } + if (!back_data || !back_data.no_free_goods) { + if (!back_data) back_data={}; + back_data['is_by_all']=1; + back_data['no_free_goods']=quan_no_goods_arr; + } } - //--如果是包邮券使用的情况下,如果商品是包邮的,那么就不进行计算-- - if (th.data.using_quan[pickid] && th.data.using_quan[pickid].isby == 1 && !is_good_no_by) { - continue; - } + //--------循环计算总价----------- + for (var j = 0; j < item.length; j++) { - //var no_ex_good_arr = null; - //if (no_ex_good) no_ex_good_arr = no_ex_good.split(','); - //----------------如果是选择了物流--------------------- - if (cart_item.exp_type == 0 && item[j].is_free_shipping == 0) { - //如果地址不为空 - if (th.data.user_addr != null) { - switch (item[j]['exp_sum_type']) { - case 1: - //统一运费 - o_shipping_price += item[j]['uniform_exp_sum']; - break; - case 3: - if (goods_piece < 0) goods_piece = 0; - //累积商品数量 - goods_piece += item[j]['goods_num']; - break; + //如果商品本身是包邮了 + if(item[j].is_free_shipping == 1) continue; + //如果是优惠活动是包邮,就不用计算包邮的费用了 + if (item[j].is_past) continue; + //--如果是包邮券使用的情况下,如果商品是包邮的,那么就不进行计算-- + if (th.data.using_quan[pickid] && th.data.using_quan[pickid].isby == 1 && th.data.is_quan_by[pickid]) { + continue; + } + if (back_data && back_data['is_by_all'] && !back_data.no_free_goods) { + continue; + } + if (back_data && back_data['is_by_all'] && back_data.no_free_goods.indexOf(item[j].goods_id) == -1) { + if (item[j]['exp_sum_type'] == 2) { + cut_good_weight += item[j]['weight'] * item[j]['goods_num']; + } + if (back_data.weight_free > 0) { + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; } + continue; } + switch (item[j]['exp_sum_type']) { + case 1: + //统一运费 + o_shipping_price += item[j]['uniform_exp_sum']; + break; + case 2: + if (goods_weight < 0) goods_weight = 0; + //累积商品重量 每种商品的重量 * 数量 + goods_weight += item[j]['weight'] * item[j]['goods_num']; - if (!no_ex_good_arr || no_ex_good_arr.indexOf(item[j].goods_id + '') == -1) { - switch (item[j]['exp_sum_type']) { - case 1: - //统一运费 - th.data.cut_o_shipping_price += item[j]['uniform_exp_sum']; - break; - case 3: - //累积商品数量 - th.data.cut_goods_piece += item[j]['goods_num']; - break; - } + if (back_data && back_data.is_by_all && !back_data.no_free_goods) { + cut_good_weight += item[j]['weight'] * item[j]['goods_num']; + 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[j]['goods_num']; + break; } - - } else { - /*-- - if(item[j]['exp_sum_type']==2 && out_of_weight!==0){ - goods_weight = -1; - out_of_weight = 0; - }--*/ } - } - //计算物流价格 - if (cart_item.exp_type == 0) { - //freight_free=0; //后面不在进行判断 + //如果是正值的时候 + 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[cart_item.wind]) code = th.data.wu_arr[cart_item.wind].code; cart_item.shipping_price = - th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, th.data.user_addr, freight_free, o_price - quan_price, rs, pickid); + ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,goods_piece, th.data.user_addr, back_data, rs); if (!th.data.using_quan[pickid] || th.data.using_quan[pickid].isby != 1) { if (cart_item.shipping_price == 0) th.data.is_by[pickid] = 1; //已经全场包邮,就不要选择券了 @@ -1875,7 +1794,6 @@ Page({ } cart_item.shipping_price = cart_item.shipping_price.toFixed(2); - //总价计算,总价不包含运费 cart_item.order_amount = (o_price - quan_price).toFixed(2); cart_item.total_amount = f_o_price.toFixed(2); @@ -2017,7 +1935,6 @@ Page({ wx.hideLoading(); }); - }); }, set_can_num: function () { @@ -2089,15 +2006,10 @@ Page({ allpice = good.offline_price * good.buynum; } - - to.getConfig2(function (ee) { - to.getwuliuprice(async function (rs) { + to.getwuliuprice(async function (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 quan_price = 0, bn_pick = th.data.bn_pick; @@ -2123,6 +2035,12 @@ Page({ } } + 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 (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && good.is_past != 1) { //看是不是有调用过包邮券 @@ -2145,7 +2063,10 @@ Page({ for (var i in quanlist) { var item = quanlist[i]; if (item.region_list && th.check_by_area(item.region_list)) continue; //如果是不包邮区域 - if (item.goods_list && th.check_by_goods(item.goods_list)) continue; //如果是不包邮商品 + if (item.goods_list) { + var no_goods_arr = item.goods_list.split(","); + if (ut.isContained(no_goods_arr, gd_arr_list)) continue; //如果是不包邮商品 + } arr.push(item); } if (arr) { @@ -2156,83 +2077,116 @@ Page({ }) } - switch (good['exp_sum_type']) { - case 1: - //统一运费 - o_shipping_price += good['uniform_exp_sum']; - break; - case 2: - if (goods_weight < 0) goods_weight = 0; - //dw - //累积商品重量 每种商品的重量 * 数量 - goods_weight += good['weight'] * good['buynum']; - if (weight_free > 0) { - out_of_weight = (weight_free * 1000) - goods_weight; + var shipping_price =0; + var quan_no_goods_arr=null; + var is_by_quan=0; + + //如果是包邮券的时候,要看看券的情况,判断一下包邮有没有不包邮模板 + if (quan_no && th.data.using_quan[pickid].isby == 1) { + var quan = th.data.using_quan[pickid]; + if (quan.goods_list) { + quan_no_goods_arr=quan.goods_list.split(","); + }else{ + is_by_quan=1; } - break; - case 3: - if (goods_piece < 0) goods_piece = 0; - //累积商品数量 - goods_piece += good['buynum']; - break; - } - - var code = ""; - if (th.data.wu_arr && th.data.wu_arr[th.data.index]) 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 gift_freight_free = freight_free; - + } + if(!is_by_quan) { + 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; + 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 (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice) - cut_price - quan_price) { - //-----------获取不包邮区域,不包邮商品------- - 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(quan_no_goods_arr) { + if (back_data && back_data.no_free_goods) { + back_data['is_by_all']=1; + var arr3 = back_data.no_free_goods.filter(item => { + return quan_no_goods_arr.includes(item) + }) + back_data.no_free_goods = null; + if (arr3.length) { + back_data.no_free_goods = arr3; } } - //如果有设置不包邮商品 - 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; + if (!back_data || !back_data.no_free_goods) { + if (!back_data) back_data={}; + back_data['is_by_all']=1; + back_data['no_free_goods']=quan_no_goods_arr; + } + } + + 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']) { + if(!back_data.no_free_goods || !back_data.no_free_goods.length) continue; + } + if (back_data && back_data['is_by_all'] && back_data.no_free_goods.indexOf(item.goods_id) == -1) { + if (item['exp_sum_type'] == 2) { + 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; + } + + 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; } } - }) - } - th.data.is_by[th.data.bn_pick] = 0; - //--------------开始计算物流------------------ - var shipping_price = - th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, th.data.user_addr, freight_free, parseFloat(allpice) - cut_price - quan_price, rs, th.data.bn_pick); + //如果是正值的时候 + if (out_of_weight >= 0) out_of_weight = -cut_good_weight; + else out_of_weight = -back_data.weight_free * 1000; - //如果有赠品的时候,也要计算赠品的物流费用 - if (th.data.buy_now_gift_goods) { - shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free, out_of_weight, - parseFloat(allpice) - cut_price - quan_price, rs, shipping_price, no_by_data, goods_weight, goods_piece); - } + var code = ""; + if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code; + th.data.is_no_by[th.data.bn_pick] = 0; + th.data.is_by[th.data.bn_pick] = 0; - if (shipping_price <= 0) { - th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券 - } + //--------------开始计算物流------------------ + shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + goods_piece, th.data.user_addr, back_data, rs); - shipping_price = parseFloat(shipping_price).toFixed(2); - var wl_txt = "formData.shipping_price"; - th.setData({ [wl_txt]: shipping_price, }) + 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,}) } else { var wl_txt = "formData.shipping_price"; @@ -2418,7 +2372,7 @@ Page({ wx.hideLoading(); }); - }); + }, requestSubscribe() { @@ -3263,89 +3217,8 @@ Page({ th.setData({ js_use_money: !th.data.js_use_money }); th.calculatePrice(); }, - //-------------------计算物流--------------- - calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, user_addr, freight_free, o_price, rs, pickid) { - 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 (user_addr == null) { - return 0; - } - //计算物流的config item; - var item = null; - //先根据 镇 县 区找计算的config - item = th.get_wuliu_config(user_addr.district, code, rs); - if (item == null) item = th.get_wuliu_config(user_addr.city, code, rs); - if (item == null) item = th.get_wuliu_config(user_addr.province, code, rs); - if (item == null) item = th.get_wuliu_default(code, rs); - if (item == null) return o_shipping_price; - var fw_price = 0, fp_price = 0; - item = item.config; - if (item == null) return o_shipping_price; - - //------超出重量---------- - if (out_of_weight < 0 && o_price >= freight_free && !th.data.is_no_by[pickid]) { - goods_weight = goods_weight + out_of_weight; - if (goods_weight == 0) goods_weight = -1; - } - - - //------按重量---------- - if (goods_weight >= 0 && item['money']) { - fw_price = parseFloat(item['money']); - if (goods_weight > item['first_weight']) { - var fw = goods_weight - item['first_weight']; - var n = Math.ceil(fw / item['second_weight']) - fw_price = fw_price + n * parseFloat(item['add_money']); - } - } - - if (th.data.free1 && freight_free <= 0) freight_free = th.data.free1; - - //当有包邮和不包邮混合在一起的时候,件数要重新计算 - if (freight_free > 0 && o_price >= freight_free && goods_piece > 0 && th.data.cut_goods_piece) - goods_piece = goods_piece - th.data.cut_goods_piece; - //------按件数---------- - if (goods_piece > 0 && item['piecemoney']) { - fp_price = parseFloat(item['piecemoney']); - if (goods_piece > item['first_piece']) { - var fp = goods_piece - item['first_piece']; - var m = Math.ceil(fp / item['second_piece']) - fp_price = fp_price + m * parseFloat(item['add_piecemoney']); - } - } - //当有包邮和不包邮混合在一起的时候,统一运费要重新计算 - if (freight_free > 0 && o_price >= freight_free && th.data.cut_o_shipping_price && price > 0) price = price - th.data.cut_o_shipping_price; - var rspice = parseFloat(price + fw_price + fp_price); - return rspice; - }, - - //------------循环获取config----------- - get_wuliu_config: function (region_id, code, rs) { - var item = null, rslist = rs.pageData; - for (var i = 0; i < rslist.length; i++) { - if (rslist[i].code == code && rslist[i].region_id == region_id) { - item = rslist[i]; - } - } - return item; - }, - //-------循环获取config,code default------- - get_wuliu_default: function (code, rs) { - var item = null, rslist = rs.pageData; - for (var i = 0; i < rslist.length; i++) { - if (rslist[i].shipping_code == code && rslist[i].is_default == 1) { - item = rslist[i]; - } - } - return item; - }, //----------立即购买,选择物流------------- bindPickerChange: function (e) { @@ -4332,73 +4205,6 @@ Page({ }, - //计算立即购买赠品的物流费用 - get_now_gift_goods_wuliu: function (code, o_shipping_price, user_addr, gift_freight_free, out_of_weight, allpice, rs, shipping_price, no_by_data, goods_weight1, goods_piece1) { - var good_arr = this.data.buy_now_gift_goods; - var goods_weight = -1, goods_piece = -1; - - var gift_shipping_price = 0; - if (shipping_price) { - gift_shipping_price = shipping_price; - } - var th = this; - var out_of_weight = null; - - - //如果有设置不包邮区域的时候 - 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 - th.data.is_no_by[th.data.bn_pick] = 1; - } - } - - for (var i in good_arr) { - var good = good_arr[i]; - switch (good['exp_sum_type']) { - case 1: - //统一运费 - gift_shipping_price += parseFloat(good['uniform_exp_sum']); - gift_shipping_price += o_shipping_price; - break; - case 2: - if (goods_weight < 0) goods_weight = 0; - //累积商品重量 每种商品的重量 * 数量 - goods_weight += good['weight'] * parseInt(good['buynum']); - if (goods_weight1 > 0) { - out_of_weight = gift_weight_free - goods_weight; - //不能调换位置 下面goods_weight会变大 - goods_weight += goods_weight1; - } - break; - case 3: - if (goods_piece < 0) goods_piece = 0; - //累积商品数量 - goods_piece += parseInt(good['buynum']); - if (goods_piece1) { - goods_piece += goods_piece1; - } - break; - } - - //如果有设置不包邮商品 - 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 - th.data.is_no_by[th.data.bn_pick] = 1; - } - } - } - - 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); - return t_shipping_price; - - }, - //从优惠的映射中拿出商品从表的item item_map_get_goods: function (goods_id, map) { for (var i in map.goods) { diff --git a/pages/cart/cart2_inte/cart2_inte.js b/pages/cart/cart2_inte/cart2_inte.js index 2fcb027..46f596d 100644 --- a/pages/cart/cart2_inte/cart2_inte.js +++ b/pages/cart/cart2_inte/cart2_inte.js @@ -425,81 +425,87 @@ Page({ var c_txt = "formData.cut_price"; th.setData({ [c_txt]: cut_price, }); } - to.getConfig2(function (ee) { - to.getwuliuprice(async function (rs) { + + to.getwuliuprice(async function (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内包邮 + //-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮---------- if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && good.is_past != 1) { - switch (good['exp_sum_type']) { - case 1: - //统一运费 - o_shipping_price += good['uniform_exp_sum']; break; - case 2: - 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; - } - break; - case 3: - if (goods_piece < 0) goods_piece = 0; - //累积商品数量 - goods_piece += good['buynum']; break; - } + 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; + 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 code = ""; - if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code; - var no_ex_id = ee.no_ex_id; - th.data.is_no_by[th.data.bn_pick] = 0; - var no_by_data = null; - var gift_freight_free = freight_free; - //有不包邮区域,且不免运费 - if (no_ex_id && freight_free > 0 && freight_free <= allpice - cut_price) { - //-----------获取不包邮区域,不包邮商品------- - await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", { - data: { store_id: os.stoid, id: no_ex_id } - }).then(res => { - if (res.data.code == 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; - // weight_free = -1; - th.data.is_no_by[th.data.bn_pick] = 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 (back_data && back_data['is_by_all']) { + if(!back_data.no_free_goods || !back_data.no_free_goods.length) continue; } - //如果有设置不包邮商品 - 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; - // weight_free = -1; - th.data.is_no_by[th.data.bn_pick] = 1; - } + + if (back_data && back_data['is_by_all'] && back_data.no_free_goods.indexOf(item.goods_id) == -1) { + if (item['exp_sum_type'] == 2) { + 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; } - } - }) - } - //--------------开始计算物流------------------ - var shipping_price = - th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, th.data.user_addr, freight_free, allpice - cut_price, rs, th.data.bn_pick); - if (shipping_price <= 0) { - th.data.is_by[th.data.bn_pick] = 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; + } + } - shipping_price = parseFloat(shipping_price).toFixed(2); - var wl_txt = "formData.shipping_price"; - th.setData({ [wl_txt]: shipping_price, }) + //如果是正值的时候 + 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 = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + goods_piece, th.data.user_addr, back_data, rs); + 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, }) } else { var wl_txt = "formData.shipping_price"; @@ -544,7 +550,7 @@ Page({ wx.hideLoading(); }); - }); + }, //--------------------提交订单----------------------- @@ -917,73 +923,6 @@ Page({ th.setData({ js_use_money: !th.data.js_use_money }); th.calculatePrice(); }, - //-------------------计算物流--------------- - calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, user_addr, freight_free, o_price, rs, pickid = null) { - 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 (user_addr == null) { return 0; } - //计算物流的config item; - var item = null; - //先根据 镇 县 区找计算的config - item = th.get_wuliu_config(user_addr.district, code, rs); - if (item == null) item = th.get_wuliu_config(user_addr.city, code, rs); - if (item == null) item = th.get_wuliu_config(user_addr.province, code, rs); - if (item == null) item = th.get_wuliu_default(code, rs); - if (item == null) return o_shipping_price; - var fw_price = 0, fp_price = 0; - item = item.config; - if (item == null) return o_shipping_price; - //------按重量---------- - if (goods_weight >= 0 && item['money']) { - fw_price = parseFloat(item['money']); - if (goods_weight > item['first_weight']) { - var fw = goods_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 && item['piecemoney']) { - fp_price = parseFloat(item['piecemoney']); - if (goods_piece > item['first_piece']) { - var fp = goods_piece - item['first_piece']; - var m = Math.ceil(fp / item['second_piece']) - fp_price = fp_price + m * parseFloat(item['add_piecemoney']); - } - } - var rspice = parseFloat(price + fw_price + fp_price); - return rspice; - }, - - //------------循环获取config----------- - get_wuliu_config: function (region_id, code, rs) { - var item = null, rslist = rs.pageData; - for (var i = 0; i < rslist.length; i++) { - if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i]; } - } - return item; - }, - //-------循环获取config,code default------- - get_wuliu_default: function (code, rs) { - var item = null, rslist = rs.pageData; - for (var i = 0; i < rslist.length; i++) { - if (rslist[i].shipping_code == code && rslist[i].is_default == 1) { item = rslist[i]; } - } - return item; - }, //----------立即购买,选择物流------------- bindPickerChange: function (e) { diff --git a/pages/cart/cart2_pt/cart2_pt.js b/pages/cart/cart2_pt/cart2_pt.js index 5a5e237..62a1635 100644 --- a/pages/cart/cart2_pt/cart2_pt.js +++ b/pages/cart/cart2_pt/cart2_pt.js @@ -1,5 +1,5 @@ var t = getApp(), app = t, a = t.request, e = require("../../../utils/common.js"), - s = require("../../../utils/util.js"), o = require("../../../utils/md5.js"), to = getApp(); + s = require("../../../utils/util.js"),ut=s, o = require("../../../utils/md5.js"), to = getApp(); var oo = t.globalData.setting, os = oo; var regeneratorRuntime = require('../../../utils/runtime.js'); var util_pay = require("../../../utils/pay.js"); @@ -401,84 +401,81 @@ Page({ allpice = parseFloat(allpice).toFixed(2); var txt = "formData.all_price"; th.setData({ [txt]: allpice, }); - console.log(th.data.formData); - to.getConfig2(function (ee) { - to.getwuliuprice(async 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']) { - case 1: - //统一运费 - o_shipping_price += good['uniform_exp_sum']; break; - case 2: - 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; - } - break; - case 3: - if (goods_piece < 0) goods_piece = 0; - //累积商品数量 - goods_piece += good['buynum']; break; - } - - console.log(th.data.wu_arr); - 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; - } + + 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; + 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 (back_data && back_data['is_by_all'] && !back_data.no_free_goods) { + continue; } - //如果有设置不包邮商品 - 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; - } + if (back_data && back_data['is_by_all'] && back_data.no_free_goods.indexOf(item.goods_id) == -1) { + if (item['exp_sum_type'] == 2) { + 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; } - } - }) - } - var shipping_price = - th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, th.data.user_addr, freight_free, allpice, rs,th.data.bn_pick); + + 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 = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + goods_piece, th.data.user_addr, back_data, rs); shipping_price = parseFloat(shipping_price).toFixed(2); var wl_txt = "formData.shipping_price"; @@ -512,7 +509,7 @@ Page({ } }); - }); + }, //--------------------提交订单----------------------- submitForm: async function (t) { @@ -861,74 +858,6 @@ Page({ th.calculatePrice(); }, - //-------------------计算物流--------------- - calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, user_addr, freight_free, o_price, rs, pickid) { - 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 (user_addr == null) { return 0; } - //计算物流的config item; - var item = null; - //先根据 镇 县 区找计算的config - item = th.get_wuliu_config(user_addr.district, code, rs); - if (item == null) item = th.get_wuliu_config(user_addr.city, code, rs); - if (item == null) item = th.get_wuliu_config(user_addr.province, code, rs); - if (item == null) item = th.get_wuliu_default(code, rs); - if (item == null) return o_shipping_price; - var fw_price = 0, fp_price = 0; - item = item.config; - if (item == null) return o_shipping_price; - //------按重量---------- - if (goods_weight >= 0 && item['money']) { - fw_price = parseFloat(item['money']); - if (goods_weight > item['first_weight']) { - var fw = goods_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']); - if (goods_piece > item['first_piece']) { - var fp = goods_piece - item['first_piece']; - var m = Math.ceil(fp / item['second_piece']) - fp_price = fp_price + m * parseFloat(item['add_piecemoney']); - } - } - var rspice = parseFloat(price + fw_price + fp_price); - return rspice; - }, - - //------------循环获取config----------- - get_wuliu_config: function (region_id, code, rs) { - var item = null, rslist = rs.pageData; - for (var i = 0; i < rslist.length; i++) { - if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i]; } - } - return item; - }, - //-------循环获取config,code default------- - get_wuliu_default: function (code, rs) { - var item = null, rslist = rs.pageData; - for (var i = 0; i < rslist.length; i++) { - if (rslist[i].shipping_code == code && rslist[i].is_default == 1) { item = rslist[i]; } - } - return item; - }, - //----------立即购买,选择物流------------- bindPickerChange: function (e) { var ind = e.detail.value diff --git a/pages/cart/cart_wk/cart_wk.js b/pages/cart/cart_wk/cart_wk.js index 21c9377..261c02e 100644 --- a/pages/cart/cart_wk/cart_wk.js +++ b/pages/cart/cart_wk/cart_wk.js @@ -2,6 +2,7 @@ var t = getApp(), oo = t.globalData.setting, os=oo; +var ut=require("../../../utils/util.js"); var regeneratorRuntime = require('../../../utils/runtime.js'); Page({ @@ -462,155 +463,98 @@ Page({ //----计算物流的钱---- calculate_wuliu() { var to = getApp(), th = this; - to.getConfig2(function (ee) { - to.getwuliuprice(async function (rs) { + 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]; - } - }) - }; + + good.buynum=th.data.order.order_goods['goods_num']; + var gd_arr_list = []; + gd_arr_list.push(good); + //--全部金额-- + var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.pt_tail_money; + //-----------当地址不为空,且是物流时,计算物流费用---------- if (th.data.user_addr != null && th.data.exp_type == 0 && good.is_free_shipping == 0) { - switch (good['exp_sum_type']) { - case 1: - //统一运费 - o_shipping_price += good['uniform_exp_sum']; - break; - case 2: - 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; - } - break; - case 3: - if (goods_piece < 0) goods_piece = 0; - //累积商品数量 - goods_piece += th.data.order.order_goods['goods_num']; - 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; - } + + 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; + 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']) { + if(!back_data.no_free_goods || !back_data.no_free_goods.length) continue; } - //如果有设置不包邮商品 - 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; - } + if (back_data && back_data['is_by_all'] && back_data.no_free_goods.indexOf(item.goods_id) == -1) { + if (item['exp_sum_type'] == 2) { + 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; } - } - }) - } - var shipping_price = - th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, - 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); - exp_price = parseFloat(exp_price); - th.setData({ exp_price: exp_price, allpice: allpice }) + 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 = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight, + goods_piece, th.data.user_addr, back_data, rs); + + var exp_price = parseFloat(shipping_price).toFixed(2); + allpice = parseFloat(exp_price) + parseFloat(allpice); + allpice = allpice.toFixed(2); + + exp_price = parseFloat(exp_price); + th.setData({ exp_price: exp_price, allpice: allpice }) } else { var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.tail_money; allpice = allpice.toFixed(2); th.setData({ exp_price: 0, allpice: allpice }) } }); - }); - }, - //----------------计算物流--------------- - calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight, - goods_piece, user_addr, freight_free, o_price, rs,pickid) { - 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 (user_addr == null) { return 0; } - //计算物流的config item; - var item = null; - //先根据 镇 县 区找计算的config - item = th.get_wuliu_config(user_addr.district, code, rs); - if (item == null) item = th.get_wuliu_config(user_addr.city, code, rs); - if (item == null) item = th.get_wuliu_config(user_addr.province, code, rs); - if (item == null) item = th.get_wuliu_default(code, rs); - if (item == null) return o_shipping_price; - var fw_price = 0, fp_price = 0; - item = item.config; - if (item == null) return o_shipping_price; - //------按重量---------- - if (goods_weight >= 0 && item['money']) { - fw_price = parseFloat(item['money']); - if (goods_weight > item['first_weight']) { - var fw = goods_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']); - if (goods_piece > item['first_piece']) { - var fp = goods_piece - item['first_piece']; - var m = Math.ceil(fp / item['second_piece']) - fp_price = fp_price + m * parseFloat(item['add_piecemoney']); - } - } - var rspice = parseFloat(price + fw_price + fp_price); - return rspice; - }, - //------------循环获取config----------- - get_wuliu_config: function (region_id, code, rs) { - var item = null, rslist = rs.pageData; - for (var i = 0; i < rslist.length; i++) { - if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i]; } - } - return item; }, + //---------------检查是否有收货地址------------------- checkAddressList: function () { var t = this; diff --git a/pages/giftpack/buygiftpack/giftpackbuy.js b/pages/giftpack/buygiftpack/giftpackbuy.js index cd914f8..defcdf2 100644 --- a/pages/giftpack/buygiftpack/giftpackbuy.js +++ b/pages/giftpack/buygiftpack/giftpackbuy.js @@ -68,11 +68,21 @@ Page({ }, onLoad: function (options) { + var th=this; + this.setData({ params: options, now:Date.parse(new Date()) / 1000, }) + getApp().getConfig2(function (e) { + var json_d = JSON.parse(e.switch_list); + th.setData({ + bconfig: e, + sys_switch:json_d + }); + }) + }, init() { var th = this; @@ -359,6 +369,11 @@ Page({ var ind = ee.currentTarget.dataset.ind; var bconfig = th.data.bconfig; + //如果开启了,则不在选择门店 + if(this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){ + return false; + } + if (!th.data.only_pk && !th.data.def_pickpu_list) { getApp().confirmBox("门店库存不足", null, 25000, !1); return false; diff --git a/pages/giftpack/giftpacklist/giftpacklist.js b/pages/giftpack/giftpacklist/giftpacklist.js index 7123c06..541124f 100644 --- a/pages/giftpack/giftpacklist/giftpacklist.js +++ b/pages/giftpack/giftpacklist/giftpacklist.js @@ -70,9 +70,20 @@ Page({ openSpecModal:0 }, onLoad: function (options) { + + var th=this; + this.setData({ params:options, }) + + getApp().getConfig2(function (e) { + var json_d = JSON.parse(e.switch_list); + th.setData({ + bconfig: e, + sys_switch:json_d + }); + }) }, init(){ let options = this.data?.params; // this.data == null ? undefined:this.data.params @@ -606,6 +617,10 @@ Page({ var ind = ee.currentTarget.dataset.ind; var bconfig = th.data.bconfig; + //如果开启了,则不在选择门店 + if(this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){ + return false; + } if (!th.data.only_pk && !th.data.def_pickpu_list) { getApp().confirmBox("门店库存不足", null, 25000, !1); return false; diff --git a/pages/giftpack/public/buy_com.js b/pages/giftpack/public/buy_com.js index 6013fb5..06bc375 100644 --- a/pages/giftpack/public/buy_com.js +++ b/pages/giftpack/public/buy_com.js @@ -44,6 +44,9 @@ module.exports = { th.data.fir_def_store = {}; //赋值空对象 return false; } + + th.setData({has_def:1}) + var ee = JSON.parse(JSON.stringify(e)); //--定时器推迟一下-- setTimeout(function () { diff --git a/pages/goods/goodsInfo/buy_flash_normal.wxml b/pages/goods/goodsInfo/buy_flash_normal.wxml index 0d15a59..86ddc6f 100644 --- a/pages/goods/goodsInfo/buy_flash_normal.wxml +++ b/pages/goods/goodsInfo/buy_flash_normal.wxml @@ -42,7 +42,7 @@ 选择门店 - 更多门店 + (库存不足) diff --git a/pages/goods/goodsInfo/buy_integral.wxml b/pages/goods/goodsInfo/buy_integral.wxml index 04b58fb..fc198a4 100644 --- a/pages/goods/goodsInfo/buy_integral.wxml +++ b/pages/goods/goodsInfo/buy_integral.wxml @@ -40,7 +40,7 @@ 选择门店 - 更多门店 + (库存不足) diff --git a/pages/goods/goodsInfo/buy_integral_normal.wxml b/pages/goods/goodsInfo/buy_integral_normal.wxml index 9449d8b..cfad7b3 100644 --- a/pages/goods/goodsInfo/buy_integral_normal.wxml +++ b/pages/goods/goodsInfo/buy_integral_normal.wxml @@ -42,7 +42,7 @@ 选择门店 - 更多门店 + (库存不足) diff --git a/pages/goods/goodsInfo/buy_pt.wxml b/pages/goods/goodsInfo/buy_pt.wxml index 96f4d63..123dfb1 100644 --- a/pages/goods/goodsInfo/buy_pt.wxml +++ b/pages/goods/goodsInfo/buy_pt.wxml @@ -63,7 +63,7 @@ 选择门店 - 更多门店 + (配送不匹配) (库存不足) diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index f492419..3ca5ffb 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -480,6 +480,8 @@ Page({ th.data.fir_def_store = {}; //赋值空对象 return false; } + th.setData({has_def:1}); + var ee = JSON.parse(JSON.stringify(e)); //--定时器推迟一下-- setTimeout(function () { @@ -489,6 +491,9 @@ Page({ ee.is_no_dis = 1; } + + + var appd = getApp().globalData; var w_time = setInterval(function () { if (that.data.is_get_local_ok == 0) return false; @@ -552,7 +557,7 @@ Page({ var that = this, th = this; getApp().getConfig2(function (e) { var sales_rules = e.sales_rules; - if (sales_rules == 2) { + if (sales_rules == 2 && [1,2,4,6,8,9].indexOf(th.data.prom_type)==-1 ) { getApp().waitfor2(that, "wait_for_user_store", "fir_goods", function () { var lock = 0, plist = null; var gd = that.data.fir_goods; @@ -5792,6 +5797,11 @@ Page({ var ind = ee.currentTarget.dataset.ind; var bconfig = th.data.bconfig; + //如果开启了,则不在选择门店 + if(this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){ + return false; + } + if (!th.data.only_pk && !th.data.def_pickpu_list) { // getApp().confirmBox("门店库存不足", null, 25000, !1); wx.showToast({ @@ -5818,6 +5828,12 @@ Page({ return false; } + //如果开启了,则不在选择门店 + if(th.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){ + return false; + } + + if (bconfig && bconfig.is_sort_storage) { wx.getLocation({ diff --git a/pages/goods/goodsInfo/goodsInfo.wxml b/pages/goods/goodsInfo/goodsInfo.wxml index 67679c0..77164b7 100644 --- a/pages/goods/goodsInfo/goodsInfo.wxml +++ b/pages/goods/goodsInfo/goodsInfo.wxml @@ -623,13 +623,13 @@ - + 选择门店 - 更多门店 + @@ -1243,11 +1243,11 @@ - + 选择门店 - 更多门店 + (库存不足) diff --git a/pages/team/team_ping/team_ping.js b/pages/team/team_ping/team_ping.js index 5217980..31f2a5b 100644 --- a/pages/team/team_ping/team_ping.js +++ b/pages/team/team_ping/team_ping.js @@ -87,7 +87,9 @@ Page({ order = null,//订单数据 goods = null,//商品数据 users = null,//会员数据 - order_goods=null;//订单商品表 + order_goods=null,//订单商品表 + team_g=null; + //获取订单表的信息根据活动user_id,pt_prom_id>0 AND pay_time>0 @@ -121,6 +123,15 @@ Page({ order[i].tx=ordertx; }) + //获取teamgroup中的值 + await getApp().request.promiseGet("/api/weshop/teamgroup/page", { + data: { store_id: os.stoid, listno: order[i].pt_listno,pageSize:1,page:1} + }).then(res => { + team_g = res.data.data.pageData[0] + + }) + + if (order[i].is_zsorder== 4) { @@ -132,13 +143,24 @@ Page({ order[i].max_ct_num = num; } + var head=[]; + if(team_g.is_xuni_ct) { + head=team_g.xuni_head_id.split(","); + order[i].is_xuni_ct=1; + } + var sf_num = order[i].ct_num; if (order[i].ct_num>=3){ sf_num=3;} sf_num=sf_num-ordertx.length; if(sf_num>0) { var arr = []; for(var j=0;j - + + + + + + + + ... diff --git a/pages/team/team_show/team_show.js b/pages/team/team_show/team_show.js index 398d04a..761a97f 100644 --- a/pages/team/team_show/team_show.js +++ b/pages/team/team_show/team_show.js @@ -134,7 +134,8 @@ Page({ var th=this; getApp().getConfig2(function(e) { - th.setData({ bconfig: e,}); + var json_d = JSON.parse(e.switch_list); + th.setData({ bconfig: e,sys_switch:json_d}); th.wait_for_store_config(); //获取默认的门店 }) @@ -611,6 +612,8 @@ Page({ th.data.fir_def_store={}; //赋值空对象 return false; } + + th.setData({has_def:1}) //--定时器推迟一下-- setTimeout(function () { if(!th.data.goods) return false; @@ -1007,7 +1010,13 @@ Page({ choice_store: function(ee) { var th = this; - var bconfig = th.data.bconfig; + var bconfig = th.data.bconfig; + + //如果开启了,则不在选择门店 + if(this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){ + return false; + } + if(!th.data.only_pk && !th.data.def_pickpu_list){ getApp().confirmBox("门店库存不足", null, 25000, !1); return false; diff --git a/pages/team/team_show/team_show.wxml b/pages/team/team_show/team_show.wxml index f745637..c6ef77c 100644 --- a/pages/team/team_show/team_show.wxml +++ b/pages/team/team_show/team_show.wxml @@ -229,7 +229,7 @@ 选择门店 - 更多门店 + diff --git a/pages/team/team_success/team_success.js b/pages/team/team_success/team_success.js index 7c9625d..9428a9b 100644 --- a/pages/team/team_success/team_success.js +++ b/pages/team/team_success/team_success.js @@ -181,6 +181,15 @@ Page({ ordertx = res.data.data.pageData; }) + var team_g=null; + //获取teamgroup中的值 + await getApp().request.promiseGet("/api/weshop/teamgroup/page", { + data: { store_id: os.stoid, listno: pt_listno,pageSize:1,page:1} + }).then(res => { + team_g = res.data.data.pageData[0] + + }) + var min_price=0; //获取活动表的信息根据活动pt_prom_id @@ -240,9 +249,23 @@ Page({ ordertx2.push(ordertx[i]); } + + var head=[]; + if(team_g.is_xuni_ct) { + head=team_g.xuni_head_id.split(","); + order.is_xuni_ct=1; + + this.setData({head:head,}); + } + + var sf_arr=[]; for (var i=0;i - 已拼{{teamlist.buy_num}}件 + 已拼{{teamlist.buy_num+teamlist.virtual}}件 @@ -95,8 +95,8 @@ 团长 - - + + @@ -143,7 +143,7 @@ 已经有 - {{ordertx.length}}人参团, 拼团成功。 + {{ordertx.length>teamlist.ct_num?ordertx.length:teamlist.ct_num}}人参团, 拼团成功。 @@ -215,6 +215,15 @@ + + + -- libgit2 0.21.4