Commit 0e766823dc92632214e907f10fce7db06b472cb9

Authored by WXD-SEASON\season
2 parents 631f9ce7 d4b9dbf0

合并阶梯促销

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,34 @@ 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 +<<<<<<< HEAD
360 364 //因为有全场优惠活动,商品参加的活动还未开始
361 365 var url="/api/weshop/activitylist/getGoodActInfo";
362 366 var req_data={
363 367 store_id:os.stoid,goodsidlist:item.goods_id,is_detail:1,user_id:user_id
  368 +=======
  369 +
  370 + //因为有全场优惠活动,商品参加的活动还未开始
  371 + var url="/api/weshop/activitylist/getGoodActInfo";
  372 + var req_data={
  373 + store_id:os.stoid,goodsidlist:item.goods_id,is_detail:1
  374 +>>>>>>> d4b9dbf03fa79fb3ff3c5889f79eea201fb49b74
364 375 };
365 376 await getApp().request.promiseGet(url, {data:req_data}).then(async function (res) {
366 377 if(res.data.code==0 && res.data.data && res.data.data.length){
367 378 for(let i in res.data.data){
  379 +<<<<<<< HEAD
368 380 let item=res.data.data[i];
369 381 if(item.prom_type==3) {
370 382 is_g_prom=1; break;
  383 +=======
  384 + let item=res.data.data[i];
  385 + if(item.prom_type==3) {
  386 + is_g_prom=1; break;
  387 +>>>>>>> d4b9dbf03fa79fb3ff3c5889f79eea201fb49b74
371 388 }
372 389 }
373 390 }
... ... @@ -430,6 +447,9 @@ Page({
430 447 }
431 448  
432 449 if (!isok) continue;
  450 +
  451 +
  452 +
433 453 }
434 454 else if (item.prom_type == 7) {
435 455 if(!th.data.zuhe_map[item.prom_id]){
... ... @@ -517,6 +537,68 @@ Page({
517 537 // continue;
518 538 // }
519 539 }
  540 + else if (item.prom_type == 10) {
  541 + if(!th.data.ladder_map[item.prom_id]){
  542 + //如果有组合购
  543 + var isok = 1;
  544 + var is_flag=1;
  545 + var act=null;
  546 + var url="/api/weshop/prom/ladderForm/getNew/"+os.stoid+"/"+user_id+"/"+item.prom_id;
  547 + await getApp().request.promiseGet(url, {}).then(res => {
  548 + console.log(res,1000);
  549 + if(res.data.code==0 && res.data.data){
  550 + if(res.data.data.isuse!=1){
  551 + isok=0;
  552 + }
  553 + //如果活动已经结束
  554 + if(res.data.data.is_end==1){
  555 + isok=0;
  556 + }
  557 + //已经结束
  558 + if(ut.gettimestamp()>res.data.data.end_time){
  559 + isok=0;
  560 + }
  561 + //还未开始
  562 + if(ut.gettimestamp()<res.data.data.start_time){
  563 + isok=0;
  564 + }
  565 + act=res.data.data;
  566 +
  567 + }else{
  568 + //未找到商品的活动
  569 + is_flag = 0;
  570 + }
  571 + })
  572 + if (!isok){
  573 + var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
  574 + getApp().request.delete(url, {});
  575 + th.data.ladder_map[item.prom_id]=-1;
  576 + continue;
  577 + }
  578 + th.data.ladder_map[item.prom_id]=act;
  579 +
  580 + //-- 获取阶梯规则 --
  581 + var url1 = "/api/weshop/prom/ladderList/list";
  582 + var req_data = {
  583 + store_id: os.stoid,
  584 + form_id: item.prom_id,
  585 + }
  586 + await getApp().request.promiseGet(url1, {
  587 + data: req_data
  588 + }).then(rs1 => {
  589 + if (rs1.data.code==0 && rs1.data.data) {
  590 + var gdlist = rs1.data.data;
  591 + th.data.ladder_map[item.prom_id].ladder_list=gdlist;
  592 + }
  593 + })
  594 + }
  595 + //直接把活动赋值给元素
  596 + if(th.data.ladder_map[item.prom_id] && th.data.ladder_map[item.prom_id]!=-1 ){
  597 + item.act=th.data.ladder_map[item.prom_id];
  598 + }
  599 +
  600 + }
  601 +
520 602 else if(item.prom_type == 0) {
521 603 //如果有优惠活动,要更新活动
522 604 await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + item.goods_id + "/1", {}).then(res => {
... ... @@ -622,9 +704,6 @@ Page({
622 704 }
623 705 }
624 706  
625   - // console.log('AAAAAAAAAAAA', all_num);
626   - // getApp().globalData.cartGoodsNum = all_num;
627   -
628 707 th.setData({
629 708 requestData: arr,
630 709 all_num: all_num,
... ... @@ -995,11 +1074,13 @@ Page({
995 1074 if(item[j].is_gift) continue;
996 1075  
997 1076 var obj=JSON.parse(JSON.stringify(item[j]));
998   - //计算之前先移除
  1077 + //计算之前先移除组合购的计算
999 1078 if(obj.prom_type==7)
1000 1079 zh_calc.remove_zhprom(dda,i,obj);
1001   -
1002   -
  1080 + //计算之前先移除阶梯购的计算
  1081 + if(obj.prom_type==10)
  1082 + ladder_calc.remove_ladder_prom(dda,i,obj);
  1083 +
1003 1084 if (fir == 0) {
1004 1085 fir = item[j].distr_type;
1005 1086 } else {
... ... @@ -1012,8 +1093,12 @@ Page({
1012 1093 var txt = "requestData[" + i + "].goods[" + j + "].selected";
1013 1094  
1014 1095 if(e.data.checkAllToggle) obj.goods_num=0;
1015   - if(obj.prom_type==7)
1016   - zh_calc.add_zhprom(dda,i,obj);
  1096 +
  1097 + //加入组合购计算
  1098 + if(obj.prom_type==7) zh_calc.add_zhprom(dda,i,obj);
  1099 + //加入阶梯促销计算
  1100 + if(obj.prom_type==10) ladder_calc.add_ladder_prom(dda,i,obj);
  1101 +
1017 1102  
1018 1103 e.setData({
1019 1104 [txt]: !e.data.checkAllToggle,
... ... @@ -1021,7 +1106,7 @@ Page({
1021 1106  
1022 1107 if (!e.data.checkAllToggle) {
1023 1108 //组合购的金额要另外算
1024   - if(item[j].prom_type!=7)
  1109 + if(item[j].prom_type!=7 && item[j].prom_type!=10)
1025 1110 tfeel += item[j].goods_num * item[j].goods_price;
1026 1111 t_num += item[j].goods_num;
1027 1112 }
... ... @@ -1059,6 +1144,12 @@ Page({
1059 1144 offline_price+=zh_calc_res.offline_price;
1060 1145 offline_num+=zh_calc_res.offline_num;
1061 1146  
  1147 + //总的价格,把阶梯促销的商品的价格拿出来
  1148 + var ladder_calc_res=ladder_calc.calculate_ladder(dda,i,this);
  1149 + tfeel+=ladder_calc_res.tfeel;
  1150 + offline_price+=ladder_calc_res.offline_price;
  1151 + offline_num+=ladder_calc_res.offline_num;
  1152 +
1062 1153 //当有线下取价的时候
1063 1154 if(offline_price){
1064 1155 var txt1= "requestData[" + i + "].offline_price";
... ... @@ -1373,7 +1464,10 @@ Page({
1373 1464  
1374 1465 //不管怎么样都要移出去
1375 1466 var obj=JSON.parse(JSON.stringify(item[c]));
  1467 +
1376 1468 zh_calc.remove_zhprom(car,a,obj);
  1469 + ladder_calc.remove_ladder_prom(car,a,obj);
  1470 +
1377 1471 if (item[c].selected == 0) {
1378 1472 ischeck = 0;
1379 1473 is_s_sele = 0;
... ... @@ -1381,11 +1475,20 @@ Page({
1381 1475 obj.goods_num=0;
1382 1476 zh_calc.add_zhprom(car,a,obj);
1383 1477 }
  1478 + if(item[c].prom_type==10) {
  1479 + obj.goods_num=0;
  1480 + ladder_calc.add_ladder_prom(car,a,obj);
  1481 + }
  1482 +
  1483 +
1384 1484 } else {
1385 1485 if(item[c].prom_type==7){
1386   - //先把商品放入组合计算的专用的区域
1387   - zh_calc.add_zhprom(car,a,obj);
1388   - }else{
  1486 + //先把商品放入组合计算的专用的区域
  1487 + zh_calc.add_zhprom(car,a,obj);
  1488 + }else if(item[c].prom_type==10){
  1489 + ladder_calc.add_ladder_prom(car,a,obj);
  1490 + }
  1491 + else{
1389 1492 tfeel += item[c].goods_num * item[c].goods_price;
1390 1493 }
1391 1494 t_num += item[c].goods_num;
... ... @@ -1400,10 +1503,17 @@ Page({
1400 1503  
1401 1504 //总的价格,把组合商品的价格拿出来
1402 1505 var zh_calc_res=zh_calc.calculate_zh(car,a,th);
  1506 + //总的价格,把阶梯促销商品的价格拿出来
  1507 + var ladder_calc_res=ladder_calc.calculate_ladder(car,a,th);
  1508 +
1403 1509 tfeel+=zh_calc_res.tfeel;
1404 1510 offline_price+=zh_calc_res.offline_price;
1405 1511 offline_num+=zh_calc_res.offline_num;
1406 1512  
  1513 + tfeel+=ladder_calc_res.tfeel;
  1514 + offline_price+=ladder_calc_res.offline_price;
  1515 + offline_num+=ladder_calc_res.offline_num;
  1516 +
1407 1517 var txt = "requestData[" + a + "].selected";
1408 1518 th.setData({
1409 1519 [txt]: Number(is_s_sele)
... ... @@ -1456,9 +1566,6 @@ Page({
1456 1566 });
1457 1567 }
1458 1568 }
1459   -
1460   - // getApp().globalData.cartGoodsNum = all_num;
1461   - // console.log('CCCCCCC', all_num, getApp().globalData.cartGoodsNum);
1462 1569  
1463 1570 this.setData({
1464 1571 checkAllToggle: ischeck,
... ... @@ -1494,6 +1601,8 @@ Page({
1494 1601  
1495 1602 // console.log('update');
1496 1603 // console.log('9995959595959',t);
  1604 + var e = this,th=e;
  1605 + var user_id = getApp().globalData.user_id;
1497 1606 rq.get("/api/weshop/goods/get/" + oo.stoid + "/" + t.goods_id, {
1498 1607 isShowLoading: 0,
1499 1608 async success(d) {
... ... @@ -1523,8 +1632,10 @@ Page({
1523 1632 }
1524 1633 goodsbuynum = buy_num_data.goodsbuynum;
1525 1634  
  1635 +
1526 1636 })
1527 1637  
  1638 +
1528 1639 var buyed_mum2 = t.goods_num + goodsbuynum;
1529 1640 if (buyed_mum2 > limit && limit > 0) {
1530 1641 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 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 + for(var h in del_g){
  111 + var it=del_g[h];
  112 + let idx = goods.findIndex(function (ele) {
  113 + return ele.goods_id == it.goods_id;
  114 + })
  115 + goods.splice(idx, 1);
  116 + }
  117 +
  118 + //-- 只统计是参与活动的商品 --
  119 + for (var ij in goods) {
  120 + var iter = goods[ij];
  121 + if (iter.prom_type != 10 || iter.prom_id != act_item.id) {
  122 + continue;
  123 + }
  124 + all_price0 += iter.goods_num * iter.goods_price;
  125 + }
  126 +
  127 + if(!c_item.ladder_prom_goods) c_item.ladder_prom_goods={};
  128 + if(!c_item.ladder_prom_goods[act_item.id]) c_item.ladder_prom_goods[act_item.id]={};
  129 +
  130 + //-- 活动的条件已经满足 --
  131 + c_item.ladder_prom_goods[act_item.id].is_has_ladder = 1;
  132 + c_item.is_has_ladder = 1;
  133 + c_item.ladder_prom_goods[act_item.id].actual_price = aprice;
  134 + c_item.ladder_prom_goods[act_item.id].cut_price = all_price0 - aprice;
  135 +
  136 + tfeel += aprice;
  137 + cut_price += all_price0 - aprice;
  138 +
  139 + }
  140 +
  141 + c_item.ladder_all_price = tfeel;
  142 + c_item.ladder_cut_price = cut_price;
  143 +
  144 + if (c_item.is_offline == 1) {
  145 + c_item.offline_price += offline_price;
  146 + c_item.offline_num += offline_num;
  147 + } else {
  148 + c_item.is_offline == 1;
  149 + c_item.offline_price = offline_price;
  150 + c_item.offline_num = offline_num;
  151 + }
  152 + },
  153 + //筛选组合购,纯粹的数组按活动id分组
  154 + find_split: function (arr) {
  155 + //过滤只有团购的商品
  156 + let oarr = arr.goods.filter(function (ele) {
  157 + return ele.prom_type == 10
  158 + })
  159 + if (!oarr || oarr.length == 0) return null;
  160 + //看一下有多少个不同的团购
  161 + let map = {},
  162 + dest = [];
  163 + for (let i = 0; i < oarr.length; i++) {
  164 + let ai = oarr[i];
  165 + let index = map[ai.prom_id]
  166 + if (!index) {
  167 + dest.push({
  168 + prom_id: ai.prom_id,
  169 + act: ai.act,
  170 + data: [ai]
  171 + });
  172 + map[ai.prom_id] = dest.length; //存储下标
  173 + } else {
  174 + let dj = dest[index - 1];
  175 + dj.data.push(ai);
  176 + }
  177 + }
  178 + return dest;
  179 + },
  180 +
  181 + //-- 平摊组合购的价格 --
  182 + calc_split_price: async function (c_arr, th) {
  183 + //-- 循环处理 --
  184 + for (var k in c_arr) {
  185 + var cart_item = c_arr[k]; //就是每一单的意思
  186 + var ord_goods = c_arr[k].goods; //就是每一单的从表的意思
  187 +
  188 + var ladder_map = cart_item.ladder_prom_goods; //一单中所有的组合购的集合
  189 + var item_map = {};
  190 + for (let i in ladder_map) {
  191 + let item = ladder_map[i];
  192 + let prom_id = i;
  193 + //如果这个活动还没有达到要求,继续下一个计算
  194 + if (!item.is_has_ladder) continue;
  195 + //过滤出相应组合购活动的商品
  196 + let glist = ord_goods.filter(function (ele) {
  197 + return ele.prom_type == 10 && ele.prom_id == i;
  198 + })
  199 +
  200 + var all_good_price = 0;
  201 + var post_gd = [];
  202 + for (let j in glist) {
  203 + let item = glist[j];
  204 + all_good_price += item.goods_price * item.goods_num;
  205 + var gitem = {
  206 + goods_id: item.goods_id,
  207 + goods_num: item.goods_num,
  208 + goods_price: item.goods_price
  209 + }
  210 + post_gd.push(gitem);
  211 + }
  212 + //要进行优惠的计算
  213 + if (all_good_price - item.actual_price) {
  214 + if (cart_item.prom_pt_json) {
  215 + cart_item.prom_pt_json.push({
  216 + "ladder_prom_id": prom_id,
  217 + "dis": (all_good_price - item.actual_price).toFixed(2),
  218 + "ispt": 0
  219 + })
  220 + } else {
  221 + cart_item.prom_pt_json = [{
  222 + "ladder_prom_id": prom_id,
  223 + "dis": (all_good_price - item.actual_price).toFixed(2),
  224 + "ispt": 0
  225 + }];
  226 + }
  227 + }
  228 + }
  229 +
  230 +
  231 + }
  232 + }
  233 +
  234 +
  235 +}
... ...
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 +<<<<<<< HEAD
1823 1862 openSpecModel: function (t) {
1824 1863 var th = this;
1825 1864 var open_store = t.currentTarget.dataset.ind;
... ... @@ -1864,8 +1903,34 @@ Page({
1864 1903 //var is_open=th.data.config
1865 1904 th.get_off_price();
1866 1905 })
1867   - }
1868   - },
  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 + }
  1933 + },
1869 1934  
1870 1935 open_next(){
1871 1936 var th=this;
... ... @@ -3037,7 +3102,11 @@ Page({
3037 3102 var user_id=getApp().globalData.user_id;
3038 3103 if(!user_id) user_id=0;
3039 3104  
  3105 +<<<<<<< HEAD
3040 3106 if (prom_type == 3 || prom_type == 0 || prom_type == 5 || prom_type == 7 || prom_type == 9) {
  3107 +=======
  3108 + if (prom_type == 3 || prom_type == 0 || prom_type == 5 || prom_type == 7 || prom_type == 10) {
  3109 +>>>>>>> d4b9dbf03fa79fb3ff3c5889f79eea201fb49b74
3041 3110 this.setData({
3042 3111 prom_type: 0,isshow: 1,
3043 3112 });
... ... @@ -5657,6 +5726,8 @@ Page({
5657 5726 //---检查有没有优惠活动---
5658 5727 check_is_youhui: function (gid, is_nor) {
5659 5728 var th = this;
  5729 + var user_id=getApp().globalData.user_id;
  5730 + if(!user_id) user_id=0;
5660 5731 //如果是普通购买的时候,要进行调用
5661 5732 if (is_nor) {
5662 5733 getApp().request.get("/api/weshop/goods/getGoodsPromNormal/" + os.stoid + "/" + gid, {
... ... @@ -5676,7 +5747,7 @@ Page({
5676 5747 getApp().request.get("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + gid + "/0", {
5677 5748 success: function (res) {
5678 5749 console.log(res);
5679   - if (res.data.code == 0) {
  5750 + if (res.data.code == 0 && res.data.data) {
5680 5751 var r_data = res.data.data;
5681 5752 var max = 0, min = 0;
5682 5753 if (r_data.collocationList) {
... ... @@ -5690,6 +5761,32 @@ Page({
5690 5761 r_data.collocationPromList.max = (max + th.data.data.shop_price).toFixed(2);
5691 5762 r_data.collocationPromList.min = (min + th.data.data.shop_price).toFixed(2);
5692 5763 }
  5764 +
  5765 + if(r_data.ladderLists){
  5766 + var act_id=r_data.ladderLists[0].form_id;
  5767 + //-- 判断会员能不能参与阶梯促销 --
  5768 + getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid+"/"+user_id + "/"+act_id, {
  5769 + }).then(res=>{
  5770 + if(res.data.code==0 && res.data.data){
  5771 + var prom_content="";
  5772 + for(let jj in r_data.ladderLists){
  5773 + if(r_data.ladderLists[jj].discount==10){
  5774 + prom_content+="第"+(parseInt(jj)+1)+"件原价,";
  5775 + }else{
  5776 + prom_content+="第"+(parseInt(jj)+1)+"件"+r_data.ladderLists[jj].discount+"折,";
  5777 + }
  5778 + }
  5779 + prom_content=ut.sub_last(prom_content);
  5780 + th.data.prom_type=10;
  5781 + th.data.prom_id=act_id;
  5782 + th.setData({
  5783 + jieti_prom:prom_content,
  5784 + ladder_act_id:act_id
  5785 + })
  5786 + }
  5787 + })
  5788 + }
  5789 +
5693 5790 th.setData({
5694 5791 order_prom: r_data.promOrder,
5695 5792 collocationGoods: r_data.collocationPromList,
... ... @@ -5698,11 +5795,8 @@ Page({
5698 5795 th.is_show_more_buy();
5699 5796 }
5700 5797 }
5701   -
5702 5798 })
5703 5799 }
5704   -
5705   -
5706 5800 },
5707 5801  
5708 5802 closePoster() {
... ... @@ -6023,13 +6117,31 @@ Page({
6023 6117 check_has_flash:function () {
6024 6118 var th=this;
6025 6119 var url="/api/weshop/activitylist/getGoodActInfo";
  6120 + var user_id=getApp().globalData.user_id;
  6121 + if(!user_id) user_id=0;
  6122 +
6026 6123 var req_data={
6027   - store_id:os.stoid,goodsidlist:this.data.data.goods_id,is_detail:1
  6124 + store_id:os.stoid,goodsidlist:this.data.data.goods_id,is_detail:1,user_id:user_id
6028 6125 };
6029 6126 //获取秒杀的多规格
6030   - getApp().request.promiseGet(url, {data:req_data}).then(res=>{
  6127 + getApp().request.promiseGet(url, {data:req_data}).then(async function (res) {
6031 6128 if(res.data.code==0 && res.data.data && res.data.data.length){
6032   - th.setData({more_flash:res.data.data});
  6129 + var arr_data=res.data.data;
  6130 + var new_arr=[];
  6131 + for(let i in arr_data){
  6132 + let item=arr_data[i];
  6133 + //找不到活动要剔除
  6134 + if(!item.act_name) continue;
  6135 + if(item.prom_type!=1) continue;
  6136 + new_arr.push(item);
  6137 + }
  6138 +
  6139 + if(new_arr.length==1){
  6140 + th.data.prom_id=new_arr[0].act_id;
  6141 + th.data.prom_type=new_arr[0].prom_type;
  6142 + }
  6143 +
  6144 + th.setData({more_flash:new_arr});
6033 6145 }
6034 6146 })
6035 6147 },
... ... @@ -6055,6 +6167,7 @@ Page({
6055 6167 success(res) {}
6056 6168 })
6057 6169 },
  6170 +<<<<<<< HEAD
6058 6171  
6059 6172 get_normal(gid){
6060 6173 this.setData({
... ... @@ -6067,7 +6180,13 @@ Page({
6067 6180 this.data.is_normal=1;
6068 6181 }
6069 6182  
  6183 +=======
  6184 +>>>>>>> d4b9dbf03fa79fb3ff3c5889f79eea201fb49b74
6070 6185  
  6186 + go_more_ladder:function (e) {
  6187 + var prom_id=e.currentTarget.dataset.id;
  6188 + getApp().goto("/pages/goods/goodsList/goodsList?ladder_id="+prom_id);
  6189 + }
6071 6190  
6072 6191  
6073 6192  
... ...
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_list/order_list.js
1 1 const app = getApp();
2   -var t = function(t) {
3   - return t && t.__esModule ? t : {
4   - default: t
5   - };
6   - }(require("../../../utils/LoadMore.js")),
7   - e = getApp(),
8   - os = e.globalData.setting,
9   - oo = e.globalData,
10   - r = e.request,
11   - rq = r,
12   - a = require("../../../utils/common.js"),
13   - s = new t.default();
  2 +var t = function (t) {
  3 + return t && t.__esModule ? t : {
  4 + default: t
  5 + };
  6 + }(require("../../../utils/LoadMore.js")),
  7 + e = getApp(),
  8 + os = e.globalData.setting,
  9 + oo = e.globalData,
  10 + r = e.request,
  11 + rq = r,
  12 + a = require("../../../utils/common.js"),
  13 + s = new t.default();
14 14 var regeneratorRuntime = require('../../../utils/runtime.js');
15   -var ut= require('../../../utils/util.js');
  15 +var ut = require('../../../utils/util.js');
16 16 var t = require("../../../utils/pay.js");
17 17  
18 18 Page({
19   - data: {
20   - url: e.globalData.setting.url,
21   - resourceUrl: e.globalData.setting.imghost,
22   - iurl: e.globalData.setting.imghost,
23   - categories: [{
24   - name: "全部",
25   - id: 0
26   - }, {
27   - name: "待付款",
28   - id: 1
29   - }, {
30   - name: "待发货",
31   - id: 2
32   - }, {
33   - name: "待收货",
34   - id: 3
35   - }, {
36   - name: "待评价",
37   - id: 4
38   - }],
39   - activeCategoryId: 0,
40   - orderList: null,
41   - currentPage: 1,
42   - //已经读取过接口
43   - is_get: 0,
44   - conf: null,
45   - iscodeall: null,
46   - sales_rules:1, //默认是显示线上库存
47   -
48   - //会员的等级价位
49   - card_field:null,
50   -
51   - back_goods_arr:null, //返回商品的列表
52   - currentIndex: 0,
53   -
54   - startDate: '',
55   - endDate: '',
56   - list2: [],
57   - currentPage2: 1,
58   - currentDate: '',
59   - total: 0, //读取时段内记录数量
60   - is_no_data2: 0,
61   - is_no_more2: 0,
62   -
63   -
64   - // 搜索内容
65   - searchContent: '',
66   - },
67   - onLoad: function(t) {
68   - // 设置日期选择器的结束时间为当前日期
69   - var now=new Date();
70   - var nowDate = now.getFullYear() + '-' + (now.getMonth() + 1) + '-' + now.getDate();
71   - var date = new Date(now.getTime() - 7 * 24 * 3600 * 1000);
72   - var startDate=date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
73   -
74   -
75   - if(t.index) {
76   - this.setData({
77   - currentIndex: t.index
78   - });
79   - };
80   -
81   - this.setData({
82   - currentDate: this.currentDate(),
83   - startDate:startDate,
84   - endDate:nowDate,
85   - });
86   -
87   -
88   - var th = this;
89   - if (t.type != undefined) this.setData({
90   - activeCategoryId: t.type
91   - });
92   - s.init(this, "", "orderList");
93   - },
94   - onShow: function() {
95   - var th=this;
96   - //---查看会员的等级价---
97   - getApp().getConfig2(function(e) {
98   - th.setData({conf: e,sales_rules:e.sales_rules });
99   - //--- 看后台是不是有开通等级卡 ---
100   - if(e.switch_list){
101   - var s_list=JSON.parse(e.switch_list);
102   - var user=getApp().globalData.userInfo;
103   - var is_open_offline=s_list.is_pricing_open;
104   - //-- 如果后台有开启等级价的功能 --
105   - if(parseInt(s_list.rank_switch)==2 && user['card_expiredate']){
106   - var str = user['card_expiredate'].replace(/-/g, '/');
107   - var end = new Date(str);
108   - end = Date.parse(end) / 1000;
109   - var now = ut.gettimestamp();
110   - //--- 判断是等级会员,且在有效期范围内 ---
111   - if(user.card_field && now<end){
112   - th.setData({card_field:user.card_field})
113   - }
114   - }
115   - //-- 判断有没有过期 --
116   - getApp().request.promiseGet("/store/storemoduleendtime/page?store_id=" +os.stoid + "&type=6",{}).then(res=>{
117   - //未购买
118   - if(res.data.code!=0 || !res.data.data || !res.data.data.pageData || !res.data.data.pageData.length){
119   - is_open_offline=0;
120   - }else{
121   - //已经过期
122   - var item=res.data.data.pageData[0];
123   - if(item.end_time<ut.gettimestamp()){
124   - is_open_offline=0;
125   - }
126   - }
127   -
128   - th.data.is_open_offline=is_open_offline;
129   - })
130   - }
131   - },1)
132   -
133   - this.resetData(), this.requestOrderList(this.data.activeCategoryId);
134   -
135   - },
136   - changeTab: function(t) {
137   - if (this.data.activeCategoryId == t.currentTarget.id) return false;
138   - this.resetData(), this.requestOrderList(t.currentTarget.id);
139   - },
140   - resetData: function() {
141   - s.resetConfig(),this.data.orderList = null, this.data.currentPage = 1;
142   - },
  19 + data: {
  20 + url: e.globalData.setting.url,
  21 + resourceUrl: e.globalData.setting.imghost,
  22 + iurl: e.globalData.setting.imghost,
  23 + categories: [{
  24 + name: "全部",
  25 + id: 0
  26 + }, {
  27 + name: "待付款",
  28 + id: 1
  29 + }, {
  30 + name: "待发货",
  31 + id: 2
  32 + }, {
  33 + name: "待收货",
  34 + id: 3
  35 + }, {
  36 + name: "待评价",
  37 + id: 4
  38 + }],
  39 + activeCategoryId: 0,
  40 + orderList: null,
  41 + currentPage: 1,
  42 + //已经读取过接口
  43 + is_get: 0,
  44 + conf: null,
  45 + iscodeall: null,
  46 + sales_rules: 1, //默认是显示线上库存
  47 +
  48 + //会员的等级价位
  49 + card_field: null,
  50 +
  51 + back_goods_arr: null, //返回商品的列表
  52 + currentIndex: 0,
  53 +
  54 + startDate: '',
  55 + endDate: '',
  56 + list2: [],
  57 + currentPage2: 1,
  58 + currentDate: '',
  59 + total: 0, //读取时段内记录数量
  60 + is_no_data2: 0,
  61 + is_no_more2: 0,
  62 +
  63 +
  64 + // 搜索内容
  65 + searchContent: '',
  66 + },
  67 + onLoad: function (t) {
  68 + // 设置日期选择器的结束时间为当前日期
  69 + var now = new Date();
  70 + var nowDate = now.getFullYear() + '-' + (now.getMonth() + 1) + '-' + now.getDate();
  71 + var date = new Date(now.getTime() - 7 * 24 * 3600 * 1000);
  72 + var startDate = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
  73 +
  74 +
  75 + if (t.index) {
  76 + this.setData({
  77 + currentIndex: t.index
  78 + });
  79 + };
  80 +
  81 + this.setData({
  82 + currentDate: this.currentDate(),
  83 + startDate: startDate,
  84 + endDate: nowDate,
  85 + });
  86 +
  87 +
  88 + var th = this;
  89 + if (t.type != undefined) this.setData({
  90 + activeCategoryId: t.type
  91 + });
  92 + s.init(this, "", "orderList");
  93 + },
  94 + onShow: function () {
  95 + var th = this;
  96 + //---查看会员的等级价---
  97 + getApp().getConfig2(function (e) {
  98 + th.setData({
  99 + conf: e,
  100 + sales_rules: e.sales_rules
  101 + });
  102 + //--- 看后台是不是有开通等级卡 ---
  103 + if (e.switch_list) {
  104 + var s_list = JSON.parse(e.switch_list);
  105 + var user = getApp().globalData.userInfo;
  106 + var is_open_offline = s_list.is_pricing_open;
  107 + //-- 如果后台有开启等级价的功能 --
  108 + if (parseInt(s_list.rank_switch) == 2 && user['card_expiredate']) {
  109 + var str = user['card_expiredate'].replace(/-/g, '/');
  110 + var end = new Date(str);
  111 + end = Date.parse(end) / 1000;
  112 + var now = ut.gettimestamp();
  113 + //--- 判断是等级会员,且在有效期范围内 ---
  114 + if (user.card_field && now < end) {
  115 + th.setData({
  116 + card_field: user.card_field
  117 + })
  118 + }
  119 + }
  120 + //-- 判断有没有过期 --
  121 + getApp().request.promiseGet("/store/storemoduleendtime/page?store_id=" + os.stoid + "&type=6", {}).then(res => {
  122 + //未购买
  123 + if (res.data.code != 0 || !res.data.data || !res.data.data.pageData || !res.data.data.pageData.length) {
  124 + is_open_offline = 0;
  125 + } else {
  126 + //已经过期
  127 + var item = res.data.data.pageData[0];
  128 + if (item.end_time < ut.gettimestamp()) {
  129 + is_open_offline = 0;
  130 + }
  131 + }
  132 +
  133 + th.data.is_open_offline = is_open_offline;
  134 + })
  135 + }
  136 + }, 1)
  137 +
  138 + this.resetData(), this.requestOrderList(this.data.activeCategoryId);
  139 +
  140 + },
  141 + changeTab: function (t) {
  142 + if (this.data.activeCategoryId == t.currentTarget.id) return false;
  143 + this.resetData(), this.requestOrderList(t.currentTarget.id);
  144 + },
  145 + resetData: function () {
  146 + s.resetConfig(), this.data.orderList = null, this.data.currentPage = 1;
  147 + },
143 148  
144 149  
145 150 /*---------获取订单列表--------*/
146 151 requestOrderList: function (t) {
147 152 var rd = Math.random() * 100;
148   - var e = this, th = e, r = e.data.url + "/api/weshop/order/page?rd=" + rd, a = "";
  153 + var e = this,
  154 + th = e,
  155 + r = e.data.url + "/api/weshop/order/page?rd=" + rd,
  156 + a = "";
149 157 switch (t) {
150 158 case "1":
151 159 r += "&wait_status=0";
... ... @@ -164,16 +172,24 @@ Page({
164 172 if (this.data.searchContent) {
165 173 r += "&keyWord=" + this.data.searchContent;
166 174 }
167   - this.setData({activeCategoryId: t});
  175 + this.setData({
  176 + activeCategoryId: t
  177 + });
168 178 r = r + "&page=" + e.data.currentPage;
169 179 s.request(r, function (t) {
170 180  
171   - th.setData({is_get: 1});
  181 + th.setData({
  182 + is_get: 1
  183 + });
172 184 var data = e.data.orderList;
173 185 data.forEach(async function (item, ind) {
174 186 var tt = null;
175 187 await getApp().request.promiseGet('/api/weshop/ordergoods/list', {
176   - data: {order_id: item.order_id, store_id: os.stoid, pageSize: 600},
  188 + data: {
  189 + order_id: item.order_id,
  190 + store_id: os.stoid,
  191 + pageSize: 600
  192 + },
177 193 }).then(res => {
178 194 tt = res;
179 195 })
... ... @@ -184,14 +200,13 @@ Page({
184 200 }
185 201 }
186 202  
187   - data[ind]['ord_url']='/pages/user/order_detail/order_detail';
  203 + data[ind]['ord_url'] = '/pages/user/order_detail/order_detail';
188 204 //-- 如果是优惠活动 --
189   - if(glist[0].prom_type==8){
190   - await getApp().request.promiseGet('/api/weshop/order/orderPresell/get/'+os.stoid+'/'+item.order_id, {
191   - }).then(res => {
192   - if(res.data.code==0){
  205 + if (glist[0].prom_type == 8) {
  206 + await getApp().request.promiseGet('/api/weshop/order/orderPresell/get/' + os.stoid + '/' + item.order_id, {}).then(res => {
  207 + if (res.data.code == 0) {
193 208 data[ind]['presell'] = res.data.data;
194   - data[ind]['ord_url']='/packageC/pages/presell/cart/cart';
  209 + data[ind]['ord_url'] = '/packageC/pages/presell/cart/cart';
195 210 }
196 211 })
197 212 }
... ... @@ -220,8 +235,10 @@ Page({
220 235 //------------对比一下有没有退款记录------------
221 236 await getApp().request.promiseGet("/api/weshop/order/returngoods/page", {
222 237 data: {
223   - order_id: item.order_id, store_id: os.stoid,
224   - user_id: oo.user_id, pageSize: 20
  238 + order_id: item.order_id,
  239 + store_id: os.stoid,
  240 + user_id: oo.user_id,
  241 + pageSize: 20
225 242 }
226 243 }).then(rs => {
227 244 var ttd = rs;
... ... @@ -244,8 +261,8 @@ Page({
244 261 });
245 262 } else {
246 263 //--------整单退--------
247   - if (ttd.data.data.pageData[0]['goods_id_list'] != null
248   - && ttd.data.data.pageData[0]['goods_id_list'] != '') {
  264 + if (ttd.data.data.pageData[0]['goods_id_list'] != null &&
  265 + ttd.data.data.pageData[0]['goods_id_list'] != '') {
249 266 var eea = ttd.data.data.pageData[0];
250 267 //1.退款正在进行中,
251 268 //2.退款被拒绝就要显示可以退款
... ... @@ -284,16 +301,16 @@ Page({
284 301 if (eea.goods_id == eeb.goods_id) {
285 302 switch (eea.status) {
286 303 case 0:
287   - case 1://退款处理中
  304 + case 1: //退款处理中
288 305 data[ind]['has_rt'] = 1; //有部分退
289 306 goodslist[iii]['return_btn'] = 2;
290 307 break;
291   - case 2://退款完成
  308 + case 2: //退款完成
292 309 data[ind]['has_rt'] = 1; //有部分退
293 310 goodslist[iii]['return_btn'] = 4;
294 311 rt_ok_num++;
295 312 break;
296   - case 3://已拒绝,重新退款
  313 + case 3: //已拒绝,重新退款
297 314 goodslist[iii]['return_btn'] = 3;
298 315 break;
299 316 default:
... ... @@ -322,166 +339,175 @@ Page({
322 339 });
323 340 data[ind]['g_num'] = g_num;
324 341 })
325   - th.setData({orderList: data,});
  342 + th.setData({
  343 + orderList: data,
  344 + });
326 345  
327 346 });
328   - e.data.currentPage++ ,
  347 + e.data.currentPage++,
329 348 wx.stopPullDownRefresh();
330   - }, null, {store_id: os.stoid, user_id: oo.user_id});
  349 + }, null, {
  350 + store_id: os.stoid,
  351 + user_id: oo.user_id
  352 + });
331 353 },
332   - //滑倒底部
333   - onReachBottom: function() {
334   - if(this.data.currentIndex == 0) {
335   - if (s.data.goodsLoadFinishFlag) {
336   - this.setData({
337   - iscodeall: 1
338   - })
339   - }
340   - s.canloadMore() && this.requestOrderList(this.data.activeCategoryId);
341   - } else {
342   - this.request_list({
343   - store_id: os.stoid,
344   - user_id: oo.user_id,
345   - page: this.data.currentPage2,
346   - });
347   - }
348   - },
349   - onPullDownRefresh: function(t) {
350   - // sty取消
351   - // this.resetData(), this.requestOrderList(this.data.activeCategoryId);
352   - },
353   -
354   - /*-----------取消订单-----------*/
355   - cancelOrder: function(t) {
356   - var e = this,
357   - a = t.currentTarget.dataset.id,
358   - th = this;
359   - var is_zsorder = parseFloat(t.currentTarget.dataset.zsorder);
360   - var index = t.currentTarget.dataset.orderindex;
361   - var order = th.data.orderList[index];
362   - var is_skill = 0;
363   - var order_goods = order.order_goods;
364   - //--判断是不是秒杀--
365   - order_goods.forEach(function(val, ind) {
366   - if (val.prom_type == 1) {
367   - is_skill = 1;
368   - return false;
369   - }
370   - })
371   -
372   - wx.showModal({
373   - title: "是否取消订单?",
374   - success: function(t) {
375   - //如果是秒杀和拼单的商品,取消订单要返回redis,并取消订单
376   - if (t.confirm) {
377   - //if(is_skill==1 || is_zsorder>=2){
378   - getApp().request.post("/api/weshop/order/cancelOrder/"+os.stoid+"/"+a+"/"+getApp().globalData.user_id, {
379   - data: {},
380   - success: function(t) {
381   - if (t.data.code == 0) {
382   - 0 == e.data.activeCategoryId ?
383   - (e.resetData(), e.requestOrderList(e.data.activeCategoryId)) : e.deleteOrderData2(a);
384   - } else {
385   - getApp().confirmBox(e.data.msg);
386   - }
387   - },
388   - })
  354 + //滑倒底部
  355 + onReachBottom: function () {
  356 + if (this.data.currentIndex == 0) {
  357 + if (s.data.goodsLoadFinishFlag) {
  358 + this.setData({
  359 + iscodeall: 1
  360 + })
  361 + }
  362 + s.canloadMore() && this.requestOrderList(this.data.activeCategoryId);
  363 + } else {
  364 + this.request_list({
  365 + store_id: os.stoid,
  366 + user_id: oo.user_id,
  367 + page: this.data.currentPage2,
  368 + });
389 369 }
390   - }
391   - });
392   - },
393   -
394   - /*-----------确认收货-----------*/
395   - confirmOrder: function(t) {
396   - var e = this,a = t.currentTarget.dataset.id;
397   - var is_zsorder = t.currentTarget.dataset.zsorder;
398   - var th = this;
399   -
400   - wx.showModal({
401   - title: "是否确认收货?",
402   - success: function(t) {
403   - t.confirm && rq.post("/api/weshop/order/confirmOrder/"+os.stoid+"/"+a+"/"+getApp().globalData.user_id,{
404   - success:function (e) {
405   - if(e.data.code==0){
406   - th.deleteOrderData2(a);
407   - getApp().confirmBox( "确认收货成功!");
408   - }
  370 + },
  371 + onPullDownRefresh: function (t) {
  372 + // sty取消
  373 + // this.resetData(), this.requestOrderList(this.data.activeCategoryId);
  374 + },
  375 +
  376 + /*-----------取消订单-----------*/
  377 + cancelOrder: function (t) {
  378 + var e = this,
  379 + a = t.currentTarget.dataset.id,
  380 + th = this;
  381 + var is_zsorder = parseFloat(t.currentTarget.dataset.zsorder);
  382 + var index = t.currentTarget.dataset.orderindex;
  383 + var order = th.data.orderList[index];
  384 + var is_skill = 0;
  385 + var order_goods = order.order_goods;
  386 + //--判断是不是秒杀--
  387 + order_goods.forEach(function (val, ind) {
  388 + if (val.prom_type == 1) {
  389 + is_skill = 1;
  390 + return false;
409 391 }
410   - })
411   - }
412   - });
413   - },
414   -
415   - //-----删除订单-----
416   - deleteOrderData: function(t) {
417   - var th = this;
418   - var order_id = t.currentTarget.dataset.order_id;
419   - var index = t.currentTarget.dataset.index;
420   - var up_data={order_id: order_id,isdel:1};
421   - var order=th.data.orderList[index];
422   - if(order.order_status!=6){
423   - up_data.order_status=5;
424   - }
425   - wx.showModal({
426   - title: "是否删除订单?",
427   - success: function(tt) {
428   - tt.confirm && rq.put("/api/weshop/order/updatebyId", {
429   - data: up_data,
430   - success: function(t) {
431   - for (var e = 0; e < th.data.orderList.length; e++)
432   - if (th.data.orderList[e].order_id == order_id) {
433   - th.data.orderList.splice(e, 1), th.setData({
434   - orderList: th.data.orderList
435   - });
436   - break;
437   - }
438   - }
439 392 })
440   - }
441   - });
442   - },
443   -
444   - deleteOrderData2: function(order_id) {
445   - var th = this;
446   - for (var e = 0; e < th.data.orderList.length; e++)
447   - if (th.data.orderList[e].order_id == order_id) {
448   - th.data.orderList.splice(e, 1), th.setData({
449   - orderList: this.data.orderList
  393 +
  394 + wx.showModal({
  395 + title: "是否取消订单?",
  396 + success: function (t) {
  397 + //如果是秒杀和拼单的商品,取消订单要返回redis,并取消订单
  398 + if (t.confirm) {
  399 + //if(is_skill==1 || is_zsorder>=2){
  400 + getApp().request.post("/api/weshop/order/cancelOrder/" + os.stoid + "/" + a + "/" + getApp().globalData.user_id, {
  401 + data: {},
  402 + success: function (t) {
  403 + if (t.data.code == 0) {
  404 + 0 == e.data.activeCategoryId ?
  405 + (e.resetData(), e.requestOrderList(e.data.activeCategoryId)) : e.deleteOrderData2(a);
  406 + } else {
  407 + getApp().confirmBox(e.data.msg);
  408 + }
  409 + },
  410 + })
  411 + }
  412 + }
450 413 });
451   - break;
452   - }
453   - },
454   -
455   - //---判断是不是有退款-----
456   - checkReturnGoodsStatus: function(t) {
457   - var e = t.currentTarget.dataset.recid;
458   - var oid = t.currentTarget.dataset.oid;
459   - r.get("/api/weshop/order/returngoods/page", {
460   - data: {
461   - goods_id: e,
462   - order_id: oid,
463   - store_id: os.stoid
464   - },
465   - success: function(t) {
466   - if (t.data.code == 0) {
467   - var r = t.data.data.total;
468   - if (0 == r) return wx.navigateTo({
469   - url: "/pages/user/return_goods/return_goods?rec_id=" + e + "&order_id=" + oid,
470   - });
471   - //--如果拒绝,就重新申请退款--
472   - if (t.data.data.pageData[0].status == 3) {
473   - return wx.navigateTo({
474   - url: "/pages/user/return_goods/return_goods?rec_id=" + e + "&order_id=" + oid,
475   - });
476   - }
  414 + },
  415 +
  416 + /*-----------确认收货-----------*/
  417 + confirmOrder: function (t) {
  418 + var e = this,
  419 + a = t.currentTarget.dataset.id;
  420 + var is_zsorder = t.currentTarget.dataset.zsorder;
  421 + var th = this;
477 422  
478   - wx.navigateTo({
479   - url: "/pages/user/return_goods_info/return_goods_info?id=" + r
480   - });
  423 + wx.showModal({
  424 + title: "是否确认收货?",
  425 + success: function (t) {
  426 + t.confirm && rq.post("/api/weshop/order/confirmOrder/" + os.stoid + "/" + a + "/" + getApp().globalData.user_id, {
  427 + success: function (e) {
  428 + if (e.data.code == 0) {
  429 + th.deleteOrderData2(a);
  430 + getApp().confirmBox("确认收货成功!");
  431 + }
  432 + }
  433 + })
  434 + }
  435 + });
  436 + },
  437 +
  438 + //-----删除订单-----
  439 + deleteOrderData: function (t) {
  440 + var th = this;
  441 + var order_id = t.currentTarget.dataset.order_id;
  442 + var index = t.currentTarget.dataset.index;
  443 + var up_data = {
  444 + order_id: order_id,
  445 + isdel: 1
  446 + };
  447 + var order = th.data.orderList[index];
  448 + if (order.order_status != 6) {
  449 + up_data.order_status = 5;
481 450 }
482   - }
483   - });
484   - },
  451 + wx.showModal({
  452 + title: "是否删除订单?",
  453 + success: function (tt) {
  454 + tt.confirm && rq.put("/api/weshop/order/updatebyId", {
  455 + data: up_data,
  456 + success: function (t) {
  457 + for (var e = 0; e < th.data.orderList.length; e++)
  458 + if (th.data.orderList[e].order_id == order_id) {
  459 + th.data.orderList.splice(e, 1), th.setData({
  460 + orderList: th.data.orderList
  461 + });
  462 + break;
  463 + }
  464 + }
  465 + })
  466 + }
  467 + });
  468 + },
  469 +
  470 + deleteOrderData2: function (order_id) {
  471 + var th = this;
  472 + for (var e = 0; e < th.data.orderList.length; e++)
  473 + if (th.data.orderList[e].order_id == order_id) {
  474 + th.data.orderList.splice(e, 1), th.setData({
  475 + orderList: this.data.orderList
  476 + });
  477 + break;
  478 + }
  479 + },
  480 +
  481 + //---判断是不是有退款-----
  482 + checkReturnGoodsStatus: function (t) {
  483 + var e = t.currentTarget.dataset.recid;
  484 + var oid = t.currentTarget.dataset.oid;
  485 + r.get("/api/weshop/order/returngoods/page", {
  486 + data: {
  487 + goods_id: e,
  488 + order_id: oid,
  489 + store_id: os.stoid
  490 + },
  491 + success: function (t) {
  492 + if (t.data.code == 0) {
  493 + var r = t.data.data.total;
  494 + if (0 == r) return wx.navigateTo({
  495 + url: "/pages/user/return_goods/return_goods?rec_id=" + e + "&order_id=" + oid,
  496 + });
  497 + //--如果拒绝,就重新申请退款--
  498 + if (t.data.data.pageData[0].status == 3) {
  499 + return wx.navigateTo({
  500 + url: "/pages/user/return_goods/return_goods?rec_id=" + e + "&order_id=" + oid,
  501 + });
  502 + }
  503 +
  504 + wx.navigateTo({
  505 + url: "/pages/user/return_goods_info/return_goods_info?id=" + r
  506 + });
  507 + }
  508 + }
  509 + });
  510 + },
485 511 /*----------跳转支付-----------*/
486 512 async jumpToCart4(t) {
487 513  
... ... @@ -490,7 +516,7 @@ Page({
490 516 var th = this;
491 517 var order = e;
492 518 var order_goods = e.order_goods;
493   - var user_id=getApp().globalData.userInfo.user_id;
  519 + var user_id = getApp().globalData.userInfo.user_id;
494 520  
495 521 // 幸运购检查库存量 api/weshop/activitylist/getActLen/{store_id}/{prom_type}/{prom_id}
496 522 if (parseInt(order_goods['0']['prom_type']) == 9) {
... ... @@ -522,9 +548,13 @@ Page({
522 548 });
523 549 return false;
524 550 }
525   -
  551 +
526 552 //要每件每件的商品进行检查,看有么有超出库存,超出限购
527   - var good = order_goods[i], goodsbuynum = 0, promgoodsbuynum = 0, gg = null,presellList=null;
  553 + var good = order_goods[i],
  554 + goodsbuynum = 0,
  555 + promgoodsbuynum = 0,
  556 + gg = null,
  557 + presellList = null;
528 558  
529 559 //获取单品的现在的活动状态
530 560 await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + good.goods_id, {}).then(res => {
... ... @@ -619,16 +649,22 @@ Page({
619 649 }
620 650  
621 651 //如果是预售的时候,
622   - if(good.prom_type==8) {
623   - await getApp().request.promiseGet("/api/weshop/order/orderPresell/countBuyGoodsSum",{
624   - data: {store_id: os.stoid, user_id: user_id, goods_id: good.goods_id, prom_id: good.prom_id},
625   - }).then(e=>{
  652 +
  653 + if (good.prom_type == 8) {
  654 + await getApp().request.promiseGet("/api/weshop/order/orderPresell/countBuyGoodsSum", {
  655 + data: {
  656 + store_id: os.stoid,
  657 + user_id: user_id,
  658 + goods_id: good.goods_id,
  659 + prom_id: good.prom_id
  660 + },
  661 + }).then(e => {
626 662 if (e.data.code == 0) {
627   - promgoodsbuynum=e.data.data.sumgoodsnum;
  663 + promgoodsbuynum = e.data.data.sumgoodsnum;
628 664 }
629 665 })
630 666  
631   - var presell_id =good.prom_id;
  667 + var presell_id = good.prom_id;
632 668 var url = "/api/weshop/marketing/marketingPresellList/list"
633 669 var rd = {
634 670 store_id: os.stoid,
... ... @@ -641,13 +677,13 @@ Page({
641 677 }).then(res => {
642 678 if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
643 679 var arr = res.data.data[0];
644   - presellList=arr
  680 + presellList = arr
645 681 }
646 682 })
647 683  
648   - if(presellList){
  684 + if (presellList) {
649 685  
650   - if(good.goods_num>presellList.presell_sumqty-presellList.buy_goodnum){
  686 + if (good.goods_num > presellList.presell_sumqty - presellList.buy_goodnum) {
651 687 var content = good.goods_name + '购买数量超出商品库存,请取消订单';
652 688 th.toast(content);
653 689 return false;
... ... @@ -733,39 +769,39 @@ Page({
733 769 }
734 770  
735 771 //商品的普通购买 ,不要进行判断
736   - if ((good.prom_type == 1 || good.prom_type == 2 || good.prom_type == 6 || good.prom_type == 4 || good.prom_type == 8)
737   - && !good.is_gift && !good.is_collocation && !good.is_integral_normal && !good.is_pd_normal) {
738   - if (gg.prom_type != good.prom_type && gg.prom_type>0) {
  772 + if ((good.prom_type == 1 || good.prom_type == 2 || good.prom_type == 6 || good.prom_type == 4 || good.prom_type == 8) &&
  773 + !good.is_gift && !good.is_collocation && !good.is_integral_normal && !good.is_pd_normal) {
  774 + if (gg.prom_type != good.prom_type && gg.prom_type > 0) {
739 775 var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买';
740 776 th.toast(content);
741 777 return false;
742 778 }
743 779  
744   - } else {
745   - if ((gg.prom_type == 1 || good.prom_type == 2 || gg.prom_type == 3 || gg.prom_type == 5 || gg.prom_type == 6 || gg.prom_type == 4)
746   - && !good.is_collocation && !good.is_gift && !good.is_integral_normal && !good.is_pd_normal) {
747   - var prom = null;
  780 + } else {
  781 + if ((gg.prom_type == 1 || gg.prom_type == 2 || gg.prom_type == 3 || gg.prom_type == 4 || gg.prom_type == 5 || gg.prom_type == 6 || gg.prom_type == 10) &&
  782 + !good.is_collocation && !good.is_gift && !good.is_integral_normal && !good.is_pd_normal) {
748 783 //---如果是活动的时候---
749   - var prom = null, th = this;
  784 + var prom = null,
  785 + th = this;
750 786 if (gg.prom_type == 1) {
751   - await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/"+ user_id + "/" + gg.prom_id, {}).then(res => {
  787 + await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + gg.prom_id, {}).then(res => {
752 788 if (res.data.code == 0) {
753 789 prom = res.data.data;
754   - prom.price=prom.user_price;
  790 + prom.price = prom.user_price;
755 791 }
756 792 })
757 793 }
758   -
759   - if (gg.prom_type == 2) {
760   - await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/"+ gg.goods_id + "/" + gg.prom_id, {}).then(res => {
761   - if (res.data.code == 0) {
762   - prom = res.data.data;
763   - prom.price=prom.price;
764   - }
765   - })
766   - }
767   -
768   -
  794 +
  795 + if (gg.prom_type == 2) {
  796 + await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + gg.goods_id + "/" + gg.prom_id, {}).then(res => {
  797 + if (res.data.code == 0) {
  798 + prom = res.data.data;
  799 + prom.price = prom.price;
  800 + }
  801 + })
  802 + }
  803 +
  804 +
769 805 if (gg.prom_type == 6) {
770 806 await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + gg.prom_id, {}).then(res => {
771 807 if (res.data.code == 0) {
... ... @@ -776,25 +812,34 @@ Page({
776 812  
777 813 if (gg.prom_type == 4) {
778 814 await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1", {
779   - data: {store_id: os.stoid, goods_id: gg.goods_id}
  815 + data: {
  816 + store_id: os.stoid,
  817 + goods_id: gg.goods_id
  818 + }
780 819 }).then(res => {
781 820 if (res.data.code == 0 && res.data.data && res.data.data.pageData) {
782 821 prom = res.data.data.pageData[0];
783 822 }
784 823 })
785 824 }
  825 + if (gg.prom_type == 10) {
  826 + var url = `/api/weshop/prom/ladderForm/getNew/${os.stoid}/${user_id}/${gg.prom_id}`;
  827 + await getApp().request.promiseGet(url, {}).then(res => {
  828 + if (res.data.code == 0 && res.data.data && !res.data.data.isuse || res.data.data.is_end == 1) {
  829 + prom = res.data.data;
  830 + }
  831 + })
  832 + }
786 833  
787 834 if (prom) {
788 835 var t_now = ut.gettimestamp();
789 836 if (prom.is_end == 0 && prom.start_time < t_now && prom.end_time > t_now) {
790   -
791 837 var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买';
792 838 th.toast(content);
793 839 return false;
794 840 }
795 841 }
796   - }
797   - else {
  842 + } else {
798 843 if (!good.is_gift && good.prom_type != 3) {
799 844 var t_ok = 1;
800 845 await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + good.goods_id + "/0", {}).then(res => {
... ... @@ -804,6 +849,7 @@ Page({
804 849 if (r_data.promGoodsLists) {
805 850 var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买';
806 851 th.toast(content);
  852 + console.log(3);
807 853 t_ok = 0;
808 854 }
809 855 }
... ... @@ -821,7 +867,7 @@ Page({
821 867 if (!good.is_gift && !good.is_collocation && gg.prom_type != 9) {
822 868 if (card_field && gg[card_field] > 0) {
823 869 if (good.goods_price != gg[card_field] && good.offline_cut <= 0) isok = 0;
824   - if (good.goods_price > gg[card_field] && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过
  870 + if (good.goods_price > gg[card_field] && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过
825 871  
826 872 } else {
827 873 if (good.goods_price != gg.shop_price && good.offline_cut <= 0) isok = 0;
... ... @@ -832,6 +878,7 @@ Page({
832 878  
833 879 var content = gg.goods_name + '商品的价格发生了变化,请取消订单重新购买1'
834 880 th.toast(content);
  881 + console.log(4);
835 882 return false;
836 883 }
837 884 }
... ... @@ -861,26 +908,28 @@ Page({
861 908 }
862 909  
863 910 //---如果是活动的时候---
864   - var prom = null, goodsinfo = good, th = this;
  911 + var prom = null,
  912 + goodsinfo = good,
  913 + th = this;
865 914 if (goodsinfo.prom_type == 1) {
866   - await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/"+ user_id + "/" + goodsinfo.prom_id, {}).then(res => {
  915 + await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + goodsinfo.prom_id, {}).then(res => {
  916 + if (res.data.code == 0) {
  917 + prom = res.data.data;
  918 + prom.price = prom.user_price;
  919 + }
  920 + })
  921 + }
  922 +
  923 + if (goodsinfo.prom_type == 2) {
  924 + await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + good.goods_id + "/" + goodsinfo.prom_id, {}).then(res => {
867 925 if (res.data.code == 0) {
868 926 prom = res.data.data;
869   - prom.price=prom.user_price;
  927 + prom.price = prom.price;
870 928 }
871 929 })
872 930 }
873   -
874   - if (goodsinfo.prom_type == 2) {
875   - await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/"+ good.goods_id + "/" + goodsinfo.prom_id, {}).then(res => {
876   - if (res.data.code == 0) {
877   - prom = res.data.data;
878   - prom.price=prom.price;
879   - }
880   - })
881   - }
882   -
883   -
  931 +
  932 +
884 933 if (goodsinfo.prom_type == 6 && !good.is_pd_normal) {
885 934 await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + goodsinfo.prom_id, {}).then(res => {
886 935 if (res.data.code == 0) {
... ... @@ -891,7 +940,10 @@ Page({
891 940  
892 941 if (goodsinfo.prom_type == 4 && !good.is_integral_normal) {
893 942 await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1", {
894   - data: {store_id: os.stoid, goods_id: goodsinfo.goods_id}
  943 + data: {
  944 + store_id: os.stoid,
  945 + goods_id: goodsinfo.goods_id
  946 + }
895 947 }).then(res => {
896 948 if (res.data.code == 0 && res.data.data && res.data.data.pageData) {
897 949 prom = res.data.data.pageData[0];
... ... @@ -917,18 +969,18 @@ Page({
917 969 }
918 970  
919 971 // --看一下会员的秒杀价格是不是发生了变化,因为会员的身份发生了变化
920   - if(goodsinfo.prom_type==1 && goodsinfo.goods_price!=prom.price){
921   - var content=goodsinfo.goods_name+'秒杀活动的价格发生了变化';
  972 + if (goodsinfo.prom_type == 1 && goodsinfo.goods_price != prom.price) {
  973 + var content = goodsinfo.goods_name + '秒杀活动的价格发生了变化';
  974 + th.toast(content);
  975 + return false;
  976 + }
  977 +
  978 + // --看一下会员的团购价格是不是发生了变化
  979 + if (goodsinfo.prom_type == 2 && goodsinfo.goods_price != prom.price) {
  980 + var content = goodsinfo.goods_name + '秒杀活动的价格发生了变化';
922 981 th.toast(content);
923 982 return false;
924 983 }
925   -
926   - // --看一下会员的团购价格是不是发生了变化
927   - if(goodsinfo.prom_type==2 && goodsinfo.goods_price!=prom.price){
928   - var content=goodsinfo.goods_name+'秒杀活动的价格发生了变化';
929   - th.toast(content);
930   - return false;
931   - }
932 984  
933 985 if (goodsinfo.prom_type == 4) {
934 986 if (good.goods_num > prom.limitqty - prom.buy_num) {
... ... @@ -937,12 +989,12 @@ Page({
937 989 th.toast(content);
938 990 return false;
939 991 }
940   - } else if(goodsinfo.prom_type == 1 || goodsinfo.prom_type == 2 || goodsinfo.prom_type == 6 ) {
941   - if(order.add_time+5*60<ut.gettimestamp()) {
  992 + } else if (goodsinfo.prom_type == 1 || goodsinfo.prom_type == 2 || goodsinfo.prom_type == 6) {
  993 + if (order.add_time + 5 * 60 < ut.gettimestamp()) {
942 994 var content = gg.goods_name + '该订单已经超时无法支付,请取消订单';
943 995 th.toast(content);
944 996 return false;
945   - }
  997 + }
946 998 }
947 999  
948 1000 }
... ... @@ -956,14 +1008,13 @@ Page({
956 1008 if (!keyid) return false;
957 1009 var offarr = null;
958 1010 await getApp().request.promiseGet("/api/weshop/goods/listWarePrice", {
959   - data: {
960   - VIPId: encodeURIComponent(user_info.erpvipid),
961   - store_id: os.stoid,
962   - PickupId: keyid,
963   - WareIds: wlist
964   - },
  1011 + data: {
  1012 + VIPId: encodeURIComponent(user_info.erpvipid),
  1013 + store_id: os.stoid,
  1014 + PickupId: keyid,
  1015 + WareIds: wlist
965 1016 },
966   - ).then(res => {
  1017 + }, ).then(res => {
967 1018 if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
968 1019 offarr = res.data.data;
969 1020 }
... ... @@ -981,201 +1032,229 @@ Page({
981 1032  
982 1033 var content = good.goods_name + '商品的价格发生了变化,请取消订单重新购买';
983 1034 th.toast(content);
  1035 + console.log(5);
984 1036 return false;
985 1037 }
986 1038 }
987 1039 }
988 1040 th.pay_next(e, o_index);
989 1041 },
990   -
991   -
992   - pay_next(e,o_index){
993   - var th=this;
994   - if (e.order_amount == 0) {
995   - var dd = {
996   - parent_sn: e.order_sn,
997   - store_id: e.store_id,
998   - type: 1,
999   - };
1000   - getApp().request.post("/api/weshop/order/pay/createOrder", {
1001   - data: dd,
1002   - success: function(t) {
1003   - if (t.data.code == 0) {
1004   - th.onload();
1005   - } else {
1006   - getApp().confirmBox(t.data.msg + "请您取消该订单");
1007   - }
1008   - }
1009   - })
1010   - return false;
1011   - }
1012   -
1013   - /*---
1014   - a.jumpToCart4({
1015   - order_sn: e.order_sn,
1016   - order_amount: e.order_amount,
1017   - type: 1 //正常单
1018   - });--*/
1019   -
1020   - t.pay(e.order_sn, function() {
1021   - wx.showToast({title: '支付成功'})
1022   - th.data.orderList.splice(o_index,1);
1023   - th.setData({orderList:th.data.orderList});
1024   - },null,os.stoid,1);
1025   -
1026   -
1027   - },
1028   -
  1042 +
  1043 +
  1044 + pay_next(e, o_index) {
  1045 + var th = this;
  1046 + if (e.order_amount == 0) {
  1047 + var dd = {
  1048 + parent_sn: e.order_sn,
  1049 + store_id: e.store_id,
  1050 + type: 1,
  1051 + };
  1052 + getApp().request.post("/api/weshop/order/pay/createOrder", {
  1053 + data: dd,
  1054 + success: function (t) {
  1055 + if (t.data.code == 0) {
  1056 + th.onload();
  1057 + } else {
  1058 + getApp().confirmBox(t.data.msg + "请您取消该订单");
  1059 + }
  1060 + }
  1061 + })
  1062 + return false;
  1063 + }
  1064 +
  1065 + /*---
  1066 + a.jumpToCart4({
  1067 + order_sn: e.order_sn,
  1068 + order_amount: e.order_amount,
  1069 + type: 1 //正常单
  1070 + });--*/
  1071 +
  1072 + t.pay(e.order_sn, function () {
  1073 + wx.showToast({
  1074 + title: '支付成功'
  1075 + })
  1076 + th.data.orderList.splice(o_index, 1);
  1077 + th.setData({
  1078 + orderList: th.data.orderList
  1079 + });
  1080 + }, null, os.stoid, 1);
  1081 +
  1082 +
  1083 + },
  1084 +
1029 1085 //---检验线下库存的数量的子函数---
1030   - async check_down_line_next(gg,num,pick_id,func){
1031   -
1032   - var lock=0,pick_no,plist;
1033   - //先读取门店的lock
1034   - await getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{
1035   - data:{store_id:os.stoid,wareId:gg.goods_id,storageId:pick_id}
1036   - }).then(res=>{
1037   - if(res.data.code==0 && res.data.data.total>0){
1038   - for(var i in res.data.data.pageData)
1039   - lock+=res.data.data.pageData[i].outQty;
1040   - }
1041   - })
1042   - //先获取门店的编号
1043   - await getApp().request.promiseGet("/api/weshop/pickup/get/"+os.stoid+"/"+pick_id,{
1044   - data:{storeId:os.stoid,goodsId:gg.goods_id,pickupId:pick_id}
1045   - }).then(res=>{
1046   - if(res.data.code==0){
1047   - pick_no=res.data.data.pickup_no;
1048   - }
1049   - })
1050   - //读取线下的门店库存
1051   - await getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{
1052   - data:{storageNos:pick_no,wareIds:encodeURIComponent(gg.erpwareid),storeId:os.stoid}
1053   - }).then(res=>{
1054   - if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length>0){
1055   - plist=res.data.data.pageData[0];
1056   - }
1057   - })
1058   -
1059   - var ob={}; ob.code=1;
1060   - if(!plist){
1061   - ob.code=-1; ob.CanOutQty=0;
1062   - func(ob);return false;
1063   - }
1064   -
1065   - if(num>plist.CanOutQty-lock){
1066   - ob.code=-1;
1067   - ob.CanOutQty=plist.CanOutQty-lock
1068   - if(ob.CanOutQty<0) ob.CanOutQty=0;
1069   - }
1070   - func(ob)
  1086 + async check_down_line_next(gg, num, pick_id, func) {
  1087 +
  1088 + var lock = 0,
  1089 + pick_no, plist;
  1090 + //先读取门店的lock
  1091 + await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", {
  1092 + data: {
  1093 + store_id: os.stoid,
  1094 + wareId: gg.goods_id,
  1095 + storageId: pick_id
  1096 + }
  1097 + }).then(res => {
  1098 + if (res.data.code == 0 && res.data.data.total > 0) {
  1099 + for (var i in res.data.data.pageData)
  1100 + lock += res.data.data.pageData[i].outQty;
  1101 + }
  1102 + })
  1103 + //先获取门店的编号
  1104 + await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + pick_id, {
  1105 + data: {
  1106 + storeId: os.stoid,
  1107 + goodsId: gg.goods_id,
  1108 + pickupId: pick_id
  1109 + }
  1110 + }).then(res => {
  1111 + if (res.data.code == 0) {
  1112 + pick_no = res.data.data.pickup_no;
  1113 + }
  1114 + })
  1115 + //读取线下的门店库存
  1116 + await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", {
  1117 + data: {
  1118 + storageNos: pick_no,
  1119 + wareIds: encodeURIComponent(gg.erpwareid),
  1120 + storeId: os.stoid
  1121 + }
  1122 + }).then(res => {
  1123 + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) {
  1124 + plist = res.data.data.pageData[0];
  1125 + }
  1126 + })
  1127 +
  1128 + var ob = {};
  1129 + ob.code = 1;
  1130 + if (!plist) {
  1131 + ob.code = -1;
  1132 + ob.CanOutQty = 0;
  1133 + func(ob);
  1134 + return false;
  1135 + }
  1136 +
  1137 + if (num > plist.CanOutQty - lock) {
  1138 + ob.code = -1;
  1139 + ob.CanOutQty = plist.CanOutQty - lock
  1140 + if (ob.CanOutQty < 0) ob.CanOutQty = 0;
  1141 + }
  1142 + func(ob)
1071 1143 },
1072   -
1073   -
1074   -
1075   - //------图片失败,默认图片---------
1076   - bind_bnerr: function(e) {
1077   - var _errImg = e.currentTarget.dataset.errorimg;
1078   - var _errObj = {};
1079   - _errObj[_errImg] = "public/images/default_goods_image_240.gif";
1080   - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
1081   - },
1082   -
1083   - //--------跳转到退款详情-----------
1084   - gotoreturn: function(t) {
1085   - var e = t.currentTarget.dataset.recid;
1086   - var oid = t.currentTarget.dataset.oid;
1087   - var wh = "";
1088   - if (e != undefined && e != null && e != "") {
1089   - wh = "&goods_id=" + e;
1090   - }
1091   - wx.navigateTo({
1092   - url: "/pages/user/return_goods_info/return_goods_info?order_id=" + oid + wh,
1093   - });
1094   - },
1095   -
1096   - //-----支付尾款------
1097   - pay_wk: function(ee) {
1098   - console.log("pay_wk");
1099   - var order_id = ee.currentTarget.dataset.order_id;
1100   - wx.navigateTo({
1101   - url: "/pages/cart/cart_wk/cart_wk?order_id=" + order_id,
1102   - });
1103   -
1104   - },
1105   -
1106   - //--判断是不是可以单个商品退--
1107   - check_for_return_btn: function(item) {
1108   - if (item.coupon_no) return false; //有用优惠券
1109   - if (item.order_prom_id) return false; //有订单优惠
1110   - if (item.order_status >= 2) return false; //订单状态>2
1111   - var istrue = true;
1112   - //----判断是不是有优惠活动和赠送商品----
1113   - for (var g in item.goodslist) {
1114   - var g_item = item.goodslist[g];
1115   - if ((g_item.prom_type == 3 && g_item.discount_amount > 0) ||
1116   - (g_item.prom_type == 3 && g_item.goods_price <= 0)
1117   - ) {
1118   - istrue = false;
1119   - break
1120   - }
1121   - if (g_item.prom_type == 5) {
1122   - istrue = false;
1123   - break
1124   - }
1125   - }
1126   - if (!istrue) return false;
1127   - var conf = this.data.conf;
1128   - //判断是不是原路退回
1129   - if (conf.refund_type == 1) return true;
1130   - else {
1131   - if (item.order_amount == 0 || item.user_money == 0) return true;
1132   - }
1133   - return false;
1134   - },
1135   - //跳到首页
1136   - goto: function(e) {
1137   - wx.navigateTo({
1138   - url: '/pages/index/index/index',
1139   - })
1140   - },
1141   -
1142   - //显示核销码
1143   - code_show: function(e) {
1144   - var th = this;
1145   - //--获取成功的时候--
1146   - var no = e.currentTarget.dataset.order_sn;
1147   - var qc_com = th.selectComponent("#qc_com"); //组件的id
1148   - var obj = {
1149   - val: no,
1150   - content: "请将二维码展示给核销员,收货更快捷"
1151   - };
1152   - qc_com.open(obj)
1153   - },
1154   -
1155   - //再来一单的功能的实现
1156   - moreOrder:function(e){
1157   -
1158   - if(this.data.moring) return false;
1159   - this.data.moring=1;
1160   -
1161   - var th=this;
1162   - var index=e.currentTarget.dataset.index;
1163   - var item=th.data.orderList[index];
1164   - th.check_more_order(item);
1165   - },
1166   -
1167   -
1168   - check_more_order:async function(item){
1169   - var pickup=null,th=this;
1170   - var user_id=getApp().globalData.user_id;
  1144 +
  1145 +
  1146 +
  1147 + //------图片失败,默认图片---------
  1148 + bind_bnerr: function (e) {
  1149 + var _errImg = e.currentTarget.dataset.errorimg;
  1150 + var _errObj = {};
  1151 + _errObj[_errImg] = "public/images/default_goods_image_240.gif";
  1152 + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
  1153 + },
  1154 +
  1155 + //--------跳转到退款详情-----------
  1156 + gotoreturn: function (t) {
  1157 + var e = t.currentTarget.dataset.recid;
  1158 + var oid = t.currentTarget.dataset.oid;
  1159 + var wh = "";
  1160 + if (e != undefined && e != null && e != "") {
  1161 + wh = "&goods_id=" + e;
  1162 + }
  1163 + wx.navigateTo({
  1164 + url: "/pages/user/return_goods_info/return_goods_info?order_id=" + oid + wh,
  1165 + });
  1166 + },
  1167 +
  1168 + //-----支付尾款------
  1169 + pay_wk: function (ee) {
  1170 + console.log("pay_wk");
  1171 + var order_id = ee.currentTarget.dataset.order_id;
  1172 + wx.navigateTo({
  1173 + url: "/pages/cart/cart_wk/cart_wk?order_id=" + order_id,
  1174 + });
  1175 +
  1176 + },
  1177 +
  1178 + //--判断是不是可以单个商品退--
  1179 + check_for_return_btn: function (item) {
  1180 + if (item.coupon_no) return false; //有用优惠券
  1181 + if (item.order_prom_id) return false; //有订单优惠
  1182 + if (item.order_status >= 2) return false; //订单状态>2
  1183 + var istrue = true;
  1184 + //----判断是不是有优惠活动和赠送商品----
  1185 + for (var g in item.goodslist) {
  1186 + var g_item = item.goodslist[g];
  1187 + if ((g_item.prom_type == 3 && g_item.discount_amount > 0) ||
  1188 + (g_item.prom_type == 3 && g_item.goods_price <= 0)
  1189 + ) {
  1190 + istrue = false;
  1191 + break
  1192 + }
  1193 + if (g_item.prom_type == 5) {
  1194 + istrue = false;
  1195 + break
  1196 + }
  1197 + }
  1198 + if (!istrue) return false;
  1199 + var conf = this.data.conf;
  1200 + //判断是不是原路退回
  1201 + if (conf.refund_type == 1) return true;
  1202 + else {
  1203 + if (item.order_amount == 0 || item.user_money == 0) return true;
  1204 + }
  1205 + return false;
  1206 + },
  1207 + //跳到首页
  1208 + goto: function (e) {
  1209 + wx.navigateTo({
  1210 + url: '/pages/index/index/index',
  1211 + })
  1212 + },
  1213 +
  1214 + //显示核销码
  1215 + code_show: function (e) {
  1216 + var th = this;
  1217 + //--获取成功的时候--
  1218 + var no = e.currentTarget.dataset.order_sn;
  1219 + var qc_com = th.selectComponent("#qc_com"); //组件的id
  1220 + var obj = {
  1221 + val: no,
  1222 + content: "请将二维码展示给核销员,收货更快捷"
  1223 + };
  1224 + qc_com.open(obj)
  1225 + },
  1226 +
  1227 + //再来一单的功能的实现
  1228 + moreOrder: function (e) {
  1229 +
  1230 + if (this.data.moring) return false;
  1231 + this.data.moring = 1;
  1232 +
  1233 + var th = this;
  1234 + var index = e.currentTarget.dataset.index;
  1235 + var item = th.data.orderList[index];
  1236 + th.check_more_order(item);
  1237 + },
  1238 +
  1239 +
  1240 + check_more_order: async function (item) {
  1241 + console.log(item, 100000);
  1242 + var pickup = null,
  1243 + th = this;
  1244 + var user_id = getApp().globalData.user_id;
1171 1245 wx.showLoading();
1172 1246 //--------获取门店-----------
1173 1247 await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + item.pickup_id, {
1174 1248  
  1249 +<<<<<<< HEAD
1175 1250 }).then(res=>{
1176 1251 if(res.data.code==0){
1177 1252 pickup = res.data.data;
1178 1253 }
  1254 +=======
  1255 + }).then(res => {
  1256 + pickup = res.data.data;
  1257 +>>>>>>> d4b9dbf03fa79fb3ff3c5889f79eea201fb49b74
1179 1258 })
1180 1259 if(!pickup){
1181 1260 wx.hideLoading();
... ... @@ -1199,96 +1278,118 @@ Page({
1199 1278 return false;
1200 1279 }
1201 1280 //--------获取商品----------
1202   - var goods_list=item.order_goods;
  1281 + var goods_list = item.order_goods;
1203 1282 //--- 返回的内容 ---
1204   - var back_goods_arr=[];
1205   - var err_text="";
1206   - for(var i in goods_list){
1207   - var g_item=goods_list[i];
  1283 + var back_goods_arr = [];
  1284 + var err_text = "";
  1285 + for (var i in goods_list) {
  1286 + var g_item = goods_list[i];
  1287 + var b_item = {}
1208 1288 //--如果是赠品,不加入购物车--
1209   - if(g_item['is_gift']) continue;
1210   - if(g_item['prom_type']==4 ){
1211   - err_text+= g_item['goods_name']+"积分购商品不加入购物车\n";
  1289 + if (g_item['is_gift']) continue;
  1290 + if (g_item['prom_type'] == 4) {
  1291 + err_text += g_item['goods_name'] + "积分购商品不加入购物车\n";
1212 1292 continue;
1213 1293 }
1214   - if(g_item['prom_type']==5){
1215   - err_text+= g_item['goods_name']+"搭配购商品不加入购物车\n";
  1294 + if (g_item['prom_type'] == 5) {
  1295 + err_text += g_item['goods_name'] + "搭配购商品不加入购物车\n";
1216 1296 continue;
1217 1297 }
1218   - if(g_item['prom_type']==6 ){
1219   - err_text+= g_item['goods_name']+"拼团商品不加入购物车\n";
  1298 + if (g_item['prom_type'] == 6) {
  1299 + err_text += g_item['goods_name'] + "拼团商品不加入购物车\n";
1220 1300 continue;
1221 1301 }
1222 1302  
1223 1303 //--获取商品--
1224   - var good=null;
  1304 + var good = null;
1225 1305 await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + g_item.goods_id, {
1226 1306  
1227   - }).then(res=>{
1228   - good=res.data.data;
1229   - })
  1307 + }).then(res => {
  1308 + good = res.data.data;
1230 1309  
1231   - if(!good){
1232   - err_text+= g_item['goods_name']+"未找到商品\n";
  1310 + })
  1311 + //调用接口判断订单优惠,
  1312 + const res = await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + g_item.goods_id + "/0", {})
  1313 + if (res.data.code == 0 && res.data.data) {
  1314 + var r_data = res.data.data;
  1315 + if (r_data.ladderLists) {
  1316 + var act_id = r_data.ladderLists[0].form_id;
  1317 + //-- 判断会员能不能参与阶梯促销 --
  1318 + const data = await getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid + "/" + user_id + "/" + act_id, {})
  1319 + if (data.data.code == 0 && data.data.data && data.data.data.isuse && data.data.data.is_end == 0) {
  1320 + b_item.prom_type = 10;
  1321 + b_item.prom_id = data.data.data.id;
  1322 + }
  1323 + }
  1324 + }
  1325 + if (!good) {
  1326 + err_text += g_item['goods_name'] + "未找到商品\n";
1233 1327 continue;
1234 1328 }
1235 1329 if (good.is_on_sale != 1) {
1236   - err_text+= g_item['goods_name']+"已经下架\n";
  1330 + err_text += g_item['goods_name'] + "已经下架\n";
1237 1331 continue;
1238 1332 }
1239 1333  
1240 1334 var timestamp = ut.gettimestamp();
1241 1335 if (good.on_time > timestamp) {
1242   - err_text+= g_item['goods_name']+"还未上架\n";
  1336 + err_text += g_item['goods_name'] + "还未上架\n";
1243 1337 continue;
1244 1338 }
1245 1339 if (good.down_time > 0) {
1246 1340 if (good.down_time < timestamp) {
1247   - err_text+=g_item['goods_name']+"已经下架\n";
  1341 + err_text += g_item['goods_name'] + "已经下架\n";
1248 1342 continue;
1249 1343 }
1250 1344 }
1251 1345  
1252 1346 //如果商品的配送方式和门店不匹配
1253   - if(good['distr_type']>0 && pickup['distr_type']>0 && good['distr_type']!=pickup['distr_type'] ){
1254   - err_text+= good['goods_name']+"配送方式不一致\n";
  1347 + if (good['distr_type'] > 0 && pickup['distr_type'] > 0 && good['distr_type'] != pickup['distr_type']) {
  1348 + err_text += good['goods_name'] + "配送方式不一致\n";
1255 1349 continue;
1256 1350 }
1257 1351  
1258   - var prom=null;
1259   - var b_item={}
1260   - b_item.goods_id=g_item.goods_id;
1261   - b_item.goods_name=g_item.goods_name;
1262   - b_item.goods_num=g_item.goods_num;
1263   - b_item.guide_id=g_item.guide_id;
1264   - b_item.guide_type=g_item.guide_type;
1265   - b_item.pickup_id=item.pickup_id;
1266   - b_item.price=good.shop_price;
1267   - b_item.goods_sn=good.goods_sn;
1268   - b_item.sku=good.sku;
1269   - b_item.is_integral_normal=g_item.is_integral_normal;
1270   -
  1352 + var prom = null;
  1353 + b_item.goods_id = g_item.goods_id;
  1354 + b_item.goods_name = g_item.goods_name;
  1355 + b_item.goods_num = g_item.goods_num;
  1356 + b_item.guide_id = g_item.guide_id;
  1357 + b_item.guide_type = g_item.guide_type;
  1358 + b_item.pickup_id = item.pickup_id;
  1359 + b_item.price = good.shop_price;
  1360 + b_item.goods_sn = good.goods_sn;
  1361 + b_item.sku = good.sku;
  1362 + b_item.is_integral_normal = g_item.is_integral_normal;
  1363 + console.log(b_item, 'b_item');
1271 1364 //-- 如果会员是等级卡的时候,同时商品也有设置相应的卡价格 --
1272   - var card_field=th.data.card_field;
1273   - if(card_field && good[card_field]>0){
1274   - b_item.price=good[card_field];
  1365 + var card_field = th.data.card_field;
  1366 + if (card_field && good[card_field] > 0) {
  1367 + b_item.price = good[card_field];
1275 1368 }
1276 1369  
1277   - var url="/api/weshop/activitylist/getGoodActInfo";
1278   - var req_data={
1279   - store_id:g_item.store_id,goodsidlist:g_item.goods_id,is_detail:1
  1370 + var url = "/api/weshop/activitylist/getGoodActInfo";
  1371 + var req_data = {
  1372 + store_id: g_item.store_id,
  1373 + goodsidlist: g_item.goods_id,
  1374 + is_detail: 1
1280 1375 };
1281   - await getApp().request.promiseGet(url, {data:req_data}).then(res=>{
1282   - if(res.data.code==0){
1283   - var list = res.data.data;
1284   - for(let i in list){
1285   - let item=list[i];
1286   - if(item.prom_type==1){ good.prom_type=1; good.prom_id=item.act_id; }
1287   - }
1288   - }
  1376 + await getApp().request.promiseGet(url, {
  1377 + data: req_data
  1378 + }).then(res => {
  1379 + if (res.data.code == 0) {
  1380 + var list = res.data.data;
  1381 + console.log('list', list);
  1382 + for (let i in list) {
  1383 + let item = list[i];
  1384 + if (item.prom_type == 1) {
  1385 + good.prom_type = 1;
  1386 + good.prom_id = item.act_id;
  1387 + }
  1388 + }
  1389 + }
1289 1390 })
1290 1391  
1291   - if(!prom) {
  1392 + if (!prom) {
1292 1393 //--判断商品当前的活动情况--
1293 1394 switch (good.prom_type) {
1294 1395 case 1:
... ... @@ -1298,29 +1399,29 @@ Page({
1298 1399 flash = res.data.data;
1299 1400 }
1300 1401 })
1301   - //----已经结束-----
  1402 + //----进行中-----
1302 1403 if (flash && flash.is_end == 0 && flash.end_time > timestamp && flash.start_time < timestamp) {
1303 1404 prom = flash;
1304 1405 prom.price = prom.user_price;
1305 1406 b_item.price = prom.user_price;
1306 1407 }
1307 1408 break;
1308   -
1309   - case 2:
1310   - var group = null;
1311   - await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + good.goods_id + "/" + good.prom_id, {}).then(res => {
1312   - if (res.data.code == 0) {
1313   - group = res.data.data;
1314   - }
1315   - })
1316   - //----已经结束-----
1317   - if (group && group.is_end == 0 && group.end_time > timestamp && group.start_time < timestamp) {
1318   - prom = group;
1319   - prom.price = prom.price;
1320   - b_item.price = prom.price;
1321   - }
1322   - break;
1323   -
  1409 +
  1410 + case 2:
  1411 + var group = null;
  1412 + await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + good.goods_id + "/" + good.prom_id, {}).then(res => {
  1413 + if (res.data.code == 0) {
  1414 + group = res.data.data;
  1415 + }
  1416 + })
  1417 + //----进行中-----
  1418 + if (group && group.is_end == 0 && group.end_time > timestamp && group.start_time < timestamp) {
  1419 + prom = group;
  1420 + prom.price = prom.price;
  1421 + b_item.price = prom.price;
  1422 + }
  1423 + break;
  1424 +
1324 1425 case 6:
1325 1426 b_item.is_pd_normal = 1;
1326 1427 break;
... ... @@ -1329,23 +1430,32 @@ Page({
1329 1430 var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + good.prom_id + "/" + getApp().globalData.userInfo.user_id;
1330 1431 await getApp().request.promiseGet(url, {}).then(res => {
1331 1432 if (res.data.code == 0 && res.data.data) {
1332   - if (res.data.data.is_show == 1 && res.data.data.is_end == 0
1333   - && ut.gettimestamp() < res.data.data.end_time
1334   - && ut.gettimestamp() > res.data.data.start_time
  1433 + if (res.data.data.is_show == 1 && res.data.data.is_end == 0 &&
  1434 + ut.gettimestamp() < res.data.data.end_time &&
  1435 + ut.gettimestamp() > res.data.data.start_time
1335 1436 ) {
1336 1437 b_item.prom_type = 7;
1337 1438 b_item.prom_id = res.data.data.id;
1338 1439 good.prom_type = 7;
1339 1440 good.prom_id = b_item.prom_id;
1340   -
1341 1441 }
1342 1442 }
1343 1443 })
1344 1444 break;
  1445 + case 10:
  1446 + let user_id = getApp().globalData.userInfo.user_id;
  1447 + var url = `/api/weshop/prom/ladderForm/getNew/${os.stoid}/${user_id}/${good.prom_id}`;
  1448 + await getApp().request.promiseGet(url, {}).then(res => {
  1449 + if (res.data.code == 0 && res.data.data && res.data.data.isuse && res.data.data.is_end == 0) {
  1450 + b_item.prom_type = 10;
  1451 + b_item.prom_id = res.data.data.id;
  1452 + }
  1453 + })
1345 1454 }
1346 1455 }
1347 1456  
1348 1457 //如果有优惠促销的时候,要看下商品的优惠活动有没有过期
  1458 +<<<<<<< HEAD
1349 1459 if(g_item.prom_type==3 || good.prom_type==3){
1350 1460 var is_g_prom=0;
1351 1461 //因为有全场优惠活动,商品参加的活动还未开始
... ... @@ -1361,6 +1471,15 @@ Page({
1361 1471 is_g_prom=1; break;
1362 1472 }
1363 1473 }
  1474 +=======
  1475 + if (g_item.prom_type == 3 || good.prom_type == 3) {
  1476 + await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + good.goods_id + "/1", {}).then(res => {
  1477 + if (res.data.code == 0) {
  1478 + var r_data = res.data.data;
  1479 + if (r_data.promGoodsLists) {
  1480 + b_item.prom_type = 3;
  1481 + b_item.prom_id = r_data.promGoodsLists[0].prom_id;
  1482 +>>>>>>> d4b9dbf03fa79fb3ff3c5889f79eea201fb49b74
1364 1483 }
1365 1484 })
1366 1485 if(is_g_prom) {
... ... @@ -1389,34 +1508,41 @@ Page({
1389 1508  
1390 1509  
1391 1510 //判断是不是线下库存的购买, 是不是秒杀活动
1392   - if(th.data.sales_rules==2 && !prom){
  1511 + if (th.data.sales_rules == 2 && !prom) {
1393 1512  
1394 1513 //-- 看一下购物车上有多少商品 --
1395   - var cart_num=0;
  1514 + var cart_num = 0;
1396 1515 await getApp().request.promiseGet("/api/weshop/cart/page", {
1397 1516 data: {
1398 1517 store_id: os.stoid,
1399 1518 user_id: getApp().globalData.user_id,
1400   - state:0, is_gift:0,
1401   - goods_id:good.goods_id,
  1519 + state: 0,
  1520 + is_gift: 0,
  1521 + goods_id: good.goods_id,
1402 1522 pick_id: b_item.pickup_id
1403 1523 }
1404   - }).then(res=>{
  1524 + }).then(res => {
1405 1525 var num = 0;
1406   - if(res.data.code==0 && res.data.data && res.data.data.pageData) {
  1526 + if (res.data.code == 0 && res.data.data && res.data.data.pageData) {
1407 1527 for (var i = 0; i < res.data.data.pageData.length; i++) {
1408 1528 num += res.data.data.pageData[i].goods_num;
1409 1529 }
1410 1530 }
1411   - cart_num=num;
  1531 + cart_num = num;
1412 1532 })
1413 1533  
1414   - var lock=0,plist=null;
  1534 + var lock = 0,
  1535 + plist = null;
1415 1536  
1416   - if(b_item.prom_type!=7) {
  1537 + if (b_item.prom_type != 7) {
1417 1538 //先读取门店的lock,
1418 1539 await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", {
1419   - data: {store_id: os.stoid, wareId: good.goods_id, storageId: b_item.pickup_id, pageSize: 1000}
  1540 + data: {
  1541 + store_id: os.stoid,
  1542 + wareId: good.goods_id,
  1543 + storageId: b_item.pickup_id,
  1544 + pageSize: 1000
  1545 + }
1420 1546 }).then(res => {
1421 1547 if (res.data.code == 0 && res.data.data.total > 0) {
1422 1548 for (var i in res.data.data.pageData)
... ... @@ -1449,100 +1575,101 @@ Page({
1449 1575 b_item.goods_num = plist.CanOutQty - lock;
1450 1576 }
1451 1577 }
1452   - var req_data={
  1578 + var req_data = {
1453 1579 store_id: os.stoid,
1454 1580 user_id: getApp().globalData.user_id,
1455 1581 goods_id: good.goods_id,
1456 1582 };
1457   - if(b_item.prom_type==7){
1458   - req_data.prom_type=7;
1459   - req_data.prom_id=b_item.prom_id;
  1583 + if (b_item.prom_type == 7) {
  1584 + req_data.prom_type = 7;
  1585 + req_data.prom_id = b_item.prom_id;
1460 1586 }
1461 1587  
1462   - var buynum=0;
1463   - var promnum=0;
  1588 + var buynum = 0;
  1589 + var promnum = 0;
1464 1590 //---要获得商品,该用户买了多少件,同步应用---
1465 1591 await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
1466 1592 data: req_data,
1467 1593 }).then(res => {
1468   - if(res.data.code==0){
  1594 + if (res.data.code == 0) {
1469 1595 var buy_num_data = res.data.data;
1470 1596 buynum = buy_num_data.goodsbuynum;
1471   - if(buy_num_data.promgoodsbuynum){
1472   - promnum=buy_num_data.promgoodsbuynum;
  1597 + if (buy_num_data.promgoodsbuynum) {
  1598 + promnum = buy_num_data.promgoodsbuynum;
1473 1599 }
1474 1600 }
1475 1601 })
1476 1602  
1477 1603 //---- 要计算商品的限购 -----
1478   - if(good['viplimited']>0){
1479   - if(cart_num+buynum>good['viplimited']){
1480   - err_text+= good['goods_name']+"超出限购\n";
  1604 + if (good['viplimited'] > 0) {
  1605 + if (cart_num + buynum > good['viplimited']) {
  1606 + err_text += good['goods_name'] + "超出限购\n";
1481 1607 continue;
1482 1608 }
1483   - good['viplimited']-=(cart_num+buynum);
1484   - if(b_item.goods_num>good['viplimited']){
1485   - b_item.goods_num=good['viplimited'];
  1609 + good['viplimited'] -= (cart_num + buynum);
  1610 + if (b_item.goods_num > good['viplimited']) {
  1611 + b_item.goods_num = good['viplimited'];
1486 1612 }
1487 1613 }
1488 1614 //不需要计算组合购的限购
1489 1615  
1490   - back_goods_arr.push(b_item); //返回商品元素
  1616 + back_goods_arr.push(b_item); //返回商品元素
1491 1617  
1492   - }else{
  1618 + } else {
1493 1619  
1494 1620 //-- 看一下购物车上有多少商品 --
1495   - var cart_num=0;
  1621 + var cart_num = 0;
1496 1622 await getApp().request.promiseGet("/api/weshop/cart/page", {
1497 1623 data: {
1498 1624 store_id: os.stoid,
1499 1625 user_id: getApp().globalData.user_id,
1500   - state:0, is_gift:0,
1501   - goods_id:good.goods_id
  1626 + state: 0,
  1627 + is_gift: 0,
  1628 + goods_id: good.goods_id
1502 1629 }
1503   - }).then(res=>{
  1630 + }).then(res => {
1504 1631 var num = 0;
1505   - if(res.data.code==0 && res.data.data && res.data.data.pageData) {
  1632 + if (res.data.code == 0 && res.data.data && res.data.data.pageData) {
1506 1633 for (var i = 0; i < res.data.data.pageData.length; i++) {
1507 1634 num += res.data.data.pageData[i].goods_num;
1508 1635 }
1509 1636 }
1510   - cart_num=num;
  1637 + cart_num = num;
1511 1638 })
1512 1639  
1513 1640  
1514   - if(good.store_count<=0){
1515   - err_text+= good['goods_name']+"库存不足\n";
  1641 + if (good.store_count <= 0) {
  1642 + err_text += good['goods_name'] + "库存不足\n";
1516 1643 continue;
1517 1644 }
1518   - if(b_item.goods_num>good.store_count)
1519   - b_item.goods_num=good.store_count;
  1645 + if (b_item.goods_num > good.store_count)
  1646 + b_item.goods_num = good.store_count;
1520 1647  
1521   - var buynum=0; //商品已经购买多少件
1522   - var promgoodsbuynum=0; //活动已经购买多少件
1523   - var redis_num = 0; //redis库存
  1648 + var buynum = 0; //商品已经购买多少件
  1649 + var promgoodsbuynum = 0; //活动已经购买多少件
  1650 + var redis_num = 0; //redis库存
1524 1651  
1525   - var req_data={
  1652 + var req_data = {
1526 1653 store_id: os.stoid,
1527 1654 user_id: getApp().globalData.user_id,
1528 1655 goods_id: good.goods_id,
1529 1656 };
1530 1657  
1531   - if(prom){
1532   - req_data.prom_type= good.prom_type;
1533   - req_data.prom_id= good.prom_id;
1534   - b_item.prom_type=good.prom_type;
1535   - b_item.prom_id=good.prom_id;
  1658 + if (prom) {
  1659 + req_data.prom_type = good.prom_type;
  1660 + req_data.prom_id = good.prom_id;
  1661 + b_item.prom_type = good.prom_type;
  1662 + b_item.prom_id = good.prom_id;
1536 1663  
1537 1664 //------判断活动是否抢光-----
1538 1665 await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
1539 1666 os.stoid + "/" + good.prom_type + "/" + good.prom_id, {
1540   - 1: 1
1541   - }).then(res => {
  1667 + 1: 1
  1668 + }).then(res => {
1542 1669 redis_num = res.data.data;
1543 1670 });
1544   - if(redis_num<=0){
1545   - err_text+= good['goods_name']+"活动不足\n";
  1671 + if (redis_num <= 0) {
  1672 + err_text += good['goods_name'] + "活动不足\n";
1546 1673 continue;
1547 1674 }
1548 1675  
... ... @@ -1552,7 +1679,7 @@ Page({
1552 1679 await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
1553 1680 data: req_data,
1554 1681 }).then(res => {
1555   - if(res.data.code==0){
  1682 + if (res.data.code == 0) {
1556 1683 var buy_num_data = res.data.data;
1557 1684 if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum;
1558 1685 buynum = buy_num_data.goodsbuynum;
... ... @@ -1560,20 +1687,20 @@ Page({
1560 1687 })
1561 1688  
1562 1689 //---- 要计算商品的限购 -----
1563   - if(good['viplimited']>0){
1564   - if(cart_num+buynum>good['viplimited']){
1565   - err_text+= good['goods_name']+"超出限购\n";
  1690 + if (good['viplimited'] > 0) {
  1691 + if (cart_num + buynum > good['viplimited']) {
  1692 + err_text += good['goods_name'] + "超出限购\n";
1566 1693 continue;
1567 1694 }
1568   - good['viplimited']-=(cart_num+buynum);
1569   - if(b_item.goods_num>good['viplimited']){
1570   - b_item.goods_num=good['viplimited'];
  1695 + good['viplimited'] -= (cart_num + buynum);
  1696 + if (b_item.goods_num > good['viplimited']) {
  1697 + b_item.goods_num = good['viplimited'];
1571 1698 }
1572 1699  
1573 1700 }
1574 1701  
1575 1702 //-- 判断活动的库存 --
1576   - if(prom) {
  1703 + if (prom) {
1577 1704 if (prom['goods_num'] <= prom['buy_num']) {
1578 1705 err_text += good['goods_name'] + "超出活动库存\n";
1579 1706 continue;
... ... @@ -1598,367 +1725,378 @@ Page({
1598 1725 }
1599 1726 }
1600 1727 }
1601   -
1602   -
1603   - back_goods_arr.push(b_item); //返回商品元素
  1728 + back_goods_arr.push(b_item); //返回商品元素
1604 1729 }
1605 1730 }
1606 1731  
1607 1732 //有重新购买的数据是时候,就要重新生成订单
1608   - if(back_goods_arr.length>0){
1609   - th.setData({back_goods_arr:back_goods_arr});
1610   - if(!err_text){
  1733 + if (back_goods_arr.length > 0) {
  1734 + th.setData({
  1735 + back_goods_arr: back_goods_arr
  1736 + });
  1737 + if (!err_text) {
1611 1738 th.more_add_cart();
1612   - }else{
  1739 + } else {
1613 1740 wx.hideLoading();
1614 1741 // 如果没有获取用户信息
1615 1742 wx.showModal({
1616   - title:'确定',
1617   - content: err_text+',确定要买其他商品码?',
  1743 + title: '确定',
  1744 + content: err_text + ',确定要买其他商品吗?',
1618 1745 success(res) {
1619 1746 if (res.confirm) {
1620 1747 //跳转到登录页
1621 1748 th.more_add_cart();
1622   - }else{
1623   - th.data.moring=0;
  1749 + } else {
  1750 + th.data.moring = 0;
1624 1751 wx.hideLoading();
1625 1752 }
1626   - },fail(){
1627   - th.data.moring=0;
  1753 + },
  1754 + fail() {
  1755 + th.data.moring = 0;
1628 1756 wx.hideLoading();
1629 1757 }
1630 1758 });
1631 1759  
1632 1760 }
1633   - }else{
1634   - th.data.moring=0;
  1761 + } else {
  1762 + th.data.moring = 0;
1635 1763 wx.hideLoading();
1636 1764 getApp().confirmBox(err_text);
1637 1765 }
1638 1766 },
1639   -
1640   - more_add_cart:async function(){
1641   - var back_goods_arr=this.data.back_goods_arr;
1642   - var err_text="";
1643   - var ok_num=0;
1644   -
1645   - for(var i in back_goods_arr){
1646   - //商品ID
1647   - var g_item=back_goods_arr[i];
1648   - var newd = {
1649   - goods_id: g_item.goods_id,
1650   - goods_num: g_item.goods_num,
1651   - pick_id: g_item.pickup_id,
1652   - user_id: oo.user_id,
1653   - store_id: os.stoid,
1654   - goods_price: g_item.price,
1655   - member_goods_price: g_item.price,
1656   - goods_name: g_item.goods_name,
1657   - goods_sn: g_item.goods_sn,
1658   - sku: g_item.sku,
1659   - };
1660   -
1661   - if(g_item.guide_id){
1662   - newd['guide_id']=g_item.guide_id;
1663   - newd['guide_type']=g_item.guide_type;
1664   - }
1665   -
1666   - if(g_item.is_integral_normal){
1667   - newd['is_integral_normal']=g_item.is_integral_normal;
1668   - }
1669   - if(g_item.is_pd_normal){
1670   - newd['is_pd_normal']=g_item.is_pd_normal;
1671   - }
1672   -
1673   - if(g_item.prom_type){
1674   - newd['prom_type']=g_item.prom_type;
1675   - newd['prom_id']=g_item.prom_id;
1676   - }
1677   -
1678   -
1679   - var b_cart_goods=null;
1680   - await getApp().request.promiseGet("/api/weshop/cart/page", {
1681   - data: {
1682   - store_id: os.stoid,
1683   - user_id: oo.user_id,
1684   - goods_id: g_item.goods_id,
1685   - pick_id: g_item.pickup_id,
1686   - },
1687   - }).then(res=>{
1688   - //-------如果购物车中有相关的数据-------
1689   - if (res.data.data.total > 0) {
1690   - b_cart_goods= res.data.data.pageData[0];
1691   - }
1692   - })
1693   -
1694   - //-- 如果就加入过购物车 --
1695   - if(b_cart_goods){
1696   - var updata = {
1697   - id: b_cart_goods.id,
1698   - goods_num: newd.goods_num + b_cart_goods.goods_num,
1699   - goods_price: newd.goods_price,
1700   - member_goods_price:newd.goods_price,
1701   - store_id: os.stoid,
1702   - };
1703   - if(newd.guide_id){
1704   - updata.guide_id=newd.guide_id;
1705   - updata.guide_type=newd.guide_type;
1706   - }
1707   - if(newd.prom_type){
1708   - updata.prom_type=newd.prom_type;
1709   - updata.prom_id=newd.prom_id;
1710   - }
1711   -
1712   - await getApp().request.promisePut("/api/weshop/cart/update", {
1713   - data: updata
1714   - }).then(res=>{
1715   - if(res.data.code==0) {
1716   - ok_num++;
1717   - }else{
1718   - err_text+=newd.goods_name+"加入购物车失败\n";
1719   - }
1720   - })
1721   -
1722   - }else{
1723   - await getApp().request.promisePost("/api/weshop/cart/save", {
1724   - data: newd
1725   - }).then(res=>{
1726   - if(res.data.code==0) {
1727   - ok_num++;
1728   - }else{
1729   - err_text+=newd.goods_name+"加入购物车失败\n";
1730   - }
1731   - })
1732   - }
1733   - }
1734   - wx.hideLoading();
1735   - this.data.moring=0;
1736   - if(ok_num==0){
1737   - //-- 如果没有获取用户信息 --
1738   - wx.showModal({
1739   - title:'提示',
1740   - content: err_text,
1741   - success(res) {}
1742   - });
1743   - }else{
1744   - if(err_text==""){
1745   - getApp().goto("/pages/cart/cart/cart");
1746   - }else{
1747   - // 如果没有获取用户信息
1748   - wx.showModal({
1749   - title:'提示',
1750   - content: err_text,
1751   - success(res) {
1752   - if (res.confirm) {
1753   - //跳转到登录页
1754   - getApp().goto("/pages/cart/cart/cart");
1755   - }
1756   - }
1757   - });
1758   -
1759   - }
1760   - }
1761   - },
1762   -
1763   - request_list: function(data, callback){
1764   - // console.log('进入request_list');
1765   -
1766   - var th = this;
1767   - if(this.data.is_load2) return false; //-- 正在加载
1768   - if(this.data.is_no_data2) return false; //-- 没有数据
1769   - if(this.data.is_no_more2) return false; //-- 没有更多
1770   -
1771   - // 开启加载状态
1772   - this.data.is_load2=1;
1773   -
1774   - // var req_data = {
1775   - // page:th.data.currentPage2
1776   - // }
1777   -
1778   - app.request.promiseGet("/api/weshop/order/pagePosOrder", {
1779   - data: data
1780   - }).then(res=>{
1781   - // 关闭加载状态
1782   - th.data.is_load2=0;
1783   - // 请求成功
1784   - if(res.data.code==0) {
1785   - if(res.data.data.pageData.length>0) {
1786   - th.data.currentPage2++;
1787   - var data = res.data.data.pageData;
1788   - // 判断有无更多数据可以加载,如果大于则没有更多数据,反之则有
1789   - if(res.data.data.page*res.data.data.pageSize > res.data.data.total){th.setData({is_no_more2:1});}
1790   - var list=th.data.list2;
1791   - list=list.concat(data);
1792   - th.setData({list2:list});
1793   - } else {
1794   - if(th.data.currentPage2==1){
1795   - th.setData({is_no_data2:1});
1796   - } else {
1797   - th.setData({is_no_more2:1});
1798   - }
1799   - }
1800   - if(callback) callback(res);
1801   - } else {
1802   - wx.showToast({
1803   - title: res.data.msg,
1804   - icon: 'none',
1805   - duration: 2000
1806   - })
1807   - }
1808   - })
1809   - },
1810   -
1811   -
1812   - onClickTab(e) {
1813   - let currentIndex = e.target.dataset.index;
1814   - this.setData({
1815   - currentIndex: currentIndex
1816   - });
1817   - console.log(this.data.currentIndex);
1818   - this.setData({
1819   - is_no_data2: 0,
1820   - is_no_more2: 0,
1821   - currentPage2: 1,
1822   - });
1823   - if(currentIndex == 0) {
1824   - console.log('线上订单');
1825   - /*---
1826   - this.setData({
1827   - startDate: '选择开始时间',
1828   - endDate: '选择结束时间',
1829   - });--*/
1830   - } else if(currentIndex == 1) {
1831   - console.log('线下订单');
1832   - this.request_list({
1833   - store_id: os.stoid,
1834   - user_id: oo.user_id,
1835   - page: 1,
1836   - BeginDate: this.data.startDate,
1837   - EndDate: this.data.endDate
1838   - });
1839   - };
1840   - },
1841   -
1842   - bindDateChange1: function(e) {
1843   - console.log('picker发送选择改变,携带值为', e.detail.value)
1844   - this.setData({
1845   - startDate: e.detail.value
1846   - })
1847   - },
1848   -
1849   - bindDateChange2: function(e) {
1850   - console.log('picker发送选择改变,携带值为', e.detail.value)
1851   - this.setData({
1852   - endDate: e.detail.value
1853   - })
1854   - },
1855   -
1856   - bindInput(e) {
1857   - this.data.searchContent = e.detail.value;
1858   - },
1859   -
1860   - searchOnline() {
1861   - console.log('online',this.data.searchContent);
1862   - if(this.data.searchContent) {
1863   - console.log(this.data.searchContent);
1864   - this.resetData(), this.requestOrderList(this.data.activeCategoryId);
1865   - } else {
1866   - wx.showToast({
1867   - title: '您还没有输入搜索内容~',
1868   - icon: 'none',
1869   - })
1870   - };
1871   - },
1872   -
1873   - searchOffline() {
1874   - console.log('执行查询');
1875   - let th = this;
1876   - let startDate = this.data.startDate;
1877   - let endDate = this.data.endDate;
1878   -
1879   - // this.data.is_no_data2 = 0;
1880   - this.setData({
1881   - currentPage2: 1,
1882   - list2: [],
1883   - is_no_data2: 0,
1884   - });
1885   -
1886   -
1887   - if(startDate == '选择开始时间' || endDate == '选择结束时间') {
1888   - wx.showToast({
1889   - title: '请选择完整的查询时间~',
1890   - icon: 'none',
1891   - })
1892   - };
1893   -
1894   - if(new Date(startDate) > new Date(endDate)) {
1895   - wx.showToast({
1896   - title: '不对噢!开始时间不能晚于结束时间~',
1897   - icon: 'none',
1898   - })
1899   - return;
1900   - };
1901   -
1902   -
1903   - this.request_list({
1904   - store_id: os.stoid,
1905   - user_id: oo.user_id,
1906   - page: 1,
1907   - BeginDate: this.data.startDate,
1908   - EndDate: this.data.endDate
1909   - }, function(res) {
1910   - if(res.data.data.total == 0) {
1911   - wx.showToast({
1912   - title: '没有找到相关订单',
1913   - icon: 'none',
1914   - duration: 2000
1915   - })
1916   - } else {
1917   - th.setData({
1918   - total: res.data.data.total
1919   - });
1920   - }
1921   - });
1922   - },
1923   -
1924   - currentDate() {
1925   - var now = new Date();
1926   - var year = now.getFullYear(); //年
1927   - var month = now.getMonth() + 1; //月
1928   - var day = now.getDate(); //日
1929   -
1930   - var clock = year + "-";
1931   -
1932   - if(month < 10) month += "0";
1933   - clock += month + "-";
1934   -
1935   - if(day < 10) day += "0";
1936   - clock += day;
1937   -
1938   - // if(hh < 10)
1939   - // clock += "0";
1940   -
1941   - // clock += hh + ":";
1942   - // if (mm < 10) clock += '0';
1943   - // clock += mm + ":";
1944   -
1945   - // if (ss < 10) clock += '0';
1946   - // clock += ss;
1947   - return clock;
1948   - },
1949   -
1950   - toast(msg){
1951   - wx.showToast({
1952   - title: msg,
1953   - icon: 'none',
1954   - duration: 3000
1955   - })
1956   - },
1957   -
1958   - go_url(e){
1959   - var url=e.currentTarget.dataset.url;
1960   - getApp().goto(url);
  1767 +
  1768 + more_add_cart: async function () {
  1769 + var back_goods_arr = this.data.back_goods_arr;
  1770 + var err_text = "";
  1771 + var ok_num = 0;
  1772 +
  1773 + for (var i in back_goods_arr) {
  1774 + //商品ID
  1775 + var g_item = back_goods_arr[i];
  1776 + console.log(g_item, 'g_item');
  1777 + var newd = {
  1778 + goods_id: g_item.goods_id,
  1779 + goods_num: g_item.goods_num,
  1780 + pick_id: g_item.pickup_id,
  1781 + user_id: oo.user_id,
  1782 + store_id: os.stoid,
  1783 + goods_price: g_item.price,
  1784 + member_goods_price: g_item.price,
  1785 + goods_name: g_item.goods_name,
  1786 + goods_sn: g_item.goods_sn,
  1787 + sku: g_item.sku,
  1788 + };
  1789 +
  1790 + if (g_item.guide_id) {
  1791 + newd['guide_id'] = g_item.guide_id;
  1792 + newd['guide_type'] = g_item.guide_type;
  1793 + }
  1794 +
  1795 + if (g_item.is_integral_normal) {
  1796 + newd['is_integral_normal'] = g_item.is_integral_normal;
  1797 + }
  1798 + if (g_item.is_pd_normal) {
  1799 + newd['is_pd_normal'] = g_item.is_pd_normal;
  1800 + }
  1801 + if (g_item.prom_type) {
  1802 + newd['prom_type'] = g_item.prom_type;
  1803 + newd['prom_id'] = g_item.prom_id;
  1804 + }
  1805 +
  1806 +
  1807 + var b_cart_goods = null;
  1808 + await getApp().request.promiseGet("/api/weshop/cart/page", {
  1809 + data: {
  1810 + store_id: os.stoid,
  1811 + user_id: oo.user_id,
  1812 + goods_id: g_item.goods_id,
  1813 + pick_id: g_item.pickup_id,
  1814 + },
  1815 + }).then(res => {
  1816 + //-------如果购物车中有相关的数据-------
  1817 + if (res.data.data.total > 0) {
  1818 + b_cart_goods = res.data.data.pageData[0];
  1819 + }
  1820 + })
  1821 +
  1822 + //-- 如果就加入过购物车 --
  1823 + if (b_cart_goods) {
  1824 + var updata = {
  1825 + id: b_cart_goods.id,
  1826 + goods_num: newd.goods_num + b_cart_goods.goods_num,
  1827 + goods_price: newd.goods_price,
  1828 + member_goods_price: newd.goods_price,
  1829 + store_id: os.stoid,
  1830 + };
  1831 + if (newd.guide_id) {
  1832 + updata.guide_id = newd.guide_id;
  1833 + updata.guide_type = newd.guide_type;
  1834 + }
  1835 + if (newd.prom_type) {
  1836 + updata.prom_type = newd.prom_type;
  1837 + updata.prom_id = newd.prom_id;
  1838 + }
  1839 +
  1840 + await getApp().request.promisePut("/api/weshop/cart/update", {
  1841 + data: updata
  1842 + }).then(res => {
  1843 + if (res.data.code == 0) {
  1844 + ok_num++;
  1845 + } else {
  1846 + err_text += newd.goods_name + "加入购物车失败\n";
  1847 + }
  1848 + })
  1849 +
  1850 + } else {
  1851 + await getApp().request.promisePost("/api/weshop/cart/save", {
  1852 + data: newd
  1853 + }).then(res => {
  1854 + if (res.data.code == 0) {
  1855 + ok_num++;
  1856 + } else {
  1857 + err_text += newd.goods_name + "加入购物车失败\n";
  1858 + }
  1859 + })
  1860 + }
  1861 + }
  1862 + wx.hideLoading();
  1863 + this.data.moring = 0;
  1864 + if (ok_num == 0) {
  1865 + //-- 如果没有获取用户信息 --
  1866 + wx.showModal({
  1867 + title: '提示',
  1868 + content: err_text,
  1869 + success(res) {}
  1870 + });
  1871 + } else {
  1872 + if (err_text == "") {
  1873 + getApp().goto("/pages/cart/cart/cart");
  1874 + } else {
  1875 + // 如果没有获取用户信息
  1876 + wx.showModal({
  1877 + title: '提示',
  1878 + content: err_text,
  1879 + success(res) {
  1880 + if (res.confirm) {
  1881 + //跳转到登录页
  1882 + getApp().goto("/pages/cart/cart/cart");
  1883 + }
  1884 + }
  1885 + });
  1886 +
  1887 + }
  1888 + }
  1889 + },
  1890 +
  1891 + request_list: function (data, callback) {
  1892 + // console.log('进入request_list');
  1893 +
  1894 + var th = this;
  1895 + if (this.data.is_load2) return false; //-- 正在加载
  1896 + if (this.data.is_no_data2) return false; //-- 没有数据
  1897 + if (this.data.is_no_more2) return false; //-- 没有更多
  1898 +
  1899 + // 开启加载状态
  1900 + this.data.is_load2 = 1;
  1901 +
  1902 + // var req_data = {
  1903 + // page:th.data.currentPage2
  1904 + // }
  1905 +
  1906 + app.request.promiseGet("/api/weshop/order/pagePosOrder", {
  1907 + data: data
  1908 + }).then(res => {
  1909 + // 关闭加载状态
  1910 + th.data.is_load2 = 0;
  1911 + // 请求成功
  1912 + if (res.data.code == 0) {
  1913 + if (res.data.data.pageData.length > 0) {
  1914 + th.data.currentPage2++;
  1915 + var data = res.data.data.pageData;
  1916 + // 判断有无更多数据可以加载,如果大于则没有更多数据,反之则有
  1917 + if (res.data.data.page * res.data.data.pageSize > res.data.data.total) {
  1918 + th.setData({
  1919 + is_no_more2: 1
  1920 + });
  1921 + }
  1922 + var list = th.data.list2;
  1923 + list = list.concat(data);
  1924 + th.setData({
  1925 + list2: list
  1926 + });
  1927 + } else {
  1928 + if (th.data.currentPage2 == 1) {
  1929 + th.setData({
  1930 + is_no_data2: 1
  1931 + });
  1932 + } else {
  1933 + th.setData({
  1934 + is_no_more2: 1
  1935 + });
  1936 + }
  1937 + }
  1938 + if (callback) callback(res);
  1939 + } else {
  1940 + wx.showToast({
  1941 + title: res.data.msg,
  1942 + icon: 'none',
  1943 + duration: 2000
  1944 + })
  1945 + }
  1946 + })
  1947 + },
  1948 +
  1949 +
  1950 + onClickTab(e) {
  1951 + let currentIndex = e.target.dataset.index;
  1952 + this.setData({
  1953 + currentIndex: currentIndex
  1954 + });
  1955 + console.log(this.data.currentIndex);
  1956 + this.setData({
  1957 + is_no_data2: 0,
  1958 + is_no_more2: 0,
  1959 + currentPage2: 1,
  1960 + });
  1961 + if (currentIndex == 0) {
  1962 + console.log('线上订单');
  1963 + /*---
  1964 + this.setData({
  1965 + startDate: '选择开始时间',
  1966 + endDate: '选择结束时间',
  1967 + });--*/
  1968 + } else if (currentIndex == 1) {
  1969 + console.log('线下订单');
  1970 + this.request_list({
  1971 + store_id: os.stoid,
  1972 + user_id: oo.user_id,
  1973 + page: 1,
  1974 + BeginDate: this.data.startDate,
  1975 + EndDate: this.data.endDate
  1976 + });
  1977 + };
  1978 + },
  1979 +
  1980 + bindDateChange1: function (e) {
  1981 + console.log('picker发送选择改变,携带值为', e.detail.value)
  1982 + this.setData({
  1983 + startDate: e.detail.value
  1984 + })
  1985 + },
  1986 +
  1987 + bindDateChange2: function (e) {
  1988 + console.log('picker发送选择改变,携带值为', e.detail.value)
  1989 + this.setData({
  1990 + endDate: e.detail.value
  1991 + })
  1992 + },
  1993 +
  1994 + bindInput(e) {
  1995 + this.data.searchContent = e.detail.value;
  1996 + },
  1997 +
  1998 + searchOnline() {
  1999 + console.log('online', this.data.searchContent);
  2000 + if (this.data.searchContent) {
  2001 + console.log(this.data.searchContent);
  2002 + this.resetData(), this.requestOrderList(this.data.activeCategoryId);
  2003 + } else {
  2004 + wx.showToast({
  2005 + title: '您还没有输入搜索内容~',
  2006 + icon: 'none',
  2007 + })
  2008 + };
  2009 + },
  2010 +
  2011 + searchOffline() {
  2012 + console.log('执行查询');
  2013 + let th = this;
  2014 + let startDate = this.data.startDate;
  2015 + let endDate = this.data.endDate;
  2016 +
  2017 + // this.data.is_no_data2 = 0;
  2018 + this.setData({
  2019 + currentPage2: 1,
  2020 + list2: [],
  2021 + is_no_data2: 0,
  2022 + });
  2023 +
  2024 +
  2025 + if (startDate == '选择开始时间' || endDate == '选择结束时间') {
  2026 + wx.showToast({
  2027 + title: '请选择完整的查询时间~',
  2028 + icon: 'none',
  2029 + })
  2030 + };
  2031 +
  2032 + if (new Date(startDate) > new Date(endDate)) {
  2033 + wx.showToast({
  2034 + title: '不对噢!开始时间不能晚于结束时间~',
  2035 + icon: 'none',
  2036 + })
  2037 + return;
  2038 + };
  2039 +
  2040 +
  2041 + this.request_list({
  2042 + store_id: os.stoid,
  2043 + user_id: oo.user_id,
  2044 + page: 1,
  2045 + BeginDate: this.data.startDate,
  2046 + EndDate: this.data.endDate
  2047 + }, function (res) {
  2048 + if (res.data.data.total == 0) {
  2049 + wx.showToast({
  2050 + title: '没有找到相关订单',
  2051 + icon: 'none',
  2052 + duration: 2000
  2053 + })
  2054 + } else {
  2055 + th.setData({
  2056 + total: res.data.data.total
  2057 + });
  2058 + }
  2059 + });
  2060 + },
  2061 +
  2062 + currentDate() {
  2063 + var now = new Date();
  2064 + var year = now.getFullYear(); //年
  2065 + var month = now.getMonth() + 1; //月
  2066 + var day = now.getDate(); //日
  2067 +
  2068 + var clock = year + "-";
  2069 +
  2070 + if (month < 10) month += "0";
  2071 + clock += month + "-";
  2072 +
  2073 + if (day < 10) day += "0";
  2074 + clock += day;
  2075 +
  2076 + // if(hh < 10)
  2077 + // clock += "0";
  2078 +
  2079 + // clock += hh + ":";
  2080 + // if (mm < 10) clock += '0';
  2081 + // clock += mm + ":";
  2082 +
  2083 + // if (ss < 10) clock += '0';
  2084 + // clock += ss;
  2085 + return clock;
  2086 + },
  2087 +
  2088 + toast(msg) {
  2089 + wx.showToast({
  2090 + title: msg,
  2091 + icon: 'none',
  2092 + duration: 3000
  2093 + })
  2094 + },
  2095 +
  2096 + go_url(e) {
  2097 + var url = e.currentTarget.dataset.url;
  2098 + getApp().goto(url);
1961 2099 }
1962   -
1963   -
  2100 +
  2101 +
1964 2102 });
1965 2103 \ No newline at end of file
... ...
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  
... ...