Commit 0b82e0fd58e198038ea9cd0a675ac7d7dba441f3

Authored by 后端研发-苏明海
2 parents cf448af5 65dadb7b

Merge branch 'dev' into 'test'

1、虚拟成团

2、运费阶梯
3、 区域价格的时候,门店控制

See merge request !1031
Showing 42 changed files with 940 additions and 1205 deletions
components/diy_store_select/diy_store_select.js
... ... @@ -43,7 +43,7 @@ Component({
43 43 }
44 44  
45 45 //获取顶部的门店
46   - getApp().get_user_store(function(){
  46 + getApp().get_user_store(function(e){
47 47 wx.getLocation({
48 48 type: 'gcj02',
49 49 success: function(res) {
... ... @@ -59,6 +59,14 @@ Component({
59 59 })
60 60  
61 61 })
  62 +
  63 +
  64 + getApp().getConfig2(function (e) {
  65 + var json_d = JSON.parse(e.switch_list);
  66 + if(json_d.is_pricing_open_store){
  67 + th.setData({ no_select:1 })
  68 + }
  69 + },1)
62 70 },
63 71  
64 72  
... ... @@ -101,10 +109,24 @@ Component({
101 109 });
102 110 return false;
103 111 }
104   - var th=this;
105   - this.get_top_sto(function(){
106   - th.setData({store:1});
107   - });
  112 + var th=this;
  113 +
  114 + if(this.data.no_select && getApp().globalData.pk_store ){
  115 + return false;
  116 + }
  117 +
  118 + //获取属性
  119 + getApp().getConfig2(function (e) {
  120 + var json_d = JSON.parse(e.switch_list);
  121 + if(getApp().globalData.pk_store && json_d.is_pricing_open_store){
  122 + return false;
  123 + }
  124 + th.get_top_sto(function(){
  125 + th.setData({store:1});
  126 + });
  127 + })
  128 +
  129 +
108 130 },
109 131 //选择更多门店
110 132 more_store: function() {
... ...
components/diy_store_select/diy_store_select.wxml
... ... @@ -3,12 +3,16 @@
3 3 <!-- 如果是自定义模板的时候 -->
4 4 <block wx:if="{{object}}">
5 5 <view class="store_sele1 flex ai_c" bindtap="sele_top_store" style="background-color:{{object.bgcolor}};color: {{object.word_color}};">
6   - <image class="logo_box circle" src="{{url+store_config.store_logo}}"></image>{{top_store?top_store.pickup_name+'[切换]':'请选择门店'}}
  6 + <image class="logo_box circle" src="{{url+store_config.store_logo}}"></image>
  7 + <block wx:if="{{no_select}}">{{top_store?top_store.pickup_name:'请选择门店'}}</block>
  8 + <block wx:else>{{top_store?top_store.pickup_name+'[切换]':'请选择门店'}}</block>
7 9 </view>
8 10 </block>
9 11 <block wx:else>
10 12 <view class="store_sele flex ai_c" bindtap="sele_top_store">
11   - <image class="logo_box circle" src="{{url+store_config.store_logo}}"></image>{{top_store?top_store.pickup_name+'[切换]':'请选择门店'}}
  13 + <image class="logo_box circle" src="{{url+store_config.store_logo}}"></image>
  14 + <block wx:if="{{no_select}}">{{top_store?top_store.pickup_name:'请选择门店'}}</block>
  15 + <block wx:else>{{top_store?top_store.pickup_name+'[切换]':'请选择门店'}}</block>
12 16 </view>
13 17 <view class="pd-view"></view>
14 18 </block>
... ...
packageA/pages/goodsInfo/buy_flash_normal.wxml
... ... @@ -44,7 +44,7 @@
44 44 <view class="fs30" style="color:black;">选择门店</view>
45 45 </view>
46 46  
47   - <view class="red-co fs28" bindtap="choice_store" >更多门店<text class="right-arrow"></text></view>
  47 + <view hidden="{{has_def && sys_switch.is_pricing_open_store}}" class="red-co fs28" bindtap="choice_store" >更多门店<text class="right-arrow"></text></view>
48 48 </view>
49 49 <view wx:if="{{only_pk && !only_pk.length}}">(库存不足)</view>
50 50 <block wx:else>
... ...
packageA/pages/goodsInfo/goodsInfo.js
... ... @@ -357,6 +357,9 @@ Page({
357 357 th.data.fir_def_store={}; //赋值空对象
358 358 return false;
359 359 }
  360 +
  361 + th.setData({has_def:1})
  362 +
360 363 var ee=JSON.parse(JSON.stringify(e));
361 364 //--定时器推迟一下--
362 365 setTimeout(function () {
... ... @@ -1287,9 +1290,7 @@ Page({
1287 1290 },
1288 1291  
1289 1292 openSpecModel: function(t) {
1290   - var th=this;
1291   - var open_store = t.currentTarget.dataset.ind;
1292   -
  1293 + var th=this; var open_store = t.currentTarget.dataset.ind;
1293 1294 if(getApp().is_sp_hao() && open_store==1){
1294 1295 wx.showToast({
1295 1296 title: "视频号商品不允许加入购物车",
... ... @@ -1300,20 +1301,22 @@ Page({
1300 1301 }
1301 1302  
1302 1303  
  1304 + //--先判断会员状态--
  1305 + var user_info = getApp().globalData.userInfo;
  1306 + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
  1307 + wx.navigateTo({
  1308 + url: '/pages/togoin/togoin',
  1309 + })
  1310 + return false;
  1311 + }
  1312 +
1303 1313 this.setData({
1304 1314 store: 0,
1305 1315 choice_sort_store: 0,
1306 1316 sort_store: 0,
1307 1317 open_ind_store: open_store,
1308 1318 })
1309   - //--先判断会员状态--
1310   - var user_info = getApp().globalData.userInfo;
1311   - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
1312   - wx.navigateTo({
1313   - url: '/pages/togoin/togoin',
1314   - })
1315   - return false;
1316   - }
  1319 +
1317 1320  
1318 1321 var ind = t.currentTarget.dataset.ind;
1319 1322 this.setData({
... ... @@ -2445,6 +2448,11 @@ Page({
2445 2448 var ind=ee.currentTarget.dataset.ind;
2446 2449 var bconfig = th.data.bconfig;
2447 2450  
  2451 +
  2452 + //如果开启了,则不在选择门店
  2453 + if(this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){
  2454 + return false;
  2455 + }
2448 2456 if(!th.data.only_pk && !th.data.def_pickpu_list){
2449 2457 getApp().confirmBox("门店库存不足", null, 25000, !1);
2450 2458 return false;
... ... @@ -3455,7 +3463,10 @@ Page({
3455 3463 let prom_type = e.currentTarget.dataset.promtype;
3456 3464 let prom_id = e.currentTarget.dataset.promid;
3457 3465 let goods_id = this.data.data.goods_id;
3458   - let url = `/packageA/pages/goodsInfo/goodsInfo?goods_id=${goods_id}&prom_type=${prom_type}&prom_id=${prom_id}`;s
  3466 + let url = `/packageA/pages/goodsInfo/goodsInfo?goods_id=${goods_id}&prom_type=${prom_type}&prom_id=${prom_id}`;
  3467 + if(prom_type==6){
  3468 + url = `/packageA/pages/serviceCard_pd/goodsInfo/goodsInfo?goods_id=${goods_id}&prom_type=${prom_type}&prom_id=${prom_id}`;
  3469 + }
3459 3470 getApp().goto(url);
3460 3471 },
3461 3472  
... ... @@ -3636,6 +3647,7 @@ Page({
3636 3647  
3637 3648 //-- 秒杀的普通购买 --
3638 3649 openSpecModel_Nor: function () {
  3650 + var th=this;
3639 3651  
3640 3652 // 是否授权登陆
3641 3653 var user_info = getApp().globalData.userInfo;
... ... @@ -3646,8 +3658,7 @@ Page({
3646 3658 return false;
3647 3659 }
3648 3660  
3649   -
3650   - this.data.g_buy_num = new Map();
  3661 + this.data.g_buy_num = new Map();
3651 3662 var th = this;
3652 3663 this.setData({open_ind_store: 5, goodsInputNum: 1});//拼团直接给4
3653 3664  
... ...
packageA/pages/goodsInfo/goodsInfo.wxml
... ... @@ -155,7 +155,7 @@
155 155 <image class="stores-img" src="{{iurl}}/miniapp/images/stores.png"></image>
156 156 <view class="fs30" style="color:black;">选择门店</view>
157 157 </view>
158   - <view class="red_bb fs26">更多门店<text class="bg_jj"></text></view>
  158 + <view hidden="{{has_def && sys_switch.is_pricing_open_store}}" class="red_bb fs26">更多门店<text class="bg_jj"></text></view>
159 159 </view>
160 160  
161 161 <view wx:if="{{def_pick_store && def_pick_store.pickup_name}}">
... ... @@ -189,6 +189,7 @@
189 189 <!-- <block> -->
190 190 <view class="flex ai_c" wx:for="{{actList}}">
191 191 <view class="cx-sizs fs30 pdr40" wx:if="{{item.prom_type == 1}}">秒杀{{index+1}}</view>
  192 + <view class="cx-sizs fs30 pdr40" wx:if="{{item.prom_type == 6}}">拼单{{index+1}}</view>
192 193 <view class="f1">
193 194 <!-- <view class="fs28 f1"> -->
194 195 <!-- <view>
... ... @@ -673,8 +674,7 @@
673 674 <image class="stores-img" src="{{iurl}}/miniapp/images/stores.png"></image>
674 675 <view class="fs30" style="color:black;">选择门店</view>
675 676 </view>
676   -
677   - <view class="red-co fs28" bindtap="choice_store">更多门店<text class="right-arrow"></text></view>
  677 + <view hidden="{{has_def && sys_switch.is_pricing_open_store}}" class="red-co fs28" bindtap="choice_store">更多门店<text class="right-arrow"></text></view>
678 678 </view>
679 679  
680 680  
... ...
packageA/pages/prom_list/prom_list.js
... ... @@ -91,6 +91,9 @@ Page({
91 91 th.data.fir_def_store={}; //赋值空对象
92 92 return false;
93 93 }
  94 +
  95 + th.setData({has_def:1})
  96 +
94 97 var appd=getApp().globalData;
95 98 var w_time = setInterval(function() {
96 99 if (that.data.is_get_local_ok == 0) return false;
... ... @@ -1252,6 +1255,11 @@ Page({
1252 1255 var th = this;
1253 1256 var ind=ee.currentTarget.dataset.ind;
1254 1257 var bconfig = th.data.bconfig;
  1258 +
  1259 + //如果开启了,则不在选择门店
  1260 + if(this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){
  1261 + return false;
  1262 + }
1255 1263  
1256 1264 if(!th.data.only_pk && !th.data.def_pickpu_list){
1257 1265 getApp().confirmBox("门店库存不足", null, 25000, !1);
... ...
packageA/pages/prom_list/prom_list.wxml
... ... @@ -106,7 +106,7 @@
106 106 <view class="fs28 xc-ash-9f">选择门店</view>
107 107 </view>
108 108  
109   - <view class="red-co fs28" bindtap="choice_store" >更多门店<text class="right-arrow"></text></view>
  109 + <view hidden="{{has_def && sys_switch.is_pricing_open_store}}" class="red-co fs28" bindtap="choice_store" >更多门店<text class="right-arrow"></text></view>
110 110 </view>
111 111 <view wx:if="{{only_pk && !only_pk.length}}">(库存不足)</view>
112 112 <block wx:else>
... ...
packageB/pages/zuhegou/index/index.js
... ... @@ -259,8 +259,7 @@ Page({
259 259 th.data.fir_def_store = {}; //赋值空对象
260 260 return false;
261 261 }
262   -
263   -
  262 + th.setData({has_def:1})
264 263  
265 264 var ee = JSON.parse(JSON.stringify(e));
266 265 var appd = getApp().globalData;
... ...
packageB/pages/zuhegou/index/index.wxml
... ... @@ -22,7 +22,7 @@
22 22 <text wx:else bindtap="choose_store">{{def_pick_store.pickup_name}}</text>
23 23 </block>
24 24  
25   - <text wx:else bindtap="choose_store" >请选择门店</text>
  25 + <text hidden="{{has_def && sys_switch.is_pricing_open_store}}" wx:else bindtap="choose_store" >请选择门店</text>
26 26 </view>
27 27  
28 28 <!-- 商品列表 -->
... ...
packageB/pages/zuhegou/preindex/index.js
... ... @@ -260,7 +260,7 @@ Page({
260 260 return false;
261 261 }
262 262  
263   -
  263 + th.setData({has_def:1})
264 264  
265 265 var ee = JSON.parse(JSON.stringify(e));
266 266 var appd = getApp().globalData;
... ...
packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js
... ... @@ -3,6 +3,7 @@ var t = getApp(),
3 3 a = t.request,
4 4 e = require("../../../../utils/common.js"),
5 5 s = require("../../../../utils/util.js"),
  6 + ut=s,
6 7 o = require("../../../../utils/md5.js"),
7 8 to = getApp();
8 9 var oo = t.globalData.setting,
... ... @@ -499,7 +500,7 @@ Page({
499 500 var th = this,
500 501 good = this.data.bn_goods;
501 502 //-----------计算商品总价--------------
502   - var allpice = good.shop_price * good.buynum;
  503 + var allpice = th.data.param.goods_price;
503 504 allpice = parseFloat(allpice).toFixed(2);
504 505 var txt = "formData.all_price";
505 506 th.setData({
... ... @@ -507,77 +508,81 @@ Page({
507 508 });
508 509 console.log(th.data.formData);
509 510  
510   - to.getConfig2(function (ee) {
511   - to.getwuliuprice(async function (rs) {
512   - console.log('calculatePrice2222');
513   - console.log(rs);
  511 +
  512 + to.getwuliuprice(async function (rs) {
  513 +
514 514 var o_shipping_price = 0,
515 515 goods_weight = -1,
516 516 goods_piece = -1;
517 517 var out_of_weight = null; //超出多少重量
518   - var freight_free = ee.freight_free; //全场满多少包邮
519   - var weight_free = ee.weight_free; //多少kg内包邮
520   - var no_ex_id = ee.no_ex_id;
  518 +
521 519 //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格----------
522 520 if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && (th.data.kt_type !=
523 521 3 || th.data.bn_goods.is_normal == 1)) {
524   - switch (good['exp_sum_type']) {
525   - case 1:
526   - //统一运费
527   - o_shipping_price += good['uniform_exp_sum'];
528   - break;
529   - case 2:
530   - if (goods_weight < 0) goods_weight = 0;
531   - //累积商品重量 每种商品的重量 * 数量
532   - goods_weight += good['weight'] * good['buynum'];
533   - if (weight_free > 0) {
534   - out_of_weight = (weight_free * 1000) - goods_weight;
535   - }
536   - break;
537   - case 3:
538   - if (goods_piece < 0) goods_piece = 0;
539   - //累积商品数量
540   - goods_piece += good['buynum'];
541   - break;
542   - }
543 522  
544   - console.log(o_shipping_price + ":" + goods_weight + ":" + goods_piece);
545   - console.log(th.data.wu_arr);
546   - th.data.is_no_by[th.data.bn_pick] = 0;
547   - var no_by_data = null;
  523 + var user_addr=th.data.user_addr;
  524 + var req_d = {
  525 + province: user_addr.province, city: user_addr.city, district: user_addr.district,
  526 + wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid
  527 + }
  528 + var back_data = null;
  529 + await getApp().request.promisePost("/api/weshop/order/areaFreight", {
  530 + is_json: 1, data: req_d
  531 + }).then(rs => {
  532 + if (rs.data.code == 0) back_data = rs.data.data;
  533 + });
  534 +
  535 + var gd_arr_list = [];
  536 + gd_arr_list.push(good);
  537 + var cut_good_weight = 0;
  538 + for (let i in gd_arr_list) {
  539 + let item = gd_arr_list[i];
  540 + if (back_data && back_data['is_by_all'] && !back_data.no_free_goods) {
  541 + continue;
  542 + }
  543 + if (back_data && back_data['is_by_all'] && back_data.no_free_goods.indexOf(item.goods_id) == -1) {
  544 + if (item['exp_sum_type'] == 2) {
  545 + cut_good_weight += item['weight'] * item['buynum'];
  546 + }
  547 + if (back_data.weight_free > 0) {
  548 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  549 + }
  550 + continue;
  551 + }
  552 +
  553 + switch (item['exp_sum_type']) {
  554 + case 1:
  555 + //统一运费
  556 + o_shipping_price += item['uniform_exp_sum'];
  557 + break;
  558 + case 2:
  559 + if (goods_weight < 0) goods_weight = 0;
  560 + //累积商品重量 每种商品的重量 * 数量
  561 + goods_weight += item['weight'] * item['buynum'];
  562 +
  563 + if (back_data && back_data.is_by_all && !back_data.no_free_goods) {
  564 + cut_good_weight += item['weight'] * item['buynum'];
  565 + if (back_data.weight_free > 0) {
  566 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  567 + }
  568 + }
  569 + break;
  570 + case 3:
  571 + if (goods_piece < 0) goods_piece = 0;
  572 + //累积商品数量
  573 + goods_piece += item['buynum'];
  574 + break;
  575 + }
  576 + }
  577 +
  578 + //如果是正值的时候
  579 + if (out_of_weight >= 0) out_of_weight = -cut_good_weight;
  580 + else out_of_weight = -back_data.weight_free * 1000;
  581 +
548 582 var code = th.data.wu_arr[th.data.index].code;
549   - var freight_free = ee.freight_free; //全场满多少包邮
550   -
551   - //有不包邮区域,且不免运费
552   - if (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice)) {
553   - //-----------获取不包邮区域,不包邮商品-------
554   - await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", {
555   - data: { store_id: os.stoid, id: no_ex_id }
556   - }).then(res => {
557   - if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
558   - no_by_data = res.data.data[0];
559   - //如果有设置不包邮区域的时候
560   - if (res.data.data[0].region_list) {
561   - if (th.check_by_area(res.data.data[0].region_list)) {
562   - freight_free = 0;
563   - // out_of_weight = 0;
564   - th.data.is_no_by[th.data.bn_pick] = 1;
565   - }
566   - }
567   - //如果有设置不包邮商品
568   - if (res.data.data[0].goods_list && freight_free) {
569   - if (th.check_by_goods(res.data.data[0].goods_list)) {
570   - freight_free = 0;
571   - // out_of_weight = 0;
572   - th.data.is_no_by[th.data.bn_pick] = 1;
573   - }
574   - }
575   - }
576   - })
577   - }
578 583 var shipping_price =
579   - th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
580   - goods_piece, th.data.user_addr, freight_free, allpice, rs,th.data.bn_pick);
  584 + ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
  585 + goods_piece, th.data.user_addr, back_data,rs);
581 586  
582 587 shipping_price = parseFloat(shipping_price).toFixed(2);
583 588 var wl_txt = "formData.shipping_price";
... ... @@ -628,7 +633,7 @@ Page({
628 633 }
629 634  
630 635 });
631   - });
  636 +
632 637 },
633 638  
634 639  
... ...
packageC/pages/luckyGo/luckyGo_goodsInfo/buy_integral.wxml
... ... @@ -40,7 +40,7 @@
40 40 <view class="fs30" style="color:black;">选择门店</view>
41 41 </view>
42 42  
43   - <view class="red-co fs28" bindtap="choice_store" >
  43 + <view hidden="{{has_def && sys_switch.is_pricing_open_store}}" class="red-co fs28" bindtap="choice_store" >
44 44 更多门店
45 45 <text class="right-arrow"></text>
46 46 </view>
... ...
packageC/pages/luckyGo/luckyGo_goodsInfo/buy_integral_normal.wxml
... ... @@ -42,7 +42,7 @@
42 42 <view class="fs30" style="color:black;">选择门店</view>
43 43 </view>
44 44  
45   - <view class="red-co fs28" bindtap="choice_store" >
  45 + <view hidden="{{has_def && sys_switch.is_pricing_open_store}}" class="red-co fs28" bindtap="choice_store" >
46 46 更多门店
47 47 <text class="right-arrow"></text>
48 48 </view>
... ...
packageC/pages/luckyGo/luckyGo_goodsInfo/buy_pt.wxml
... ... @@ -64,7 +64,7 @@
64 64 <view class="fs28 xc-ash-9f">选择门店</view>
65 65 </view>
66 66  
67   - <view class="red-co fs28" bindtap="choice_store" >
  67 + <view hidden="{{has_def && sys_switch.is_pricing_open_store}}" class="red-co fs28" bindtap="choice_store" >
68 68 更多门店
69 69 <text class="right-arrow"></text>
70 70 </view>
... ...
packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js
... ... @@ -474,6 +474,8 @@ Page({
474 474 th.data.fir_def_store = {}; //赋值空对象
475 475 return false;
476 476 }
  477 +
  478 + th.setData({has_def:1})
477 479 var ee = JSON.parse(JSON.stringify(e));
478 480 //--定时器推迟一下--
479 481 setTimeout(function () {
... ... @@ -1825,7 +1827,9 @@ Page({
1825 1827  
1826 1828 // console.log('11111111111111111111111111======》');
1827 1829 // getApp().goto("/packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart?is_bnow=1&goods_id=" + e.goods_id);
1828   - 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);
  1830 + //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);
  1831 +
  1832 + getApp().goto("/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id)
1829 1833  
1830 1834 })
1831 1835 } else {
... ... @@ -2064,8 +2068,6 @@ Page({
2064 2068 return false;
2065 2069 }
2066 2070  
2067   -
2068   -
2069 2071 if (th.data.more_flash && open_store == 1) {
2070 2072 th.setData({ is_pop_more: 1 });
2071 2073 } else {
... ... @@ -3877,6 +3879,8 @@ Page({
3877 3879 // ind == 1 为普通购买
3878 3880 openSpecModel_pt: function (e) {
3879 3881  
  3882 +
  3883 +
3880 3884 this.setData({ open_ind_store: 9, goodsInputNum: 1 });
3881 3885 // 判断是否有待支付订单
3882 3886 var aid = this.data.group_id;
... ... @@ -3919,7 +3923,6 @@ Page({
3919 3923 var th = this;
3920 3924 var ind = parseInt(e.currentTarget.dataset.ind);
3921 3925  
3922   - console.log('当前ind========>>>>', ind);
3923 3926  
3924 3927 //ind == 1是普通购买
3925 3928 if (ind == 1) {
... ... @@ -5433,7 +5436,13 @@ Page({
5433 5436 var ind = ee.currentTarget.dataset.ind;
5434 5437 var bconfig = th.data.bconfig;
5435 5438  
5436   - if (!th.data.only_pk && !th.data.def_pickpu_list) {
  5439 + //如果开启了,则不在选择门店
  5440 + if(this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){
  5441 + return false;
  5442 + }
  5443 +
  5444 +
  5445 + if (!th.data.only_pk && !th.data.def_pickpu_list) {
5437 5446 getApp().confirmBox("门店库存不足", null, 25000, !1);
5438 5447 return false;
5439 5448 }
... ... @@ -5449,6 +5458,7 @@ Page({
5449 5458 }
5450 5459  
5451 5460  
  5461 +
5452 5462 if (bconfig && bconfig.is_sort_storage) {
5453 5463 wx.getLocation({
5454 5464 type: 'gcj02',
... ...
packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxml
... ... @@ -406,7 +406,7 @@
406 406 <image class="stores-img" src="{{iurl}}/miniapp/images/stores.png"></image>
407 407 <view class="fs30" style="color:black;">选择门店</view>
408 408 </view>
409   - <view class="red_bb fs26">更多门店<text class="bg_jj"></text></view>
  409 + <view hidden="{{has_def && sys_switch.is_pricing_open_store}}" class="red_bb fs26">更多门店<text class="bg_jj"></text></view>
410 410 </view>
411 411 <view wx:if="{{def_pick_store && def_pick_store.pickup_name}}">
412 412 <view class="flex-space-between address ai_end pdv10">
... ... @@ -1115,7 +1115,7 @@
1115 1115 <image class="stores-img" src="{{iurl}}/miniapp/images/stores.png"></image>
1116 1116 <view class="fs30" style="color:black;">选择门店</view>
1117 1117 </view>
1118   - <view class="red-co fs28" bindtap="choice_store">更多门店<text class="right-arrow"></text></view>
  1118 + <view hidden="{{has_def && sys_switch.is_pricing_open_store}}" class="red-co fs28" bindtap="choice_store">更多门店<text class="right-arrow"></text></view>
1119 1119 </view>
1120 1120 <view wx:if="{{only_pk && !only_pk.length}}">(库存不足)</view>
1121 1121 <block wx:else>
... ...
packageC/pages/presell/cart/cart.js
  1 +//这个页面是付尾款
1 2 var t = getApp(), app = t, a = t.request, e = require("../../../../utils/common.js"),
2 3 s = require("../../../../utils/util.js"), ut = s, o = require("../../../../utils/md5.js"), to = getApp();
3 4 var oo = t.globalData.setting, os = oo;
... ... @@ -1717,33 +1718,21 @@ Page({
1717 1718 //----计算物流的钱----
1718 1719 calculate_wuliu() {
1719 1720 var to = getApp(), th = this;
1720   - to.getConfig2(function (ee) {
1721   - to.getwuliuprice(async function (rs) {
  1721 + to.getwuliuprice(async function (rs) {
1722 1722 var o_shipping_price = 0,
1723 1723 goods_weight = -1,
1724 1724 goods_piece = -1,
1725 1725 good = th.data.goods,
1726 1726 quan_price = 0,
1727 1727 exp_price = 0;
1728   - var no_ex_id = ee.no_ex_id;
  1728 +
1729 1729 var quan_no = null;
1730 1730 var bn_pick = th.data.pickup.pickup_id;
1731 1731 var allpice = th.data.all_price;
1732 1732 var out_of_weight = null; //超出多少重量
1733   - var freight_free = ee.freight_free; //全场满多少包邮
1734   - var weight_free = ee.weight_free; //多少kg内包邮
1735   - var no_ex_good = null;
1736   - var by_qc = {};
1737   - if (no_ex_id && freight_free > 0) {
1738   - //-----------获取不包邮区域,不包邮商品-------
1739   - await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", {
1740   - data: { store_id: os.stoid, id: no_ex_id }
1741   - }).then(res => {
1742   - if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
1743   - by_qc = res.data.data[0];
1744   - }
1745   - })
1746   - };
  1733 +
  1734 + good.buynum=th.data.order.order_goods.goods_num;
  1735 +
1747 1736 if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined)
1748 1737 quan_no = th.data.using_quan[bn_pick].coupon_no;
1749 1738  
... ... @@ -1814,59 +1803,74 @@ Page({
1814 1803 if (quan_no && th.data.using_quan[bn_pick].isby == 1) {
1815 1804 exp_price = 0;
1816 1805 } else {
1817   - switch (good['exp_sum_type']) {
1818   - case 1:
1819   - //统一运费
1820   - o_shipping_price += good['uniform_exp_sum'];
1821   - break;
1822   - case 2:
1823   - if (goods_weight < 0) goods_weight = 0;
1824   - //累积商品重量 每种商品的重量 * 数量
1825   - goods_weight += good['weight'] * th.data.order.order_goods['goods_num'];
1826   - if (weight_free > 0) {
1827   - out_of_weight = (weight_free * 1000) - goods_weight;
1828   - }
1829   - break;
1830   - case 3:
1831   - if (goods_piece < 0) goods_piece = 0;
1832   - //累积商品数量
1833   - goods_piece += th.data.order.order_goods['goods_num'];
1834   - break;
  1806 + var user_addr=th.data.user_addr;
  1807 + var req_d = {
  1808 + province: user_addr.province, city: user_addr.city, district: user_addr.district,
  1809 + wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid
1835 1810 }
  1811 + var back_data = null;
  1812 + await getApp().request.promisePost("/api/weshop/order/areaFreight", {
  1813 + is_json: 1, data: req_d
  1814 + }).then(rs => {
  1815 + if (rs.data.code == 0) back_data = rs.data.data;
  1816 + });
  1817 +
  1818 + var gd_arr_list = [];
  1819 + gd_arr_list.push(good);
  1820 +
  1821 + var cut_good_weight = 0;
  1822 + for (let i in gd_arr_list) {
  1823 + let item = gd_arr_list[i];
  1824 + if (back_data && back_data['is_by_all'] && !back_data.no_free_goods) {
  1825 + continue;
  1826 + }
  1827 + if (back_data && back_data['is_by_all'] && back_data.no_free_goods.indexOf(item.goods_id) == -1) {
  1828 + if (item['exp_sum_type'] == 2) {
  1829 + cut_good_weight += item['weight'] * item['buynum'];
  1830 + }
  1831 + if (back_data.weight_free > 0) {
  1832 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  1833 + }
  1834 + continue;
  1835 + }
1836 1836  
1837   - var code = th.data.wu_arr[th.data.index].code;
1838   - th.data.is_no_by[th.data.bn_pick] = 0;
1839   - var no_by_data = null;
1840   - //有不包邮区域,且不免运费
1841   - if (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice)) {
1842   - //-----------获取不包邮区域,不包邮商品-------
1843   - await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", {
1844   - data: { store_id: os.stoid, id: no_ex_id }
1845   - }).then(res => {
1846   - if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
1847   - no_by_data = res.data.data[0];
1848   - //如果有设置不包邮区域的时候
1849   - if (res.data.data[0].region_list) {
1850   - if (th.check_by_area(res.data.data[0].region_list)) {
1851   - freight_free = 0;
1852   - // out_of_weight = 0;
1853   - th.data.is_no_by[th.data.bn_pick] = 1;
1854   - }
1855   - }
1856   - //如果有设置不包邮商品
1857   - if (res.data.data[0].goods_list && freight_free) {
1858   - if (th.check_by_goods(res.data.data[0].goods_list)) {
1859   - freight_free = 0;
1860   - // out_of_weight = 0;
1861   - th.data.is_no_by[th.data.bn_pick] = 1;
  1837 + switch (item['exp_sum_type']) {
  1838 + case 1:
  1839 + //统一运费
  1840 + o_shipping_price += item['uniform_exp_sum'];
  1841 + break;
  1842 + case 2:
  1843 + if (goods_weight < 0) goods_weight = 0;
  1844 + //累积商品重量 每种商品的重量 * 数量
  1845 + goods_weight += item['weight'] * item['buynum'];
  1846 +
  1847 + if (back_data && back_data.is_by_all && !back_data.no_free_goods) {
  1848 + cut_good_weight += item['weight'] * item['buynum'];
  1849 + if (back_data.weight_free > 0) {
  1850 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
1862 1851 }
1863 1852 }
1864   - }
1865   - })
  1853 + break;
  1854 + case 3:
  1855 + if (goods_piece < 0) goods_piece = 0;
  1856 + //累积商品数量
  1857 + goods_piece += item['buynum'];
  1858 + break;
  1859 + }
1866 1860 }
1867   - var shipping_price =
1868   - th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
1869   - goods_piece, th.data.user_addr, freight_free, allpice, rs,th.data.bn_pick);
  1861 +
  1862 + //如果是正值的时候
  1863 + if (out_of_weight >= 0) out_of_weight = -cut_good_weight;
  1864 + else out_of_weight = -back_data.weight_free * 1000;
  1865 +
  1866 +
  1867 + var code = th.data.wu_arr[th.data.index].code;
  1868 + th.data.is_no_by[th.data.bn_pick] = 0;
  1869 +
  1870 + //--------------开始计算物流------------------
  1871 + var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
  1872 + goods_piece, th.data.user_addr, back_data, rs);
  1873 +
1870 1874 exp_price = parseFloat(shipping_price).toFixed(2);
1871 1875 }
1872 1876 th.wuliu_next(allpice, quan_price, exp_price);
... ... @@ -1874,7 +1878,6 @@ Page({
1874 1878 th.wuliu_next(allpice, quan_price, exp_price);
1875 1879 }
1876 1880 });
1877   - });
1878 1881 },
1879 1882 //相同的东西统一在一起
1880 1883 wuliu_next(allpice, quan_price, exp_price) {
... ...
packageC/pages/presell/cart/cart2.js
  1 +//预售全款
1 2 var t = getApp(), app = t, a = t.request, e = require("../../../../utils/common.js"),
2 3 s = require("../../../../utils/util.js"), ut = s, to = getApp();
3 4 var oo = t.globalData.setting, os = oo;
... ... @@ -613,9 +614,7 @@ Page({
613 614  
614 615 var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
615 616 var out_of_weight = null; //超出多少重量
616   - var freight_free = ee.freight_free; //全场满多少包邮
617   - var weight_free = ee.weight_free; //多少kg内包邮
618   - var no_ex_id = ee.no_ex_id;
  617 +
619 618 //---如果有选择优惠券的情况下---
620 619 var quan_price = 0, bn_pick = th.data.bn_pick;
621 620 var quan_no = null;
... ... @@ -673,83 +672,91 @@ Page({
673 672 })
674 673 }
675 674  
676   - switch (good['exp_sum_type']) {
677   - case 1:
678   - //统一运费
679   - o_shipping_price += good['uniform_exp_sum'];
680   - break;
681   - case 2:
682   - if (goods_weight < 0) goods_weight = 0;
683   - //累积商品重量 每种商品的重量 * 数量
684   - goods_weight += good['weight'] * good['buynum'];
685   - if (weight_free > 0) {
686   - out_of_weight = (weight_free * 1000) - goods_weight;
687   - }
688   - break;
689   - case 3:
690   - if (goods_piece < 0) goods_piece = 0;
691   - //累积商品数量
692   - goods_piece += good['buynum'];
693   - break;
694   - }
695   -
696   - var code = "";
697   - if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code;
  675 + var shipping_price =0;
  676 + //-- 在没有使用包邮券的时候 --
  677 + if(!quan_no || !th.data.using_quan[bn_pick].isby) {
698 678  
699   - th.data.is_no_by[th.data.bn_pick] = 0;
  679 + var gd_arr_list = [];
  680 + gd_arr_list.push(good);
  681 + if (th.data.buy_now_gift_goods) {
  682 + gd_arr_list = [...gd_arr_list, ...th.data.buy_now_gift_goods];
  683 + }
700 684  
701   - var no_by_data = null;
702   - var gift_freight_free = freight_free;
  685 + var user_addr=th.data.user_addr;
  686 + var req_d = {
  687 + province: user_addr.province, city: user_addr.city, district: user_addr.district,
  688 + wuliu: parseFloat(parseFloat(allpice) - cut_price - quan_price).toFixed(2), store_id: os.stoid
  689 + }
  690 + var back_data = null;
  691 + await getApp().request.promisePost("/api/weshop/order/areaFreight", {
  692 + is_json: 1, data: req_d
  693 + }).then(rs => {
  694 + if (rs.data.code == 0) back_data = rs.data.data;
  695 + });
703 696  
704   - //有不包邮区域,且不免运费
705   - if (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice) - cut_price - quan_price) {
706   - //-----------获取不包邮区域,不包邮商品-------
707   - await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", {
708   - data: { store_id: os.stoid, id: no_ex_id }
709   - }).then(res => {
710   - if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
711   - no_by_data = res.data.data[0];
712   - //如果有设置不包邮区域的时候
713   - if (res.data.data[0].region_list) {
714   - if (th.check_by_area(res.data.data[0].region_list)) {
715   - freight_free = 0;
716   - // out_of_weight = 0;
717   - // weight_free=-1;
718   - th.data.is_no_by[th.data.bn_pick] = 1;
719   - }
  697 + var cut_good_weight = 0;
  698 + for (let i in gd_arr_list) {
  699 + let item = gd_arr_list[i];
  700 + if (back_data && back_data['is_by_all'] && !back_data.no_free_goods) {
  701 + continue;
  702 + }
  703 + if (back_data && back_data['is_by_all'] && back_data.no_free_goods.indexOf(item.goods_id) == -1) {
  704 + if (item['exp_sum_type'] == 2) {
  705 + cut_good_weight += item['weight'] * item['buynum'];
720 706 }
721   - //如果有设置不包邮商品
722   - if (res.data.data[0].goods_list && freight_free) {
723   - if (th.check_by_goods(res.data.data[0].goods_list)) {
724   - freight_free = 0;
725   - // out_of_weight = 0;
726   - // weight_free=-1;
727   - th.data.is_no_by[th.data.bn_pick] = 1;
728   - }
  707 + if (back_data.weight_free > 0) {
  708 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
729 709 }
  710 + continue;
730 711 }
731   - })
732   - }
733 712  
734   - th.data.is_by[th.data.bn_pick] = 0;
735   - //--------------开始计算物流------------------
736   - var shipping_price =
737   - th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
738   - goods_piece, th.data.user_addr, freight_free, parseFloat(allpice) - cut_price - quan_price, rs,th.data.bn_pick);
  713 + switch (item['exp_sum_type']) {
  714 + case 1:
  715 + //统一运费
  716 + o_shipping_price += item['uniform_exp_sum'];
  717 + break;
  718 + case 2:
  719 + if (goods_weight < 0) goods_weight = 0;
  720 + //累积商品重量 每种商品的重量 * 数量
  721 + goods_weight += item['weight'] * item['buynum'];
  722 +
  723 + if (back_data && back_data.is_by_all && !back_data.no_free_goods) {
  724 + cut_good_weight += item['weight'] * item['buynum'];
  725 + if (back_data.weight_free > 0) {
  726 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  727 + }
  728 + }
  729 + break;
  730 + case 3:
  731 + if (goods_piece < 0) goods_piece = 0;
  732 + //累积商品数量
  733 + goods_piece += item['buynum'];
  734 + break;
  735 + }
  736 + }
  737 +
  738 + //如果是正值的时候
  739 + if (out_of_weight >= 0) out_of_weight = -cut_good_weight;
  740 + else out_of_weight = -back_data.weight_free * 1000;
739 741  
740   - //如果有赠品的时候,也要计算赠品的物流费用
741   - if (th.data.buy_now_gift_goods) {
742   - 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,
743   - parseFloat(allpice) - cut_price - quan_price, rs, shipping_price, no_by_data, goods_weight, goods_piece,th.data.bn_pick);
744   - }
745 742  
746   - if (shipping_price <= 0) {
747   - th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券
  743 + var code = "";
  744 + if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code;
  745 +
  746 + //--------------开始计算物流------------------
  747 + var shipping_price =
  748 + ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
  749 + goods_piece, th.data.user_addr, back_data, rs);
  750 +
  751 +
  752 + if (shipping_price <= 0) {
  753 + th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券
  754 + }
748 755 }
749 756  
750 757 shipping_price = parseFloat(shipping_price).toFixed(2);
751 758 var wl_txt = "formData.shipping_price";
752   - th.setData({ [wl_txt]: shipping_price, })
  759 + th.setData({[wl_txt]: shipping_price,})
753 760  
754 761 } else {
755 762 var wl_txt = "formData.shipping_price";
... ... @@ -1682,79 +1689,6 @@ Page({
1682 1689 th.setData({ js_use_money: !th.data.js_use_money });
1683 1690 th.calculatePrice();
1684 1691 },
1685   - //-------------------计算物流---------------
1686   - calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight,
1687   - goods_piece, user_addr, freight_free, o_price, rs,pickid) {
1688   - var price = 0, th = this;
1689   - price += parseFloat(o_shipping_price);
1690   - //如果是包邮
1691   - if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) {
1692   - return 0;
1693   - }
1694   - if (user_addr == null) {
1695   - return 0;
1696   - }
1697   - //计算物流的config item;
1698   - var item = null;
1699   - //先根据 镇 县 区找计算的config
1700   - item = th.get_wuliu_config(user_addr.district, code, rs);
1701   - if (item == null) item = th.get_wuliu_config(user_addr.city, code, rs);
1702   - if (item == null) item = th.get_wuliu_config(user_addr.province, code, rs);
1703   - if (item == null) item = th.get_wuliu_default(code, rs);
1704   - if (item == null) return o_shipping_price;
1705   - var fw_price = 0, fp_price = 0;
1706   - item = item.config;
1707   - if (item == null) return o_shipping_price;
1708   - //------按重量----------
1709   - if (goods_weight >= 0 && item['money']) {
1710   - fw_price = parseFloat(item['money']);
1711   - if (goods_weight > item['first_weight']) {
1712   - var fw = goods_weight - item['first_weight'];
1713   - var n = Math.ceil(fw / item['second_weight'])
1714   - fw_price = fw_price + n * parseFloat(item['add_money']);
1715   - }
1716   - }
1717   -
1718   - //------超出重量----------
1719   - if (out_of_weight < 0 && o_price >= freight_free && !th.data.is_no_by[pickid]) {
1720   - fw_price = parseFloat(item['money']);
1721   - var out_of_weight = Math.abs(out_of_weight);
1722   - var n = Math.ceil(out_of_weight / item['second_weight'])
1723   - fw_price = fw_price + n * parseFloat(item['add_money']);
1724   - }
1725   - //------按件数----------
1726   - if (goods_piece > 0 && item['piecemoney']) {
1727   - fp_price = parseFloat(item['piecemoney']);
1728   - if (goods_piece > item['first_piece']) {
1729   - var fp = goods_piece - item['first_piece'];
1730   - var m = Math.ceil(fp / item['second_piece'])
1731   - fp_price = fp_price + m * parseFloat(item['add_piecemoney']);
1732   - }
1733   - }
1734   - var rspice = parseFloat(price + fw_price + fp_price);
1735   - return rspice;
1736   - },
1737   -
1738   - //------------循环获取config-----------
1739   - get_wuliu_config: function (region_id, code, rs) {
1740   - var item = null, rslist = rs.pageData;
1741   - for (var i = 0; i < rslist.length; i++) {
1742   - if (rslist[i].code == code && rslist[i].region_id == region_id) {
1743   - item = rslist[i];
1744   - }
1745   - }
1746   - return item;
1747   - },
1748   - //-------循环获取config,code default-------
1749   - get_wuliu_default: function (code, rs) {
1750   - var item = null, rslist = rs.pageData;
1751   - for (var i = 0; i < rslist.length; i++) {
1752   - if (rslist[i].shipping_code == code && rslist[i].is_default == 1) {
1753   - item = rslist[i];
1754   - }
1755   - }
1756   - return item;
1757   - },
1758 1692  
1759 1693 //----------立即购买,选择物流-------------
1760 1694 bindPickerChange: function (e) {
... ... @@ -2552,62 +2486,6 @@ Page({
2552 2486 }
2553 2487 },
2554 2488  
2555   - //计算立即购买赠品的物流费用
2556   - 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) {
2557   - var good = this.data.buy_now_gift_goods;
2558   - var goods_weight = -1, goods_piece = -1;
2559   - var gift_shipping_price = 0;
2560   - var th = this;
2561   - switch (good['exp_sum_type']) {
2562   - case 1:
2563   - //统一运费
2564   - gift_shipping_price += good['uniform_exp_sum'];
2565   - gift_shipping_price += o_shipping_price;
2566   - break;
2567   - case 2:
2568   - if (goods_weight < 0) goods_weight = 0;
2569   - //累积商品重量 每种商品的重量 * 数量
2570   - goods_weight += good['weight'] * good['buynum'];
2571   - if (goods_weight1 > 0) {
2572   - out_of_weight = gift_weight_free - goods_weight;
2573   - //不能调换位置 下面goods_weight会变大
2574   - goods_weight += goods_weight1;
2575   - }
2576   - break;
2577   - case 3:
2578   - if (goods_piece < 0) goods_piece = 0;
2579   - //累积商品数量
2580   - goods_piece += good['buynum'];
2581   - if (goods_piece1) {
2582   - goods_piece += goods_piece1;
2583   - }
2584   - break;
2585   - }
2586   -
2587   -
2588   - //如果有设置不包邮区域的时候
2589   - if (no_by_data && no_by_data.region_list) {
2590   - if (th.check_by_area(no_by_data.region_list)) {
2591   - gift_freight_free = 0;
2592   - // out_of_weight = 0;
2593   - th.data.is_no_by[th.data.bn_pick] = 1;
2594   - }
2595   - }
2596   - //如果有设置不包邮商品
2597   - if (no_by_data && no_by_data.goods_list && gift_freight_free) {
2598   - if (th.check_by_goods(no_by_data.goods_list, good.goods_id)) {
2599   - gift_freight_free = 0;
2600   - // out_of_weight = 0;
2601   - th.data.is_no_by[th.data.bn_pick]=1;
2602   - }
2603   - }
2604   -
2605   - var t_shipping_price =
2606   - this.calculatewuliu(code, gift_shipping_price, goods_weight, out_of_weight,
2607   - goods_piece, user_addr, gift_freight_free, allpice, rs,th.data.bn_pick);
2608   - return t_shipping_price;
2609   -
2610   - },
2611 2489  
2612 2490 //从优惠的映射中拿出商品从表的item
2613 2491 item_map_get_goods: function (goods_id, map) {
... ...
packageC/pages/presell/cart/cart2_pre.js
  1 +//预付定金
1 2 var t = getApp(), app = t, a = t.request, ut = require("../../../../utils/util.js");
2 3 var os = t.globalData.setting;
3 4 var regeneratorRuntime = require('../../../../utils/runtime.js');
... ... @@ -340,34 +341,74 @@ Page({
340 341 th.setData({ [txt]: allpice, });
341 342 console.log(th.data.formData);
342 343  
343   - app.getConfig2(function (ee) {
344   - app.getwuliuprice(function (rs) {
  344 + app.getwuliuprice(async function (rs) {
345 345 var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
346 346 var out_of_weight = null; //超出多少重量
347   - var freight_free = ee.freight_free; //全场满多少包邮
348   - var weight_free = ee.weight_free; //多少kg内包邮
349   - var no_ex_id = ee.no_ex_id;
  347 +
350 348 //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格----------
351 349 if (th.data.user_addr != null && th.data.bn_exp_type == 0
352 350 && good.is_free_shipping == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) {
353   - switch (good['exp_sum_type']) {
354   - case 1:
355   - //统一运费
356   - o_shipping_price += good['uniform_exp_sum']; break;
357   - case 2:
358   - if (goods_weight < 0) goods_weight = 0;
359   - //累积商品重量 每种商品的重量 * 数量
360   - goods_weight += good['weight'] * good['buynum'];
361   - if (weight_free > 0) {
362   - out_of_weight = (weight_free * 1000) - goods_weight;
  351 +
  352 + var user_addr=th.data.user_addr;
  353 + var req_d = {
  354 + province: user_addr.province, city: user_addr.city, district: user_addr.district,
  355 + wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid
  356 + }
  357 + var back_data = null;
  358 + await getApp().request.promisePost("/api/weshop/order/areaFreight", {
  359 + is_json: 1, data: req_d
  360 + }).then(rs => {
  361 + if (rs.data.code == 0) back_data =rs.data.data;
  362 + });
  363 +
  364 + var gd_arr_list = [];
  365 + gd_arr_list.push(good);
  366 + var cut_good_weight = 0;
  367 + for (let i in gd_arr_list) {
  368 + let item = data[i];
  369 + if (back_data && back_data['is_by_all'] && !back_data.no_free_goods) {
  370 + continue;
  371 + }
  372 + if (back_data && back_data['is_by_all'] && back_data.no_free_goods.indexOf(item.goods_id) == -1) {
  373 + if (item['exp_sum_type'] == 2) {
  374 + cut_good_weight += item['weight'] * item['buynum'];
363 375 }
364   - break;
365   - case 3:
366   - if (goods_piece < 0) goods_piece = 0;
367   - //累积商品数量
368   - goods_piece += good['buynum']; break;
  376 + if (back_data.weight_free > 0) {
  377 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  378 + }
  379 + continue;
  380 + }
  381 +
  382 + switch (item['exp_sum_type']) {
  383 + case 1:
  384 + //统一运费
  385 + o_shipping_price += item['uniform_exp_sum'];
  386 + break;
  387 + case 2:
  388 + if (goods_weight < 0) goods_weight = 0;
  389 + //累积商品重量 每种商品的重量 * 数量
  390 + goods_weight += item['weight'] * item['buynum'];
  391 +
  392 + if (back_data && back_data.is_by_all && !back_data.no_free_goods) {
  393 + cut_good_weight += item['weight'] * item['buynum'];
  394 + if (back_data.weight_free > 0) {
  395 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  396 + }
  397 + }
  398 + break;
  399 + case 3:
  400 + if (goods_piece < 0) goods_piece = 0;
  401 + //累积商品数量
  402 + goods_piece += item['buynum'];
  403 + break;
  404 + }
369 405 }
370 406  
  407 + //如果是正值的时候
  408 + if (out_of_weight >= 0) out_of_weight = -cut_good_weight;
  409 + else out_of_weight = -back_data.weight_free * 1000;
  410 +
  411 +
371 412 var code = th.data.wu_arr[th.data.index].code;
372 413 var shipping_price =
373 414 th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
... ... @@ -405,7 +446,7 @@ Page({
405 446 }
406 447  
407 448 });
408   - });
  449 +
409 450 },
410 451  
411 452 // -- 支付的下一步 --
... ...
packageC/pages/presell/goodsInfo/goodsInfo.js
... ... @@ -679,6 +679,8 @@ Page({
679 679 th.data.fir_def_store = {}; //赋值空对象
680 680 return false;
681 681 }
  682 + th.setData({has_def:1})
  683 +
682 684 var ee = JSON.parse(JSON.stringify(e));
683 685  
684 686 if (th.data.fir_goods) var g_distr_type = th.data.fir_goods.distr_type;
... ... @@ -3206,6 +3208,11 @@ Page({
3206 3208 var ind = ee.currentTarget.dataset.ind;
3207 3209 var bconfig = th.data.bconfig;
3208 3210  
  3211 + //如果开启了,则不在选择门店
  3212 + if(this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){
  3213 + return false;
  3214 + }
  3215 +
3209 3216 if (!th.data.only_pk && !th.data.def_pickpu_list) {
3210 3217 getApp().confirmBox("门店库存不足", null, 25000, !1);
3211 3218 return false;
... ...
packageC/pages/presell/goodsInfo/goodsInfo.wxml
... ... @@ -154,7 +154,7 @@
154 154 <image class="stores-img" src="{{iurl}}/miniapp/images/stores.png"></image>
155 155 <view class="fs30" style="color:black;">选择门店</view>
156 156 </view>
157   - <view class="red_bb fs26">更多门店<text class="bg_jj"></text></view>
  157 + <view hidden="{{has_def && sys_switch.is_pricing_open_store}}" class="red_bb fs26">更多门店<text class="bg_jj"></text></view>
158 158 </view>
159 159 <view wx:if="{{def_pick_store && def_pick_store.pickup_name}}">
160 160 <view class="flex-space-between address ai_end pdv10">
... ... @@ -602,7 +602,7 @@
602 602 <image class="stores-img" src="{{iurl}}/miniapp/images/stores.png"></image>
603 603 <view class="fs30" style="color:black;">选择门店</view>
604 604 </view>
605   - <view class="red-co fs28" bindtap="choice_store">更多门店<text class="right-arrow"></text></view>
  605 + <view hidden="{{has_def && sys_switch.is_pricing_open_store}}" class="red-co fs28" bindtap="choice_store">更多门店<text class="right-arrow"></text></view>
606 606 </view>
607 607 <view wx:if="{{only_pk && !only_pk.length}}">(库存不足)</view>
608 608 <block wx:else>
... ...
packageC/pages/presell/pregoodsInfo/goodsInfo.js
... ... @@ -675,6 +675,9 @@ Page({
675 675 th.data.fir_def_store = {}; //赋值空对象
676 676 return false;
677 677 }
  678 +
  679 + th.setData({has_def:1})
  680 +
678 681 var ee = JSON.parse(JSON.stringify(e));
679 682  
680 683 if (th.data.fir_goods) var g_distr_type = th.data.fir_goods.distr_type;
... ... @@ -3174,6 +3177,11 @@ Page({
3174 3177 var ind = ee.currentTarget.dataset.ind;
3175 3178 var bconfig = th.data.bconfig;
3176 3179  
  3180 + //如果开启了,则不在选择门店
  3181 + if(this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){
  3182 + return false;
  3183 + }
  3184 +
3177 3185 if (!th.data.only_pk && !th.data.def_pickpu_list) {
3178 3186 getApp().confirmBox("门店库存不足", null, 25000, !1);
3179 3187 return false;
... ...
packageC/pages/presell/pregoodsInfo/goodsInfo.wxml
... ... @@ -154,7 +154,7 @@
154 154 <image class="stores-img" src="{{iurl}}/miniapp/images/stores.png"></image>
155 155 <view class="fs30" style="color:black;">选择门店</view>
156 156 </view>
157   - <view class="red_bb fs26">更多门店<text class="bg_jj"></text></view>
  157 + <view hidden="{{has_def && sys_switch.is_pricing_open_store}}" class="red_bb fs26">更多门店<text class="bg_jj"></text></view>
158 158 </view>
159 159 <view wx:if="{{def_pick_store && def_pick_store.pickup_name}}">
160 160 <view class="flex-space-between address ai_end pdv10">
... ... @@ -596,7 +596,7 @@
596 596 <image class="stores-img" src="{{iurl}}/miniapp/images/stores.png"></image>
597 597 <view class="fs30" style="color:black;">选择门店</view>
598 598 </view>
599   - <view class="red-co fs28" bindtap="choice_store">更多门店<text class="right-arrow"></text></view>
  599 + <view hidden="{{has_def && sys_switch.is_pricing_open_store}}" class="red-co fs28" bindtap="choice_store">更多门店<text class="right-arrow"></text></view>
600 600 </view>
601 601 <view wx:if="{{only_pk && !only_pk.length}}">(库存不足)</view>
602 602 <block wx:else>
... ...
pages/cart/cart2/cart2.js
... ... @@ -1457,8 +1457,7 @@ Page({
1457 1457 //-------------------计算订单价格-------------------
1458 1458 calculatePrice: function (t, s) {
1459 1459 var th = this;
1460   - to.getConfig2(function (ee) {
1461   - to.getwuliuprice(async function (rs) {
  1460 + to.getwuliuprice(async function (rs) {
1462 1461 wx.showLoading({ title: "处理中." })
1463 1462 //是不是区域包邮
1464 1463 th.data.is_area_by = 0;
... ... @@ -1480,24 +1479,7 @@ Page({
1480 1479 var all_order_prom = 0; //所有的订单优惠
1481 1480  
1482 1481 var umoney = th.data.userinfo.user_money - th.data.txmon - (th.data.userinfo.frozen_money ? th.data.userinfo.frozen_money : 0);
1483   - var freight_free = ee.freight_free; //全场满多少包邮
1484   - var free1 = freight_free;
1485   -
1486   - var weight_free = ee.weight_free; //多少kg内包邮
1487   - var no_ex_id = ee.no_ex_id;
1488   - var no_ex_good = null;
1489   - var by_qc = {};
1490 1482 var out_of_weight = 0; //超出多少重量
1491   - if (no_ex_id && freight_free > 0) {
1492   - //-----------获取不包邮区域,不包邮商品-------
1493   - await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", {
1494   - data: { store_id: os.stoid, id: no_ex_id }
1495   - }).then(res => {
1496   - if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
1497   - by_qc = res.data.data[0];
1498   - }
1499   - })
1500   - };
1501 1483 var c_arr = JSON.parse(JSON.stringify(th.data.old_cartlist));
1502 1484  
1503 1485 if (th.data.cartlist && th.data.cartlist.length > 0) {
... ... @@ -1646,84 +1628,8 @@ Page({
1646 1628  
1647 1629 th.data.is_no_past = 1; //不包邮标识符
1648 1630  
1649   - var no_ex_good_arr = null;
1650   - //--有不包邮区域,且不免运费,全场的计算,要减到优惠金额 和券的金额--
1651   - 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)) {
1652   - //如果有设置不包邮区域的时候
1653   - if (by_qc.region_list != "" && by_qc.region_list != null && by_qc.region_list != undefined) {
1654   - if (th.check_by_area(by_qc.region_list)) {
1655   - freight_free = 0;
1656   - th.data.is_area_by = 1;
1657   - //goods_weight = -1;
1658   - //out_of_weight = 0;
1659   - th.data.is_no_by[pickid] = 1;
1660   - }
1661   - }
1662   - //如果有设置不包邮区商品
1663   - if (by_qc.goods_list != "" && by_qc.goods_list != undefined && by_qc != null && freight_free > 0) {
1664   - freight_free = 0;
1665   - //goods_weight = -1;
1666   - //out_of_weight = 0;
1667   - //th.data.is_no_by[pickid] = 1;
1668   - no_ex_good = by_qc.goods_list;
1669   - if (no_ex_good) no_ex_good_arr = no_ex_good.split(',');
1670   - }
1671   - }
1672   -
1673   -
1674   -
1675   - var is_in_no_ex_goods_arr = 0;
1676   - var by_g_weight = 0;
1677   - //--------循环计算商品总物流-----------
1678   - for (var jo = 0; jo < item.length; jo++) {
1679   - //----------------如果是选择了物流---------------------
1680   - if (cart_item.exp_type == 0 && item[jo].is_free_shipping == 0 && th.data.user_addr != null) {
1681   -
1682   - //判断是否有设置限制重量包邮,先看商品有没有包邮
1683   - if (!no_ex_good_arr || no_ex_good_arr.indexOf(item[jo].goods_id + '') == -1) {
1684   - if (!th.data.is_area_by) th.data.free1 = free1;
1685   - //此时是 模板里面没有不包邮商品列表或者是 该商品没有再不包邮商品列表礼包
1686   - if (item[jo]['is_past'] !== 1 && item[jo]['exp_sum_type'] == 2) {
1687   - if (goods_weight < 0) goods_weight = 0;
1688   - //累积商品重量 每种商品的重量 * 数量
1689   - goods_weight += item[jo]['weight'] * item[jo]['goods_num'];
1690   - by_g_weight += item[jo]['weight'] * item[jo]['goods_num'];
1691   -
1692   - if (free1 > 0) {
1693   - if (weight_free > 0) {
1694   - out_of_weight = (weight_free * 1000) - by_g_weight;
1695   - } else {
1696   - out_of_weight = -by_g_weight;
1697   - }
1698   - }
1699   -
1700   - }
1701   - }
1702   - //这个是在不包邮列表礼包
1703   - else if (no_ex_good_arr.indexOf(item[jo].goods_id + '') > -1) {
1704   - is_in_no_ex_goods_arr = 1;
1705   - if (item[jo]['is_past'] !== 1 && item[jo]['exp_sum_type'] == 2) {
1706   - if (goods_weight < 0) goods_weight = 0;
1707   - //累积商品重量 每种商品的重量 * 数量
1708   - goods_weight += item[jo]['weight'] * item[jo]['goods_num'];
1709   - }
1710   -
1711   - }
1712   - }
1713   - }
1714   -
1715   - if (free1 > 0) {
1716   - //当商品没有超出的时候
1717   - if (out_of_weight >= 0) {
1718   - out_of_weight = -by_g_weight;
1719   - } else {
1720   - if (weight_free > 0) out_of_weight = -weight_free * 1000;
1721   - }
1722   - }
1723   -
1724   - //所有的商品都不在不包邮商品列表,freight_free为0的时候,以及不是区域包邮
1725   - if (!is_in_no_ex_goods_arr && !freight_free && !th.data.is_area_by) freight_free = free1;
1726   -
  1631 + var back_data = null;
  1632 + var quan_no_goods_arr=null;
1727 1633 //--如果是物流,且选择了地址,就要开始显示包邮券,且包邮券也已经优惠了优惠活动的金额--
1728 1634 if (cart_item.exp_type == 0 && th.data.user_addr != null && !cart_item.is_xz_yh) {
1729 1635 //看是不是有调用过包邮券
... ... @@ -1768,104 +1674,117 @@ Page({
1768 1674 }
1769 1675 })
1770 1676 }
  1677 +
  1678 + var user_addr=th.data.user_addr;
  1679 + var req_d = {
  1680 + province: user_addr.province, city: user_addr.city, district: user_addr.district,
  1681 + wuliu:parseFloat(o_price - quan_price).toFixed(2),store_id: os.stoid
  1682 + }
  1683 + await getApp().request.promisePost("/api/weshop/order/areaFreight", {
  1684 + is_json: 1, data: req_d
  1685 + }).then(rs => {
  1686 + if (rs.data.code == 0) back_data =rs.data.data;
  1687 + });
  1688 +
1771 1689 }
1772 1690  
  1691 +
1773 1692 //如果是包邮券的时候,要看看券的情况
1774 1693 if (quan_no && th.data.using_quan[pickid].isby == 1) {
1775 1694 var quan = th.data.using_quan[pickid];
1776 1695 if (!quan.goods_list) {
1777 1696 th.data.is_quan_by[pickid] = 1; //专门给券的判断用的
1778 1697 } else {
1779   - th.data.is_quan_by[pickid] = 0;
1780   - //看有没有模板的包邮
1781   - if (no_ex_good) {
1782   - var arr = no_ex_good.split(",");
1783   - var arr2 = quan.goods_list.split(",");
1784   - if (ut.isContained(arr, arr2)) {
1785   - getApp().my_warnning("全场不包邮商品和包邮券的重复", 0, th);
1786   - th.data.using_quan[pickid] = {};
1787   - th.setData({ using_quan: th.data.using_quan })
1788   - return false;
1789   - }
1790   - var n_arr = ut.mergeArray(arr, arr2);
1791   - no_ex_good = n_arr.join(",");
1792   - } else {
1793   - no_ex_good = quan.goods_list;
1794   - }
  1698 + th.data.is_quan_by[pickid] = 0;
  1699 + quan_no_goods_arr = quan.goods_list.split(",");
  1700 +
1795 1701 }
1796 1702 } else {
1797 1703 th.data.is_quan_by[pickid] = 0; //专门给券的判断用的
1798 1704 }
1799 1705  
1800   - //--------循环计算总价-----------
1801   - for (var j = 0; j < item.length; j++) {
1802   - //如果都包邮,都没必要等级数量了
1803   - if (th.data.is_quan_by[pickid]) continue;
1804   - //如果是优惠活动是包邮,就不用计算包邮的费用了
1805   - if (item[j].is_past) continue;
1806   - //是不是不包邮的商品
1807   - var is_good_no_by = 0;
1808   - if (no_ex_good) {
1809   - is_good_no_by = th.check_by_goods(no_ex_good, item[j].goods_id);
  1706 + var cut_good_weight=0;
  1707 + //计算物流价格
  1708 + if (cart_item.exp_type == 0 && th.data.user_addr && !th.data.is_quan_by[pickid]) {
  1709 +
  1710 + //如果有包邮券的不包邮商品的时候
  1711 + if(quan_no_goods_arr) {
  1712 + if (back_data && back_data.no_free_goods) {
  1713 + back_data['is_by_all']=1;
  1714 + var arr3 = back_data.no_free_goods.filter(item => {
  1715 + return quan_no_goods_arr.includes(item)
  1716 + })
  1717 + back_data.no_free_goods = null;
  1718 + if (arr3.length) {
  1719 + back_data.no_free_goods = arr3;
  1720 + }
  1721 + }
  1722 + if (!back_data || !back_data.no_free_goods) {
  1723 + if (!back_data) back_data={};
  1724 + back_data['is_by_all']=1;
  1725 + back_data['no_free_goods']=quan_no_goods_arr;
  1726 + }
1810 1727 }
1811 1728  
1812   - //--如果是包邮券使用的情况下,如果商品是包邮的,那么就不进行计算--
1813   - if (th.data.using_quan[pickid] && th.data.using_quan[pickid].isby == 1 && !is_good_no_by) {
1814   - continue;
1815   - }
  1729 + //--------循环计算总价-----------
  1730 + for (var j = 0; j < item.length; j++) {
1816 1731  
1817   - //var no_ex_good_arr = null;
1818   - //if (no_ex_good) no_ex_good_arr = no_ex_good.split(',');
1819   - //----------------如果是选择了物流---------------------
1820   - if (cart_item.exp_type == 0 && item[j].is_free_shipping == 0) {
1821   - //如果地址不为空
1822   - if (th.data.user_addr != null) {
1823   - switch (item[j]['exp_sum_type']) {
1824   - case 1:
1825   - //统一运费
1826   - o_shipping_price += item[j]['uniform_exp_sum'];
1827   - break;
1828   - case 3:
1829   - if (goods_piece < 0) goods_piece = 0;
1830   - //累积商品数量
1831   - goods_piece += item[j]['goods_num'];
1832   - break;
  1732 + //如果商品本身是包邮了
  1733 + if(item[j].is_free_shipping == 1) continue;
  1734 + //如果是优惠活动是包邮,就不用计算包邮的费用了
  1735 + if (item[j].is_past) continue;
  1736 + //--如果是包邮券使用的情况下,如果商品是包邮的,那么就不进行计算--
  1737 + if (th.data.using_quan[pickid] && th.data.using_quan[pickid].isby == 1 && th.data.is_quan_by[pickid]) {
  1738 + continue;
  1739 + }
  1740 + if (back_data && back_data['is_by_all'] && !back_data.no_free_goods) {
  1741 + continue;
  1742 + }
  1743 + if (back_data && back_data['is_by_all'] && back_data.no_free_goods.indexOf(item[j].goods_id) == -1) {
  1744 + if (item[j]['exp_sum_type'] == 2) {
  1745 + cut_good_weight += item[j]['weight'] * item[j]['goods_num'];
  1746 + }
  1747 + if (back_data.weight_free > 0) {
  1748 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
1833 1749 }
  1750 + continue;
1834 1751 }
1835 1752  
  1753 + switch (item[j]['exp_sum_type']) {
  1754 + case 1:
  1755 + //统一运费
  1756 + o_shipping_price += item[j]['uniform_exp_sum'];
  1757 + break;
  1758 + case 2:
  1759 + if (goods_weight < 0) goods_weight = 0;
  1760 + //累积商品重量 每种商品的重量 * 数量
  1761 + goods_weight += item[j]['weight'] * item[j]['goods_num'];
1836 1762  
1837   - if (!no_ex_good_arr || no_ex_good_arr.indexOf(item[j].goods_id + '') == -1) {
1838   - switch (item[j]['exp_sum_type']) {
1839   - case 1:
1840   - //统一运费
1841   - th.data.cut_o_shipping_price += item[j]['uniform_exp_sum'];
1842   - break;
1843   - case 3:
1844   - //累积商品数量
1845   - th.data.cut_goods_piece += item[j]['goods_num'];
1846   - break;
1847   - }
  1763 + if (back_data && back_data.is_by_all && !back_data.no_free_goods) {
  1764 + cut_good_weight += item[j]['weight'] * item[j]['goods_num'];
  1765 + if (back_data.weight_free > 0) {
  1766 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  1767 + }
  1768 + }
  1769 + break;
  1770 + case 3:
  1771 + if (goods_piece < 0) goods_piece = 0;
  1772 + //累积商品数量
  1773 + goods_piece += item[j]['goods_num'];
  1774 + break;
1848 1775 }
1849 1776  
1850   -
1851   - } else {
1852   - /*--
1853   - if(item[j]['exp_sum_type']==2 && out_of_weight!==0){
1854   - goods_weight = -1;
1855   - out_of_weight = 0;
1856   - }--*/
1857 1777 }
1858   - }
1859 1778  
1860   - //计算物流价格
1861   - if (cart_item.exp_type == 0) {
1862   - //freight_free=0; //后面不在进行判断
  1779 + //如果是正值的时候
  1780 + if (out_of_weight >= 0) out_of_weight = -cut_good_weight;
  1781 + else out_of_weight = -back_data.weight_free * 1000;
  1782 +
1863 1783 var code = "";
1864 1784 if (th.data.wu_arr && th.data.wu_arr[cart_item.wind])
1865 1785 code = th.data.wu_arr[cart_item.wind].code;
1866 1786 cart_item.shipping_price =
1867   - th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
1868   - goods_piece, th.data.user_addr, freight_free, o_price - quan_price, rs, pickid);
  1787 + ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,goods_piece, th.data.user_addr, back_data, rs);
1869 1788  
1870 1789 if (!th.data.using_quan[pickid] || th.data.using_quan[pickid].isby != 1) {
1871 1790 if (cart_item.shipping_price == 0) th.data.is_by[pickid] = 1; //已经全场包邮,就不要选择券了
... ... @@ -1875,7 +1794,6 @@ Page({
1875 1794 }
1876 1795  
1877 1796 cart_item.shipping_price = cart_item.shipping_price.toFixed(2);
1878   -
1879 1797 //总价计算,总价不包含运费
1880 1798 cart_item.order_amount = (o_price - quan_price).toFixed(2);
1881 1799 cart_item.total_amount = f_o_price.toFixed(2);
... ... @@ -2017,7 +1935,6 @@ Page({
2017 1935 wx.hideLoading();
2018 1936  
2019 1937 });
2020   - });
2021 1938 },
2022 1939  
2023 1940 set_can_num: function () {
... ... @@ -2089,15 +2006,10 @@ Page({
2089 2006 allpice = good.offline_price * good.buynum;
2090 2007 }
2091 2008  
2092   -
2093   - to.getConfig2(function (ee) {
2094   - to.getwuliuprice(async function (rs) {
  2009 + to.getwuliuprice(async function (rs) {
2095 2010  
2096 2011 var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
2097 2012 var out_of_weight = null; //超出多少重量
2098   - var freight_free = ee.freight_free; //全场满多少包邮
2099   - var weight_free = ee.weight_free; //多少kg内包邮
2100   - var no_ex_id = ee.no_ex_id;
2101 2013  
2102 2014 //---如果有选择优惠券的情况下---
2103 2015 var quan_price = 0, bn_pick = th.data.bn_pick;
... ... @@ -2123,6 +2035,12 @@ Page({
2123 2035 }
2124 2036 }
2125 2037  
  2038 + var gd_arr_list = [];
  2039 + gd_arr_list.push(good);
  2040 + if (th.data.buy_now_gift_goods) {
  2041 + gd_arr_list = [...gd_arr_list, ...th.data.buy_now_gift_goods];
  2042 + }
  2043 +
2126 2044 //-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮----------
2127 2045 if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && good.is_past != 1) {
2128 2046 //看是不是有调用过包邮券
... ... @@ -2145,7 +2063,10 @@ Page({
2145 2063 for (var i in quanlist) {
2146 2064 var item = quanlist[i];
2147 2065 if (item.region_list && th.check_by_area(item.region_list)) continue; //如果是不包邮区域
2148   - if (item.goods_list && th.check_by_goods(item.goods_list)) continue; //如果是不包邮商品
  2066 + if (item.goods_list) {
  2067 + var no_goods_arr = item.goods_list.split(",");
  2068 + if (ut.isContained(no_goods_arr, gd_arr_list)) continue; //如果是不包邮商品
  2069 + }
2149 2070 arr.push(item);
2150 2071 }
2151 2072 if (arr) {
... ... @@ -2156,83 +2077,116 @@ Page({
2156 2077 })
2157 2078 }
2158 2079  
2159   - switch (good['exp_sum_type']) {
2160   - case 1:
2161   - //统一运费
2162   - o_shipping_price += good['uniform_exp_sum'];
2163   - break;
2164   - case 2:
2165   - if (goods_weight < 0) goods_weight = 0;
2166   - //dw
2167   - //累积商品重量 每种商品的重量 * 数量
2168   - goods_weight += good['weight'] * good['buynum'];
2169   - if (weight_free > 0) {
2170   - out_of_weight = (weight_free * 1000) - goods_weight;
  2080 + var shipping_price =0;
  2081 + var quan_no_goods_arr=null;
  2082 + var is_by_quan=0;
  2083 +
  2084 + //如果是包邮券的时候,要看看券的情况,判断一下包邮有没有不包邮模板
  2085 + if (quan_no && th.data.using_quan[pickid].isby == 1) {
  2086 + var quan = th.data.using_quan[pickid];
  2087 + if (quan.goods_list) {
  2088 + quan_no_goods_arr=quan.goods_list.split(",");
  2089 + }else{
  2090 + is_by_quan=1;
2171 2091 }
2172   - break;
2173   - case 3:
2174   - if (goods_piece < 0) goods_piece = 0;
2175   - //累积商品数量
2176   - goods_piece += good['buynum'];
2177   - break;
2178   - }
2179   -
2180   - var code = "";
2181   - if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code;
2182   -
2183   - th.data.is_no_by[th.data.bn_pick] = 0;
2184   -
2185   - var no_by_data = null;
2186   - var gift_freight_free = freight_free;
2187   -
  2092 + }
  2093 + if(!is_by_quan) {
  2094 + var user_addr = th.data.user_addr;
  2095 + var req_d = {
  2096 + province: user_addr.province,
  2097 + city: user_addr.city,
  2098 + district: user_addr.district,
  2099 + wuliu: parseFloat(parseFloat(allpice) - cut_price - quan_price).toFixed(2),
  2100 + store_id: os.stoid
  2101 + }
  2102 + var back_data = null;
  2103 + await getApp().request.promisePost("/api/weshop/order/areaFreight", {
  2104 + is_json: 1, data: req_d
  2105 + }).then(rs => {
  2106 + if (rs.data.code == 0) back_data = rs.data.data;
  2107 + });
2188 2108  
2189   - //有不包邮区域,且不免运费
2190   - if (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice) - cut_price - quan_price) {
2191   - //-----------获取不包邮区域,不包邮商品-------
2192   - await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", {
2193   - data: { store_id: os.stoid, id: no_ex_id }
2194   - }).then(res => {
2195   - if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
2196   - no_by_data = res.data.data[0];
2197   - //如果有设置不包邮区域的时候
2198   - if (res.data.data[0].region_list) {
2199   - if (th.check_by_area(res.data.data[0].region_list)) {
2200   - freight_free = 0;
2201   - // out_of_weight = 0;
2202   - th.data.is_no_by[th.data.bn_pick] = 1;
  2109 + //如果有包邮券的不包邮商品的时候
  2110 + if(quan_no_goods_arr) {
  2111 + if (back_data && back_data.no_free_goods) {
  2112 + back_data['is_by_all']=1;
  2113 + var arr3 = back_data.no_free_goods.filter(item => {
  2114 + return quan_no_goods_arr.includes(item)
  2115 + })
  2116 + back_data.no_free_goods = null;
  2117 + if (arr3.length) {
  2118 + back_data.no_free_goods = arr3;
2203 2119 }
2204 2120 }
2205   - //如果有设置不包邮商品
2206   - if (res.data.data[0].goods_list && freight_free) {
2207   - if (th.check_by_goods(res.data.data[0].goods_list)) {
2208   - freight_free = 0;
2209   - // out_of_weight = 0;
2210   - th.data.is_no_by[th.data.bn_pick] = 1;
  2121 + if (!back_data || !back_data.no_free_goods) {
  2122 + if (!back_data) back_data={};
  2123 + back_data['is_by_all']=1;
  2124 + back_data['no_free_goods']=quan_no_goods_arr;
  2125 + }
  2126 + }
  2127 +
  2128 + var cut_good_weight = 0;
  2129 + for (let i in gd_arr_list) {
  2130 + let item = gd_arr_list[i];
  2131 + if (back_data && back_data['is_by_all']) {
  2132 + if(!back_data.no_free_goods || !back_data.no_free_goods.length) continue;
  2133 + }
  2134 + if (back_data && back_data['is_by_all'] && back_data.no_free_goods.indexOf(item.goods_id) == -1) {
  2135 + if (item['exp_sum_type'] == 2) {
  2136 + cut_good_weight += item['weight'] * item['buynum'];
  2137 + }
  2138 + if (back_data.weight_free > 0) {
  2139 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
2211 2140 }
  2141 + continue;
  2142 + }
  2143 +
  2144 + switch (item['exp_sum_type']) {
  2145 + case 1:
  2146 + //统一运费
  2147 + o_shipping_price += item['uniform_exp_sum'];
  2148 + break;
  2149 + case 2:
  2150 + if (goods_weight < 0) goods_weight = 0;
  2151 + //累积商品重量 每种商品的重量 * 数量
  2152 + goods_weight += item['weight'] * item['buynum'];
  2153 +
  2154 + if (back_data && back_data.is_by_all && !back_data.no_free_goods) {
  2155 + cut_good_weight += item['weight'] * item['buynum'];
  2156 + if (back_data.weight_free > 0) {
  2157 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  2158 + }
  2159 + }
  2160 + break;
  2161 + case 3:
  2162 + if (goods_piece < 0) goods_piece = 0;
  2163 + //累积商品数量
  2164 + goods_piece += item['buynum'];
  2165 + break;
2212 2166 }
2213 2167 }
2214   - })
2215   - }
2216 2168  
2217   - th.data.is_by[th.data.bn_pick] = 0;
2218   - //--------------开始计算物流------------------
2219   - var shipping_price =
2220   - th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
2221   - goods_piece, th.data.user_addr, freight_free, parseFloat(allpice) - cut_price - quan_price, rs, th.data.bn_pick);
  2169 + //如果是正值的时候
  2170 + if (out_of_weight >= 0) out_of_weight = -cut_good_weight;
  2171 + else out_of_weight = -back_data.weight_free * 1000;
2222 2172  
2223   - //如果有赠品的时候,也要计算赠品的物流费用
2224   - if (th.data.buy_now_gift_goods) {
2225   - shipping_price = th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free, out_of_weight,
2226   - parseFloat(allpice) - cut_price - quan_price, rs, shipping_price, no_by_data, goods_weight, goods_piece);
2227   - }
  2173 + var code = "";
  2174 + if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code;
  2175 + th.data.is_no_by[th.data.bn_pick] = 0;
  2176 + th.data.is_by[th.data.bn_pick] = 0;
2228 2177  
2229   - if (shipping_price <= 0) {
2230   - th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券
2231   - }
  2178 + //--------------开始计算物流------------------
  2179 + shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
  2180 + goods_piece, th.data.user_addr, back_data, rs);
2232 2181  
2233   - shipping_price = parseFloat(shipping_price).toFixed(2);
2234   - var wl_txt = "formData.shipping_price";
2235   - th.setData({ [wl_txt]: shipping_price, })
  2182 + if (shipping_price <= 0) {
  2183 + th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券
  2184 + }
  2185 + }
  2186 +
  2187 + shipping_price = parseFloat(shipping_price).toFixed(2);
  2188 + var wl_txt = "formData.shipping_price";
  2189 + th.setData({[wl_txt]: shipping_price,})
2236 2190  
2237 2191 } else {
2238 2192 var wl_txt = "formData.shipping_price";
... ... @@ -2418,7 +2372,7 @@ Page({
2418 2372 wx.hideLoading();
2419 2373  
2420 2374 });
2421   - });
  2375 +
2422 2376 },
2423 2377  
2424 2378 requestSubscribe() {
... ... @@ -3263,89 +3217,8 @@ Page({
3263 3217 th.setData({ js_use_money: !th.data.js_use_money });
3264 3218 th.calculatePrice();
3265 3219 },
3266   - //-------------------计算物流---------------
3267   - calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight,
3268   - goods_piece, user_addr, freight_free, o_price, rs, pickid) {
3269   - var price = 0, th = this;
3270   - price += parseFloat(o_shipping_price);
3271   - //如果是包邮
3272   - if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) {
3273   - return 0;
3274   - }
3275   - if (user_addr == null) {
3276   - return 0;
3277   - }
3278   - //计算物流的config item;
3279   - var item = null;
3280   - //先根据 镇 县 区找计算的config
3281   - item = th.get_wuliu_config(user_addr.district, code, rs);
3282   - if (item == null) item = th.get_wuliu_config(user_addr.city, code, rs);
3283   - if (item == null) item = th.get_wuliu_config(user_addr.province, code, rs);
3284   - if (item == null) item = th.get_wuliu_default(code, rs);
3285   - if (item == null) return o_shipping_price;
3286   - var fw_price = 0, fp_price = 0;
3287   - item = item.config;
3288   - if (item == null) return o_shipping_price;
3289   -
3290   - //------超出重量----------
3291   - if (out_of_weight < 0 && o_price >= freight_free && !th.data.is_no_by[pickid]) {
3292   - goods_weight = goods_weight + out_of_weight;
3293   - if (goods_weight == 0) goods_weight = -1;
3294   - }
3295   -
3296   -
3297   - //------按重量----------
3298   - if (goods_weight >= 0 && item['money']) {
3299   - fw_price = parseFloat(item['money']);
3300   - if (goods_weight > item['first_weight']) {
3301   - var fw = goods_weight - item['first_weight'];
3302   - var n = Math.ceil(fw / item['second_weight'])
3303   - fw_price = fw_price + n * parseFloat(item['add_money']);
3304   - }
3305   - }
3306   -
3307   - if (th.data.free1 && freight_free <= 0) freight_free = th.data.free1;
3308   -
3309 3220  
3310   - //当有包邮和不包邮混合在一起的时候,件数要重新计算
3311   - if (freight_free > 0 && o_price >= freight_free && goods_piece > 0 && th.data.cut_goods_piece)
3312   - goods_piece = goods_piece - th.data.cut_goods_piece;
3313   - //------按件数----------
3314   - if (goods_piece > 0 && item['piecemoney']) {
3315   - fp_price = parseFloat(item['piecemoney']);
3316   - if (goods_piece > item['first_piece']) {
3317   - var fp = goods_piece - item['first_piece'];
3318   - var m = Math.ceil(fp / item['second_piece'])
3319   - fp_price = fp_price + m * parseFloat(item['add_piecemoney']);
3320   - }
3321   - }
3322   - //当有包邮和不包邮混合在一起的时候,统一运费要重新计算
3323   - if (freight_free > 0 && o_price >= freight_free && th.data.cut_o_shipping_price && price > 0) price = price - th.data.cut_o_shipping_price;
3324 3221  
3325   - var rspice = parseFloat(price + fw_price + fp_price);
3326   - return rspice;
3327   - },
3328   -
3329   - //------------循环获取config-----------
3330   - get_wuliu_config: function (region_id, code, rs) {
3331   - var item = null, rslist = rs.pageData;
3332   - for (var i = 0; i < rslist.length; i++) {
3333   - if (rslist[i].code == code && rslist[i].region_id == region_id) {
3334   - item = rslist[i];
3335   - }
3336   - }
3337   - return item;
3338   - },
3339   - //-------循环获取config,code default-------
3340   - get_wuliu_default: function (code, rs) {
3341   - var item = null, rslist = rs.pageData;
3342   - for (var i = 0; i < rslist.length; i++) {
3343   - if (rslist[i].shipping_code == code && rslist[i].is_default == 1) {
3344   - item = rslist[i];
3345   - }
3346   - }
3347   - return item;
3348   - },
3349 3222  
3350 3223 //----------立即购买,选择物流-------------
3351 3224 bindPickerChange: function (e) {
... ... @@ -4332,73 +4205,6 @@ Page({
4332 4205  
4333 4206 },
4334 4207  
4335   - //计算立即购买赠品的物流费用
4336   - 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) {
4337   - var good_arr = this.data.buy_now_gift_goods;
4338   - var goods_weight = -1, goods_piece = -1;
4339   -
4340   - var gift_shipping_price = 0;
4341   - if (shipping_price) {
4342   - gift_shipping_price = shipping_price;
4343   - }
4344   - var th = this;
4345   - var out_of_weight = null;
4346   -
4347   -
4348   - //如果有设置不包邮区域的时候
4349   - if (no_by_data && no_by_data.region_list) {
4350   - if (th.check_by_area(no_by_data.region_list)) {
4351   - gift_freight_free = 0;
4352   - // out_of_weight = 0
4353   - th.data.is_no_by[th.data.bn_pick] = 1;
4354   - }
4355   - }
4356   -
4357   - for (var i in good_arr) {
4358   - var good = good_arr[i];
4359   - switch (good['exp_sum_type']) {
4360   - case 1:
4361   - //统一运费
4362   - gift_shipping_price += parseFloat(good['uniform_exp_sum']);
4363   - gift_shipping_price += o_shipping_price;
4364   - break;
4365   - case 2:
4366   - if (goods_weight < 0) goods_weight = 0;
4367   - //累积商品重量 每种商品的重量 * 数量
4368   - goods_weight += good['weight'] * parseInt(good['buynum']);
4369   - if (goods_weight1 > 0) {
4370   - out_of_weight = gift_weight_free - goods_weight;
4371   - //不能调换位置 下面goods_weight会变大
4372   - goods_weight += goods_weight1;
4373   - }
4374   - break;
4375   - case 3:
4376   - if (goods_piece < 0) goods_piece = 0;
4377   - //累积商品数量
4378   - goods_piece += parseInt(good['buynum']);
4379   - if (goods_piece1) {
4380   - goods_piece += goods_piece1;
4381   - }
4382   - break;
4383   - }
4384   -
4385   - //如果有设置不包邮商品
4386   - if (no_by_data && no_by_data.goods_list && gift_freight_free) {
4387   - if (th.check_by_goods(no_by_data.goods_list, good.goods_id)) {
4388   - gift_freight_free = 0;
4389   - // out_of_weight = 0
4390   - th.data.is_no_by[th.data.bn_pick] = 1;
4391   - }
4392   - }
4393   - }
4394   -
4395   - var t_shipping_price =
4396   - this.calculatewuliu(code, gift_shipping_price, goods_weight, out_of_weight,
4397   - goods_piece, user_addr, gift_freight_free, allpice, rs, th.data.bn_pick);
4398   - return t_shipping_price;
4399   -
4400   - },
4401   -
4402 4208 //从优惠的映射中拿出商品从表的item
4403 4209 item_map_get_goods: function (goods_id, map) {
4404 4210 for (var i in map.goods) {
... ...
pages/cart/cart2_inte/cart2_inte.js
... ... @@ -425,81 +425,87 @@ Page({
425 425 var c_txt = "formData.cut_price";
426 426 th.setData({ [c_txt]: cut_price, });
427 427 }
428   - to.getConfig2(function (ee) {
429   - to.getwuliuprice(async function (rs) {
  428 +
  429 + to.getwuliuprice(async function (rs) {
430 430  
431 431 var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
432 432 var out_of_weight = null; //超出多少重量
433   - var freight_free = ee.freight_free; //全场满多少包邮
434   - var weight_free = ee.weight_free; //多少kg内包邮
  433 +
435 434 //-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮----------
436 435 if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && good.is_past != 1) {
437 436  
438   - switch (good['exp_sum_type']) {
439   - case 1:
440   - //统一运费
441   - o_shipping_price += good['uniform_exp_sum']; break;
442   - case 2:
443   - if (goods_weight < 0) goods_weight = 0;
444   - //累积商品重量 每种商品的重量 * 数量
445   - goods_weight += good['weight'] * good['buynum'];
446   - if (weight_free > 0) {
447   - out_of_weight = (weight_free * 1000) - goods_weight;
448   - }
449   - break;
450   - case 3:
451   - if (goods_piece < 0) goods_piece = 0;
452   - //累积商品数量
453   - goods_piece += good['buynum']; break;
454   - }
  437 + var user_addr=th.data.user_addr;
  438 + var req_d = {
  439 + province: user_addr.province, city: user_addr.city, district: user_addr.district,
  440 + wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid
  441 + }
  442 + var back_data = null;
  443 + await getApp().request.promisePost("/api/weshop/order/areaFreight", {
  444 + is_json: 1, data: req_d
  445 + }).then(rs => {
  446 + if (rs.data.code == 0) back_data = rs.data.data;
  447 + });
455 448  
456   - var code = "";
457   - if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code;
458   - var no_ex_id = ee.no_ex_id;
459   - th.data.is_no_by[th.data.bn_pick] = 0;
460   - var no_by_data = null;
461   - var gift_freight_free = freight_free;
462   - //有不包邮区域,且不免运费
463   - if (no_ex_id && freight_free > 0 && freight_free <= allpice - cut_price) {
464   - //-----------获取不包邮区域,不包邮商品-------
465   - await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", {
466   - data: { store_id: os.stoid, id: no_ex_id }
467   - }).then(res => {
468   - if (res.data.code == 0) {
469   - no_by_data = res.data.data[0];
470   - //如果有设置不包邮区域的时候
471   - if (res.data.data[0].region_list) {
472   - if (th.check_by_area(res.data.data[0].region_list)) {
473   - freight_free = 0;
474   - // out_of_weight = 0;
475   - // weight_free = -1;
476   - th.data.is_no_by[th.data.bn_pick] = 1;
477   - }
  449 + var gd_arr_list = [];
  450 + gd_arr_list.push(good);
  451 + var cut_good_weight = 0;
  452 + for (let i in gd_arr_list) {
  453 + let item = gd_arr_list[i];
  454 + if (back_data && back_data['is_by_all']) {
  455 + if(!back_data.no_free_goods || !back_data.no_free_goods.length) continue;
478 456 }
479   - //如果有设置不包邮商品
480   - if (res.data.data[0].goods_list && freight_free) {
481   - if (th.check_by_goods(res.data.data[0].goods_list)) {
482   - freight_free = 0;
483   - // out_of_weight = 0;
484   - // weight_free = -1;
485   - th.data.is_no_by[th.data.bn_pick] = 1;
486   - }
  457 +
  458 + if (back_data && back_data['is_by_all'] && back_data.no_free_goods.indexOf(item.goods_id) == -1) {
  459 + if (item['exp_sum_type'] == 2) {
  460 + cut_good_weight += item['weight'] * item['buynum'];
  461 + }
  462 + if (back_data.weight_free > 0) {
  463 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  464 + }
  465 + continue;
487 466 }
488   - }
489   - })
490   - }
491 467  
492   - //--------------开始计算物流------------------
493   - var shipping_price =
494   - th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
495   - goods_piece, th.data.user_addr, freight_free, allpice - cut_price, rs, th.data.bn_pick);
496   - if (shipping_price <= 0) {
497   - th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券
498   - }
  468 + switch (item['exp_sum_type']) {
  469 + case 1:
  470 + //统一运费
  471 + o_shipping_price += item['uniform_exp_sum'];
  472 + break;
  473 + case 2:
  474 + if (goods_weight < 0) goods_weight = 0;
  475 + //累积商品重量 每种商品的重量 * 数量
  476 + goods_weight += item['weight'] * item['buynum'];
  477 +
  478 + if (back_data && back_data.is_by_all && !back_data.no_free_goods) {
  479 + cut_good_weight += item['weight'] * item['buynum'];
  480 + if (back_data.weight_free > 0) {
  481 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  482 + }
  483 + }
  484 + break;
  485 + case 3:
  486 + if (goods_piece < 0) goods_piece = 0;
  487 + //累积商品数量
  488 + goods_piece += item['buynum'];
  489 + break;
  490 + }
  491 + }
499 492  
500   - shipping_price = parseFloat(shipping_price).toFixed(2);
501   - var wl_txt = "formData.shipping_price";
502   - th.setData({ [wl_txt]: shipping_price, })
  493 + //如果是正值的时候
  494 + if (out_of_weight >= 0) out_of_weight = -cut_good_weight;
  495 + else out_of_weight = -back_data.weight_free * 1000;
  496 +
  497 + var code = "";
  498 + if (th.data.wu_arr && th.data.wu_arr[th.data.index]) code = th.data.wu_arr[th.data.index].code;
  499 + //--------------开始计算物流------------------
  500 + var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
  501 + goods_piece, th.data.user_addr, back_data, rs);
  502 + if (shipping_price <= 0) {
  503 + th.data.is_by[th.data.bn_pick] = 1; //已经是包邮了,就不要选择包邮券
  504 + }
  505 +
  506 + shipping_price = parseFloat(shipping_price).toFixed(2);
  507 + var wl_txt = "formData.shipping_price";
  508 + th.setData({ [wl_txt]: shipping_price, })
503 509  
504 510 } else {
505 511 var wl_txt = "formData.shipping_price";
... ... @@ -544,7 +550,7 @@ Page({
544 550 wx.hideLoading();
545 551  
546 552 });
547   - });
  553 +
548 554 },
549 555  
550 556 //--------------------提交订单-----------------------
... ... @@ -917,73 +923,6 @@ Page({
917 923 th.setData({ js_use_money: !th.data.js_use_money });
918 924 th.calculatePrice();
919 925 },
920   - //-------------------计算物流---------------
921   - calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight,
922   - goods_piece, user_addr, freight_free, o_price, rs, pickid = null) {
923   - var price = 0, th = this;
924   - price += parseFloat(o_shipping_price);
925   - //如果是包邮
926   - if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) { return 0; }
927   - if (user_addr == null) { return 0; }
928   - //计算物流的config item;
929   - var item = null;
930   - //先根据 镇 县 区找计算的config
931   - item = th.get_wuliu_config(user_addr.district, code, rs);
932   - if (item == null) item = th.get_wuliu_config(user_addr.city, code, rs);
933   - if (item == null) item = th.get_wuliu_config(user_addr.province, code, rs);
934   - if (item == null) item = th.get_wuliu_default(code, rs);
935   - if (item == null) return o_shipping_price;
936   - var fw_price = 0, fp_price = 0;
937   - item = item.config;
938   - if (item == null) return o_shipping_price;
939   - //------按重量----------
940   - if (goods_weight >= 0 && item['money']) {
941   - fw_price = parseFloat(item['money']);
942   - if (goods_weight > item['first_weight']) {
943   - var fw = goods_weight - item['first_weight'];
944   - var n = Math.ceil(fw / item['second_weight'])
945   - fw_price = fw_price + n * parseFloat(item['add_money']);
946   - }
947   - }
948   - //------超出重量----------
949   - if (out_of_weight < 0 && o_price >= freight_free && !th.data.is_no_by[pickid]) {
950   - fw_price = parseFloat(item['money']);
951   - var out_of_weight = Math.abs(out_of_weight);
952   - if (out_of_weight > item['first_weight']) {
953   - var fw = out_of_weight - item['first_weight'];
954   - var n = Math.ceil(fw / item['second_weight'])
955   - fw_price = fw_price + n * parseFloat(item['add_money']);
956   - }
957   - }
958   - //------按件数----------
959   - if (goods_piece > 0 && item['piecemoney']) {
960   - fp_price = parseFloat(item['piecemoney']);
961   - if (goods_piece > item['first_piece']) {
962   - var fp = goods_piece - item['first_piece'];
963   - var m = Math.ceil(fp / item['second_piece'])
964   - fp_price = fp_price + m * parseFloat(item['add_piecemoney']);
965   - }
966   - }
967   - var rspice = parseFloat(price + fw_price + fp_price);
968   - return rspice;
969   - },
970   -
971   - //------------循环获取config-----------
972   - get_wuliu_config: function (region_id, code, rs) {
973   - var item = null, rslist = rs.pageData;
974   - for (var i = 0; i < rslist.length; i++) {
975   - if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i]; }
976   - }
977   - return item;
978   - },
979   - //-------循环获取config,code default-------
980   - get_wuliu_default: function (code, rs) {
981   - var item = null, rslist = rs.pageData;
982   - for (var i = 0; i < rslist.length; i++) {
983   - if (rslist[i].shipping_code == code && rslist[i].is_default == 1) { item = rslist[i]; }
984   - }
985   - return item;
986   - },
987 926  
988 927 //----------立即购买,选择物流-------------
989 928 bindPickerChange: function (e) {
... ...
pages/cart/cart2_pt/cart2_pt.js
1 1 var t = getApp(), app = t, a = t.request, e = require("../../../utils/common.js"),
2   - s = require("../../../utils/util.js"), o = require("../../../utils/md5.js"), to = getApp();
  2 + s = require("../../../utils/util.js"),ut=s, o = require("../../../utils/md5.js"), to = getApp();
3 3 var oo = t.globalData.setting, os = oo;
4 4 var regeneratorRuntime = require('../../../utils/runtime.js');
5 5 var util_pay = require("../../../utils/pay.js");
... ... @@ -401,84 +401,81 @@ Page({
401 401 allpice = parseFloat(allpice).toFixed(2);
402 402 var txt = "formData.all_price";
403 403 th.setData({ [txt]: allpice, });
404   - console.log(th.data.formData);
405 404  
406   - to.getConfig2(function (ee) {
407   - to.getwuliuprice(async function (rs) {
  405 + to.getwuliuprice(async function (rs) {
408 406 console.log('calculatePrice2222');
409 407 console.log(rs);
410 408 var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
411 409 var out_of_weight = null; //超出多少重量
412   - var freight_free = ee.freight_free; //全场满多少包邮
413   - var weight_free = ee.weight_free; //多少kg内包邮
414   - var no_ex_id = ee.no_ex_id;
415   - var no_ex_good = null;
416   - var by_qc = {};
417   - if (no_ex_id && freight_free > 0) {
418   - //-----------获取不包邮区域,不包邮商品-------
419   - await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", {
420   - data: { store_id: os.stoid, id: no_ex_id }
421   - }).then(res => {
422   - if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
423   - by_qc = res.data.data[0];
424   - }
425   - })
426   - };
  410 +
427 411 //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格----------
428 412 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)) {
429   - switch (good['exp_sum_type']) {
430   - case 1:
431   - //统一运费
432   - o_shipping_price += good['uniform_exp_sum']; break;
433   - case 2:
434   - if (goods_weight < 0) goods_weight = 0;
435   - //累积商品重量 每种商品的重量 * 数量
436   - goods_weight += good['weight'] * good['buynum'];
437   - if (weight_free > 0) {
438   - out_of_weight = (weight_free * 1000) - goods_weight;
439   - }
440   - break;
441   - case 3:
442   - if (goods_piece < 0) goods_piece = 0;
443   - //累积商品数量
444   - goods_piece += good['buynum']; break;
445   - }
446   -
447   - console.log(th.data.wu_arr);
448   - var code = th.data.wu_arr[th.data.index].code;
449   - th.data.is_no_by[th.data.bn_pick] = 0;
450   - var no_by_data = null;
451   - //--全部金额--
452   - //有不包邮区域,且不免运费
453   - if (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice)) {
454   - //-----------获取不包邮区域,不包邮商品-------
455   - await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", {
456   - data: { store_id: os.stoid, id: no_ex_id }
457   - }).then(res => {
458   - if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
459   - no_by_data = res.data.data[0];
460   - //如果有设置不包邮区域的时候
461   - if (res.data.data[0].region_list) {
462   - if (th.check_by_area(res.data.data[0].region_list)) {
463   - freight_free = 0;
464   - // out_of_weight = 0;
465   - th.data.is_no_by[th.data.bn_pick] = 1;
466   - }
  413 +
  414 + var user_addr=th.data.user_addr;
  415 + var req_d = {
  416 + province: user_addr.province, city: user_addr.city, district: user_addr.district,
  417 + wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid
  418 + }
  419 + var back_data = null;
  420 + await getApp().request.promisePost("/api/weshop/order/areaFreight", {
  421 + is_json: 1, data: req_d
  422 + }).then(rs => {
  423 + if (rs.data.code == 0) back_data = rs.data.data;
  424 + });
  425 +
  426 + var gd_arr_list = [];
  427 + gd_arr_list.push(good);
  428 + var cut_good_weight = 0;
  429 + for (let i in gd_arr_list) {
  430 + let item = gd_arr_list[i];
  431 + if (back_data && back_data['is_by_all'] && !back_data.no_free_goods) {
  432 + continue;
467 433 }
468   - //如果有设置不包邮商品
469   - if (res.data.data[0].goods_list && freight_free) {
470   - if (th.check_by_goods(res.data.data[0].goods_list)) {
471   - freight_free = 0;
472   - // out_of_weight = 0;
473   - th.data.is_no_by[th.data.bn_pick] = 1;
474   - }
  434 + if (back_data && back_data['is_by_all'] && back_data.no_free_goods.indexOf(item.goods_id) == -1) {
  435 + if (item['exp_sum_type'] == 2) {
  436 + cut_good_weight += item['weight'] * item['buynum'];
  437 + }
  438 + if (back_data.weight_free > 0) {
  439 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  440 + }
  441 + continue;
475 442 }
476   - }
477   - })
478   - }
479   - var shipping_price =
480   - th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
481   - goods_piece, th.data.user_addr, freight_free, allpice, rs,th.data.bn_pick);
  443 +
  444 + switch (item['exp_sum_type']) {
  445 + case 1:
  446 + //统一运费
  447 + o_shipping_price += item['uniform_exp_sum'];
  448 + break;
  449 + case 2:
  450 + if (goods_weight < 0) goods_weight = 0;
  451 + //累积商品重量 每种商品的重量 * 数量
  452 + goods_weight += item['weight'] * item['buynum'];
  453 +
  454 + if (back_data && back_data.is_by_all && !back_data.no_free_goods) {
  455 + cut_good_weight += item['weight'] * item['buynum'];
  456 + if (back_data.weight_free > 0) {
  457 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  458 + }
  459 + }
  460 + break;
  461 + case 3:
  462 + if (goods_piece < 0) goods_piece = 0;
  463 + //累积商品数量
  464 + goods_piece += item['buynum'];
  465 + break;
  466 + }
  467 + }
  468 +
  469 + //如果是正值的时候
  470 + if (out_of_weight >= 0) out_of_weight = -cut_good_weight;
  471 + else out_of_weight = -back_data.weight_free * 1000;
  472 +
  473 +
  474 + var code = th.data.wu_arr[th.data.index].code;
  475 +
  476 + //--------------开始计算物流------------------
  477 + var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
  478 + goods_piece, th.data.user_addr, back_data, rs);
482 479  
483 480 shipping_price = parseFloat(shipping_price).toFixed(2);
484 481 var wl_txt = "formData.shipping_price";
... ... @@ -512,7 +509,7 @@ Page({
512 509 }
513 510  
514 511 });
515   - });
  512 +
516 513 },
517 514 //--------------------提交订单-----------------------
518 515 submitForm: async function (t) {
... ... @@ -861,74 +858,6 @@ Page({
861 858 th.calculatePrice();
862 859 },
863 860  
864   - //-------------------计算物流---------------
865   - calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight,
866   - goods_piece, user_addr, freight_free, o_price, rs, pickid) {
867   - var price = 0, th = this;
868   - price += parseFloat(o_shipping_price);
869   - //如果是包邮
870   - if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) { return 0; }
871   - if (user_addr == null) { return 0; }
872   - //计算物流的config item;
873   - var item = null;
874   - //先根据 镇 县 区找计算的config
875   - item = th.get_wuliu_config(user_addr.district, code, rs);
876   - if (item == null) item = th.get_wuliu_config(user_addr.city, code, rs);
877   - if (item == null) item = th.get_wuliu_config(user_addr.province, code, rs);
878   - if (item == null) item = th.get_wuliu_default(code, rs);
879   - if (item == null) return o_shipping_price;
880   - var fw_price = 0, fp_price = 0;
881   - item = item.config;
882   - if (item == null) return o_shipping_price;
883   - //------按重量----------
884   - if (goods_weight >= 0 && item['money']) {
885   - fw_price = parseFloat(item['money']);
886   - if (goods_weight > item['first_weight']) {
887   - var fw = goods_weight - item['first_weight'];
888   - var n = Math.ceil(fw / item['second_weight'])
889   - fw_price = fw_price + n * parseFloat(item['add_money']);
890   - }
891   - }
892   - //------超出重量----------
893   - if (out_of_weight < 0 && o_price >= freight_free && !th.data.is_no_by[pickid]) {
894   - fw_price = parseFloat(item['money']);
895   - var out_of_weight = Math.abs(out_of_weight);
896   - if (out_of_weight > item['first_weight']) {
897   - var fw = out_of_weight - item['first_weight'];
898   - var n = Math.ceil(fw / item['second_weight'])
899   - fw_price = fw_price + n * parseFloat(item['add_money']);
900   - }
901   - }
902   - //------按件数----------
903   - if (goods_piece > 0) {
904   - fp_price = parseFloat(item['piecemoney']);
905   - if (goods_piece > item['first_piece']) {
906   - var fp = goods_piece - item['first_piece'];
907   - var m = Math.ceil(fp / item['second_piece'])
908   - fp_price = fp_price + m * parseFloat(item['add_piecemoney']);
909   - }
910   - }
911   - var rspice = parseFloat(price + fw_price + fp_price);
912   - return rspice;
913   - },
914   -
915   - //------------循环获取config-----------
916   - get_wuliu_config: function (region_id, code, rs) {
917   - var item = null, rslist = rs.pageData;
918   - for (var i = 0; i < rslist.length; i++) {
919   - if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i]; }
920   - }
921   - return item;
922   - },
923   - //-------循环获取config,code default-------
924   - get_wuliu_default: function (code, rs) {
925   - var item = null, rslist = rs.pageData;
926   - for (var i = 0; i < rslist.length; i++) {
927   - if (rslist[i].shipping_code == code && rslist[i].is_default == 1) { item = rslist[i]; }
928   - }
929   - return item;
930   - },
931   -
932 861 //----------立即购买,选择物流-------------
933 862 bindPickerChange: function (e) {
934 863 var ind = e.detail.value
... ...
pages/cart/cart_wk/cart_wk.js
... ... @@ -2,6 +2,7 @@
2 2 var t = getApp(),
3 3 oo = t.globalData.setting,
4 4 os=oo;
  5 +var ut=require("../../../utils/util.js");
5 6 var regeneratorRuntime = require('../../../utils/runtime.js');
6 7  
7 8 Page({
... ... @@ -462,155 +463,98 @@ Page({
462 463 //----计算物流的钱----
463 464 calculate_wuliu() {
464 465 var to = getApp(), th = this;
465   - to.getConfig2(function (ee) {
466   - to.getwuliuprice(async function (rs) {
  466 + to.getwuliuprice(async function (rs) {
467 467 var o_shipping_price = 0, goods_weight = -1, goods_piece = -1, good = th.data.goods;
468 468 var out_of_weight = null; //超出多少重量
469   - var no_ex_id = ee.no_ex_id;
470   - var freight_free = ee.freight_free; //全场满多少包邮
471   - var weight_free = ee.weight_free; //多少kg内包邮
472   - var no_ex_good = null;
473   - var by_qc = {};
474   - if (no_ex_id && freight_free > 0) {
475   - //-----------获取不包邮区域,不包邮商品-------
476   - await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", {
477   - data: { store_id: os.stoid, id: no_ex_id }
478   - }).then(res => {
479   - if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
480   - by_qc = res.data.data[0];
481   - }
482   - })
483   - };
  469 +
  470 + good.buynum=th.data.order.order_goods['goods_num'];
  471 + var gd_arr_list = [];
  472 + gd_arr_list.push(good);
  473 + //--全部金额--
  474 + var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.pt_tail_money;
  475 +
484 476 //-----------当地址不为空,且是物流时,计算物流费用----------
485 477 if (th.data.user_addr != null && th.data.exp_type == 0 && good.is_free_shipping == 0) {
486   - switch (good['exp_sum_type']) {
487   - case 1:
488   - //统一运费
489   - o_shipping_price += good['uniform_exp_sum'];
490   - break;
491   - case 2:
492   - if (goods_weight < 0) goods_weight = 0;
493   - //累积商品重量 每种商品的重量 * 数量
494   - goods_weight += good['weight'] * th.data.order.order_goods['goods_num'];
495   - if (weight_free > 0) {
496   - out_of_weight = (weight_free * 1000) - goods_weight;
497   - }
498   - break;
499   - case 3:
500   - if (goods_piece < 0) goods_piece = 0;
501   - //累积商品数量
502   - goods_piece += th.data.order.order_goods['goods_num'];
503   - break;
504   - }
505   - var code = th.data.wu_arr[th.data.index].code;
506   - th.data.is_no_by[th.data.bn_pick] = 0;
507   - var no_by_data = null;
508   - //--全部金额--
509   - var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.pt_tail_money;
510   - //有不包邮区域,且不免运费
511   - if (no_ex_id && freight_free > 0 && freight_free <= parseFloat(allpice)) {
512   - //-----------获取不包邮区域,不包邮商品-------
513   - await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods", {
514   - data: { store_id: os.stoid, id: no_ex_id }
515   - }).then(res => {
516   - if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
517   - no_by_data = res.data.data[0];
518   - //如果有设置不包邮区域的时候
519   - if (res.data.data[0].region_list) {
520   - if (th.check_by_area(res.data.data[0].region_list)) {
521   - freight_free = 0;
522   - // out_of_weight = 0;
523   - th.data.is_no_by[th.data.bn_pick] = 1;
524   - }
  478 +
  479 + var user_addr=th.data.user_addr;
  480 + var req_d = {
  481 + province: user_addr.province, city: user_addr.city, district: user_addr.district,
  482 + wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid
  483 + }
  484 + var back_data = null;
  485 + await getApp().request.promisePost("/api/weshop/order/areaFreight", {
  486 + is_json: 1, data: req_d
  487 + }).then(rs => {
  488 + if (rs.data.code == 0) back_data = rs.data.data;
  489 + });
  490 +
  491 + var cut_good_weight = 0;
  492 + for (let i in gd_arr_list) {
  493 + let item = gd_arr_list[i];
  494 + if (back_data && back_data['is_by_all']) {
  495 + if(!back_data.no_free_goods || !back_data.no_free_goods.length) continue;
525 496 }
526   - //如果有设置不包邮商品
527   - if (res.data.data[0].goods_list && freight_free) {
528   - if (th.check_by_goods(res.data.data[0].goods_list)) {
529   - freight_free = 0;
530   - // out_of_weight = 0;
531   - th.data.is_no_by[th.data.bn_pick] = 1;
532   - }
  497 + if (back_data && back_data['is_by_all'] && back_data.no_free_goods.indexOf(item.goods_id) == -1) {
  498 + if (item['exp_sum_type'] == 2) {
  499 + cut_good_weight += item['weight'] * item['buynum'];
  500 + }
  501 + if (back_data.weight_free > 0) {
  502 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  503 + }
  504 + continue;
533 505 }
534   - }
535   - })
536   - }
537   - var shipping_price =
538   - th.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
539   - goods_piece, th.data.user_addr, freight_free, allpice, rs,th.data.bn_pick);
540   - var exp_price = parseFloat(shipping_price).toFixed(2);
541   - allpice = parseFloat(exp_price) + parseFloat(allpice);
542   - allpice = allpice.toFixed(2);
543 506  
544   - exp_price = parseFloat(exp_price);
545   - th.setData({ exp_price: exp_price, allpice: allpice })
  507 + switch (item['exp_sum_type']) {
  508 + case 1:
  509 + //统一运费
  510 + o_shipping_price += item['uniform_exp_sum'];
  511 + break;
  512 + case 2:
  513 + if (goods_weight < 0) goods_weight = 0;
  514 + //累积商品重量 每种商品的重量 * 数量
  515 + goods_weight += item['weight'] * item['buynum'];
  516 +
  517 + if (back_data && back_data.is_by_all && !back_data.no_free_goods) {
  518 + cut_good_weight += item['weight'] * item['buynum'];
  519 + if (back_data.weight_free > 0) {
  520 + out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
  521 + }
  522 + }
  523 + break;
  524 + case 3:
  525 + if (goods_piece < 0) goods_piece = 0;
  526 + //累积商品数量
  527 + goods_piece += item['buynum'];
  528 + break;
  529 + }
  530 + }
  531 +
  532 + //如果是正值的时候
  533 + if (out_of_weight >= 0) out_of_weight = -cut_good_weight;
  534 + else out_of_weight = -back_data.weight_free * 1000;
  535 +
  536 + var code = th.data.wu_arr[th.data.index].code;
  537 +
  538 + //--------------开始计算物流------------------
  539 + var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
  540 + goods_piece, th.data.user_addr, back_data, rs);
  541 +
  542 + var exp_price = parseFloat(shipping_price).toFixed(2);
  543 + allpice = parseFloat(exp_price) + parseFloat(allpice);
  544 + allpice = allpice.toFixed(2);
  545 +
  546 + exp_price = parseFloat(exp_price);
  547 + th.setData({ exp_price: exp_price, allpice: allpice })
546 548 } else {
547 549 var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.tail_money;
548 550 allpice = allpice.toFixed(2);
549 551 th.setData({ exp_price: 0, allpice: allpice })
550 552 }
551 553 });
552   - });
553   - },
554 554  
555   - //----------------计算物流---------------
556   - calculatewuliu: function (code, o_shipping_price, goods_weight, out_of_weight,
557   - goods_piece, user_addr, freight_free, o_price, rs,pickid) {
558   - var price = 0, th = this;
559   - price += parseFloat(o_shipping_price);
560   - //如果是包邮
561   - if (freight_free > 0 && o_price >= freight_free && out_of_weight >= 0) { return 0; }
562   - if (user_addr == null) { return 0; }
563   - //计算物流的config item;
564   - var item = null;
565   - //先根据 镇 县 区找计算的config
566   - item = th.get_wuliu_config(user_addr.district, code, rs);
567   - if (item == null) item = th.get_wuliu_config(user_addr.city, code, rs);
568   - if (item == null) item = th.get_wuliu_config(user_addr.province, code, rs);
569   - if (item == null) item = th.get_wuliu_default(code, rs);
570   - if (item == null) return o_shipping_price;
571   - var fw_price = 0, fp_price = 0;
572   - item = item.config;
573   - if (item == null) return o_shipping_price;
574   - //------按重量----------
575   - if (goods_weight >= 0 && item['money']) {
576   - fw_price = parseFloat(item['money']);
577   - if (goods_weight > item['first_weight']) {
578   - var fw = goods_weight - item['first_weight'];
579   - var n = Math.ceil(fw / item['second_weight'])
580   - fw_price = fw_price + n * parseFloat(item['add_money']);
581   - }
582   - }
583   - //------超出重量----------
584   - if (out_of_weight < 0 && o_price >= freight_free && !th.data.is_no_by[pickid]) {
585   - fw_price = parseFloat(item['money']);
586   - var out_of_weight = Math.abs(out_of_weight);
587   - if (out_of_weight > item['first_weight']) {
588   - var fw = out_of_weight - item['first_weight'];
589   - var n = Math.ceil(fw / item['second_weight'])
590   - fw_price = fw_price + n * parseFloat(item['add_money']);
591   - }
592   - }
593   - //------按件数----------
594   - if (goods_piece > 0) {
595   - fp_price = parseFloat(item['piecemoney']);
596   - if (goods_piece > item['first_piece']) {
597   - var fp = goods_piece - item['first_piece'];
598   - var m = Math.ceil(fp / item['second_piece'])
599   - fp_price = fp_price + m * parseFloat(item['add_piecemoney']);
600   - }
601   - }
602   - var rspice = parseFloat(price + fw_price + fp_price);
603   - return rspice;
604   - },
605   - //------------循环获取config-----------
606   - get_wuliu_config: function (region_id, code, rs) {
607   - var item = null, rslist = rs.pageData;
608   - for (var i = 0; i < rslist.length; i++) {
609   - if (rslist[i].code == code && rslist[i].region_id == region_id) { item = rslist[i]; }
610   - }
611   - return item;
612 555 },
613 556  
  557 +
614 558 //---------------检查是否有收货地址-------------------
615 559 checkAddressList: function () {
616 560 var t = this;
... ...
pages/giftpack/buygiftpack/giftpackbuy.js
... ... @@ -68,11 +68,21 @@ Page({
68 68  
69 69 },
70 70 onLoad: function (options) {
  71 + var th=this;
  72 +
71 73 this.setData({
72 74 params: options,
73 75 now:Date.parse(new Date()) / 1000,
74 76 })
75 77  
  78 + getApp().getConfig2(function (e) {
  79 + var json_d = JSON.parse(e.switch_list);
  80 + th.setData({
  81 + bconfig: e,
  82 + sys_switch:json_d
  83 + });
  84 + })
  85 +
76 86 },
77 87 init() {
78 88 var th = this;
... ... @@ -359,6 +369,11 @@ Page({
359 369 var ind = ee.currentTarget.dataset.ind;
360 370 var bconfig = th.data.bconfig;
361 371  
  372 + //如果开启了,则不在选择门店
  373 + if(this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){
  374 + return false;
  375 + }
  376 +
362 377 if (!th.data.only_pk && !th.data.def_pickpu_list) {
363 378 getApp().confirmBox("门店库存不足", null, 25000, !1);
364 379 return false;
... ...
pages/giftpack/giftpacklist/giftpacklist.js
... ... @@ -70,9 +70,20 @@ Page({
70 70 openSpecModal:0
71 71 },
72 72 onLoad: function (options) {
  73 +
  74 + var th=this;
  75 +
73 76 this.setData({
74 77 params:options,
75 78 })
  79 +
  80 + getApp().getConfig2(function (e) {
  81 + var json_d = JSON.parse(e.switch_list);
  82 + th.setData({
  83 + bconfig: e,
  84 + sys_switch:json_d
  85 + });
  86 + })
76 87 },
77 88 init(){
78 89 let options = this.data?.params; // this.data == null ? undefined:this.data.params
... ... @@ -606,6 +617,10 @@ Page({
606 617 var ind = ee.currentTarget.dataset.ind;
607 618 var bconfig = th.data.bconfig;
608 619  
  620 + //如果开启了,则不在选择门店
  621 + if(this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){
  622 + return false;
  623 + }
609 624 if (!th.data.only_pk && !th.data.def_pickpu_list) {
610 625 getApp().confirmBox("门店库存不足", null, 25000, !1);
611 626 return false;
... ...
pages/giftpack/public/buy_com.js
... ... @@ -44,6 +44,9 @@ module.exports = {
44 44 th.data.fir_def_store = {}; //赋值空对象
45 45 return false;
46 46 }
  47 +
  48 + th.setData({has_def:1})
  49 +
47 50 var ee = JSON.parse(JSON.stringify(e));
48 51 //--定时器推迟一下--
49 52 setTimeout(function () {
... ...
pages/goods/goodsInfo/buy_flash_normal.wxml
... ... @@ -42,7 +42,7 @@
42 42 <view class="fs30" style="color:black;">选择门店</view>
43 43 </view>
44 44  
45   - <view class="red-co fs28" bindtap="choice_store" >更多门店<text class="right-arrow"></text></view>
  45 + <view hidden="{{has_def && sys_switch.is_pricing_open_store}}" class="red-co fs28" bindtap="choice_store" >更多门店<text class="right-arrow"></text></view>
46 46 </view>
47 47 <view wx:if="{{only_pk && !only_pk.length}}">(库存不足)</view>
48 48 <block wx:else>
... ...
pages/goods/goodsInfo/buy_integral.wxml
... ... @@ -40,7 +40,7 @@
40 40 <view class="fs30" style="color:black;">选择门店</view>
41 41 </view>
42 42  
43   - <view class="red-co fs28" bindtap="choice_store">更多门店<text class="right-arrow"></text></view>
  43 + <view hidden="{{has_def && sys_switch.is_pricing_open_store}}" class="red-co fs28" bindtap="choice_store">更多门店<text class="right-arrow"></text></view>
44 44 </view>
45 45 <view wx:if="{{only_pk && !only_pk.length}}">(库存不足)</view>
46 46 <block wx:else>
... ...
pages/goods/goodsInfo/buy_integral_normal.wxml
... ... @@ -42,7 +42,7 @@
42 42 <view class="fs30" style="color:black;">选择门店</view>
43 43 </view>
44 44  
45   - <view class="red-co fs28" bindtap="choice_store" >更多门店<text class="right-arrow"></text></view>
  45 + <view hidden="{{has_def && sys_switch.is_pricing_open_store}}" class="red-co fs28" bindtap="choice_store" >更多门店<text class="right-arrow"></text></view>
46 46 </view>
47 47 <view wx:if="{{only_pk && !only_pk.length}}">(库存不足)</view>
48 48 <block wx:else>
... ...
pages/goods/goodsInfo/buy_pt.wxml
... ... @@ -63,7 +63,7 @@
63 63 <view class="fs28 xc-ash-9f">选择门店</view>
64 64 </view>
65 65  
66   - <view class="red-co fs28" bindtap="choice_store" >更多门店<text class="right-arrow"></text></view>
  66 + <view hidden="{{has_def && sys_switch.is_pricing_open_store}}" class="red-co fs28" bindtap="choice_store" >更多门店<text class="right-arrow"></text></view>
67 67 </view>
68 68 <view class="no_store" wx:if="{{def_pick_store.is_no_dis}}">(配送不匹配)</view>
69 69 <view class="no_store" wx:elif="{{is_normal && def_pick_store && def_pick_store.CanOutQty<=0}}">(库存不足)</view>
... ...
pages/goods/goodsInfo/goodsInfo.js
... ... @@ -480,6 +480,8 @@ Page({
480 480 th.data.fir_def_store = {}; //赋值空对象
481 481 return false;
482 482 }
  483 + th.setData({has_def:1});
  484 +
483 485 var ee = JSON.parse(JSON.stringify(e));
484 486 //--定时器推迟一下--
485 487 setTimeout(function () {
... ... @@ -489,6 +491,9 @@ Page({
489 491 ee.is_no_dis = 1;
490 492 }
491 493  
  494 +
  495 +
  496 +
492 497 var appd = getApp().globalData;
493 498 var w_time = setInterval(function () {
494 499 if (that.data.is_get_local_ok == 0) return false;
... ... @@ -552,7 +557,7 @@ Page({
552 557 var that = this, th = this;
553 558 getApp().getConfig2(function (e) {
554 559 var sales_rules = e.sales_rules;
555   - if (sales_rules == 2) {
  560 + if (sales_rules == 2 && [1,2,4,6,8,9].indexOf(th.data.prom_type)==-1 ) {
556 561 getApp().waitfor2(that, "wait_for_user_store", "fir_goods", function () {
557 562 var lock = 0, plist = null;
558 563 var gd = that.data.fir_goods;
... ... @@ -5792,6 +5797,11 @@ Page({
5792 5797 var ind = ee.currentTarget.dataset.ind;
5793 5798 var bconfig = th.data.bconfig;
5794 5799  
  5800 + //如果开启了,则不在选择门店
  5801 + if(this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){
  5802 + return false;
  5803 + }
  5804 +
5795 5805 if (!th.data.only_pk && !th.data.def_pickpu_list) {
5796 5806 // getApp().confirmBox("门店库存不足", null, 25000, !1);
5797 5807 wx.showToast({
... ... @@ -5818,6 +5828,12 @@ Page({
5818 5828 return false;
5819 5829 }
5820 5830  
  5831 + //如果开启了,则不在选择门店
  5832 + if(th.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){
  5833 + return false;
  5834 + }
  5835 +
  5836 +
5821 5837  
5822 5838 if (bconfig && bconfig.is_sort_storage) {
5823 5839 wx.getLocation({
... ...
pages/goods/goodsInfo/goodsInfo.wxml
... ... @@ -623,13 +623,13 @@
623 623 </view>
624 624 <!-- 门店收货地址 -->
625 625 <view class="xc-address_frame bdt16 flex-vertical xc-ash {{def_pick_store!=null?'sn_height':'on_height'}}">
626   - <view class="address_frame" bindtap="choice_store" data-ind="0">
  626 + <view class="address_frame" bindtap="choice_store" data-ind="0">
627 627 <view class="flex-vertical-between ">
628 628 <view class="flex-vertical select_store_height">
629 629 <image class="stores-img" src="{{iurl}}/miniapp/images/stores.png"></image>
630 630 <view class="fs30" style="color:black;">选择门店</view>
631 631 </view>
632   - <view class="red_bb fs26">更多门店<text class="bg_jj"></text></view>
  632 + <view hidden="{{has_def && sys_switch.is_pricing_open_store}}" class="red_bb fs26">更多门店<text class="bg_jj"></text></view>
633 633 </view>
634 634 <view wx:if="{{def_pick_store && def_pick_store.pickup_name}}">
635 635 <view class="flex-space-between address ai_end pdv10">
... ... @@ -1243,11 +1243,11 @@
1243 1243 </view>
1244 1244 </view>
1245 1245 <!-- 没有门店的时候 -->
1246   - <view class="flex" bindtap="choice_store" wx:else>
  1246 + <view class="flex" bindtap="choice_store" wx:else>
1247 1247 <image class="stores-img" src="{{iurl}}/miniapp/images/stores.png"></image>
1248 1248 <view class="fs30" style="color:black;">选择门店</view>
1249 1249 </view>
1250   - <view class="red-co fs28" bindtap="choice_store">更多门店<text class="right-arrow"></text></view>
  1250 + <view hidden="{{has_def && sys_switch.is_pricing_open_store}}" class="red-co fs28" bindtap="choice_store">更多门店<text class="right-arrow"></text></view>
1251 1251 </view>
1252 1252 <view wx:if="{{only_pk && !only_pk.length}}">(库存不足)</view>
1253 1253 <block wx:else>
... ...
pages/team/team_ping/team_ping.js
... ... @@ -87,7 +87,9 @@ Page({
87 87 order = null,//订单数据
88 88 goods = null,//商品数据
89 89 users = null,//会员数据
90   - order_goods=null;//订单商品表
  90 + order_goods=null,//订单商品表
  91 + team_g=null;
  92 +
91 93  
92 94 //获取订单表的信息根据活动user_id,pt_prom_id>0 AND pay_time>0
93 95  
... ... @@ -121,6 +123,15 @@ Page({
121 123 order[i].tx=ordertx;
122 124 })
123 125  
  126 + //获取teamgroup中的值
  127 + await getApp().request.promiseGet("/api/weshop/teamgroup/page", {
  128 + data: { store_id: os.stoid, listno: order[i].pt_listno,pageSize:1,page:1}
  129 + }).then(res => {
  130 + team_g = res.data.data.pageData[0]
  131 +
  132 + })
  133 +
  134 +
124 135  
125 136  
126 137 if (order[i].is_zsorder== 4) {
... ... @@ -132,13 +143,24 @@ Page({
132 143 order[i].max_ct_num = num;
133 144 }
134 145  
  146 + var head=[];
  147 + if(team_g.is_xuni_ct) {
  148 + head=team_g.xuni_head_id.split(",");
  149 + order[i].is_xuni_ct=1;
  150 + }
  151 +
135 152 var sf_num = order[i].ct_num;
136 153 if (order[i].ct_num>=3){ sf_num=3;}
137 154 sf_num=sf_num-ordertx.length;
138 155 if(sf_num>0) {
139 156 var arr = [];
140 157 for(var j=0;j<sf_num;j++){
141   - arr.push(j);
  158 + if(team_g.is_xuni_ct){
  159 + arr.push(head[j]);
  160 + }else{
  161 + arr.push(j);
  162 + }
  163 +
142 164 }
143 165 order[i].sf_num=arr;
144 166 }
... ...
pages/team/team_ping/team_ping.wxml
... ... @@ -91,7 +91,14 @@
91 91 <view class='foot-l-tx' style="margin-right:20rpx">
92 92 <view wx:if="{{item.tx}}" style="display: flex">
93 93 <image wx:for="{{item.tx}}" wx:for-item="aitem" src='{{aitem.head_pic}}'></image>
94   - <image src='{{iurl}}/miniapp/images/shafa.png' wx:for="{{item.sf_num}}"></image>
  94 + <block wx:if="{{item.is_xuni_ct}}">
  95 + <image src='{{iurl}}/miniapp/images/anonymous/anonymous{{item}}.png' wx:for="{{item.sf_num}}"></image>
  96 + </block>
  97 + <block wx:else>
  98 + <image src='{{iurl}}/miniapp/images/shafa.png' wx:for="{{item.sf_num}}"></image>
  99 + </block>
  100 +
  101 +
95 102 <view class="xc-ellipsis" wx:if="{{item.tx.length>3}}">...</view>
96 103 </view>
97 104 </view>
... ...
pages/team/team_show/team_show.js
... ... @@ -134,7 +134,8 @@ Page({
134 134  
135 135 var th=this;
136 136 getApp().getConfig2(function(e) {
137   - th.setData({ bconfig: e,});
  137 + var json_d = JSON.parse(e.switch_list);
  138 + th.setData({ bconfig: e,sys_switch:json_d});
138 139 th.wait_for_store_config(); //获取默认的门店
139 140 })
140 141  
... ... @@ -611,6 +612,8 @@ Page({
611 612 th.data.fir_def_store={}; //赋值空对象
612 613 return false;
613 614 }
  615 +
  616 + th.setData({has_def:1})
614 617 //--定时器推迟一下--
615 618 setTimeout(function () {
616 619 if(!th.data.goods) return false;
... ... @@ -1007,7 +1010,13 @@ Page({
1007 1010 choice_store: function(ee) {
1008 1011  
1009 1012 var th = this;
1010   - var bconfig = th.data.bconfig;
  1013 + var bconfig = th.data.bconfig;
  1014 +
  1015 + //如果开启了,则不在选择门店
  1016 + if(this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){
  1017 + return false;
  1018 + }
  1019 +
1011 1020 if(!th.data.only_pk && !th.data.def_pickpu_list){
1012 1021 getApp().confirmBox("门店库存不足", null, 25000, !1);
1013 1022 return false;
... ...
pages/team/team_show/team_show.wxml
... ... @@ -229,7 +229,7 @@
229 229 <view class="fs28 xc-ash-9f">选择门店</view>
230 230 </view>
231 231  
232   - <view class="red-co fs28" bindtap="choice_store">更多门店<text class="right-arrow"></text></view>
  232 + <view hidden="{{has_def && sys_switch.is_pricing_open_store}}" class="red-co fs28" bindtap="choice_store">更多门店<text class="right-arrow"></text></view>
233 233  
234 234  
235 235 </view>
... ...
pages/team/team_success/team_success.js
... ... @@ -181,6 +181,15 @@ Page({
181 181 ordertx = res.data.data.pageData;
182 182 })
183 183  
  184 + var team_g=null;
  185 + //获取teamgroup中的值
  186 + await getApp().request.promiseGet("/api/weshop/teamgroup/page", {
  187 + data: { store_id: os.stoid, listno: pt_listno,pageSize:1,page:1}
  188 + }).then(res => {
  189 + team_g = res.data.data.pageData[0]
  190 +
  191 + })
  192 +
184 193  
185 194 var min_price=0;
186 195 //获取活动表的信息根据活动pt_prom_id
... ... @@ -240,9 +249,23 @@ Page({
240 249 ordertx2.push(ordertx[i]);
241 250 }
242 251  
  252 +
  253 + var head=[];
  254 + if(team_g.is_xuni_ct) {
  255 + head=team_g.xuni_head_id.split(",");
  256 + order.is_xuni_ct=1;
  257 +
  258 + this.setData({head:head,});
  259 + }
  260 +
  261 +
243 262 var sf_arr=[];
244 263 for (var i=0;i<sf_num;i++){
245   - sf_arr.push(i);
  264 + if(team_g.is_xuni_ct){
  265 + sf_arr.push(head[i]);
  266 + }else{
  267 + sf_arr.push(i);
  268 + }
246 269 }
247 270  
248 271  
... ... @@ -283,6 +306,8 @@ Page({
283 306  
284 307 })
285 308  
  309 + if(!teamlist.virtual) teamlist.virtual=0;
  310 +
286 311 //--当是成团的时候的操作--
287 312 if(order.pt_status==2 || order.pt_status==4 || order.pt_status==5){
288 313 //设置值
... ...
pages/team/team_success/team_success.wxml
... ... @@ -23,7 +23,7 @@
23 23 </view>
24 24 <view class="xc-wc fs24">
25 25 <view>
26   - <view class="">已拼{{teamlist.buy_num}}件</view>
  26 + <view class="">已拼{{teamlist.buy_num+teamlist.virtual}}件</view>
27 27 <view class="flex xc-valframe t-c">
28 28 <view class="xc-frame-img">
29 29 <image class="picture" src="{{iurl}}/miniapp/images/bai-ren.png"></image>
... ... @@ -95,8 +95,8 @@
95 95 <image src='{{item.head_pic}}'></image>
96 96 <span wx:if="{{item.is_pt_tz==1}}">团长</span>
97 97 </view>
98   - <view class='d' wx:for="{{sf_arr}}" wx:if="{{p_status!=2}}">
99   - <image src='{{iurl}}/miniapp/images/shafa.png'></image>
  98 + <view class='d' wx:for="{{sf_arr}}">
  99 + <image src='{{iurl}}/miniapp/images/anonymous/anonymous{{item}}.png'></image>
100 100 </view>
101 101  
102 102 <view class='xc-ellipsis-img flex-vertical' wx:if="{{ordertx.length>5}}">
... ... @@ -143,7 +143,7 @@
143 143 <!-- 会员团 -->
144 144 <view class='bodytimecen' wx:if='{{(teamlist.kttype==1 || teamlist.kttype==2) && p_status==2}}'>
145 145 已经有
146   - <text class="xc-wc">{{ordertx.length}}</text>人参团, 拼团成功。
  146 + <text class="xc-wc">{{ordertx.length>teamlist.ct_num?ordertx.length:teamlist.ct_num}}</text>人参团, 拼团成功。
147 147 </view>
148 148  
149 149 <!----//旁边直线---->
... ... @@ -215,6 +215,15 @@
215 215 </view>
216 216  
217 217  
  218 + <view class='zhangxi' hidden="{{hiddenName}}" wx:for="{{head}}" >
  219 + <view class='img rel'>
  220 + <image src='{{iurl}}/miniapp/images/anonymous/anonymous{{item}}.png'></image>匿名
  221 + </view>
  222 + <view class='zssj'>{{filters.format_time(teamgroup.buyenddate,1)}} 参团</view>
  223 + <view class="clear"></view>
  224 + </view>
  225 +
  226 +
218 227 <view class='clear'></view>
219 228 </view>
220 229 <view class='clear'></view>
... ...