Commit 09c4905f261e02a4ac93a5b7bdd73cc76f2fa875

Authored by 泉州测试
2 parents d923de19 9267aaf9

Merge branch 'dev' of http://git.vipzhuang.cn/wxd/MShopWeApp into dev

... ... @@ -50,7 +50,7 @@ App({
50 50 config: null, //门店参数
51 51 config2: null, //门店配置
52 52 code: null,
53   - user_id:null,//3277,// 6519901,//6453964,// 4687,// 6519870,//5682094,
  53 + user_id:null,// 6519870,//5682094,
54 54 buy_now:null,
55 55 picklist:null, //门店列表
56 56 wuliuprice: null, //物流价格表
... ... @@ -661,8 +661,10 @@ App({
661 661 this.globalData.config=null; //清除config的缓存
662 662 this.globalData.gr_index=0; //商品分组的序列
663 663 this.globalData.pk_store=null;
664   - this.globalData.wxapp_buy_obj=null
665   -
  664 + this.globalData.wxapp_buy_obj=null;
  665 + this.globalData.dis_buy_obj=null; //等级卡的购买记录
  666 + this.globalData.storeFooter=null; //底部的导航
  667 + this.globalData.full_screen=null; //全屏
666 668 },
667 669  
668 670 clear_word:function (word) {
... ...
components/diy_goodsGroup/diy_goodsGroup.wxml
... ... @@ -669,7 +669,7 @@
669 669 <view class="sp">
670 670 <swiper-item class="s_it" wx:for="{{goods_array}}">
671 671 <block wx:for="{{item}}" wx:for-item="aitem" wx:for-index="aind">
672   - <navigator url="{{g_filter.get_url_by_type(item)}}" style="width: 32%" >
  672 + <navigator url="{{g_filter.get_url_by_type(aitem)}}" style="width: 32%" >
673 673 <view class="one {{object.big_order_type==0?'zj':''}}{{object.big_order_type==1?'yj':''}} " style="margin-left: 10rpx">
674 674 <view class='sp_top'>
675 675 <view class='s_img' style="position: relative; width: 100%">
... ...
components/goods_list/goods_list.wxml
... ... @@ -15,7 +15,7 @@
15 15 <!-- 商品名称 -->
16 16 <view class="goods_name ellipsis-2 fs28">{{item.goods_name}}</view>
17 17 <!-- 判断是否有活动价 -->
18   - <block wx:if="{{(item.prom_price>0 || item.prom_integral>0) && item.prom_id>0 && item.prom_type!=7}}">
  18 + <block wx:if="{{(item.prom_price>0 || item.prom_integral>0) && item.prom_id>0 && item.prom_type!=7 && item.prom_type!=10}}">
19 19 <view class="pdt10">
20 20 <view class="money flex xc-wc" >
21 21 <text wx:if="{{item.prom_integral}}"><text class="fs35" style="font-weight: bold;">{{item.prom_integral}}</text>积分</text>
... ...
pages/cart/cart/cart.js
... ... @@ -5,8 +5,9 @@ var t = getApp(),
5 5 app = getApp(),
6 6 rq = t.request,
7 7 ut = require("../../../utils/util.js"),
8   - zh_calc = require("zh_calculate.js");
9   - var regeneratorRuntime = require('../../../utils/runtime.js');
  8 + zh_calc = require("zh_calculate.js"),
  9 + ladder_calc = require("ladder_calculate.js");
  10 + var regeneratorRuntime = require('../../../utils/runtime.js');
10 11  
11 12 Page({
12 13 data: {
... ... @@ -38,6 +39,8 @@ Page({
38 39 zuhe_map:{},
39 40 zuhe_map_good:{},
40 41 in_zhact_gdmap:{}, //不同门店参与同一活动的限购
  42 +
  43 + ladder_map:{}, //阶梯促销需要的map
41 44 },
42 45 onLoad: function() {
43 46 var a = this,ee=a;
... ... @@ -83,7 +86,6 @@ Page({
83 86 th.setData({
84 87 bconfig: e,sales_rules:e.sales_rules
85 88 });
86   -
87 89 getApp().request.promiseGet("/store/storemoduleendtime/page?store_id=" +os.stoid + "&type=6",{}).then(res=>{
88 90 //未购买
89 91 if(res.data.code!=0 || !res.data.data || !res.data.data.pageData || !res.data.data.pageData.length){
... ... @@ -210,6 +212,8 @@ Page({
210 212 get_cart: function() {
211 213 var th = this;
212 214 th.data.in_zhact_gdmap={};
  215 + th.data.ladder_map={};
  216 +
213 217 var rd = Math.random().toString(36).substr(2, 15);
214 218 var user_id=getApp().globalData.userInfo.user_id;
215 219 getApp().request.get("/api/weshop/cart/list", {
... ... @@ -223,8 +227,7 @@ Page({
223 227 success:async function(su) {
224 228 console.log(su,10000);
225 229 //按门店分类的数组
226   - var arr = new Array(),
227   - carr = su.data.data.pageData;
  230 + var arr = new Array(), carr = su.data.data.pageData;
228 231 var all_num = 0;
229 232  
230 233 if(carr && carr.length>0) {
... ... @@ -354,20 +357,22 @@ Page({
354 357 }
355 358 }
356 359  
357   - //--判断优惠活动有没有过期--
  360 + //--判断优惠活动有没有过期,--
358 361 else if (item.prom_type == 3) {
359 362 var isok = 1,is_g_prom=0;
  363 +
360 364 //因为有全场优惠活动,商品参加的活动还未开始
361 365 var url="/api/weshop/activitylist/getGoodActInfo";
362 366 var req_data={
363   - store_id:os.stoid,goodsidlist:item.goods_id,is_detail:1,user_id:user_id
  367 + store_id:os.stoid,goodsidlist:item.goods_id,is_detail:1,user_id:user_id
364 368 };
365 369 await getApp().request.promiseGet(url, {data:req_data}).then(async function (res) {
366 370 if(res.data.code==0 && res.data.data && res.data.data.length){
367 371 for(let i in res.data.data){
368   - let item=res.data.data[i];
369   - if(item.prom_type==3) {
370   - is_g_prom=1; break;
  372 + let item=res.data.data[i];
  373 + if(item.prom_type==3) {
  374 + is_g_prom=1; break;
  375 +
371 376 }
372 377 }
373 378 }
... ... @@ -430,6 +435,9 @@ Page({
430 435 }
431 436  
432 437 if (!isok) continue;
  438 +
  439 +
  440 +
433 441 }
434 442 else if (item.prom_type == 7) {
435 443 if(!th.data.zuhe_map[item.prom_id]){
... ... @@ -517,6 +525,68 @@ Page({
517 525 // continue;
518 526 // }
519 527 }
  528 + else if (item.prom_type == 10) {
  529 + if(!th.data.ladder_map[item.prom_id]){
  530 + //如果有组合购
  531 + var isok = 1;
  532 + var is_flag=1;
  533 + var act=null;
  534 + var url="/api/weshop/prom/ladderForm/getNew/"+os.stoid+"/"+user_id+"/"+item.prom_id;
  535 + await getApp().request.promiseGet(url, {}).then(res => {
  536 + console.log(res,1000);
  537 + if(res.data.code==0 && res.data.data){
  538 + if(res.data.data.isuse!=1){
  539 + isok=0;
  540 + }
  541 + //如果活动已经结束
  542 + if(res.data.data.is_end==1){
  543 + isok=0;
  544 + }
  545 + //已经结束
  546 + if(ut.gettimestamp()>res.data.data.end_time){
  547 + isok=0;
  548 + }
  549 + //还未开始
  550 + if(ut.gettimestamp()<res.data.data.start_time){
  551 + isok=0;
  552 + }
  553 + act=res.data.data;
  554 +
  555 + }else{
  556 + //未找到商品的活动
  557 + is_flag = 0;
  558 + }
  559 + })
  560 + if (!isok){
  561 + var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
  562 + getApp().request.delete(url, {});
  563 + th.data.ladder_map[item.prom_id]=-1;
  564 + continue;
  565 + }
  566 + th.data.ladder_map[item.prom_id]=act;
  567 +
  568 + //-- 获取阶梯规则 --
  569 + var url1 = "/api/weshop/prom/ladderList/list";
  570 + var req_data = {
  571 + store_id: os.stoid,
  572 + form_id: item.prom_id,
  573 + }
  574 + await getApp().request.promiseGet(url1, {
  575 + data: req_data
  576 + }).then(rs1 => {
  577 + if (rs1.data.code==0 && rs1.data.data) {
  578 + var gdlist = rs1.data.data;
  579 + th.data.ladder_map[item.prom_id].ladder_list=gdlist;
  580 + }
  581 + })
  582 + }
  583 + //直接把活动赋值给元素
  584 + if(th.data.ladder_map[item.prom_id] && th.data.ladder_map[item.prom_id]!=-1 ){
  585 + item.act=th.data.ladder_map[item.prom_id];
  586 + }
  587 +
  588 + }
  589 +
520 590 else if(item.prom_type == 0) {
521 591 //如果有优惠活动,要更新活动
522 592 await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + item.goods_id + "/1", {}).then(res => {
... ... @@ -622,9 +692,6 @@ Page({
622 692 }
623 693 }
624 694  
625   - // console.log('AAAAAAAAAAAA', all_num);
626   - // getApp().globalData.cartGoodsNum = all_num;
627   -
628 695 th.setData({
629 696 requestData: arr,
630 697 all_num: all_num,
... ... @@ -995,11 +1062,13 @@ Page({
995 1062 if(item[j].is_gift) continue;
996 1063  
997 1064 var obj=JSON.parse(JSON.stringify(item[j]));
998   - //计算之前先移除
  1065 + //计算之前先移除组合购的计算
999 1066 if(obj.prom_type==7)
1000 1067 zh_calc.remove_zhprom(dda,i,obj);
1001   -
1002   -
  1068 + //计算之前先移除阶梯购的计算
  1069 + if(obj.prom_type==10)
  1070 + ladder_calc.remove_ladder_prom(dda,i,obj);
  1071 +
1003 1072 if (fir == 0) {
1004 1073 fir = item[j].distr_type;
1005 1074 } else {
... ... @@ -1012,8 +1081,12 @@ Page({
1012 1081 var txt = "requestData[" + i + "].goods[" + j + "].selected";
1013 1082  
1014 1083 if(e.data.checkAllToggle) obj.goods_num=0;
1015   - if(obj.prom_type==7)
1016   - zh_calc.add_zhprom(dda,i,obj);
  1084 +
  1085 + //加入组合购计算
  1086 + if(obj.prom_type==7) zh_calc.add_zhprom(dda,i,obj);
  1087 + //加入阶梯促销计算
  1088 + if(obj.prom_type==10) ladder_calc.add_ladder_prom(dda,i,obj);
  1089 +
1017 1090  
1018 1091 e.setData({
1019 1092 [txt]: !e.data.checkAllToggle,
... ... @@ -1021,7 +1094,7 @@ Page({
1021 1094  
1022 1095 if (!e.data.checkAllToggle) {
1023 1096 //组合购的金额要另外算
1024   - if(item[j].prom_type!=7)
  1097 + if(item[j].prom_type!=7 && item[j].prom_type!=10)
1025 1098 tfeel += item[j].goods_num * item[j].goods_price;
1026 1099 t_num += item[j].goods_num;
1027 1100 }
... ... @@ -1059,6 +1132,12 @@ Page({
1059 1132 offline_price+=zh_calc_res.offline_price;
1060 1133 offline_num+=zh_calc_res.offline_num;
1061 1134  
  1135 + //总的价格,把阶梯促销的商品的价格拿出来
  1136 + var ladder_calc_res=ladder_calc.calculate_ladder(dda,i,this);
  1137 + tfeel+=ladder_calc_res.tfeel;
  1138 + offline_price+=ladder_calc_res.offline_price;
  1139 + offline_num+=ladder_calc_res.offline_num;
  1140 +
1062 1141 //当有线下取价的时候
1063 1142 if(offline_price){
1064 1143 var txt1= "requestData[" + i + "].offline_price";
... ... @@ -1373,7 +1452,10 @@ Page({
1373 1452  
1374 1453 //不管怎么样都要移出去
1375 1454 var obj=JSON.parse(JSON.stringify(item[c]));
  1455 +
1376 1456 zh_calc.remove_zhprom(car,a,obj);
  1457 + ladder_calc.remove_ladder_prom(car,a,obj);
  1458 +
1377 1459 if (item[c].selected == 0) {
1378 1460 ischeck = 0;
1379 1461 is_s_sele = 0;
... ... @@ -1381,11 +1463,20 @@ Page({
1381 1463 obj.goods_num=0;
1382 1464 zh_calc.add_zhprom(car,a,obj);
1383 1465 }
  1466 + if(item[c].prom_type==10) {
  1467 + obj.goods_num=0;
  1468 + ladder_calc.add_ladder_prom(car,a,obj);
  1469 + }
  1470 +
  1471 +
1384 1472 } else {
1385 1473 if(item[c].prom_type==7){
1386   - //先把商品放入组合计算的专用的区域
1387   - zh_calc.add_zhprom(car,a,obj);
1388   - }else{
  1474 + //先把商品放入组合计算的专用的区域
  1475 + zh_calc.add_zhprom(car,a,obj);
  1476 + }else if(item[c].prom_type==10){
  1477 + ladder_calc.add_ladder_prom(car,a,obj);
  1478 + }
  1479 + else{
1389 1480 tfeel += item[c].goods_num * item[c].goods_price;
1390 1481 }
1391 1482 t_num += item[c].goods_num;
... ... @@ -1400,10 +1491,17 @@ Page({
1400 1491  
1401 1492 //总的价格,把组合商品的价格拿出来
1402 1493 var zh_calc_res=zh_calc.calculate_zh(car,a,th);
  1494 + //总的价格,把阶梯促销商品的价格拿出来
  1495 + var ladder_calc_res=ladder_calc.calculate_ladder(car,a,th);
  1496 +
1403 1497 tfeel+=zh_calc_res.tfeel;
1404 1498 offline_price+=zh_calc_res.offline_price;
1405 1499 offline_num+=zh_calc_res.offline_num;
1406 1500  
  1501 + tfeel+=ladder_calc_res.tfeel;
  1502 + offline_price+=ladder_calc_res.offline_price;
  1503 + offline_num+=ladder_calc_res.offline_num;
  1504 +
1407 1505 var txt = "requestData[" + a + "].selected";
1408 1506 th.setData({
1409 1507 [txt]: Number(is_s_sele)
... ... @@ -1456,9 +1554,6 @@ Page({
1456 1554 });
1457 1555 }
1458 1556 }
1459   -
1460   - // getApp().globalData.cartGoodsNum = all_num;
1461   - // console.log('CCCCCCC', all_num, getApp().globalData.cartGoodsNum);
1462 1557  
1463 1558 this.setData({
1464 1559 checkAllToggle: ischeck,
... ... @@ -1494,6 +1589,8 @@ Page({
1494 1589  
1495 1590 // console.log('update');
1496 1591 // console.log('9995959595959',t);
  1592 + var e = this,th=e;
  1593 + var user_id = getApp().globalData.user_id;
1497 1594 rq.get("/api/weshop/goods/get/" + oo.stoid + "/" + t.goods_id, {
1498 1595 isShowLoading: 0,
1499 1596 async success(d) {
... ... @@ -1523,8 +1620,10 @@ Page({
1523 1620 }
1524 1621 goodsbuynum = buy_num_data.goodsbuynum;
1525 1622  
  1623 +
1526 1624 })
1527 1625  
  1626 +
1528 1627 var buyed_mum2 = t.goods_num + goodsbuynum;
1529 1628 if (buyed_mum2 > limit && limit > 0) {
1530 1629 wx.showModal({
... ...
pages/cart/cart/cart.wxml
... ... @@ -164,6 +164,15 @@
164 164 </view>
165 165 </block>
166 166  
  167 + <!-- 阶梯促销提示多少件的优惠 -->
  168 + <block wx:if="{{item.l_need_list && item.l_need_list.length>0 && !is_edit}}">
  169 +
  170 + <view class="fs28 pdr20 pdl20 pdb20 c-red2 flex jc_sb" wx:for="{{item.l_need_list}}">
  171 + <text>{{item.title}}</text>
  172 + <text data-url="/pages/goods/goodsList/goodsList?ladder_id={{item.id}}" bindtap="go_url">去凑单</text>
  173 + </view>
  174 + </block>
  175 +
167 176  
168 177 <!-- 线下取价 -->
169 178 <view style="margin:10rpx 0; padding: 0 30rpx;color: #999" wx:if="{{item.offline_price}}" class="fs28">
... ...
pages/cart/cart/ladder_calculate.js 0 → 100644
  1 +module.exports = {
  2 + //辅助数组添加元素功能
  3 + find_in_add: function(list, ele) {
  4 + var idx=list.findIndex(function (e) {
  5 + return e.goods_id==ele.goods_id;
  6 + })
  7 + if(idx>-1) return false;
  8 + list.push(ele);
  9 + },
  10 + //辅助数组添加元素功能
  11 + find_in_remove: function(list, ele) {
  12 + var idx=list.findIndex(function (e) {
  13 + return e.goods_id==ele.goods_id;
  14 + })
  15 + if(idx==-1) return false;
  16 + list.splice(idx, 1);
  17 + },
  18 +
  19 + //主要是把组合购的商品分离出来
  20 + add_ladder_prom: function(car, a, ele) {
  21 + var point = car[a];
  22 + if (point.ladder_map) {
  23 + if (point.ladder_map[ele.prom_id]) {
  24 + this.find_in_add(point.ladder_map[ele.prom_id].goods, ele);
  25 + } else {
  26 + point.ladder_map[ele.prom_id] = {
  27 + goods: [],
  28 + act: ele.act
  29 + };
  30 + point.ladder_map[ele.prom_id].goods.push(ele);
  31 + }
  32 + } else {
  33 + point.ladder_map = {};
  34 + point.ladder_map[ele.prom_id] = {
  35 + goods: [],
  36 + act: ele.act
  37 + };
  38 + point.ladder_map[ele.prom_id].goods.push(ele);
  39 + }
  40 + },
  41 + //未选中的商品,要从中剔除
  42 + remove_ladder_prom: function(car, a, ele) {
  43 + var point = car[a];
  44 + if (point.ladder_map) {
  45 + if (point.ladder_map[ele.prom_id]) {
  46 + this.find_in_remove(point.ladder_map[ele.prom_id].goods, ele);
  47 + }
  48 + }
  49 + },
  50 +
  51 + //把组合购的商品价格计算出来,同时每个会员都有购买组合商品的上限!ladder_b_num是已经购买了多少件
  52 + calculate_ladder: function(car, a, th) {
  53 + var car_item = car[a];
  54 + var tfeel = 0,offline_price = 0,offline_num = 0;
  55 + var txt = "requestData[" + a + "].l_need_list";
  56 + var need_to=[];
  57 +
  58 + //活动的列表都存储在这里面,可以快速查询
  59 + if (!car_item.ladder_map) {
  60 + var res = {
  61 + tfeel: tfeel,
  62 + offline_price: offline_price,
  63 + offline_num: offline_num
  64 + };
  65 + th.setData({
  66 + [txt]: null
  67 + });
  68 + return res;
  69 + }
  70 +
  71 + //因为可能有多个组合购的活动
  72 + for (var mi in car_item.ladder_map) {
  73 + var bitem = car_item.ladder_map[mi];
  74 + var act = bitem.act; //获取到组合购的详情
  75 + var all_num = 0; //商品数量之和
  76 + var all_price = 0;
  77 + var aprice=0;
  78 + var no_in_arr = []; //剩余的未加入组合购
  79 +
  80 + var title =""; //提示语;
  81 + var goods = car_item.goods;
  82 +
  83 + //-- 每件商品要剔除的量 --
  84 + for (let v3 in car_item.goods) {
  85 + car_item.goods[v3].l_need_downlow_num=0;
  86 + }
  87 +
  88 + //寻找一下
  89 + function get_num2(ite) {
  90 + var vh=car_item.goods.findIndex(function (e) {
  91 + return e.goods_id == ite.goods_id
  92 + })
  93 + if(vh>-1) return car_item.goods[vh];
  94 + return 0;
  95 + }
  96 +
  97 + for (var i in goods) {
  98 + if(goods[i].prom_type!=10) continue;
  99 + if(!goods[i].selected) continue;
  100 + if(goods[i].prom_id!=act.id) continue;
  101 + var item = goods[i];
  102 + item.goods_price=item.goods_price;
  103 + item.offline_price=item.offline_price;
  104 + item.cart_num =item.goods_num;
  105 + all_num += item.cart_num;
  106 + for (var j = 0; j < item.cart_num; j++) {
  107 + no_in_arr.push({
  108 + price: item.goods_price,offline_price:item.offline_price,goods_id:item.goods_id,shop_price:item.shop_price
  109 + })
  110 + }
  111 + }
  112 +
  113 + function sortData(a, b) {
  114 + return a.price - b.price
  115 + }
  116 + no_in_arr.sort(sortData);
  117 +
  118 + //开始阶梯计算价格
  119 + var lev=0;
  120 + for(let j in act.ladder_list){
  121 + if(no_in_arr.length==0) break;
  122 + let item_j=act.ladder_list[j];
  123 + var end=no_in_arr.pop();
  124 + var new_price=parseInt(item_j.discount_field)==1?end.shop_price:end.price;
  125 + aprice+=new_price* parseFloat(item_j.discount)/10;
  126 + lev++;
  127 + }
  128 +
  129 + //获取阶梯促销的下一个促销
  130 + if(lev>0 && lev<act.ladder_list.length){
  131 + title = "再买1件,第"+(lev+1)+"件"+act.ladder_list[lev].discount+"折";
  132 + var it = {
  133 + id: act.id,
  134 + pickup_id: car_item.pid,
  135 + title: title
  136 + };
  137 + need_to.push(it);
  138 + }
  139 +
  140 + all_price+=aprice;
  141 + //算一下剩余的钱
  142 + if (no_in_arr.length) {
  143 + for (var ii in no_in_arr) {
  144 + var item = no_in_arr[ii];
  145 + var gitem=get_num2(item);
  146 + if(gitem) {
  147 + if (!gitem.l_need_downlow_num) {
  148 + gitem.l_need_downlow_num = 1;
  149 + }
  150 + else {
  151 + gitem.l_need_downlow_num++;
  152 + }
  153 + all_price += item.price;
  154 + if (item.offline_price) {
  155 + offline_price += gitem.goods_price - gitem.offline_price;
  156 + offline_num += 1;
  157 + }
  158 + }
  159 + }
  160 + }
  161 + tfeel += all_price;
  162 + }
  163 + var res = {
  164 + tfeel: tfeel,
  165 + aprice:aprice,
  166 + offline_price: offline_price,
  167 + offline_num: offline_num,
  168 + };
  169 +
  170 + th.setData({ [txt]: need_to});
  171 + return res;
  172 + },
  173 +
  174 + find_need_to: function(list, iter) {
  175 + if (!list || list.length <= 0) return -1;
  176 + for (var i in list) {
  177 + var item = list[i];
  178 + if (item.id == iter.id) {
  179 + return i;
  180 + }
  181 + }
  182 + return -1;
  183 + },
  184 +
  185 + //筛选阶梯促销,纯粹的数组按活动id分组
  186 + find_split: function(arr) {
  187 + //过滤只有团购的商品
  188 + var oarr = arr.goods.filter(function(ele) {
  189 + return ele.prom_type == 10
  190 + })
  191 + if(!oarr || oarr.length==0) return null;
  192 + //看一下有多少个不同的团购
  193 + var map = {},dest = [];
  194 + for (var i = 0; i < oarr.length; i++) {
  195 + var ai = oarr[i];
  196 + var index=map[ai.prom_id]
  197 + if (!index) {
  198 + dest.push({
  199 + prom_id: ai.prom_id,
  200 + data: [ai]
  201 + });
  202 + map[ai.prom_id]=dest.length; //存储下标
  203 + } else {
  204 + var dj = dest[index-1];
  205 + dj.data.push(ai);
  206 + }
  207 + }
  208 + return dest;
  209 + }
  210 +
  211 +
  212 +}
... ...
pages/cart/cart2/cart2.js
... ... @@ -4,6 +4,7 @@ var oo = t.globalData.setting, os = oo;
4 4 var regeneratorRuntime = require('../../../utils/runtime.js');
5 5 var util_pay = require("../../../utils/pay.js");
6 6 var zh_calc = require("zh_calculate.js");
  7 +var ladder_calc = require("ladder_calculate.js");
7 8  
8 9 Page({
9 10 data: {
... ... @@ -33,6 +34,7 @@ Page({
33 34 couponCode: "",//使用优惠券(多单就用逗号隔开)
34 35 shipping_price: 0,//物流费用
35 36 },
  37 +
36 38 /*-----------当是购物车结算的时候-------------*/
37 39 cartlist: null,
38 40 old_cartlist: null,
... ... @@ -124,7 +126,10 @@ Page({
124 126 in_zhact_gdmap:{}, //不同门店参与同一活动的限购
125 127 hid_inp:1,
126 128 user_note:{},
127   - zuhe_map_good:{},
  129 + zuhe_map_good:{}, //组合购的map表
  130 + ladder_map:{}, //阶梯促销的map表
  131 +
  132 + state:0, //阶梯促销的的立即购买也走购物车流程state=1
128 133 },
129 134 onLoad: function (t) {
130 135 wx.setNavigationBarTitle({title: "填写订单",})
... ... @@ -140,6 +145,11 @@ Page({
140 145 }
141 146 });
142 147  
  148 + //阶梯购的立即购买
  149 + if(t.state){
  150 + th.data.state=1;
  151 + }
  152 +
143 153  
144 154 },
145 155 onUnload: function () {
... ... @@ -407,9 +417,11 @@ Page({
407 417 //-----真的获取购物车,入口--------
408 418 get_cart: function () {
409 419 var th = this, app = getApp();
  420 + var state=0;
  421 + if(th.data.state) state=1;
410 422 a.get("/api/weshop/cart/list", {
411 423 data: {
412   - user_id: to.globalData.user_id, selected: 1, state: 0,
  424 + user_id: to.globalData.user_id, selected: 1, state: state,
413 425 store_id: oo.stoid, pageSize: 600
414 426 },
415 427 success: async function (su) {
... ... @@ -452,54 +464,113 @@ Page({
452 464 }
453 465  
454 466 //要把组合购的东西拿出来算一下
455   - if (item1.prom_type == 7) {
456   - var isok = 1;
457   - var is_flag=1;
458   - //如果有组合购
459   - var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + item1.prom_id+'/'+getApp().globalData.userInfo.user_id;
460   - await getApp().request.promiseGet(url, {}).then(res => {
461   - if (res.data.code == 0 && res.data.data) {
462   - //如果活动已经结束
463   - if (res.data.data.is_end == 1) {
464   - isok = 0;
465   - }
466   - if (ut.gettimestamp() > res.data.data.end_time) {
467   - isok = 0;
  467 + if(item1.prom_type == 7) {
  468 + if(!th.data.zuhe_map_good[item1.prom_id]) {
  469 + var isok = 1;
  470 + var is_flag = 1;
  471 + //如果有组合购
  472 + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + item1.prom_id + '/' + getApp().globalData.userInfo.user_id;
  473 + await getApp().request.promiseGet(url, {}).then(res => {
  474 + if (res.data.code == 0 && res.data.data) {
  475 + //如果活动已经结束
  476 + if (res.data.data.is_end == 1) {
  477 + isok = 0;
  478 + }
  479 + if (ut.gettimestamp() > res.data.data.end_time) {
  480 + isok = 0;
  481 + }
  482 + item1.act = res.data.data;
  483 + } else {
  484 + //未找到商品的活动
  485 + is_flag = 0;
468 486 }
469   - item1.act = res.data.data;
470   - } else {
471   - //未找到商品的活动
472   - is_flag = 0;
  487 + })
  488 + if (!isok) {
  489 + getApp().my_warnning("组合购的活动已经过期", 0, th);
  490 + return false;
473 491 }
474   - })
475   - if (!isok) {
476   - getApp().my_warnning("组合购的活动已经过期", 0, th);
477   - return false;
478   - }
479   - var url1 = "/api/weshop/prom/zhbuyGoods/page";
480   - var req_data = {
481   - page: 1,
482   - pageSize: 2000,
483   - store_id: os.stoid,
484   - zh_id: item1.prom_id,
  492 + var url1 = "/api/weshop/prom/zhbuyGoods/page";
  493 + var req_data = {
  494 + page: 1,
  495 + pageSize: 2000,
  496 + store_id: os.stoid,
  497 + zh_id: item1.prom_id,
  498 + }
  499 + await getApp().request.promiseGet(url1, {
  500 + data: req_data
  501 + }).then(res => {
  502 + if (ut.ajax_ok(res)) {
  503 + var gdlist = res.data.data.pageData;
  504 + gdlist.forEach(i => {
  505 + if (item1.goods_id == i.goods_id && !is_flag) {
  506 + item1.prom_type = 0;
  507 + item1.prom_type1 = 0;
  508 + item1.prom_id = 0;
  509 + item1.prom_id1 = 0
  510 + }
  511 + })
  512 + th.data.zuhe_map_good[item1.prom_id] = gdlist;
  513 + }
  514 + })
485 515 }
486   - await getApp().request.promiseGet(url1, {
487   - data: req_data
488   - }).then(res => {
489   - if (ut.ajax_ok(res)) {
490   - var gdlist = res.data.data.pageData;
491   - gdlist.forEach(i=>{
492   - if(item1.goods_id==i.goods_id&&!is_flag){
493   - item1.prom_type=0;
494   - item1.prom_type1=0;
495   - item1.prom_id=0;
496   - item1.prom_id1=0
  516 + }
  517 + if(item1.prom_type==10){
  518 + if(!th.data.ladder_map[item1.prom_id]){
  519 + //如果有组合购
  520 + var isok = 1;
  521 + var is_flag=1;
  522 + var act=null;
  523 + var url="/api/weshop/prom/ladderForm/get/"+os.stoid+"/"+item1.prom_id;
  524 + await getApp().request.promiseGet(url, {}).then(res => {
  525 + console.log(res,1000);
  526 + if(res.data.code==0 && res.data.data){
  527 + if(res.data.data.isuse!=1){
  528 + isok=0;
497 529 }
498   - })
499   - th.data.zuhe_map_good[item1.prom_id]=gdlist;
  530 + //如果活动已经结束
  531 + if(res.data.data.is_end==1){
  532 + isok=0;
  533 + }
  534 + //已经结束
  535 + if(ut.gettimestamp()>res.data.data.end_time){
  536 + isok=0;
  537 + }
  538 + //还未开始
  539 + if(ut.gettimestamp()<res.data.data.start_time){
  540 + isok=0;
  541 + }
  542 + act=res.data.data;
  543 +
  544 + }else{
  545 + //未找到商品的活动
  546 + is_flag = 0;
  547 + }
  548 + })
  549 + if (!isok){
  550 + var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
  551 + getApp().request.delete(url, {});
  552 + th.data.ladder_map[item1.prom_id]=-1;
  553 + continue;
500 554 }
501   - })
  555 + th.data.ladder_map[item1.prom_id]=act;
  556 +
  557 + //-- 获取阶梯规则 --
  558 + var url1 = "/api/weshop/prom/ladderList/list";
  559 + var req_data = {
  560 + store_id: os.stoid,
  561 + form_id: item1.prom_id,
  562 + }
  563 + await getApp().request.promiseGet(url1, {
  564 + data: req_data
  565 + }).then(rs1 => {
  566 + if (rs1.data.code==0 && rs1.data.data) {
  567 + var gdlist = rs1.data.data;
  568 + th.data.ladder_map[item1.prom_id].ladder_list=gdlist;
  569 + }
  570 + })
  571 + }
502 572 }
  573 +
503 574 }
504 575  
505 576 //在分组的时候,就不要再调用接口,await
... ... @@ -688,31 +759,31 @@ Page({
688 759 //存储不同活动的商品列表
689 760 u_item.zh_prom_goods = {};
690 761 for (let var1 in obj) {
691   - var h_item=obj[var1];
692   - var gdlist= th.data.zuhe_map_good[h_item.prom_id];
693   - //获取活动需要的商品列表
694   - // u_item.zh_prom_goods[h_item.prom_id]=gdlist;
695   - // var h_item = obj[var1];
696   - // var gdlist = null;
697   - // var url1 = "/api/weshop/prom/zhbuyGoods/page";
698   - // var req_data = {
699   - // page: 1,
700   - // pageSize: 2000,
701   - // store_id: os.stoid,
702   - // zh_id: h_item.prom_id,
703   - // }
704   - // await getApp().request.promiseGet(url1, {
705   - // data: req_data
706   - // }).then(res => {
707   - // if (ut.ajax_ok(res)) {
708   - // gdlist = res.data.data.pageData;
709   - // }
710   - // })
  762 + var h_item = obj[var1];
  763 + var gdlist = th.data.zuhe_map_good[h_item.prom_id];
711 764 //获取活动需要的商品列表
712 765 u_item.zh_prom_goods[h_item.prom_id] = {gdlist: gdlist, act: h_item.act};
713 766 }
714 767 zh_calc.fir_set_arr(u_item, th);
715 768 }
  769 +
  770 + //每一个门店内的阶梯促销要进行拆分,
  771 + //还得把阶梯促销商品的多余商品的线下价格算一算
  772 + for (let var1 in arr) {
  773 + //把阶梯促销进行分组
  774 + var obj = ladder_calc.find_split(u_item);
  775 + if (!obj) continue;
  776 + //存储不同阶梯促销活动的商品列表
  777 + u_item.ladder_map = {};
  778 + for (let var1 in obj) {
  779 + var h_item=obj[var1];
  780 + var act= th.data.ladder_map[h_item.prom_id];
  781 + //获取活动需要的商品列表
  782 + u_item.ladder_map[h_item.prom_id] =act;
  783 + }
  784 + ladder_calc.fir_set_arr(u_item, th);
  785 + }
  786 +
716 787 //深拷贝
717 788 th.data.old_cartlist = JSON.parse(JSON.stringify(arr));
718 789 th.setData({
... ... @@ -1270,6 +1341,7 @@ Page({
1270 1341 var all_coupon_price_m = 0; //所有的订单用户使用优惠券价格
1271 1342 var all_cutprice = 0; //所有的优惠减
1272 1343 var all_zh_cutprice = 0; //所有的组合优惠减
  1344 + var all_ladder_cutprice = 0; //所有的阶梯促销优惠减
1273 1345 var all_order_prom = 0; //所有的订单优惠
1274 1346  
1275 1347 var umoney = th.data.userinfo.user_money - th.data.txmon - (th.data.userinfo.frozen_money ? th.data.userinfo.frozen_money : 0);
... ... @@ -1302,6 +1374,8 @@ Page({
1302 1374 await th.calc_per(c_arr);
1303 1375 //调用函数计算每件组合购商品的单价,
1304 1376 await zh_calc.calc_zh_split_price(c_arr,th);
  1377 + //调用函数计算每件阶梯促销商品的单价,
  1378 + await ladder_calc.calc_split_price(c_arr,th);
1305 1379 //调用函数计算,优惠券优惠什么商品价格,优惠券优惠什么商品
1306 1380 await th.get_cart_quan(c_arr);
1307 1381 //---循环购物车---
... ... @@ -1333,7 +1407,10 @@ Page({
1333 1407 var coupon_price = 0;
1334 1408 var quan_no = null;
1335 1409 var is_has_zh=c_arr[i].is_has_zh;
1336   - var zh_prom_goods=c_arr[i].zh_prom_goods; //组合购计算的原始数据存储空间
  1410 + var is_has_ladder=c_arr[i].is_has_ladder;
  1411 +
  1412 + var zh_prom_goods=c_arr[i].zh_prom_goods; //组合购计算的原始数据存储空间
  1413 + var ladder_prom_goods=c_arr[i].ladder_prom_goods; //组合购计算的原始数据存储空间
1337 1414  
1338 1415 if (th.data.using_quan[pickid] != null && th.data.using_quan[pickid] != undefined)
1339 1416 quan_no = th.data.using_quan[pickid].coupon_no;
... ... @@ -1361,12 +1438,24 @@ Page({
1361 1438  
1362 1439 //--------循环计算总价-----------
1363 1440 for (var j = 0; j < item.length; j++) {
1364   - if(item[j].prom_type!=7){
1365   - o_price_no_zh += item[j].goods_price * item[j].goods_num;
  1441 +
  1442 + var is_no_zh=0;
  1443 + if(item[j].prom_type!=7 && item[j].prom_type!=10 ) is_no_zh=1;
  1444 +
  1445 + //组合购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加
  1446 + if(item[j].prom_type==7 && zh_prom_goods && zh_prom_goods[item[j].prom_id]
  1447 + && zh_prom_goods[item[j].prom_id].act.is_orderyh )
  1448 + {
  1449 + is_no_zh=1;
1366 1450 }
1367 1451 //组合购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加
1368   - else if(zh_prom_goods && zh_prom_goods[item[j].prom_id] && zh_prom_goods[item[j].prom_id].act.is_orderyh )
  1452 + if(item[j].prom_type==10 && ladder_prom_goods && ladder_prom_goods[item[j].prom_id]
  1453 + && th.data.ladder_map[item[j].prom_id].is_useorderyh )
1369 1454 {
  1455 + is_no_zh=1;
  1456 + }
  1457 +
  1458 + if(is_no_zh){
1370 1459 o_price_no_zh += item[j].goods_price * item[j].goods_num;
1371 1460 }
1372 1461 o_price += item[j].goods_price * item[j].goods_num;
... ... @@ -1385,13 +1474,25 @@ Page({
1385 1474 //找到那些可以订单优惠叠加的
1386 1475 for(let ij in zh_prom_goods){
1387 1476 let kitem=zh_prom_goods[ij];
1388   - var is_has_zh=kitem.is_has_zh;
1389 1477 if(kitem.act.is_orderyh)
1390 1478 o_price_no_zh-=kitem.cut_price;
1391 1479 }
1392 1480 }
1393 1481 }
1394 1482  
  1483 + //如果有组合购优惠的钱,就要减价
  1484 + if (c_arr[i].ladder_cut_price>0 || c_arr[i].ladder_cut_price<0){
  1485 + o_price -= c_arr[i].ladder_cut_price;
  1486 + if(o_price_no_zh>0){
  1487 + //找到那些可以订单优惠叠加的
  1488 + for(let ij in ladder_prom_goods){
  1489 + let kitem=ladder_prom_goods[ij];
  1490 + if(th.data.ladder_map[ij].is_useorderyh )
  1491 + o_price_no_zh-=kitem.cut_price;
  1492 + }
  1493 + }
  1494 + }
  1495 +
1395 1496 //-- 计算线下取价的功能 --
1396 1497 if (cart_item.is_offline == 1) {
1397 1498 o_price = o_price - cart_item.offline_price;
... ... @@ -1581,6 +1682,13 @@ Page({
1581 1682 o_condition=o_price_no_zh-quan_price;
1582 1683 }
1583 1684  
  1685 + //看一下是不是不用组合购的订单优惠的叠加
  1686 + if(is_has_ladder){
  1687 + o_condition=o_price_no_zh-quan_price;
  1688 + }
  1689 +
  1690 +
  1691 +
1584 1692 var order_m = 0;
1585 1693 //---判断是不是有订单优惠---
1586 1694 await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
... ... @@ -1664,6 +1772,7 @@ Page({
1664 1772 all_coupon_price_m += parseFloat(cart_item.coupon_price);
1665 1773 all_cutprice += parseFloat(cart_item.cut_price);
1666 1774 all_zh_cutprice += parseFloat(cart_item.zh_cut_price);
  1775 + all_ladder_cutprice += parseFloat(cart_item.ladder_cut_price);
1667 1776 all_order_prom += parseFloat(cart_item.order_prom_amount);
1668 1777 }
1669 1778  
... ... @@ -1677,6 +1786,7 @@ Page({
1677 1786 all_cutprice = all_cutprice.toFixed(2);
1678 1787 all_order_prom = all_order_prom.toFixed(2);
1679 1788 all_zh_cutprice = parseFloat(all_zh_cutprice).toFixed(2);
  1789 + all_ladder_cutprice = parseFloat(all_ladder_cutprice).toFixed(2);
1680 1790  
1681 1791 var atxt = "formData.total_amount";
1682 1792 var atxt1 = "formData.order_amount";
... ... @@ -1687,12 +1797,13 @@ Page({
1687 1797 var atxt6 = "formData.cut_price";
1688 1798 var atxt7 = "formData.order_prom_amount";
1689 1799 var atxt8 = "formData.zh_cut_price";
  1800 + var atxt9 = "formData.ladder_cut_price";
1690 1801  
1691 1802 th.setData({
1692 1803 [atxt]: all_total_m, [atxt1]: all_order_m,
1693 1804 [atxt2]: all_price, [atxt3]: all_user_m, [atxt4]: all_shipping_m,
1694 1805 [atxt5]: all_coupon_price_m, [atxt6]: all_cutprice,
1695   - [atxt7]: all_order_prom, show_submit: 1, [atxt8]: all_zh_cutprice
  1806 + [atxt7]: all_order_prom, show_submit: 1, [atxt8]: all_zh_cutprice, [atxt9]: all_ladder_cutprice
1696 1807 })
1697 1808 th.data.order_prom_list_cart = c_arr;
1698 1809 th.set_can_num();
... ... @@ -2380,13 +2491,22 @@ Page({
2380 2491 //--判断优惠活动的提交--
2381 2492 if (t_item.cut_price > 0) {
2382 2493 order_prom_list.discount_amount += t_item.cut_price;
2383   - order_prom_list.prom_pt_json = JSON.stringify(t_item.prom_pt_json);
2384 2494 }
2385 2495 //--判断组合优惠活动的提交--
2386 2496 if (t_item.zh_cut_price > 0 || t_item.zh_cut_price<0) {
2387 2497 order_prom_list.discount_amount += t_item.zh_cut_price;
2388 2498 order_prom_list.zh_pt_json = JSON.stringify(t_item.zh_pt_json);
2389 2499 }
  2500 +
  2501 + //--判断阶梯优惠活动的提交--
  2502 + if (t_item.ladder_cut_price > 0 || t_item.ladder_cut_price<0) {
  2503 + order_prom_list.discount_amount += t_item.ladder_cut_price;
  2504 + }
  2505 +
  2506 + if(t_item.prom_pt_json){
  2507 + order_prom_list.prom_pt_json = JSON.stringify(t_item.prom_pt_json);
  2508 + }
  2509 +
2390 2510 if (t_item.s_intValue > 0) {
2391 2511 order_prom_list.give_integral = t_item.s_intValue;
2392 2512 }
... ... @@ -2461,6 +2581,7 @@ Page({
2461 2581 switch (g_item.prom_type) {
2462 2582 case 1:
2463 2583 case 2:
  2584 + case 10:
2464 2585 goods.prom_type = g_item.prom_type;
2465 2586 goods.prom_id = g_item.prom_id;
2466 2587 break;
... ... @@ -2525,6 +2646,12 @@ Page({
2525 2646 goods.room_id = g_item.room_id;
2526 2647 room_ids += g_item.room_id + ",";
2527 2648 }
  2649 +
  2650 + //如果有阶梯促销
  2651 + if(g_item.ladder_list_id){
  2652 + goods.ladder_list_id=g_item.ladder_list_id;
  2653 + }
  2654 +
2528 2655 item.order_goods.push(goods);
2529 2656 }
2530 2657  
... ... @@ -3409,6 +3536,7 @@ Page({
3409 3536 get_cart_quan: async function (order_prom_list_cart) {
3410 3537 var th = this;
3411 3538 var is_xz_yh = 1;
  3539 + var user_id=getApp().globalData.user_id;
3412 3540 //等待值的出现
3413 3541 //getApp().waitfor2(this,"g_cart_q_time","order_prom_list_cart",async function () {
3414 3542 //var arr=th.data.order_prom_list_cart;
... ... @@ -3442,7 +3570,19 @@ Page({
3442 3570 }).then(res => {
3443 3571 if (res.data.code == 0) prom1 = res.data.data;
3444 3572 })
3445   - if(!prom1.isQuan){
  3573 + if(prom1 && !prom1.isQuan){
  3574 + continue;
  3575 + }
  3576 + }
  3577 +
  3578 + //--如果是团购,要判断有没有限制使用优惠券
  3579 + if(gd.prom_type == 10){
  3580 + var prom1=null;
  3581 + await getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/"+ os.stoid +"/"+user_id+"/"+ gd.prom_id, {
  3582 + }).then(res => {
  3583 + if (res.data.code == 0) prom1 = res.data.data;
  3584 + })
  3585 + if(prom1 && prom1.isuse && prom1. is_usecoupon){
3446 3586 continue;
3447 3587 }
3448 3588 }
... ...
pages/cart/cart2/cart2.wxml
... ... @@ -95,7 +95,8 @@
95 95  
96 96 <!-----商品名称规格------>
97 97 <view class="order-num flex-space-between">
98   - <view class="co-red">¥<text class="fs36">{{filters.toFix(items.goods_price,2)}}</text></view>
  98 + <view wx:if="{{items.prom_type==10}}" class="co-red">¥<text class="fs36">{{filters.toFix(items.goods_price,2)}}</text><text>({{items.discount}}折)</text></view>
  99 + <view wx:else class="co-red">¥<text class="fs36">{{filters.toFix(items.goods_price,2)}}</text></view>
99 100 <view class="goods-num">x{{items.goods_num}}</view>
100 101 </view>
101 102 </navigator>
... ... @@ -431,6 +432,11 @@
431 432 <view>组合购优惠</view>
432 433 <view class="co-red">- ¥ {{filters.toFix(formData.zh_cut_price,2)}}元</view>
433 434 </view>
  435 + <!-- 组合购优惠金额 -->
  436 + <view class="item" wx:if="{{formData.ladder_cut_price>0 || formData.ladder_cut_price<0}}">
  437 + <view>阶梯促销优惠</view>
  438 + <view class="co-red">- ¥ {{filters.toFix(formData.ladder_cut_price,2)}}元</view>
  439 + </view>
434 440  
435 441 <!-- 订单优惠优惠金额 -->
436 442 <view class="item" wx:if="{{formData.order_prom_amount>0}}">
... ...
pages/cart/cart2/ladder_calculate.js 0 → 100644
  1 +var regeneratorRuntime = require('../../../utils/runtime.js');
  2 +module.exports = {
  3 + //主要的作用,就是把阶梯促销多余的商品进行拆分,
  4 + //如果没有达成阶梯促销的要求,所有的商品都打回原价购买
  5 + fir_set_arr: function (c_item, th) {
  6 + //寻找一下
  7 + function get_num2(ite) {
  8 + var vh = c_item.goods.findIndex(function (e) {
  9 + return e.goods_id == ite.goods_id
  10 + })
  11 + if (vh > -1) return vh;
  12 + return 0;
  13 + }
  14 +
  15 + //组合活动,以及组合活动从表的商品
  16 + let ladder_map = c_item.ladder_map;
  17 + let goods = c_item.goods; //一个门店中所有的商品
  18 + let tfeel = 0, cut_price = 0, offline_price = 0, offline_num = 0;
  19 + //多个活动要拿来循环一下
  20 + for (let i in ladder_map) {
  21 + let title = ""; //提示语;
  22 + //其中的一个活动
  23 + let act_item = ladder_map[i];
  24 + let ladder_list = act_item.ladder_list;
  25 +
  26 + let all_num = 0; //商品数量之和
  27 + let all_price0 = 0; //商品数量之和
  28 + let aprice = 0; //达到活动条件的购买价格
  29 +
  30 + let no_in_arr = []; //剩余的未加入组合购
  31 + let del_g=[];
  32 + for (var li in goods) {
  33 + if (goods[li].prom_type != 10) continue;
  34 + if (goods[li].prom_id != act_item.id) continue;
  35 + var item = goods[li];
  36 + item.goods_price = item.goods_price;
  37 + item.offline_price = item.offline_price;
  38 + item.cart_num = item.goods_num;
  39 + all_num += item.cart_num;
  40 + for (var j = 0; j < item.cart_num; j++) {
  41 + no_in_arr.push({
  42 + price: item.goods_price,
  43 + offline_price: item.offline_price,
  44 + goods_id: item.goods_id,
  45 + shop_price: item.shop_price,
  46 + item:item
  47 + })
  48 + }
  49 + del_g.push(item);
  50 + }
  51 +
  52 + //开始阶梯计算价格
  53 + var lev = 0;
  54 + for (let j in ladder_list) {
  55 + if (no_in_arr.length == 0) break;
  56 + let item_j =ladder_list[j];
  57 + var end = no_in_arr.pop();
  58 + var new_price = parseInt(item_j.discount_field) == 1 ? end.shop_price : end.price;
  59 + var account=new_price * parseFloat(item_j.discount) / 10;
  60 + aprice +=account;
  61 +
  62 + //-- 单个文件新增 --
  63 + let new_g = JSON.parse(JSON.stringify(end.item));
  64 + new_g.goods_num = 1;
  65 + new_g.account = account.toFixed(2);
  66 + new_g.discount = item_j.discount;
  67 + new_g.goods_price =new_price;
  68 + new_g.ladder_list_id =item_j.id;
  69 + goods.push(new_g);
  70 + lev++;
  71 + }
  72 +
  73 + let goods_map = {};
  74 + //算一下剩余的商品
  75 + if (no_in_arr.length) {
  76 + for (let ii in no_in_arr) {
  77 + let item = no_in_arr[ii];
  78 + if (item.offline_price) {
  79 + offline_price += item.price - item.offline_price;
  80 + offline_num += 1;
  81 + }
  82 + if (goods_map[item.goods_id]) {
  83 + var num = goods_map[item.goods_id];
  84 + goods_map[item.goods_id] = ++num;
  85 + } else {
  86 + goods_map[item.goods_id] = 1;
  87 + }
  88 + }
  89 + }
  90 +
  91 + if (Object.keys(goods_map).length) {
  92 + //这里就开始拆分提交订单时的列表
  93 + for (let j in goods_map) {
  94 + //map中存的就是商品的数量
  95 + let num = goods_map[j];
  96 + //找到相应的商品
  97 + let idx = goods.findIndex(function (ele) {
  98 + return ele.goods_id == j;
  99 + })
  100 + //goods[idx].goods_num -= num;
  101 + let new_g = JSON.parse(JSON.stringify(goods[idx]));
  102 + new_g.goods_num = num;
  103 + new_g.prom_type = 0;
  104 + new_g.prom_id = 0;
  105 + goods.push(new_g);
  106 + //goods.splice(idx, 1);
  107 + }
  108 + }
  109 +
  110 + //-- 最后剔除不要参与的数据 --
  111 + for(var h in del_g){
  112 + var it=del_g[h];
  113 + let idx = goods.findIndex(function (ele) {
  114 + return ele.goods_id == it.goods_id
  115 + })
  116 + goods.splice(idx, 1);
  117 + }
  118 +
  119 + //-- 只统计是参与活动的商品 --
  120 + for (var ij in goods) {
  121 + var iter = goods[ij];
  122 + if (iter.prom_type != 10 || iter.prom_id != act_item.id) {
  123 + continue;
  124 + }
  125 + all_price0 += iter.goods_num * iter.goods_price;
  126 + }
  127 +
  128 + if(!c_item.ladder_prom_goods) c_item.ladder_prom_goods={};
  129 + if(!c_item.ladder_prom_goods[act_item.id]) c_item.ladder_prom_goods[act_item.id]={};
  130 +
  131 + //-- 活动的条件已经满足 --
  132 + c_item.ladder_prom_goods[act_item.id].is_has_ladder = 1;
  133 + c_item.is_has_ladder = 1;
  134 + c_item.ladder_prom_goods[act_item.id].actual_price = aprice;
  135 + c_item.ladder_prom_goods[act_item.id].cut_price = all_price0 - aprice;
  136 +
  137 + tfeel += aprice;
  138 + cut_price += all_price0 - aprice;
  139 +
  140 + }
  141 +
  142 + c_item.ladder_all_price = tfeel;
  143 + c_item.ladder_cut_price = cut_price;
  144 +
  145 + if (c_item.is_offline == 1) {
  146 + c_item.offline_price += offline_price;
  147 + c_item.offline_num += offline_num;
  148 + } else {
  149 + c_item.is_offline == 1;
  150 + c_item.offline_price = offline_price;
  151 + c_item.offline_num = offline_num;
  152 + }
  153 + },
  154 + //筛选组合购,纯粹的数组按活动id分组
  155 + find_split: function (arr) {
  156 + //过滤只有团购的商品
  157 + let oarr = arr.goods.filter(function (ele) {
  158 + return ele.prom_type == 10
  159 + })
  160 + if (!oarr || oarr.length == 0) return null;
  161 + //看一下有多少个不同的团购
  162 + let map = {},
  163 + dest = [];
  164 + for (let i = 0; i < oarr.length; i++) {
  165 + let ai = oarr[i];
  166 + let index = map[ai.prom_id]
  167 + if (!index) {
  168 + dest.push({
  169 + prom_id: ai.prom_id,
  170 + act: ai.act,
  171 + data: [ai]
  172 + });
  173 + map[ai.prom_id] = dest.length; //存储下标
  174 + } else {
  175 + let dj = dest[index - 1];
  176 + dj.data.push(ai);
  177 + }
  178 + }
  179 + return dest;
  180 + },
  181 +
  182 + //-- 平摊组合购的价格 --
  183 + calc_split_price: async function (c_arr, th) {
  184 + //-- 循环处理 --
  185 + for (var k in c_arr) {
  186 + var cart_item = c_arr[k]; //就是每一单的意思
  187 + var ord_goods = c_arr[k].goods; //就是每一单的从表的意思
  188 +
  189 + var ladder_map = cart_item.ladder_prom_goods; //一单中所有的组合购的集合
  190 + var item_map = {};
  191 + for (let i in ladder_map) {
  192 + let item = ladder_map[i];
  193 + let prom_id = i;
  194 + //如果这个活动还没有达到要求,继续下一个计算
  195 + if (!item.is_has_ladder) continue;
  196 + //过滤出相应组合购活动的商品
  197 + let glist = ord_goods.filter(function (ele) {
  198 + return ele.prom_type == 10 && ele.prom_id == i;
  199 + })
  200 +
  201 + var all_good_price = 0;
  202 + var post_gd = [];
  203 + for (let j in glist) {
  204 + let item = glist[j];
  205 + all_good_price += item.goods_price * item.goods_num;
  206 + var gitem = {
  207 + goods_id: item.goods_id,
  208 + goods_num: item.goods_num,
  209 + goods_price: item.goods_price
  210 + }
  211 + post_gd.push(gitem);
  212 + }
  213 + //要进行优惠的计算
  214 + if (all_good_price - item.actual_price) {
  215 + if (cart_item.prom_pt_json) {
  216 + cart_item.prom_pt_json.push({
  217 + "ladder_prom_id": prom_id,
  218 + "dis": (all_good_price - item.actual_price).toFixed(2),
  219 + "ispt": 0
  220 + })
  221 + } else {
  222 + cart_item.prom_pt_json = [{
  223 + "ladder_prom_id": prom_id,
  224 + "dis": (all_good_price - item.actual_price).toFixed(2),
  225 + "ispt": 0
  226 + }];
  227 + }
  228 + }
  229 + }
  230 +
  231 +
  232 + }
  233 + }
  234 +
  235 +
  236 +}
... ...
pages/cart/cart2_pt/cart2_pt.js
... ... @@ -296,7 +296,7 @@ Page({
296 296 th.setData({ user_addr: ie });
297 297 if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) {
298 298 th.setData({ add_back: 1 });
299   - if (this.data.bn_goods) th.calculatePrice2();
  299 + if (th.data.bn_goods) th.calculatePrice2();
300 300 }
301 301 })
302 302 //--更新默认地址--,看一下是不是跳到地址页面
... ...
pages/goods/goodsInfo/goodsInfo.js
... ... @@ -845,7 +845,7 @@ Page({
845 845  
846 846  
847 847 //获取统一条形码,普通商品和优惠促销的商品
848   - if (ee.data.data.prom_type == 0 || ee.data.data.prom_type == 3 || ee.data.data.prom_type == 5 || ee.data.data.prom_type == 7 || ee.data.data.prom_type == 9) {
  848 + if (ee.data.data.prom_type == 0 || ee.data.data.prom_type == 3 || ee.data.data.prom_type == 5 || ee.data.data.prom_type == 7 || ee.data.data.prom_type == 9 || ee.data.data.prom_type == 10) {
849 849 //默认门店要拿下门店库存
850 850 if (that.data.sales_rules == 2 && that.data.is_newsales_rules) {
851 851 //获取门店
... ... @@ -1348,10 +1348,15 @@ Page({
1348 1348 })
1349 1349  
1350 1350 }
1351   - else if (th.data.prom_type == 0 || th.data.prom_type == 3 || th.data.prom_type == 4 || th.data.prom_type == 5) {
  1351 + else if (th.data.prom_type == 0 || th.data.prom_type == 3 || th.data.prom_type == 4 || th.data.prom_type == 5 || th.data.prom_type==10) {
1352 1352 newd.prom_type = 0;
1353 1353 newd.prom_id = 0;
1354 1354  
  1355 + if(th.data.prom_type == 10){
  1356 + newd.prom_type = th.data.prom_type;
  1357 + newd.prom_id = th.data.prom_id;
  1358 + }
  1359 +
1355 1360 //---如果是线下门店销售的时候---
1356 1361 if (th.data.sales_rules == 2) {
1357 1362 var pick = th.get_pick_from_list(th.data.sto_sele_id)
... ... @@ -1444,6 +1449,7 @@ Page({
1444 1449 user_id: oo.user_id,
1445 1450 goods_id: a,
1446 1451 pick_id: e.data.sto_sele_id,
  1452 + state:0
1447 1453 },
1448 1454 success: function (re) {
1449 1455  
... ... @@ -1512,9 +1518,41 @@ Page({
1512 1518 });
1513 1519  
1514 1520 }
1515   - //else "exchange" == t.currentTarget.dataset.action ? this.exchange(d) : this.buyNow(d);
1516 1521 else {
1517 1522  
  1523 + if(newd.prom_type==10){
  1524 + //----先看会员在购物车中是否加入了该商品,立即购买的-----
  1525 + getApp().request.get("/api/weshop/cart/page", {
  1526 + data: {
  1527 + store_id: e.data.stoid,
  1528 + user_id: oo.user_id,
  1529 + state:1
  1530 + },
  1531 + success: function (res) {
  1532 + //-------如果购物车中有相关的数据---------
  1533 + if (res.data.code==0 && res.data.data.total > 0) {
  1534 + for(let j in res.data.data.pageData){
  1535 + let item_j=res.data.data.pageData[j];
  1536 + var url = '/api/weshop/cart/del/' +e.data.stoid+ '/' + item_j.id;
  1537 + getApp().request.delete(url, {});
  1538 + }
  1539 + }
  1540 + newd.state=1;
  1541 + getApp().request.post("/api/weshop/cart/save", {
  1542 + data: newd,
  1543 + success: function (t) {
  1544 + th.closeSpecModal();
  1545 + getApp().goto("/pages/cart/cart2/cart2?state=1");
  1546 + }
  1547 + });
  1548 +
  1549 +
  1550 + }
  1551 + })
  1552 + return false;
  1553 + }
  1554 +
  1555 +
1518 1556 if (th.data.prom_goods) {
1519 1557 var prom_d = th.data.prom_goods;
1520 1558 for (var i in prom_d) {
... ... @@ -1820,6 +1858,7 @@ Page({
1820 1858 });
1821 1859 },
1822 1860  
  1861 +
1823 1862 openSpecModel: function (t) {
1824 1863 var th = this;
1825 1864 var open_store = t.currentTarget.dataset.ind;
... ... @@ -1864,9 +1903,35 @@ Page({
1864 1903 //var is_open=th.data.config
1865 1904 th.get_off_price();
1866 1905 })
  1906 + //--先判断会员状态--
  1907 + var user_info = getApp().globalData.userInfo;
  1908 + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
  1909 + wx.navigateTo({
  1910 + url: '/pages/togoin/togoin',
  1911 + })
  1912 + return false;
  1913 + }
  1914 + var is_go_next = 1;
  1915 + if (th.data.more_flash && th.data.more_flash.length > 1 && open_store == 1) {
  1916 + is_go_next = 0;
  1917 + }
  1918 + if (is_go_next) {
  1919 + var ind = t.currentTarget.dataset.ind;
  1920 + //回调。判断是不是优惠促销
  1921 + th.check_is_prom_goods(function () {
  1922 + th.setData({
  1923 + openSpecModal: !0,
  1924 + openSpecModal_ind: ind,
  1925 + });
  1926 + //var is_open=th.data.config
  1927 + th.get_off_price();
  1928 + })
  1929 + } else {
  1930 + th.setData({is_pop_more: 1});
  1931 +
  1932 + }
1867 1933 }
1868 1934 },
1869   -
1870 1935 open_next(){
1871 1936 var th=this;
1872 1937 //回调。判断是不是优惠促销
... ... @@ -3037,7 +3102,7 @@ Page({
3037 3102 var user_id=getApp().globalData.user_id;
3038 3103 if(!user_id) user_id=0;
3039 3104  
3040   - if (prom_type == 3 || prom_type == 0 || prom_type == 5 || prom_type == 7 || prom_type == 9) {
  3105 + if (prom_type == 3 || prom_type == 0 || prom_type == 5 || prom_type == 7 || prom_type == 9 || prom_type == 10) {
3041 3106 this.setData({
3042 3107 prom_type: 0,isshow: 1,
3043 3108 });
... ... @@ -5657,6 +5722,8 @@ Page({
5657 5722 //---检查有没有优惠活动---
5658 5723 check_is_youhui: function (gid, is_nor) {
5659 5724 var th = this;
  5725 + var user_id=getApp().globalData.user_id;
  5726 + if(!user_id) user_id=0;
5660 5727 //如果是普通购买的时候,要进行调用
5661 5728 if (is_nor) {
5662 5729 getApp().request.get("/api/weshop/goods/getGoodsPromNormal/" + os.stoid + "/" + gid, {
... ... @@ -5676,7 +5743,7 @@ Page({
5676 5743 getApp().request.get("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + gid + "/0", {
5677 5744 success: function (res) {
5678 5745 console.log(res);
5679   - if (res.data.code == 0) {
  5746 + if (res.data.code == 0 && res.data.data) {
5680 5747 var r_data = res.data.data;
5681 5748 var max = 0, min = 0;
5682 5749 if (r_data.collocationList) {
... ... @@ -5690,6 +5757,32 @@ Page({
5690 5757 r_data.collocationPromList.max = (max + th.data.data.shop_price).toFixed(2);
5691 5758 r_data.collocationPromList.min = (min + th.data.data.shop_price).toFixed(2);
5692 5759 }
  5760 +
  5761 + if(r_data.ladderLists){
  5762 + var act_id=r_data.ladderLists[0].form_id;
  5763 + //-- 判断会员能不能参与阶梯促销 --
  5764 + getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid+"/"+user_id + "/"+act_id, {
  5765 + }).then(res=>{
  5766 + if(res.data.code==0 && res.data.data){
  5767 + var prom_content="";
  5768 + for(let jj in r_data.ladderLists){
  5769 + if(r_data.ladderLists[jj].discount==10){
  5770 + prom_content+="第"+(parseInt(jj)+1)+"件原价,";
  5771 + }else{
  5772 + prom_content+="第"+(parseInt(jj)+1)+"件"+r_data.ladderLists[jj].discount+"折,";
  5773 + }
  5774 + }
  5775 + prom_content=ut.sub_last(prom_content);
  5776 + th.data.prom_type=10;
  5777 + th.data.prom_id=act_id;
  5778 + th.setData({
  5779 + jieti_prom:prom_content,
  5780 + ladder_act_id:act_id
  5781 + })
  5782 + }
  5783 + })
  5784 + }
  5785 +
5693 5786 th.setData({
5694 5787 order_prom: r_data.promOrder,
5695 5788 collocationGoods: r_data.collocationPromList,
... ... @@ -5698,11 +5791,8 @@ Page({
5698 5791 th.is_show_more_buy();
5699 5792 }
5700 5793 }
5701   -
5702 5794 })
5703 5795 }
5704   -
5705   -
5706 5796 },
5707 5797  
5708 5798 closePoster() {
... ... @@ -6023,13 +6113,31 @@ Page({
6023 6113 check_has_flash:function () {
6024 6114 var th=this;
6025 6115 var url="/api/weshop/activitylist/getGoodActInfo";
  6116 + var user_id=getApp().globalData.user_id;
  6117 + if(!user_id) user_id=0;
  6118 +
6026 6119 var req_data={
6027   - store_id:os.stoid,goodsidlist:this.data.data.goods_id,is_detail:1
  6120 + store_id:os.stoid,goodsidlist:this.data.data.goods_id,is_detail:1,user_id:user_id
6028 6121 };
6029 6122 //获取秒杀的多规格
6030   - getApp().request.promiseGet(url, {data:req_data}).then(res=>{
  6123 + getApp().request.promiseGet(url, {data:req_data}).then(async function (res) {
6031 6124 if(res.data.code==0 && res.data.data && res.data.data.length){
6032   - th.setData({more_flash:res.data.data});
  6125 + var arr_data=res.data.data;
  6126 + var new_arr=[];
  6127 + for(let i in arr_data){
  6128 + let item=arr_data[i];
  6129 + //找不到活动要剔除
  6130 + if(!item.act_name) continue;
  6131 + if(item.prom_type!=1) continue;
  6132 + new_arr.push(item);
  6133 + }
  6134 +
  6135 + if(new_arr.length==1){
  6136 + th.data.prom_id=new_arr[0].act_id;
  6137 + th.data.prom_type=new_arr[0].prom_type;
  6138 + }
  6139 +
  6140 + th.setData({more_flash:new_arr});
6033 6141 }
6034 6142 })
6035 6143 },
... ... @@ -6055,7 +6163,6 @@ Page({
6055 6163 success(res) {}
6056 6164 })
6057 6165 },
6058   -
6059 6166 get_normal(gid){
6060 6167 this.setData({
6061 6168 prom_type: 0,
... ... @@ -6065,10 +6172,12 @@ Page({
6065 6172 this.get_sto();
6066 6173 this.check_is_youhui(gid,1);
6067 6174 this.data.is_normal=1;
  6175 + },
  6176 + go_more_ladder:function (e) {
  6177 + var prom_id=e.currentTarget.dataset.id;
  6178 + getApp().goto("/pages/goods/goodsList/goodsList?ladder_id="+prom_id);
6068 6179 }
6069 6180  
6070 6181  
6071 6182  
6072   -
6073   -
6074 6183 });
... ...
pages/goods/goodsInfo/goodsInfo.wxml
... ... @@ -612,6 +612,24 @@
612 612 </view>
613 613 </block>
614 614  
  615 + <block wx:if="{{jieti_prom}}">
  616 + <view class="cx-frame flex jc_sb" bindtap="go_more_ladder" data-id="{{ladder_act_id}}"
  617 + style="position: relative; height: auto">
  618 + <view class="flex" style="width: 92%">
  619 + <view class="cx-sizs fs30" style="width: 90rpx;flex-shrink: 0">阶梯促</view>
  620 + <!-- 中间显示层 -->
  621 + <view class="ellipsis-1 fs24">
  622 + <text class="jie_show fs22">阶</text>
  623 + {{jieti_prom}}
  624 + </view>
  625 + </view>
  626 + <view data-coupon="1" bindtap="show_more_cx" class="cx-obtain-coupon wsize">
  627 + <text class="bg_jj" style="position: relative;right: 3rpx"></text>
  628 + </view>
  629 + </view>
  630 + </block>
  631 +
  632 +
615 633 <!-- 要判断是不是有订单优惠 -->
616 634 <block wx:if="{{order_prom}}">
617 635 <view class="cx-frame flex" style="position: relative; height: auto">
... ... @@ -652,26 +670,30 @@
652 670 <!-- 判断是不是有秒杀 -->
653 671 <block wx:if="{{more_flash}}">
654 672  
655   - <block wx:for="{{more_flash}}">
656   -
657   - <view class="cx-frame flex" style="position: relative; height: auto" wx:if="{{item.prom_type==1}}" >
658   - <view class="cx-sizs wsize" style="width: 144rpx">秒杀</view>
659   - <!-- 中间显示层 -->
660   - <view class="flex ai-center jc_sb" style="width: 570rpx" bindtap="go_more_flash" data-id="{{item.act_id}}">
661   - <view class="flex">
662   - <view class="miao_lab">秒</view>
663   - <view class="order_hui">
664   - <view class="fs28 ellipsis-1">{{item.act_name}}</view>
665   - <view class="fs26">
666   - (活动时间:{{tool.format_tt(item.s_time)}} - {{tool.format_tt(item.e_time)}})
  673 + <block wx:for="{{more_flash}}">
  674 + <view class="cx-frame flex" style="position: relative; height: auto" wx:if="{{item.prom_type==1}}">
  675 + <view class="cx-sizs wsize" style="width: 144rpx">秒杀</view>
  676 + <!-- 中间显示层 -->
  677 + <view class="flex ai-center jc_sb" style="width: 570rpx" bindtap="go_more_flash"
  678 + data-id="{{item.act_id}}">
  679 + <view class="flex">
  680 + <view class="miao_lab">秒</view>
  681 + <view class="order_hui">
  682 + <view class="fs28 ellipsis-1">{{item.act_name}}</view>
  683 + <view class="fs26">
  684 + (活动时间:{{tool.format_tt(item.s_time)}} - {{tool.format_tt(item.e_time)}})
  685 + </view>
667 686 </view>
668 687 </view>
  688 + <view>
  689 + <text class="bg_jj is_more_cx" style="position: relative;top:-10rpx"></text>
  690 + </view>
669 691 </view>
670   - <view><text class="bg_jj is_more_cx" style="position: relative;top:-10rpx"></text></view>
671 692 </view>
672   - </view>
673 693 </block>
674 694 </block>
  695 +
  696 + <!-- 保障服务 -->
675 697 <view class="bz_view flex bdt16" wx:if="{{bconfig}}" style="">
676 698 <image class="bzfu_img" src="{{iurl}}/miniapp/images/bzfu_w.png"></image>
677 699 <view class="flex f1 ai_c rel">
... ... @@ -679,8 +701,6 @@
679 701 <view bindtap="clickCollapse" class="cx-obtain-coupon wsize arrow">
680 702 <text class="bg_jj {{flag?'down1':''}}"></text>
681 703 </view>
682   - <!-- <text class="bg_jj" bindtap="clickCollapse"></text> -->
683   - <!-- <text class="iconfont icon-shuangjiantouxia c-db"></text> -->
684 704 </view>
685 705 </view>
686 706 <!-- - 搭配促销 -- -->
... ...
pages/goods/goodsInfo/goodsInfo.wxss
... ... @@ -2875,4 +2875,6 @@ button.custom-service::after{
2875 2875 line-height: 70rpx;
2876 2876 border-radius: 50%;
2877 2877 color: #aaa;
2878   -}
2879 2878 \ No newline at end of file
  2879 +}
  2880 +
  2881 +.jie_show{ display: inline-block; width: 40rpx; height: 40rpx; background-color:#ff0505;border-radius:50%;color: #fff;text-align: center; margin: 0 20rpx }
2880 2882 \ No newline at end of file
... ...
pages/goods/goodsList/goodsList.js
... ... @@ -69,8 +69,12 @@ Page({
69 69  
70 70 if (0 != t.is_new && t.is_new != undefined) { url += "&is_new=" + t.is_new; }
71 71 if (0 != t.is_hot && t.is_hot != undefined) { url += "&is_hot=" + t.is_hot; }
72   -
73   -
  72 + if (0 != t.ladder_id && t.ladder_id != undefined) { url += "&ladder_id=" + t.ladder_id; }
  73 +
  74 + var user_id=getApp().globalData.user_id;
  75 + if(!user_id) user_id=0;
  76 + url += "&user_id="+user_id;
  77 +
74 78 // 优惠促销列表
75 79 if(t.prom_goods_id) {
76 80 url += '&prom_goods_id=' + t.prom_goods_id;
... ... @@ -96,6 +100,34 @@ Page({
96 100 }
97 101 })
98 102 }
  103 +
  104 + //--- 阶梯优惠活动的凑单 ---
  105 + if(t.ladder_id){
  106 + var user_id=getApp().globalData.user_id;
  107 + if(!user_id) user_id=0;
  108 + getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/"+oo.stoid+"/"+user_id+"/"+t.ladder_id,{
  109 + }).then(res=>{
  110 + if(res.data.code==0 && res.data.data){
  111 + var arr= res.data.data;
  112 + var url1="/api/weshop/prom/ladderList/list?store_id="+oo.stoid+"&form_id="+arr.id;
  113 + getApp().request.promiseGet(url1, {}).then(rs=>{
  114 + if(rs.data.code==0 && rs.data.data && rs.data.data.length) {
  115 + var prom_content="";
  116 + for(let jj in rs.data.data){
  117 + if(rs.data.data[jj].discount==10){
  118 + prom_content+="第"+(parseInt(jj)+1)+"件原价,";
  119 + }else{
  120 + prom_content+="第"+(parseInt(jj)+1)+"件"+rs.data.data[jj].discount+"折,";
  121 + }
  122 + }
  123 + prom_content=ut.sub_last(prom_content);
  124 + th.setData({jieti_prom:prom_content})
  125 + }
  126 + })
  127 + }
  128 + })
  129 + }
  130 +
99 131 this.requestGoodsList(url);
100 132 getApp().getConfig2(function(rs){
101 133 //计算等级价相关
... ...
pages/goods/goodsList/goodsList.wxml
... ... @@ -12,8 +12,10 @@
12 12 <text space="{{true}}" wx:if="{{item.content.is_libao && item.content.is_libao!='0'}}">送{{item.content.lb_name}} </text>
13 13 </view>
14 14 </block>
  15 + <!-- 新增 -->
  16 + <view wx:if="{{jieti_prom}}" class="fs30 ellipsis-1" style="padding: 20rpx">阶梯促销:{{jieti_prom}}</view>
  17 +
15 18 </view>
16   -
17 19 <view class="pd20 flex ai-center jc_sb">
18 20 <!-- 搜索框 -->
19 21 <view class="search-box f1">
... ...
pages/user/order_detail/order_detail.js
... ... @@ -993,7 +993,8 @@ Page({
993 993 var back_goods_arr=[];
994 994 var err_text="";
995 995 for(var i in goods_list){
996   - var g_item=goods_list[i];
  996 + var g_item=goods_list[i];
  997 + var b_item={};
997 998 //--如果是赠品,不加入购物车--
998 999 if(g_item['is_gift']) continue;
999 1000 if(g_item['prom_type']==4 ){
... ... @@ -1015,7 +1016,22 @@ Page({
1015 1016  
1016 1017 }).then(res=>{
1017 1018 good=res.data.data;
1018   - })
  1019 + })
  1020 +
  1021 + //调用接口判断订单优惠,
  1022 + const res = await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + g_item.goods_id + "/0", {})
  1023 + if (res.data.code == 0 && res.data.data) {
  1024 + var r_data = res.data.data;
  1025 + if (r_data.ladderLists) {
  1026 + var act_id = r_data.ladderLists[0].form_id;
  1027 + //-- 判断会员能不能参与阶梯促销 --
  1028 + const data = await getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid + "/" + user_id + "/" + act_id, {})
  1029 + if (data.data.code == 0 && data.data.data && data.data.data.isuse && data.data.data.is_end == 0) {
  1030 + b_item.prom_type = 10;
  1031 + b_item.prom_id = data.data.data.id;
  1032 + }
  1033 + }
  1034 + }
1019 1035  
1020 1036 if(!good){
1021 1037 err_text+= g_item['goods_name']+"未找到商品\n";
... ... @@ -1045,7 +1061,7 @@ Page({
1045 1061 }
1046 1062  
1047 1063 var prom=null;
1048   - var b_item={}
  1064 +
1049 1065 b_item.goods_id=g_item.goods_id;
1050 1066 b_item.goods_name=g_item.goods_name;
1051 1067 b_item.goods_num=g_item.goods_num;
... ... @@ -1110,28 +1126,38 @@ Page({
1110 1126 b_item.price = prom.price;
1111 1127 }
1112 1128 break;
1113   - case 6:
1114   - b_item.is_pd_normal = 1;
1115   - break;
1116   - case 7:
1117   - //如果有组合购
1118   - var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + good.prom_id + "/" + getApp().globalData.userInfo.user_id;
1119   - await getApp().request.promiseGet(url, {}).then(res => {
1120   - if (res.data.code == 0 && res.data.data) {
1121   - if (res.data.data.is_show == 1 && res.data.data.is_end == 0
1122   - && ut.gettimestamp() < res.data.data.end_time
1123   - && ut.gettimestamp() > res.data.data.start_time
1124   - ) {
1125   - b_item.prom_type = 7;
1126   - b_item.prom_id = res.data.data.id;
1127   - good.prom_type = 7;
1128   - good.prom_id = res.data.data.id;
1129   - }
1130   - }
1131   - })
1132   - break;
1133   - }
1134   - }
  1129 + case 6:
  1130 + b_item.is_pd_normal = 1;
  1131 + break;
  1132 + case 7:
  1133 + //如果有组合购
  1134 + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + good.prom_id + "/" + getApp().globalData.userInfo.user_id;
  1135 + await getApp().request.promiseGet(url, {}).then(res => {
  1136 + if (res.data.code == 0 && res.data.data) {
  1137 + if (res.data.data.is_show == 1 && res.data.data.is_end == 0
  1138 + && ut.gettimestamp() < res.data.data.end_time
  1139 + && ut.gettimestamp() > res.data.data.start_time
  1140 + ) {
  1141 + b_item.prom_type = 7;
  1142 + b_item.prom_id = res.data.data.id;
  1143 + good.prom_type = 7;
  1144 + good.prom_id = res.data.data.id;
  1145 + }
  1146 + }
  1147 + })
  1148 + break;
  1149 + case 10:
  1150 + let user_id = getApp().globalData.userInfo.user_id;
  1151 + var url = `/api/weshop/prom/ladderForm/getNew/${os.stoid}/${user_id}/${good.prom_id}`;
  1152 + await getApp().request.promiseGet(url, {}).then(res => {
  1153 + if (res.data.code == 0 && res.data.data && res.data.data.isuse && res.data.data.is_end == 0) {
  1154 + b_item.prom_type = 10;
  1155 + b_item.prom_id = res.data.data.id;
  1156 + }
  1157 + })
  1158 + break;
  1159 + }
  1160 + }
1135 1161  
1136 1162 //如果有优惠促销的时候,要看下商品的优惠活动有没有过期
1137 1163 if(g_item.prom_type==3 || good.prom_type==3){
... ...
pages/user/order_detail/order_detail.wxml
... ... @@ -32,7 +32,7 @@
32 32 </navigator>
33 33  
34 34 <view class="order-num">
35   - <view class="goods-price">¥{{item.member_goods_price}}</view>
  35 + <view class="goods-price">¥{{item.member_goods_price}}<text wx:if="{{item.prom_type==10}}" style="margin-left: 5rpx">({{item.ladder_discount}}折)</text> </view>
36 36 <view class="goods-num">×{{item.goods_num}}</view>
37 37  
38 38 <!-- 不是整单退的时候 -->
... ...
pages/user/order_list/order_list.js
... ... @@ -1205,6 +1205,7 @@ Page({
1205 1205 var err_text="";
1206 1206 for(var i in goods_list){
1207 1207 var g_item=goods_list[i];
  1208 + var b_item={};
1208 1209 //--如果是赠品,不加入购物车--
1209 1210 if(g_item['is_gift']) continue;
1210 1211 if(g_item['prom_type']==4 ){
... ... @@ -1228,6 +1229,20 @@ Page({
1228 1229 good=res.data.data;
1229 1230 })
1230 1231  
  1232 + //调用接口判断订单优惠,
  1233 + const res = await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + g_item.goods_id + "/0", {})
  1234 + if (res.data.code == 0 && res.data.data) {
  1235 + var r_data = res.data.data;
  1236 + if (r_data.ladderLists) {
  1237 + var act_id = r_data.ladderLists[0].form_id;
  1238 + //-- 判断会员能不能参与阶梯促销 --
  1239 + const data = await getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid + "/" + user_id + "/" + act_id, {})
  1240 + if (data.data.code == 0 && data.data.data && data.data.data.isuse && data.data.data.is_end == 0) {
  1241 + b_item.prom_type = 10;
  1242 + b_item.prom_id = data.data.data.id;
  1243 + }
  1244 + }
  1245 + }
1231 1246 if(!good){
1232 1247 err_text+= g_item['goods_name']+"未找到商品\n";
1233 1248 continue;
... ... @@ -1256,7 +1271,7 @@ Page({
1256 1271 }
1257 1272  
1258 1273 var prom=null;
1259   - var b_item={}
  1274 +
1260 1275 b_item.goods_id=g_item.goods_id;
1261 1276 b_item.goods_name=g_item.goods_name;
1262 1277 b_item.goods_num=g_item.goods_num;
... ... @@ -1287,7 +1302,6 @@ Page({
1287 1302 }
1288 1303 }
1289 1304 })
1290   -
1291 1305 if(!prom) {
1292 1306 //--判断商品当前的活动情况--
1293 1307 switch (good.prom_type) {
... ... @@ -1342,6 +1356,17 @@ Page({
1342 1356 }
1343 1357 })
1344 1358 break;
  1359 + case 10:
  1360 +
  1361 + let user_id = getApp().globalData.userInfo.user_id;
  1362 + var url = `/api/weshop/prom/ladderForm/getNew/${os.stoid}/${user_id}/${good.prom_id}`;
  1363 + await getApp().request.promiseGet(url, {}).then(res => {
  1364 + if (res.data.code == 0 && res.data.data && res.data.data.isuse && res.data.data.is_end == 0) {
  1365 + b_item.prom_type = 10;
  1366 + b_item.prom_id = res.data.data.id;
  1367 + }
  1368 + })
  1369 + break;
1345 1370 }
1346 1371 }
1347 1372  
... ...
pages/user/order_list/order_list.wxml
... ... @@ -148,7 +148,7 @@
148 148 <!-- 幸运购prom_type等于9 -->
149 149 <!-- 如果是幸运购就显示幸运购参团价格 -->
150 150 <view class="fs26" wx:if="{{goods.prom_type == 9}}">{{filters.toFix(goods.goods_price,2)}}</view>
151   - <view class="fs26" wx:else>{{filters.toFix(goods.member_goods_price,2)}}</view>
  151 + <view class="fs26" wx:else>{{filters.toFix(goods.member_goods_price,2)}} <text wx:if="{{goods.prom_type==10}}">({{goods.ladder_discount}}折)</text> </view>
152 152 </view>
153 153 <view class="fs26 c-a9">x{{goods.goods_num}}</view>
154 154 </view>
... ...
utils/LoadMore.js
... ... @@ -59,52 +59,49 @@ var e = function() {
59 59 var n = !0;
60 60  
61 61 var i, r = s.data.listName, l = s.data.resultName, d = s.data.resultListName;
62   - i = "" != r ? t.data.data[r] : t.data.data.pageData; //data.pageData是接口固定会出现的,封装好了
  62 + i = "" != r ? t.data.data[r] : (t.data.data && t.data.data.pageData?t.data.data.pageData:null); //data.pageData是接口固定会出现的,封装好了
63 63 var u = !1, g = null, c = s.data.page;
64 64  
65   - console.log('loadmore');
66   - console.log(t.data.data.pageData);
67   - console.log(c );
68   -
69 65 //如果已经的第二页的时候,就是把数据加入数组
70 66 if (c !=undefined && c.data[l]) {
71 67 u = !0;
72 68 var f = null;
73 69 f = "" != d ? c.data[l][d] : c.data[l], [].push.apply(f, i), g = c.data[l];
74   - } else g = t.data.data.pageData;
  70 + } else g = (t.data.data && t.data.data.pageData?t.data.data.pageData:null);
75 71  
76 72  
77 73 //格式化
78 74 var glist="";
79   -
80   - for (var ii = 0; ii < g.length; ii++) {
81   - //if(g[i].prom_type == 1 || g[i].prom_type == 2 || g[i].prom_type == 6) {
82   - if (g[ii].prom_type && g[ii].prom_type == 1) {
83   - glist += g[ii].goods_id+",";
84   - }
85   - if (g[ii].original_img!=undefined){
86   - if (g[ii].original_img.indexOf(oo.imghost)==-1)
87   - g[ii].original_img = oo.imghost + g[ii].original_img;
88   - }
89   -
90   - if (g[ii].add_time != undefined && rurl.indexOf("goodscollect")<0){
91   - var tx = g[ii].add_time + "";
92   - if (tx.indexOf('-') == -1) {
93   - g[ii].add_time = ut.formatTime(g[ii].add_time, 'yyyy-MM-dd hh:mm:ss');
  75 + if(g) {
  76 + for (var ii = 0; ii < g.length; ii++) {
  77 + //if(g[i].prom_type == 1 || g[i].prom_type == 2 || g[i].prom_type == 6) {
  78 + if (g[ii].prom_type && g[ii].prom_type == 1) {
  79 + glist += g[ii].goods_id + ",";
  80 + }
  81 + if (g[ii].original_img != undefined) {
  82 + if (g[ii].original_img.indexOf(oo.imghost) == -1)
  83 + g[ii].original_img = oo.imghost + g[ii].original_img;
  84 + }
  85 +
  86 + if (g[ii].add_time != undefined && rurl.indexOf("goodscollect") < 0) {
  87 + var tx = g[ii].add_time + "";
  88 + if (tx.indexOf('-') == -1) {
  89 + g[ii].add_time = ut.formatTime(g[ii].add_time, 'yyyy-MM-dd hh:mm:ss');
  90 + }
  91 + }
  92 + if (rurl.indexOf('comment/page') != -1) {
  93 + console.log('comment/page');
  94 + console.log(g[ii].img);
  95 + var tx1 = g[ii].img;
  96 +
  97 + if (tx1 != "" && tx1 != null && ut.isString(tx1)) {
  98 + var arr = ut.unserialize(tx1);
  99 + g[ii].img = arr;
  100 + } else if (!ut.isArray(tx1)) {
  101 + g[ii].img = "";
  102 + }
  103 + }
94 104 }
95   - }
96   - if (rurl.indexOf('comment/page')!=-1){
97   - console.log('comment/page');
98   - console.log(g[ii].img);
99   - var tx1 = g[ii].img;
100   -
101   - if (tx1 != "" && tx1 != null && ut.isString(tx1)){
102   - var arr = ut.unserialize(tx1);
103   - g[ii].img=arr;
104   - } else if (!ut.isArray(tx1)){
105   - g[ii].img="";
106   - }
107   - }
108 105 }
109 106  
110 107  
... ...