diff --git a/packageC/pages/presell/cart/cart.js b/packageC/pages/presell/cart/cart.js index 75812e0..7616c84 100644 --- a/packageC/pages/presell/cart/cart.js +++ b/packageC/pages/presell/cart/cart.js @@ -117,7 +117,9 @@ Page({ order_id: '', exp_price:0, order_prom_amount:0, - paying:0 + paying:0, + + same_ok:1 }, onLoad: function (t) { @@ -516,7 +518,7 @@ Page({ //-- 如果商品有同城配送的参数的时候,一件代发商品不能显示同城配送按钮 -- if(goods.is_same_city && th.data.is_same_city && goods.whsle_id<=0){ - getApp().request.promiseGet("/api/weshop/pickup/get/"+os.stoid+"/"+order.pickup_id, {}).then(res=>{ + await getApp().request.promiseGet("/api/weshop/pickup/get/"+os.stoid+"/"+order.pickup_id, {}).then(res=>{ if(res.data.code==0){ var pk=res.data.data; if(pk && pk.is_same_city){ @@ -659,6 +661,11 @@ Page({ break; //物流 } + + if(th.data.show_same_city==1 && th.data.sys_switch.pickupway && th.data.sys_switch.pickupway == 2 ){ + exp_type = 2; + } + if (th.data.exp_type) { exp_type=th.data.exp_type } @@ -703,7 +710,7 @@ Page({ async calculatePrice2() { var th = this; if (!this.data.pre_arr) return false; - th.setData({ show_submit: 0,disabled_btn:0}) + th.setData({ show_submit: 0,disabled_btn:0 }) //--计算物流-- if (this.data.exp_type == 0) { @@ -2107,11 +2114,11 @@ Page({ } + var bn_pick = th.data.pickup.pickup_id //如果同意参与订单优惠 if (ord_prom) { //th.check_is_order_prom(o_condition,async function (ord_price) { var ord_price=o_condition; - var bn_pick = th.data.pickup.pickup_id var order_prom_amount = 0; var order_prom_id = 0; var order_m = 0; @@ -2227,6 +2234,58 @@ Page({ var o_condition1 = parseFloat(o_condition) - parseFloat(th.data.presell.presell_deposit); if (o_condition1 < 0) o_condition1 = 0; + + if(th.data.exp_type == 2) { + var good = th.data.goods; + //--------------开始计算物流------------------ + var shipping_price = 0; + var lon = 0; + var lat = 0; + //-- 获取距离 -- + await getApp().request.promisePost("/api/weshop/order/sameCityExp/getGeocoder", { + is_json: 1, data: {address: th.data.user_addr.more_address + th.data.user_addr.address} + }).then(res => { + if (res.data.code == 0) { + var data = JSON.parse(res.data.data); + if (data.status == 0) { + lon = data.result.location.lng; + lat = data.result.location.lat; + } + } + }) + var gd_w = good['weight'] * good['buynum']; + //-- 获取距离 -- + var req_data = { + store_id: os.stoid, + order_amount: parseFloat(o_condition1), + lon: lon, lat: lat, + pickup_id: bn_pick, + goods_weight: gd_w, + } + + var is_next = 1; + //获取同城配送参数 + await getApp().request.promisePost("/api/weshop/order/sameCityExp/getMoney", { + is_json: 1, + data: req_data + }).then(res => { + if (res.data.code == 0) { + shipping_price = res.data.data; + } else { + is_next = 0; + wx.showToast({ + title: res.data.msg, icon: 'none', duration: 2000 + }) + } + }) + if (!is_next) { + th.setData({show_submit: 1, disabled_btn: 1,same_ok: 0}) + return false + } + exp_price = parseFloat(shipping_price).toFixed(2); + } + + var the_price=parseFloat(o_condition1) + parseFloat(exp_price); if(the_price - + diff --git a/packageC/pages/presell/cart/cart2.js b/packageC/pages/presell/cart/cart2.js index 8ed4d78..09c1b2d 100644 --- a/packageC/pages/presell/cart/cart2.js +++ b/packageC/pages/presell/cart/cart2.js @@ -129,6 +129,8 @@ Page({ dis_config:null, bn_use_commission:0, //是不是使用佣金 + same_ok:1 + }, onLoad: function (t) { wx.setNavigationBarTitle({ title: "填写订单", }) @@ -232,6 +234,10 @@ Page({ //先获取是否有关闭使用优惠券 getApp().getConfig2(function (ee) { var json_d = JSON.parse(ee.switch_list); + + //测试强行写死,后面一定要删除 + //json_d.pickupway=2; + th.data.json_d = json_d; th.data.ispt_goods = json_d.ispt_goods; //是不是平摊到单品的控制参数赋值 var is_default_logistics = json_d.is_default_logistics; @@ -407,7 +413,7 @@ Page({ //-- 如果商品有同城配送的参数的时候,一件代发商品不能显示同城配送按钮 -- if(gd.is_same_city && th.data.is_same_city && gd.whsle_id<=0){ - getApp().request.promiseGet("/api/weshop/pickup/get/"+os.stoid+"/"+th.data.gg.pick_id, {}).then(res=>{ + await getApp().request.promiseGet("/api/weshop/pickup/get/"+os.stoid+"/"+th.data.gg.pick_id, {}).then(res=>{ if(res.data.code==0){ var pk=res.data.data; if(pk && pk.is_same_city){ @@ -468,6 +474,10 @@ Page({ break; } + if(th.data.show_same_city==1 && th.data.json_d.pickupway && th.data.json_d.pickupway == 2 ){ + et = 2; + } + var m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code; if (et == 0 && def_exp_code && !th.data.is_default_logistics) { @@ -993,7 +1003,10 @@ Page({ }) } }) - if(!is_next) return false + if(!is_next) { + th.setData({show_submit:1, submit: 0,same_ok:0 }) + return false + } } total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price); @@ -1814,7 +1827,7 @@ Page({ setexptype: function (t) { var th = this; var ty = t.currentTarget.dataset.t, def_exp_code = getApp().globalData.userInfo.def_exp_code; - th.setData({ bn_exp_type: ty }); + th.setData({ bn_exp_type: ty,same_ok:1 }); if (ty == 0) { th.setData({ is_all_zt: 0 }); } diff --git a/packageE/pages/cart/cart2/cart2.js b/packageE/pages/cart/cart2/cart2.js index f6afe97..4d90fd4 100644 --- a/packageE/pages/cart/cart2/cart2.js +++ b/packageE/pages/cart/cart2/cart2.js @@ -269,8 +269,9 @@ Page({ //先获取是否有关闭使用优惠券 getApp().getConfig2(function (ee) { var json_d = JSON.parse(ee.switch_list); + //测试强行写死,后面一定要删除 - json_d.pickupway=2; + //json_d.pickupway=2; th.data.json_d = json_d; th.data.ispt_goods = json_d.ispt_goods; //是不是平摊到单品的控制参数赋值 @@ -6833,7 +6834,15 @@ Page({ if(this.data.bn_exp_type==2){ - + if(!item.is_same_city){ + wx.showToast({ + title: "商品不支持同城配送", + icon: 'none', + duration: 2000 + }) + th.setData({ submit: 0 }); + return false; + } }else{ if(item.distr_type==1){ @@ -6942,7 +6951,12 @@ Page({ //-- 如果是选中 -- if (e.selected) { - var exp_type=this.data.order_prom_list_cart[cart_index].exp_type; //配送方式 + var m_cartlist=this.data.old_cartlist; + if(this.data.order_prom_list_cart){ + m_cartlist=this.data.order_prom_list_cart; + } + + var exp_type=m_cartlist[cart_index].exp_type; //配送方式 //如果是自提的时候 if(exp_type==1){ @@ -6956,13 +6970,29 @@ Page({ } }else{ - if(item.distr_type==1){ - wx.showToast({ - title: "商品的配送方式不一致", - icon: 'none', - duration: 2000 - }) - return false; + + if(exp_type==2){ + + if(!item.is_same_city){ + wx.showToast({ + title: "商品不支持同城配送", + icon: 'none', + duration: 2000 + }) + th.setData({ submit: 0 }); + return false; + } + + }else { + + if (item.distr_type == 1) { + wx.showToast({ + title: "商品的配送方式不一致", + icon: 'none', + duration: 2000 + }) + return false; + } } } @@ -7019,8 +7049,9 @@ Page({ //-- 如果有一件代发的商品或者不是同城配送的配送 -- if (narr[hi].is_same_city != 1 || narr[hi].whsle_id > 0) { - th.setData({ show_same_city: 0 }) + //th.setData({ show_same_city: 0 }) } + } //自选的时候,系统配置了默认的配送方式是物流的时候 if (distr_t == 0 && th.data.json_d.pickupway && th.data.json_d.pickupway == 1) { diff --git a/pages/cart/cart2_inte/cart2_inte.js b/pages/cart/cart2_inte/cart2_inte.js index 45ec9c9..871f656 100644 --- a/pages/cart/cart2_inte/cart2_inte.js +++ b/pages/cart/cart2_inte/cart2_inte.js @@ -81,6 +81,8 @@ Page({ show_submit: 0, //提交按钮变正常显示 udata: null,//用户预存值,数据 is_pre_cut:0, //是否可以使用预存 0是不可以1的可以 + + same_ok:1, //同城配送的控制,默认ok }, onLoad: function (t) { wx.setNavigationBarTitle({ title: "填写订单", }) @@ -96,6 +98,10 @@ Page({ //先获取是否有关闭使用优惠券 getApp().getConfig2(function (ee) { var json_d = JSON.parse(ee.switch_list); + + //测试强行写死,后面一定要删除 + //json_d.pickupway=2; + th.data.json_d = json_d; th.data.ispt_goods = json_d.ispt_goods; //是不是平摊到单品的控制参数赋值 var is_default_logistics = json_d.is_default_logistics; @@ -496,6 +502,11 @@ Page({ case 2: et = 0; break; } + if(th.data.show_same_city==1 && th.data.json_d.pickupway && th.data.json_d.pickupway == 2 ){ + et = 2; + } + + if (th.data.bn_goods) et = th.data.bn_exp_type var m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code; @@ -984,7 +995,10 @@ Page({ }) } }) - if(!is_next) return false + if(!is_next){ + th.setData({show_submit:1, submit: 0,same_ok:0 }) + return false + } } @@ -1419,7 +1433,8 @@ Page({ setexptype: function (t) { var th = this; var ty = t.currentTarget.dataset.t, def_exp_code = getApp().globalData.userInfo.def_exp_code; - th.setData({ bn_exp_type: ty }); + + th.setData({ bn_exp_type: ty,same_ok:1 }); //当物流为空的时候。 if (ty == 0 && th.data.wu_arr == null) { th.data.isget_by_quan = {}; diff --git a/pages/cart/cart2_inte/cart2_inte.wxml b/pages/cart/cart2_inte/cart2_inte.wxml index 1cd8270..59acd10 100644 --- a/pages/cart/cart2_inte/cart2_inte.wxml +++ b/pages/cart/cart2_inte/cart2_inte.wxml @@ -199,7 +199,7 @@ 应付金额:¥{{formData.order_amount}} 应付积分:{{formData.integral}}积分 - + diff --git a/pages/cart/cart2_pt/cart2_pt.js b/pages/cart/cart2_pt/cart2_pt.js index ed306e1..71dcc00 100644 --- a/pages/cart/cart2_pt/cart2_pt.js +++ b/pages/cart/cart2_pt/cart2_pt.js @@ -72,6 +72,8 @@ Page({ bn_is_order_yh:1, //是不是订单优惠 bn_is_post_temp:1, //是不是进行计算包邮模板 + + same_ok:1, //同城配送的控制,默认ok }, onLoad: function (t) { console.log("onLoad_pt_cart"); @@ -380,6 +382,10 @@ Page({ break; } + if(th.data.show_same_city==1 && th.data.json_d.pickupway && th.data.json_d.pickupway == 2 ){ + et = 2; + } + t.data.data.shop_price = gg.goods_price; //--如果是普通购买的时候-- if (gg.is_normal == 1) { @@ -564,6 +570,10 @@ Page({ //先获取是否有关闭使用优惠券 getApp().getConfig2(function (ee) { var json_d = JSON.parse(ee.switch_list); + + //测试强行写死,后面一定要删除 + //json_d.pickupway=2; + th.data.json_d = json_d; th.data.ispt_goods = json_d.ispt_goods; //是不是平摊到单品的控制参数赋值 var is_default_logistics = json_d.is_default_logistics; @@ -851,7 +861,10 @@ Page({ }) } }) - if (!is_next) return false + if (!is_next){ + th.setData({show_submit:1, submit: 0,same_ok:0 }) + return false + } } //-- 如果是订单优惠的时候,allpice要拿来减掉一些 -- @@ -1426,7 +1439,7 @@ Page({ setexptype: function (t) { var th = this; var ty = t.currentTarget.dataset.t; - th.setData({ bn_exp_type: ty }); + th.setData({ bn_exp_type: ty, same_ok:0 }); //当物流为空的时候。 if (ty == 0 && th.data.wu_arr == null) { return th.get_wuliu(th.calculatePrice2()); diff --git a/pages/cart/cart2_pt/cart2_pt.wxml b/pages/cart/cart2_pt/cart2_pt.wxml index 87cefab..68aa51e 100644 --- a/pages/cart/cart2_pt/cart2_pt.wxml +++ b/pages/cart/cart2_pt/cart2_pt.wxml @@ -198,7 +198,7 @@ 应付金额:¥{{formData.order_amount}} - + diff --git a/pages/cart/cart_wk/cart_wk.js b/pages/cart/cart_wk/cart_wk.js index 0b2f618..c35b14f 100644 --- a/pages/cart/cart_wk/cart_wk.js +++ b/pages/cart/cart_wk/cart_wk.js @@ -50,7 +50,8 @@ Page({ bn_is_order_yh:1, //是不是订单优惠 bn_is_post_temp:1, //是不是进行计算包邮模板 - paying:0 //支付中 + paying:0, //支付中 + same_ok:1 //同城配送的控制 }, @@ -71,6 +72,11 @@ Page({ //--初始化-- getApp().getConfig2(function (e) { var json_d = JSON.parse(e.switch_list); + + //测试强行写死,后面一定要删除 + //json_d.pickupway=2; + + th.data.json_d = json_d; var is_default_logistics = json_d.is_default_logistics; var is_same_city = json_d.is_same_city; @@ -343,7 +349,7 @@ Page({ //-- 如果商品有同城配送的参数的时候,一件代发商品不能显示同城配送按钮 -- if(goods.is_same_city && th.data.is_same_city && goods.whsle_id<=0){ - getApp().request.promiseGet("/api/weshop/pickup/get/"+os.stoid+"/"+order.pickup_id, {}).then(res=>{ + await getApp().request.promiseGet("/api/weshop/pickup/get/"+os.stoid+"/"+order.pickup_id, {}).then(res=>{ if(res.data.code==0){ var pk=res.data.data; if(pk && pk.is_same_city){ @@ -369,6 +375,12 @@ Page({ break; //物流 } + if(th.data.show_same_city==1 && th.data.json_d.pickupway && th.data.json_d.pickupway == 2 ){ + exp_type = 2; + } + + + order.order_goods = order_goods; //-- 计算获得佣金的金额 -- @@ -416,6 +428,7 @@ Page({ var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.tail_money; var o_condition = allpice; var ord_prom=null; + var order_prom_amount=0; if (th.data.bn_is_order_yh) { await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { @@ -432,6 +445,10 @@ Page({ //--计算物流-- if (th.data.exp_type == 0) { th.calculate_wuliu(); + return false; + }else if(th.data.exp_type == 2){ + th.calculate_same_city(); + return false; } else { var order_prom_id=0; @@ -454,6 +471,10 @@ Page({ } } + + + + //--订单优惠的显示-- var order_prom_txt1 = "formData.order_prom_id"; var order_prom_txt2 = "formData.order_prom_amount"; @@ -498,7 +519,7 @@ Page({ set_wuliu: function (e) { var type = e.currentTarget.dataset.type, th = this; this.setData({ - exp_type: type + exp_type: type,same_ok:1 }); //--计算物流的值-- if (type == 0) { @@ -525,6 +546,7 @@ Page({ //如果有再计算价格的过程中,不能提交订单 if(this.data.submit){ return false} + if(!this.data.same_ok){ return false} //--物流支付时要有地址-- if (this.data.exp_type == 0 && this.data.user_addr == null) { @@ -984,7 +1006,10 @@ Page({ }) } }) - if(!is_next) return false + if(!is_next) { + th.setData({show_submit:1, submit: 0,same_ok:0 }) + return false + } var exp_price = parseFloat(shipping_price).toFixed(2); allpice = parseFloat(exp_price) + parseFloat(allpice); diff --git a/pages/cart/cart_wk/cart_wk.wxml b/pages/cart/cart_wk/cart_wk.wxml index 8fbfebb..d030b69 100644 --- a/pages/cart/cart_wk/cart_wk.wxml +++ b/pages/cart/cart_wk/cart_wk.wxml @@ -135,7 +135,7 @@ ¥{{filters.toFix(order.tail_money+exp_price,2)}} --> 支付合计:¥{{filters.toFix(order.tail_money+exp_price-(bn_use_commission?goods.use_commission:0)-formData.order_prom_amount ,2)}} - 支付尾款 + 支付尾款