Closed
Merge Request #908 · created by 后端研发-苏明海


Dev ladder


From dev_ladder into dev

Closed by 后端研发-苏明海

Changes were not merged into target branch

1 participants





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,35 +357,86 @@ Page({
354 357 }
355 358 }
356 359  
357   - //--判断优惠活动有没有过期--
  360 + //--判断优惠活动有没有过期,--
358 361 else if (item.prom_type == 3) {
359   - var isok = 1;
360   - await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + item.goods_id + "/1", {}).then(res => {
361   - if (res.data.code == 0) {
362   - var r_data = res.data.data;
363   - if (!r_data.promGoodsLists) {
  362 + var isok = 1,is_g_prom=0;
  363 +
  364 + //因为有全场优惠活动,商品参加的活动还未开始
  365 + var url="/api/weshop/activitylist/getGoodActInfo";
  366 + var req_data={
  367 + store_id:os.stoid,goodsidlist:item.goods_id,is_detail:1
  368 + };
  369 + await getApp().request.promiseGet(url, {data:req_data}).then(async function (res) {
  370 + if(res.data.code==0 && res.data.data && res.data.data.length){
  371 + for(let i in res.data.data){
  372 + let item=res.data.data[i];
  373 + if(item.prom_type==3) {
  374 + is_g_prom=1; break;
  375 + }
  376 + }
  377 + }
  378 + })
  379 +
  380 + if(is_g_prom){
  381 + await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + item.goods_id + "/1", {}).then(res => {
  382 + if (res.data.code == 0) {
  383 + var r_data = res.data.data;
  384 + if (!r_data.promGoodsLists) {
  385 + var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
  386 + getApp().request.delete(url, {});
  387 + //商品已经无活动
  388 + isok = 0;
  389 + }else{
  390 + //如果活动的ID不一样,说明原先的活动已经没有参与了或者过期了
  391 + if(item.prom_id!=r_data.promGoodsLists[0].prom_id ){
  392 + var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
  393 + getApp().request.delete(url, {});
  394 + //商品已经下架
  395 + isok = 0;
  396 + }
  397 + }
  398 +
  399 + } else {
364 400 var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
365 401 getApp().request.delete(url, {});
366   - //商品已经无活动
  402 + //商品已经下架
367 403 isok = 0;
368   - }else{
369   - //如果活动的ID不一样,说明原先的活动已经没有参与了或者过期了
370   - if(item.prom_id!=r_data.promGoodsLists[0].prom_id ){
371   - var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
372   - getApp().request.delete(url, {});
373   - //商品已经下架
374   - isok = 0;
375   - }
376   - }
377   -
378   - } else {
379   - var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
380   - getApp().request.delete(url, {});
381   - //商品已经下架
382   - isok = 0;
383   - }
384   - })
  404 + }
  405 + })
  406 +
  407 + }else{
  408 + await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromNormal/" + os.stoid + "/" + item.goods_id, {}).then(res => {
  409 + if (res.data.code == 0) {
  410 + var r_data = res.data.data;
  411 + if (!r_data.promGoodsLists) {
  412 + var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
  413 + getApp().request.delete(url, {});
  414 + //商品已经无活动
  415 + isok = 0;
  416 + }else{
  417 + //如果活动的ID不一样,说明原先的活动已经没有参与了或者过期了
  418 + if(item.prom_id!=r_data.promGoodsLists[0].prom_id ){
  419 + var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
  420 + getApp().request.delete(url, {});
  421 + //商品已经下架
  422 + isok = 0;
  423 + }
  424 + }
  425 +
  426 + } else {
  427 + var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
  428 + getApp().request.delete(url, {});
  429 + //商品已经下架
  430 + isok = 0;
  431 + }
  432 + })
  433 +
  434 + }
  435 +
385 436 if (!isok) continue;
  437 +
  438 +
  439 +
386 440 }
387 441 else if (item.prom_type == 7) {
388 442 if(!th.data.zuhe_map[item.prom_id]){
... ... @@ -470,6 +524,68 @@ Page({
470 524 // continue;
471 525 // }
472 526 }
  527 + else if (item.prom_type == 10) {
  528 + if(!th.data.ladder_map[item.prom_id]){
  529 + //如果有组合购
  530 + var isok = 1;
  531 + var is_flag=1;
  532 + var act=null;
  533 + var url="/api/weshop/prom/ladderForm/getNew/"+os.stoid+"/"+user_id+"/"+item.prom_id;
  534 + await getApp().request.promiseGet(url, {}).then(res => {
  535 + console.log(res,1000);
  536 + if(res.data.code==0 && res.data.data){
  537 + if(res.data.data.isuse!=1){
  538 + isok=0;
  539 + }
  540 + //如果活动已经结束
  541 + if(res.data.data.is_end==1){
  542 + isok=0;
  543 + }
  544 + //已经结束
  545 + if(ut.gettimestamp()>res.data.data.end_time){
  546 + isok=0;
  547 + }
  548 + //还未开始
  549 + if(ut.gettimestamp()<res.data.data.start_time){
  550 + isok=0;
  551 + }
  552 + act=res.data.data;
  553 +
  554 + }else{
  555 + //未找到商品的活动
  556 + is_flag = 0;
  557 + }
  558 + })
  559 + if (!isok){
  560 + var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
  561 + getApp().request.delete(url, {});
  562 + th.data.ladder_map[item.prom_id]=-1;
  563 + continue;
  564 + }
  565 + th.data.ladder_map[item.prom_id]=act;
  566 +
  567 + //-- 获取阶梯规则 --
  568 + var url1 = "/api/weshop/prom/ladderList/list";
  569 + var req_data = {
  570 + store_id: os.stoid,
  571 + form_id: item.prom_id,
  572 + }
  573 + await getApp().request.promiseGet(url1, {
  574 + data: req_data
  575 + }).then(rs1 => {
  576 + if (rs1.data.code==0 && rs1.data.data) {
  577 + var gdlist = rs1.data.data;
  578 + th.data.ladder_map[item.prom_id].ladder_list=gdlist;
  579 + }
  580 + })
  581 + }
  582 + //直接把活动赋值给元素
  583 + if(th.data.ladder_map[item.prom_id] && th.data.ladder_map[item.prom_id]!=-1 ){
  584 + item.act=th.data.ladder_map[item.prom_id];
  585 + }
  586 +
  587 + }
  588 +
473 589 else if(item.prom_type == 0) {
474 590 //如果有优惠活动,要更新活动
475 591 await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + item.goods_id + "/1", {}).then(res => {
... ... @@ -575,9 +691,6 @@ Page({
575 691 }
576 692 }
577 693  
578   - // console.log('AAAAAAAAAAAA', all_num);
579   - // getApp().globalData.cartGoodsNum = all_num;
580   -
581 694 th.setData({
582 695 requestData: arr,
583 696 all_num: all_num,
... ... @@ -948,11 +1061,13 @@ Page({
948 1061 if(item[j].is_gift) continue;
949 1062  
950 1063 var obj=JSON.parse(JSON.stringify(item[j]));
951   - //计算之前先移除
  1064 + //计算之前先移除组合购的计算
952 1065 if(obj.prom_type==7)
953 1066 zh_calc.remove_zhprom(dda,i,obj);
954   -
955   -
  1067 + //计算之前先移除阶梯购的计算
  1068 + if(obj.prom_type==10)
  1069 + ladder_calc.remove_ladder_prom(dda,i,obj);
  1070 +
956 1071 if (fir == 0) {
957 1072 fir = item[j].distr_type;
958 1073 } else {
... ... @@ -965,8 +1080,12 @@ Page({
965 1080 var txt = "requestData[" + i + "].goods[" + j + "].selected";
966 1081  
967 1082 if(e.data.checkAllToggle) obj.goods_num=0;
968   - if(obj.prom_type==7)
969   - zh_calc.add_zhprom(dda,i,obj);
  1083 +
  1084 + //加入组合购计算
  1085 + if(obj.prom_type==7) zh_calc.add_zhprom(dda,i,obj);
  1086 + //加入阶梯促销计算
  1087 + if(obj.prom_type==10) ladder_calc.add_ladder_prom(dda,i,obj);
  1088 +
970 1089  
971 1090 e.setData({
972 1091 [txt]: !e.data.checkAllToggle,
... ... @@ -974,7 +1093,7 @@ Page({
974 1093  
975 1094 if (!e.data.checkAllToggle) {
976 1095 //组合购的金额要另外算
977   - if(item[j].prom_type!=7)
  1096 + if(item[j].prom_type!=7 && item[j].prom_type!=10)
978 1097 tfeel += item[j].goods_num * item[j].goods_price;
979 1098 t_num += item[j].goods_num;
980 1099 }
... ... @@ -1012,6 +1131,12 @@ Page({
1012 1131 offline_price+=zh_calc_res.offline_price;
1013 1132 offline_num+=zh_calc_res.offline_num;
1014 1133  
  1134 + //总的价格,把阶梯促销的商品的价格拿出来
  1135 + var ladder_calc_res=ladder_calc.calculate_ladder(dda,i,this);
  1136 + tfeel+=ladder_calc_res.tfeel;
  1137 + offline_price+=ladder_calc_res.offline_price;
  1138 + offline_num+=ladder_calc_res.offline_num;
  1139 +
1015 1140 //当有线下取价的时候
1016 1141 if(offline_price){
1017 1142 var txt1= "requestData[" + i + "].offline_price";
... ... @@ -1326,7 +1451,10 @@ Page({
1326 1451  
1327 1452 //不管怎么样都要移出去
1328 1453 var obj=JSON.parse(JSON.stringify(item[c]));
  1454 +
1329 1455 zh_calc.remove_zhprom(car,a,obj);
  1456 + ladder_calc.remove_ladder_prom(car,a,obj);
  1457 +
1330 1458 if (item[c].selected == 0) {
1331 1459 ischeck = 0;
1332 1460 is_s_sele = 0;
... ... @@ -1334,11 +1462,20 @@ Page({
1334 1462 obj.goods_num=0;
1335 1463 zh_calc.add_zhprom(car,a,obj);
1336 1464 }
  1465 + if(item[c].prom_type==10) {
  1466 + obj.goods_num=0;
  1467 + ladder_calc.add_ladder_prom(car,a,obj);
  1468 + }
  1469 +
  1470 +
1337 1471 } else {
1338 1472 if(item[c].prom_type==7){
1339   - //先把商品放入组合计算的专用的区域
1340   - zh_calc.add_zhprom(car,a,obj);
1341   - }else{
  1473 + //先把商品放入组合计算的专用的区域
  1474 + zh_calc.add_zhprom(car,a,obj);
  1475 + }else if(item[c].prom_type==10){
  1476 + ladder_calc.add_ladder_prom(car,a,obj);
  1477 + }
  1478 + else{
1342 1479 tfeel += item[c].goods_num * item[c].goods_price;
1343 1480 }
1344 1481 t_num += item[c].goods_num;
... ... @@ -1353,10 +1490,17 @@ Page({
1353 1490  
1354 1491 //总的价格,把组合商品的价格拿出来
1355 1492 var zh_calc_res=zh_calc.calculate_zh(car,a,th);
  1493 + //总的价格,把阶梯促销商品的价格拿出来
  1494 + var ladder_calc_res=ladder_calc.calculate_ladder(car,a,th);
  1495 +
1356 1496 tfeel+=zh_calc_res.tfeel;
1357 1497 offline_price+=zh_calc_res.offline_price;
1358 1498 offline_num+=zh_calc_res.offline_num;
1359 1499  
  1500 + tfeel+=ladder_calc_res.tfeel;
  1501 + offline_price+=ladder_calc_res.offline_price;
  1502 + offline_num+=ladder_calc_res.offline_num;
  1503 +
1360 1504 var txt = "requestData[" + a + "].selected";
1361 1505 th.setData({
1362 1506 [txt]: Number(is_s_sele)
... ... @@ -1409,9 +1553,6 @@ Page({
1409 1553 });
1410 1554 }
1411 1555 }
1412   -
1413   - // getApp().globalData.cartGoodsNum = all_num;
1414   - // console.log('CCCCCCC', all_num, getApp().globalData.cartGoodsNum);
1415 1556  
1416 1557 this.setData({
1417 1558 checkAllToggle: ischeck,
... ... @@ -1423,11 +1564,8 @@ Page({
1423 1564  
1424 1565 //----------------------更新购物数量,加减,调用接口---------------------
1425 1566 postCardList: function(t, item, pitem) {
1426   -
1427 1567 var e = this,th=e;
1428 1568 var user_id = getApp().globalData.user_id;
1429   - // console.log('update');
1430   - // console.log('9995959595959',t);
1431 1569 rq.get("/api/weshop/goods/get/" + oo.stoid + "/" + t.goods_id, {
1432 1570 isShowLoading: 0,
1433 1571 async success(d) {
... ... @@ -1456,12 +1594,9 @@ Page({
1456 1594 th.setData({[txt]:promgoodsbuynum});
1457 1595 }
1458 1596 goodsbuynum = buy_num_data.goodsbuynum;
1459   -
1460   -
1461   - // console.log('goodsbuynum===========', goodsbuynum);
  1597 +
1462 1598 })
1463 1599  
1464   -
1465 1600  
1466 1601 var buyed_mum2 = t.goods_num + goodsbuynum;
1467 1602 if (buyed_mum2 > limit && limit > 0) {
... ...
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({
... ... @@ -1269,6 +1340,7 @@ Page({
1269 1340 var all_coupon_price_m = 0; //所有的订单用户使用优惠券价格
1270 1341 var all_cutprice = 0; //所有的优惠减
1271 1342 var all_zh_cutprice = 0; //所有的组合优惠减
  1343 + var all_ladder_cutprice = 0; //所有的阶梯促销优惠减
1272 1344 var all_order_prom = 0; //所有的订单优惠
1273 1345  
1274 1346 var umoney = th.data.userinfo.user_money - th.data.txmon - (th.data.userinfo.frozen_money ? th.data.userinfo.frozen_money : 0);
... ... @@ -1301,6 +1373,8 @@ Page({
1301 1373 await th.calc_per(c_arr);
1302 1374 //调用函数计算每件组合购商品的单价,
1303 1375 await zh_calc.calc_zh_split_price(c_arr,th);
  1376 + //调用函数计算每件阶梯促销商品的单价,
  1377 + await ladder_calc.calc_split_price(c_arr,th);
1304 1378 //调用函数计算,优惠券优惠什么商品价格,优惠券优惠什么商品
1305 1379 await th.get_cart_quan(c_arr);
1306 1380 //---循环购物车---
... ... @@ -1332,7 +1406,10 @@ Page({
1332 1406 var coupon_price = 0;
1333 1407 var quan_no = null;
1334 1408 var is_has_zh=c_arr[i].is_has_zh;
1335   - var zh_prom_goods=c_arr[i].zh_prom_goods; //组合购计算的原始数据存储空间
  1409 + var is_has_ladder=c_arr[i].is_has_ladder;
  1410 +
  1411 + var zh_prom_goods=c_arr[i].zh_prom_goods; //组合购计算的原始数据存储空间
  1412 + var ladder_prom_goods=c_arr[i].ladder_prom_goods; //组合购计算的原始数据存储空间
1336 1413  
1337 1414 if (th.data.using_quan[pickid] != null && th.data.using_quan[pickid] != undefined)
1338 1415 quan_no = th.data.using_quan[pickid].coupon_no;
... ... @@ -1360,12 +1437,24 @@ Page({
1360 1437  
1361 1438 //--------循环计算总价-----------
1362 1439 for (var j = 0; j < item.length; j++) {
1363   - if(item[j].prom_type!=7){
1364   - o_price_no_zh += item[j].goods_price * item[j].goods_num;
  1440 +
  1441 + var is_no_zh=0;
  1442 + if(item[j].prom_type!=7 && item[j].prom_type!=10 ) is_no_zh=1;
  1443 +
  1444 + //组合购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加
  1445 + if(item[j].prom_type==7 && zh_prom_goods && zh_prom_goods[item[j].prom_id]
  1446 + && zh_prom_goods[item[j].prom_id].act.is_orderyh )
  1447 + {
  1448 + is_no_zh=1;
1365 1449 }
1366 1450 //组合购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加
1367   - else if(zh_prom_goods && zh_prom_goods[item[j].prom_id] && zh_prom_goods[item[j].prom_id].act.is_orderyh )
  1451 + if(item[j].prom_type==10 && ladder_prom_goods && ladder_prom_goods[item[j].prom_id]
  1452 + && th.data.ladder_map[item[j].prom_id].is_useorderyh )
1368 1453 {
  1454 + is_no_zh=1;
  1455 + }
  1456 +
  1457 + if(is_no_zh){
1369 1458 o_price_no_zh += item[j].goods_price * item[j].goods_num;
1370 1459 }
1371 1460 o_price += item[j].goods_price * item[j].goods_num;
... ... @@ -1384,13 +1473,25 @@ Page({
1384 1473 //找到那些可以订单优惠叠加的
1385 1474 for(let ij in zh_prom_goods){
1386 1475 let kitem=zh_prom_goods[ij];
1387   - var is_has_zh=kitem.is_has_zh;
1388 1476 if(kitem.act.is_orderyh)
1389 1477 o_price_no_zh-=kitem.cut_price;
1390 1478 }
1391 1479 }
1392 1480 }
1393 1481  
  1482 + //如果有组合购优惠的钱,就要减价
  1483 + if (c_arr[i].ladder_cut_price>0 || c_arr[i].ladder_cut_price<0){
  1484 + o_price -= c_arr[i].ladder_cut_price;
  1485 + if(o_price_no_zh>0){
  1486 + //找到那些可以订单优惠叠加的
  1487 + for(let ij in ladder_prom_goods){
  1488 + let kitem=ladder_prom_goods[ij];
  1489 + if(th.data.ladder_map[ij].is_useorderyh )
  1490 + o_price_no_zh-=kitem.cut_price;
  1491 + }
  1492 + }
  1493 + }
  1494 +
1394 1495 //-- 计算线下取价的功能 --
1395 1496 if (cart_item.is_offline == 1) {
1396 1497 o_price = o_price - cart_item.offline_price;
... ... @@ -1580,6 +1681,13 @@ Page({
1580 1681 o_condition=o_price_no_zh-quan_price;
1581 1682 }
1582 1683  
  1684 + //看一下是不是不用组合购的订单优惠的叠加
  1685 + if(is_has_ladder){
  1686 + o_condition=o_price_no_zh-quan_price;
  1687 + }
  1688 +
  1689 +
  1690 +
1583 1691 var order_m = 0;
1584 1692 //---判断是不是有订单优惠---
1585 1693 await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
... ... @@ -1663,6 +1771,7 @@ Page({
1663 1771 all_coupon_price_m += parseFloat(cart_item.coupon_price);
1664 1772 all_cutprice += parseFloat(cart_item.cut_price);
1665 1773 all_zh_cutprice += parseFloat(cart_item.zh_cut_price);
  1774 + all_ladder_cutprice += parseFloat(cart_item.ladder_cut_price);
1666 1775 all_order_prom += parseFloat(cart_item.order_prom_amount);
1667 1776 }
1668 1777  
... ... @@ -1676,6 +1785,7 @@ Page({
1676 1785 all_cutprice = all_cutprice.toFixed(2);
1677 1786 all_order_prom = all_order_prom.toFixed(2);
1678 1787 all_zh_cutprice = parseFloat(all_zh_cutprice).toFixed(2);
  1788 + all_ladder_cutprice = parseFloat(all_ladder_cutprice).toFixed(2);
1679 1789  
1680 1790 var atxt = "formData.total_amount";
1681 1791 var atxt1 = "formData.order_amount";
... ... @@ -1686,12 +1796,13 @@ Page({
1686 1796 var atxt6 = "formData.cut_price";
1687 1797 var atxt7 = "formData.order_prom_amount";
1688 1798 var atxt8 = "formData.zh_cut_price";
  1799 + var atxt9 = "formData.ladder_cut_price";
1689 1800  
1690 1801 th.setData({
1691 1802 [atxt]: all_total_m, [atxt1]: all_order_m,
1692 1803 [atxt2]: all_price, [atxt3]: all_user_m, [atxt4]: all_shipping_m,
1693 1804 [atxt5]: all_coupon_price_m, [atxt6]: all_cutprice,
1694   - [atxt7]: all_order_prom, show_submit: 1, [atxt8]: all_zh_cutprice
  1805 + [atxt7]: all_order_prom, show_submit: 1, [atxt8]: all_zh_cutprice, [atxt9]: all_ladder_cutprice
1695 1806 })
1696 1807 th.data.order_prom_list_cart = c_arr;
1697 1808 th.set_can_num();
... ... @@ -2379,13 +2490,22 @@ Page({
2379 2490 //--判断优惠活动的提交--
2380 2491 if (t_item.cut_price > 0) {
2381 2492 order_prom_list.discount_amount += t_item.cut_price;
2382   - order_prom_list.prom_pt_json = JSON.stringify(t_item.prom_pt_json);
2383 2493 }
2384 2494 //--判断组合优惠活动的提交--
2385 2495 if (t_item.zh_cut_price > 0 || t_item.zh_cut_price<0) {
2386 2496 order_prom_list.discount_amount += t_item.zh_cut_price;
2387 2497 order_prom_list.zh_pt_json = JSON.stringify(t_item.zh_pt_json);
2388 2498 }
  2499 +
  2500 + //--判断阶梯优惠活动的提交--
  2501 + if (t_item.ladder_cut_price > 0 || t_item.ladder_cut_price<0) {
  2502 + order_prom_list.discount_amount += t_item.ladder_cut_price;
  2503 + }
  2504 +
  2505 + if(t_item.prom_pt_json){
  2506 + order_prom_list.prom_pt_json = JSON.stringify(t_item.prom_pt_json);
  2507 + }
  2508 +
2389 2509 if (t_item.s_intValue > 0) {
2390 2510 order_prom_list.give_integral = t_item.s_intValue;
2391 2511 }
... ... @@ -2460,6 +2580,7 @@ Page({
2460 2580 switch (g_item.prom_type) {
2461 2581 case 1:
2462 2582 case 2:
  2583 + case 10:
2463 2584 goods.prom_type = g_item.prom_type;
2464 2585 goods.prom_id = g_item.prom_id;
2465 2586 break;
... ... @@ -2524,6 +2645,12 @@ Page({
2524 2645 goods.room_id = g_item.room_id;
2525 2646 room_ids += g_item.room_id + ",";
2526 2647 }
  2648 +
  2649 + //如果有阶梯促销
  2650 + if(g_item.ladder_list_id){
  2651 + goods.ladder_list_id=g_item.ladder_list_id;
  2652 + }
  2653 +
2527 2654 item.order_goods.push(goods);
2528 2655 }
2529 2656  
... ... @@ -3408,6 +3535,7 @@ Page({
3408 3535 get_cart_quan: async function (order_prom_list_cart) {
3409 3536 var th = this;
3410 3537 var is_xz_yh = 1;
  3538 + var user_id=getApp().globalData.user_id;
3411 3539 //等待值的出现
3412 3540 //getApp().waitfor2(this,"g_cart_q_time","order_prom_list_cart",async function () {
3413 3541 //var arr=th.data.order_prom_list_cart;
... ... @@ -3441,7 +3569,19 @@ Page({
3441 3569 }).then(res => {
3442 3570 if (res.data.code == 0) prom1 = res.data.data;
3443 3571 })
3444   - if(!prom1.isQuan){
  3572 + if(prom1 && !prom1.isQuan){
  3573 + continue;
  3574 + }
  3575 + }
  3576 +
  3577 + //--如果是团购,要判断有没有限制使用优惠券
  3578 + if(gd.prom_type == 10){
  3579 + var prom1=null;
  3580 + await getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/"+ os.stoid +"/"+user_id+"/"+ gd.prom_id, {
  3581 + }).then(res => {
  3582 + if (res.data.code == 0) prom1 = res.data.data;
  3583 + })
  3584 + if(prom1 && prom1.isuse && prom1. is_usecoupon){
3445 3585 continue;
3446 3586 }
3447 3587 }
... ...
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
... ... @@ -840,7 +840,7 @@ Page({
840 840  
841 841  
842 842 //获取统一条形码,普通商品和优惠促销的商品
843   - 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) {
  843 + 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 == 10) {
844 844 //默认门店要拿下门店库存
845 845 if (that.data.sales_rules == 2 && that.data.is_newsales_rules) {
846 846 //获取门店
... ... @@ -1056,7 +1056,7 @@ Page({
1056 1056 if (this.data.prom_type == 1 || this.data.prom_type == 2) {
1057 1057 this.getactLen(function (num) {
1058 1058 if (num < th.data.goodsInputNum) {
1059   - getApp().my_warnning("秒杀库存不足!", 0, th);
  1059 + getApp().my_warnning("活动库存不足!", 0, th);
1060 1060 return false;
1061 1061 } else {
1062 1062 th.add_cart_func(t);
... ... @@ -1066,9 +1066,7 @@ Page({
1066 1066 th.add_cart_func(t);
1067 1067 }
1068 1068 },
1069   -
1070   -
1071   -
  1069 +
1072 1070 //-- 加入购物的函数 --
1073 1071 add_cart_func_inte: function (t) {
1074 1072 var i = getApp().request;
... ... @@ -1342,10 +1340,15 @@ Page({
1342 1340 })
1343 1341  
1344 1342 }
1345   - else if (th.data.prom_type == 0 || th.data.prom_type == 3 || th.data.prom_type == 4 || th.data.prom_type == 5) {
  1343 + 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) {
1346 1344 newd.prom_type = 0;
1347 1345 newd.prom_id = 0;
1348 1346  
  1347 + if(th.data.prom_type == 10){
  1348 + newd.prom_type = th.data.prom_type;
  1349 + newd.prom_id = th.data.prom_id;
  1350 + }
  1351 +
1349 1352 //---如果是线下门店销售的时候---
1350 1353 if (th.data.sales_rules == 2) {
1351 1354 var pick = th.get_pick_from_list(th.data.sto_sele_id)
... ... @@ -1438,6 +1441,7 @@ Page({
1438 1441 user_id: oo.user_id,
1439 1442 goods_id: a,
1440 1443 pick_id: e.data.sto_sele_id,
  1444 + state:0
1441 1445 },
1442 1446 success: function (re) {
1443 1447  
... ... @@ -1506,9 +1510,41 @@ Page({
1506 1510 });
1507 1511  
1508 1512 }
1509   - //else "exchange" == t.currentTarget.dataset.action ? this.exchange(d) : this.buyNow(d);
1510 1513 else {
1511 1514  
  1515 + if(newd.prom_type==10){
  1516 + //----先看会员在购物车中是否加入了该商品,立即购买的-----
  1517 + getApp().request.get("/api/weshop/cart/page", {
  1518 + data: {
  1519 + store_id: e.data.stoid,
  1520 + user_id: oo.user_id,
  1521 + state:1
  1522 + },
  1523 + success: function (res) {
  1524 + //-------如果购物车中有相关的数据---------
  1525 + if (res.data.code==0 && res.data.data.total > 0) {
  1526 + for(let j in res.data.data.pageData){
  1527 + let item_j=res.data.data.pageData[j];
  1528 + var url = '/api/weshop/cart/del/' +e.data.stoid+ '/' + item_j.id;
  1529 + getApp().request.delete(url, {});
  1530 + }
  1531 + }
  1532 + newd.state=1;
  1533 + getApp().request.post("/api/weshop/cart/save", {
  1534 + data: newd,
  1535 + success: function (t) {
  1536 + th.closeSpecModal();
  1537 + getApp().goto("/pages/cart/cart2/cart2?state=1");
  1538 + }
  1539 + });
  1540 +
  1541 +
  1542 + }
  1543 + })
  1544 + return false;
  1545 + }
  1546 +
  1547 +
1512 1548 if (th.data.prom_goods) {
1513 1549 var prom_d = th.data.prom_goods;
1514 1550 for (var i in prom_d) {
... ... @@ -1803,39 +1839,43 @@ Page({
1803 1839 });
1804 1840 },
1805 1841  
1806   - openSpecModel: function (t) {
1807   - var th = this;
1808   - var open_store = t.currentTarget.dataset.ind;
1809   - this.setData({
1810   - store: 0,
1811   - choice_sort_store: 0,
1812   - sort_store: 0,
1813   - open_ind_store: open_store,
1814   - })
1815   - //--先判断会员状态--
1816   - var user_info = getApp().globalData.userInfo;
1817   - if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
1818   - wx.navigateTo({
1819   - url: '/pages/togoin/togoin',
1820   - })
1821   - return false;
1822   - }
1823   -
1824   - if(th.data.more_flash && open_store==1){
1825   - th.setData({is_pop_more:1});
1826   - }else{
1827   - var ind = t.currentTarget.dataset.ind;
1828   - //回调。判断是不是优惠促销
1829   - th.check_is_prom_goods(function () {
1830   - th.setData({
1831   - openSpecModal: !0,
1832   - openSpecModal_ind: ind,
1833   - });
1834   - //var is_open=th.data.config
1835   - th.get_off_price();
  1842 + openSpecModel: function (t) {
  1843 + var th = this;
  1844 + var open_store = t.currentTarget.dataset.ind;
  1845 + this.setData({
  1846 + store: 0,
  1847 + choice_sort_store: 0,
  1848 + sort_store: 0,
  1849 + open_ind_store: open_store,
1836 1850 })
1837   - }
1838   - },
  1851 + //--先判断会员状态--
  1852 + var user_info = getApp().globalData.userInfo;
  1853 + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
  1854 + wx.navigateTo({
  1855 + url: '/pages/togoin/togoin',
  1856 + })
  1857 + return false;
  1858 + }
  1859 + var is_go_next = 1;
  1860 + if (th.data.more_flash && th.data.more_flash.length > 1 && open_store == 1) {
  1861 + is_go_next = 0;
  1862 + }
  1863 + if (is_go_next) {
  1864 + var ind = t.currentTarget.dataset.ind;
  1865 + //回调。判断是不是优惠促销
  1866 + th.check_is_prom_goods(function () {
  1867 + th.setData({
  1868 + openSpecModal: !0,
  1869 + openSpecModal_ind: ind,
  1870 + });
  1871 + //var is_open=th.data.config
  1872 + th.get_off_price();
  1873 + })
  1874 + } else {
  1875 + th.setData({is_pop_more: 1});
  1876 +
  1877 + }
  1878 + },
1839 1879  
1840 1880 open_next(){
1841 1881 var th=this;
... ... @@ -2996,7 +3036,7 @@ Page({
2996 3036 var user_id=getApp().globalData.user_id;
2997 3037 if(!user_id) user_id=0;
2998 3038  
2999   - if (prom_type == 3 || prom_type == 0 || prom_type == 5 || prom_type == 7) {
  3039 + if (prom_type == 3 || prom_type == 0 || prom_type == 5 || prom_type == 7 || prom_type == 10) {
3000 3040 this.setData({
3001 3041 prom_type: 0,isshow: 1,
3002 3042 });
... ... @@ -3100,6 +3140,7 @@ Page({
3100 3140  
3101 3141  
3102 3142 }
  3143 +
3103 3144 if (prom_type == 1 && prom_id==0){
3104 3145 this.setData({
3105 3146 prom_type: 0,isshow: 1,
... ... @@ -5657,6 +5698,8 @@ Page({
5657 5698 //---检查有没有优惠活动---
5658 5699 check_is_youhui: function (gid, is_nor) {
5659 5700 var th = this;
  5701 + var user_id=getApp().globalData.user_id;
  5702 + if(!user_id) user_id=0;
5660 5703 //如果是普通购买的时候,要进行调用
5661 5704 if (is_nor) {
5662 5705 getApp().request.get("/api/weshop/goods/getGoodsPromNormal/" + os.stoid + "/" + gid, {
... ... @@ -5676,7 +5719,7 @@ Page({
5676 5719 getApp().request.get("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + gid + "/0", {
5677 5720 success: function (res) {
5678 5721 console.log(res);
5679   - if (res.data.code == 0) {
  5722 + if (res.data.code == 0 && res.data.data) {
5680 5723 var r_data = res.data.data;
5681 5724 var max = 0, min = 0;
5682 5725 if (r_data.collocationList) {
... ... @@ -5690,6 +5733,32 @@ Page({
5690 5733 r_data.collocationPromList.max = (max + th.data.data.shop_price).toFixed(2);
5691 5734 r_data.collocationPromList.min = (min + th.data.data.shop_price).toFixed(2);
5692 5735 }
  5736 +
  5737 + if(r_data.ladderLists){
  5738 + var act_id=r_data.ladderLists[0].form_id;
  5739 + //-- 判断会员能不能参与阶梯促销 --
  5740 + getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid+"/"+user_id + "/"+act_id, {
  5741 + }).then(res=>{
  5742 + if(res.data.code==0 && res.data.data){
  5743 + var prom_content="";
  5744 + for(let jj in r_data.ladderLists){
  5745 + if(r_data.ladderLists[jj].discount==10){
  5746 + prom_content+="第"+(parseInt(jj)+1)+"件原价,";
  5747 + }else{
  5748 + prom_content+="第"+(parseInt(jj)+1)+"件"+r_data.ladderLists[jj].discount+"折,";
  5749 + }
  5750 + }
  5751 + prom_content=ut.sub_last(prom_content);
  5752 + th.data.prom_type=10;
  5753 + th.data.prom_id=act_id;
  5754 + th.setData({
  5755 + jieti_prom:prom_content,
  5756 + ladder_act_id:act_id
  5757 + })
  5758 + }
  5759 + })
  5760 + }
  5761 +
5693 5762 th.setData({
5694 5763 order_prom: r_data.promOrder,
5695 5764 collocationGoods: r_data.collocationPromList,
... ... @@ -5698,11 +5767,8 @@ Page({
5698 5767 th.is_show_more_buy();
5699 5768 }
5700 5769 }
5701   -
5702 5770 })
5703 5771 }
5704   -
5705   -
5706 5772 },
5707 5773  
5708 5774 closePoster() {
... ... @@ -6018,13 +6084,31 @@ Page({
6018 6084 check_has_flash:function () {
6019 6085 var th=this;
6020 6086 var url="/api/weshop/activitylist/getGoodActInfo";
  6087 + var user_id=getApp().globalData.user_id;
  6088 + if(!user_id) user_id=0;
  6089 +
6021 6090 var req_data={
6022   - store_id:os.stoid,goodsidlist:this.data.data.goods_id,is_detail:1
  6091 + store_id:os.stoid,goodsidlist:this.data.data.goods_id,is_detail:1,user_id:user_id
6023 6092 };
6024 6093 //获取秒杀的多规格
6025   - getApp().request.promiseGet(url, {data:req_data}).then(res=>{
  6094 + getApp().request.promiseGet(url, {data:req_data}).then(async function (res) {
6026 6095 if(res.data.code==0 && res.data.data && res.data.data.length){
6027   - th.setData({more_flash:res.data.data});
  6096 + var arr_data=res.data.data;
  6097 + var new_arr=[];
  6098 + for(let i in arr_data){
  6099 + let item=arr_data[i];
  6100 + //找不到活动要剔除
  6101 + if(!item.act_name) continue;
  6102 + if(item.prom_type!=1) continue;
  6103 + new_arr.push(item);
  6104 + }
  6105 +
  6106 + if(new_arr.length==1){
  6107 + th.data.prom_id=new_arr[0].act_id;
  6108 + th.data.prom_type=new_arr[0].prom_type;
  6109 + }
  6110 +
  6111 + th.setData({more_flash:new_arr});
6028 6112 }
6029 6113 })
6030 6114 },
... ... @@ -6049,9 +6133,12 @@ Page({
6049 6133 corpId: id,
6050 6134 success(res) {}
6051 6135 })
6052   - }
6053   -
  6136 + },
6054 6137  
  6138 + go_more_ladder:function (e) {
  6139 + var prom_id=e.currentTarget.dataset.id;
  6140 + getApp().goto("/pages/goods/goodsList/goodsList?ladder_id="+prom_id);
  6141 + }
6055 6142  
6056 6143  
6057 6144 });
... ...
pages/goods/goodsInfo/goodsInfo.wxml
... ... @@ -614,6 +614,24 @@
614 614 </view>
615 615 </block>
616 616  
  617 + <block wx:if="{{jieti_prom}}">
  618 + <view class="cx-frame flex jc_sb" bindtap="go_more_ladder" data-id="{{ladder_act_id}}"
  619 + style="position: relative; height: auto">
  620 + <view class="flex" style="width: 92%">
  621 + <view class="cx-sizs fs30" style="width: 90rpx;flex-shrink: 0">阶梯促</view>
  622 + <!-- 中间显示层 -->
  623 + <view class="ellipsis-1 fs24">
  624 + <text class="jie_show fs22">阶</text>
  625 + {{jieti_prom}}
  626 + </view>
  627 + </view>
  628 + <view data-coupon="1" bindtap="show_more_cx" class="cx-obtain-coupon wsize">
  629 + <text class="bg_jj" style="position: relative;right: 3rpx"></text>
  630 + </view>
  631 + </view>
  632 + </block>
  633 +
  634 +
617 635 <!-- 要判断是不是有订单优惠 -->
618 636 <block wx:if="{{order_prom}}">
619 637 <view class="cx-frame flex" style="position: relative; height: auto">
... ... @@ -654,26 +672,30 @@
654 672 <!-- 判断是不是有秒杀 -->
655 673 <block wx:if="{{more_flash}}">
656 674  
657   - <block wx:for="{{more_flash}}">
658   -
659   - <view class="cx-frame flex" style="position: relative; height: auto" wx:if="{{item.prom_type==1}}" >
660   - <view class="cx-sizs wsize" style="width: 144rpx">秒杀</view>
661   - <!-- 中间显示层 -->
662   - <view class="flex ai-center jc_sb" style="width: 570rpx" bindtap="go_more_flash" data-id="{{item.act_id}}">
663   - <view class="flex">
664   - <view class="miao_lab">秒</view>
665   - <view class="order_hui">
666   - <view class="fs28 ellipsis-1">{{item.act_name}}</view>
667   - <view class="fs26">
668   - (活动时间:{{tool.format_tt(item.s_time)}} - {{tool.format_tt(item.e_time)}})
  675 + <block wx:for="{{more_flash}}">
  676 + <view class="cx-frame flex" style="position: relative; height: auto" wx:if="{{item.prom_type==1}}">
  677 + <view class="cx-sizs wsize" style="width: 144rpx">秒杀</view>
  678 + <!-- 中间显示层 -->
  679 + <view class="flex ai-center jc_sb" style="width: 570rpx" bindtap="go_more_flash"
  680 + data-id="{{item.act_id}}">
  681 + <view class="flex">
  682 + <view class="miao_lab">秒</view>
  683 + <view class="order_hui">
  684 + <view class="fs28 ellipsis-1">{{item.act_name}}</view>
  685 + <view class="fs26">
  686 + (活动时间:{{tool.format_tt(item.s_time)}} - {{tool.format_tt(item.e_time)}})
  687 + </view>
669 688 </view>
670 689 </view>
  690 + <view>
  691 + <text class="bg_jj is_more_cx" style="position: relative;top:-10rpx"></text>
  692 + </view>
671 693 </view>
672   - <view><text class="bg_jj is_more_cx" style="position: relative;top:-10rpx"></text></view>
673 694 </view>
674   - </view>
675 695 </block>
676 696 </block>
  697 +
  698 + <!-- 保障服务 -->
677 699 <view class="bz_view flex bdt16" wx:if="{{bconfig}}" style="">
678 700 <image class="bzfu_img" src="{{iurl}}/miniapp/images/bzfu_w.png"></image>
679 701 <view class="flex f1 ai_c rel">
... ... @@ -681,8 +703,6 @@
681 703 <view bindtap="clickCollapse" class="cx-obtain-coupon wsize arrow">
682 704 <text class="bg_jj {{flag?'down1':''}}"></text>
683 705 </view>
684   - <!-- <text class="bg_jj" bindtap="clickCollapse"></text> -->
685   - <!-- <text class="iconfont icon-shuangjiantouxia c-db"></text> -->
686 706 </view>
687 707 </view>
688 708 <!-- - 搭配促销 -- -->
... ...
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
... ... @@ -67,8 +67,12 @@ Page({
67 67  
68 68 if (0 != t.is_new && t.is_new != undefined) { url += "&is_new=" + t.is_new; }
69 69 if (0 != t.is_hot && t.is_hot != undefined) { url += "&is_hot=" + t.is_hot; }
70   -
71   -
  70 + if (0 != t.ladder_id && t.ladder_id != undefined) { url += "&ladder_id=" + t.ladder_id; }
  71 +
  72 + var user_id=getApp().globalData.user_id;
  73 + if(!user_id) user_id=0;
  74 + url += "&user_id="+user_id;
  75 +
72 76 // 优惠促销列表
73 77 if(t.prom_goods_id) {
74 78 url += '&prom_goods_id=' + t.prom_goods_id;
... ... @@ -94,6 +98,34 @@ Page({
94 98 }
95 99 })
96 100 }
  101 +
  102 + //--- 阶梯优惠活动的凑单 ---
  103 + if(t.ladder_id){
  104 + var user_id=getApp().globalData.user_id;
  105 + if(!user_id) user_id=0;
  106 + getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/"+oo.stoid+"/"+user_id+"/"+t.ladder_id,{
  107 + }).then(res=>{
  108 + if(res.data.code==0 && res.data.data){
  109 + var arr= res.data.data;
  110 + var url1="/api/weshop/prom/ladderList/list?store_id="+oo.stoid+"&form_id="+arr.id;
  111 + getApp().request.promiseGet(url1, {}).then(rs=>{
  112 + if(rs.data.code==0 && rs.data.data && rs.data.data.length) {
  113 + var prom_content="";
  114 + for(let jj in rs.data.data){
  115 + if(rs.data.data[jj].discount==10){
  116 + prom_content+="第"+(parseInt(jj)+1)+"件原价,";
  117 + }else{
  118 + prom_content+="第"+(parseInt(jj)+1)+"件"+rs.data.data[jj].discount+"折,";
  119 + }
  120 + }
  121 + prom_content=ut.sub_last(prom_content);
  122 + th.setData({jieti_prom:prom_content})
  123 + }
  124 + })
  125 + }
  126 + })
  127 + }
  128 +
97 129 this.requestGoodsList(url);
98 130 getApp().getConfig2(function(rs){
99 131 //计算等级价相关
... ...
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,22 +200,23 @@ 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 }
198 213 //------------对比一下有没有退款记录------------
199 214 await getApp().request.promiseGet("/api/weshop/order/returngoods/page", {
200 215 data: {
201   - order_id: item.order_id, store_id: os.stoid,
202   - user_id: oo.user_id, pageSize: 20
  216 + order_id: item.order_id,
  217 + store_id: os.stoid,
  218 + user_id: oo.user_id,
  219 + pageSize: 20
203 220 }
204 221 }).then(rs => {
205 222 var ttd = rs;
... ... @@ -222,8 +239,8 @@ Page({
222 239 });
223 240 } else {
224 241 //--------整单退--------
225   - if (ttd.data.data.pageData[0]['goods_id_list'] != null
226   - && ttd.data.data.pageData[0]['goods_id_list'] != '') {
  242 + if (ttd.data.data.pageData[0]['goods_id_list'] != null &&
  243 + ttd.data.data.pageData[0]['goods_id_list'] != '') {
227 244 var eea = ttd.data.data.pageData[0];
228 245 //1.退款正在进行中,
229 246 //2.退款被拒绝就要显示可以退款
... ... @@ -262,16 +279,16 @@ Page({
262 279 if (eea.goods_id == eeb.goods_id) {
263 280 switch (eea.status) {
264 281 case 0:
265   - case 1://退款处理中
  282 + case 1: //退款处理中
266 283 data[ind]['has_rt'] = 1; //有部分退
267 284 goodslist[iii]['return_btn'] = 2;
268 285 break;
269   - case 2://退款完成
  286 + case 2: //退款完成
270 287 data[ind]['has_rt'] = 1; //有部分退
271 288 goodslist[iii]['return_btn'] = 4;
272 289 rt_ok_num++;
273 290 break;
274   - case 3://已拒绝,重新退款
  291 + case 3: //已拒绝,重新退款
275 292 goodslist[iii]['return_btn'] = 3;
276 293 break;
277 294 default:
... ... @@ -300,166 +317,175 @@ Page({
300 317 });
301 318 data[ind]['g_num'] = g_num;
302 319 })
303   - th.setData({orderList: data,});
  320 + th.setData({
  321 + orderList: data,
  322 + });
304 323  
305 324 });
306   - e.data.currentPage++ ,
  325 + e.data.currentPage++,
307 326 wx.stopPullDownRefresh();
308   - }, null, {store_id: os.stoid, user_id: oo.user_id});
  327 + }, null, {
  328 + store_id: os.stoid,
  329 + user_id: oo.user_id
  330 + });
309 331 },
310   - //滑倒底部
311   - onReachBottom: function() {
312   - if(this.data.currentIndex == 0) {
313   - if (s.data.goodsLoadFinishFlag) {
314   - this.setData({
315   - iscodeall: 1
316   - })
317   - }
318   - s.canloadMore() && this.requestOrderList(this.data.activeCategoryId);
319   - } else {
320   - this.request_list({
321   - store_id: os.stoid,
322   - user_id: oo.user_id,
323   - page: this.data.currentPage2,
324   - });
325   - }
326   - },
327   - onPullDownRefresh: function(t) {
328   - // sty取消
329   - // this.resetData(), this.requestOrderList(this.data.activeCategoryId);
330   - },
331   -
332   - /*-----------取消订单-----------*/
333   - cancelOrder: function(t) {
334   - var e = this,
335   - a = t.currentTarget.dataset.id,
336   - th = this;
337   - var is_zsorder = parseFloat(t.currentTarget.dataset.zsorder);
338   - var index = t.currentTarget.dataset.orderindex;
339   - var order = th.data.orderList[index];
340   - var is_skill = 0;
341   - var order_goods = order.order_goods;
342   - //--判断是不是秒杀--
343   - order_goods.forEach(function(val, ind) {
344   - if (val.prom_type == 1) {
345   - is_skill = 1;
346   - return false;
347   - }
348   - })
349   -
350   - wx.showModal({
351   - title: "是否取消订单?",
352   - success: function(t) {
353   - //如果是秒杀和拼单的商品,取消订单要返回redis,并取消订单
354   - if (t.confirm) {
355   - //if(is_skill==1 || is_zsorder>=2){
356   - getApp().request.post("/api/weshop/order/cancelOrder/"+os.stoid+"/"+a+"/"+getApp().globalData.user_id, {
357   - data: {},
358   - success: function(t) {
359   - if (t.data.code == 0) {
360   - 0 == e.data.activeCategoryId ?
361   - (e.resetData(), e.requestOrderList(e.data.activeCategoryId)) : e.deleteOrderData2(a);
362   - } else {
363   - getApp().confirmBox(e.data.msg);
364   - }
365   - },
366   - })
  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 + })
  389 + }
  390 + }
  391 + });
  392 + },
  393 +
  394 + /*-----------确认收货-----------*/
  395 + confirmOrder: function (t) {
  396 + var e = this,
  397 + a = t.currentTarget.dataset.id;
  398 + var is_zsorder = t.currentTarget.dataset.zsorder;
  399 + var th = this;
  400 +
  401 + wx.showModal({
  402 + title: "是否确认收货?",
  403 + success: function (t) {
  404 + t.confirm && rq.post("/api/weshop/order/confirmOrder/" + os.stoid + "/" + a + "/" + getApp().globalData.user_id, {
  405 + success: function (e) {
  406 + if (e.data.code == 0) {
  407 + th.deleteOrderData2(a);
  408 + getApp().confirmBox("确认收货成功!");
  409 + }
  410 + }
  411 + })
  412 + }
  413 + });
  414 + },
  415 +
  416 + //-----删除订单-----
  417 + deleteOrderData: function (t) {
  418 + var th = this;
  419 + var order_id = t.currentTarget.dataset.order_id;
  420 + var index = t.currentTarget.dataset.index;
  421 + var up_data = {
  422 + order_id: order_id,
  423 + isdel: 1
  424 + };
  425 + var order = th.data.orderList[index];
  426 + if (order.order_status != 6) {
  427 + up_data.order_status = 5;
367 428 }
368   - }
369   - });
370   - },
371   -
372   - /*-----------确认收货-----------*/
373   - confirmOrder: function(t) {
374   - var e = this,a = t.currentTarget.dataset.id;
375   - var is_zsorder = t.currentTarget.dataset.zsorder;
376   - var th = this;
377   -
378   - wx.showModal({
379   - title: "是否确认收货?",
380   - success: function(t) {
381   - t.confirm && rq.post("/api/weshop/order/confirmOrder/"+os.stoid+"/"+a+"/"+getApp().globalData.user_id,{
382   - success:function (e) {
383   - if(e.data.code==0){
384   - th.deleteOrderData2(a);
385   - getApp().confirmBox( "确认收货成功!");
386   - }
  429 + wx.showModal({
  430 + title: "是否删除订单?",
  431 + success: function (tt) {
  432 + tt.confirm && rq.put("/api/weshop/order/updatebyId", {
  433 + data: up_data,
  434 + success: function (t) {
  435 + for (var e = 0; e < th.data.orderList.length; e++)
  436 + if (th.data.orderList[e].order_id == order_id) {
  437 + th.data.orderList.splice(e, 1), th.setData({
  438 + orderList: th.data.orderList
  439 + });
  440 + break;
  441 + }
  442 + }
  443 + })
387 444 }
388   - })
389   - }
390   - });
391   - },
392   -
393   - //-----删除订单-----
394   - deleteOrderData: function(t) {
395   - var th = this;
396   - var order_id = t.currentTarget.dataset.order_id;
397   - var index = t.currentTarget.dataset.index;
398   - var up_data={order_id: order_id,isdel:1};
399   - var order=th.data.orderList[index];
400   - if(order.order_status!=6){
401   - up_data.order_status=5;
402   - }
403   - wx.showModal({
404   - title: "是否删除订单?",
405   - success: function(tt) {
406   - tt.confirm && rq.put("/api/weshop/order/updatebyId", {
407   - data: up_data,
408   - success: function(t) {
409   - for (var e = 0; e < th.data.orderList.length; e++)
410   - if (th.data.orderList[e].order_id == order_id) {
  445 + });
  446 + },
  447 +
  448 + deleteOrderData2: function (order_id) {
  449 + var th = this;
  450 + for (var e = 0; e < th.data.orderList.length; e++)
  451 + if (th.data.orderList[e].order_id == order_id) {
411 452 th.data.orderList.splice(e, 1), th.setData({
412   - orderList: th.data.orderList
  453 + orderList: this.data.orderList
413 454 });
414 455 break;
415   - }
416   - }
417   - })
418   - }
419   - });
420   - },
421   -
422   - deleteOrderData2: function(order_id) {
423   - var th = this;
424   - for (var e = 0; e < th.data.orderList.length; e++)
425   - if (th.data.orderList[e].order_id == order_id) {
426   - th.data.orderList.splice(e, 1), th.setData({
427   - orderList: this.data.orderList
428   - });
429   - break;
430   - }
431   - },
432   -
433   - //---判断是不是有退款-----
434   - checkReturnGoodsStatus: function(t) {
435   - var e = t.currentTarget.dataset.recid;
436   - var oid = t.currentTarget.dataset.oid;
437   - r.get("/api/weshop/order/returngoods/page", {
438   - data: {
439   - goods_id: e,
440   - order_id: oid,
441   - store_id: os.stoid
442   - },
443   - success: function(t) {
444   - if (t.data.code == 0) {
445   - var r = t.data.data.total;
446   - if (0 == r) return wx.navigateTo({
447   - url: "/pages/user/return_goods/return_goods?rec_id=" + e + "&order_id=" + oid,
448   - });
449   - //--如果拒绝,就重新申请退款--
450   - if (t.data.data.pageData[0].status == 3) {
451   - return wx.navigateTo({
452   - url: "/pages/user/return_goods/return_goods?rec_id=" + e + "&order_id=" + oid,
453   - });
454   - }
  456 + }
  457 + },
455 458  
456   - wx.navigateTo({
457   - url: "/pages/user/return_goods_info/return_goods_info?id=" + r
458   - });
459   - }
460   - }
461   - });
462   - },
  459 + //---判断是不是有退款-----
  460 + checkReturnGoodsStatus: function (t) {
  461 + var e = t.currentTarget.dataset.recid;
  462 + var oid = t.currentTarget.dataset.oid;
  463 + r.get("/api/weshop/order/returngoods/page", {
  464 + data: {
  465 + goods_id: e,
  466 + order_id: oid,
  467 + store_id: os.stoid
  468 + },
  469 + success: function (t) {
  470 + if (t.data.code == 0) {
  471 + var r = t.data.data.total;
  472 + if (0 == r) return wx.navigateTo({
  473 + url: "/pages/user/return_goods/return_goods?rec_id=" + e + "&order_id=" + oid,
  474 + });
  475 + //--如果拒绝,就重新申请退款--
  476 + if (t.data.data.pageData[0].status == 3) {
  477 + return wx.navigateTo({
  478 + url: "/pages/user/return_goods/return_goods?rec_id=" + e + "&order_id=" + oid,
  479 + });
  480 + }
  481 +
  482 + wx.navigateTo({
  483 + url: "/pages/user/return_goods_info/return_goods_info?id=" + r
  484 + });
  485 + }
  486 + }
  487 + });
  488 + },
463 489 /*----------跳转支付-----------*/
464 490 async jumpToCart4(t) {
465 491 var o_index = t.currentTarget.dataset.idx;
... ... @@ -467,7 +493,7 @@ Page({
467 493 var th = this;
468 494 var order = e;
469 495 var order_goods = e.order_goods;
470   - var user_id=getApp().globalData.userInfo.user_id;
  496 + var user_id = getApp().globalData.userInfo.user_id;
471 497  
472 498 var wlist = "";
473 499 for (var i in order_goods) {
... ... @@ -480,9 +506,13 @@ Page({
480 506 });
481 507 return false;
482 508 }
483   -
  509 +
484 510 //要每件每件的商品进行检查,看有么有超出库存,超出限购
485   - var good = order_goods[i], goodsbuynum = 0, promgoodsbuynum = 0, gg = null,presellList=null;
  511 + var good = order_goods[i],
  512 + goodsbuynum = 0,
  513 + promgoodsbuynum = 0,
  514 + gg = null,
  515 + presellList = null;
486 516  
487 517 //获取单品的现在的活动状态
488 518 await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + good.goods_id, {}).then(res => {
... ... @@ -577,16 +607,21 @@ Page({
577 607 }
578 608  
579 609 //如果是预售的时候,
580   - if(good.prom_type==8){
581   - await getApp().request.promiseGet("/api/weshop/order/orderPresell/countBuyGoodsSum",{
582   - data: {store_id: os.stoid, user_id: user_id, goods_id: good.goods_id, prom_id: good.prom_id},
583   - }).then(e=>{
  610 + if (good.prom_type == 8) {
  611 + await getApp().request.promiseGet("/api/weshop/order/orderPresell/countBuyGoodsSum", {
  612 + data: {
  613 + store_id: os.stoid,
  614 + user_id: user_id,
  615 + goods_id: good.goods_id,
  616 + prom_id: good.prom_id
  617 + },
  618 + }).then(e => {
584 619 if (e.data.code == 0) {
585   - promgoodsbuynum=e.data.data.sumgoodsnum;
  620 + promgoodsbuynum = e.data.data.sumgoodsnum;
586 621 }
587 622 })
588 623  
589   - var presell_id =good.prom_id;
  624 + var presell_id = good.prom_id;
590 625 var url = "/api/weshop/marketing/marketingPresellList/list"
591 626 var rd = {
592 627 store_id: os.stoid,
... ... @@ -599,13 +634,13 @@ Page({
599 634 }).then(res => {
600 635 if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
601 636 var arr = res.data.data[0];
602   - presellList=arr
  637 + presellList = arr
603 638 }
604 639 })
605 640  
606   - if(presellList){
  641 + if (presellList) {
607 642  
608   - if(good.goods_num>presellList.presell_sumqty-presellList.buy_goodnum){
  643 + if (good.goods_num > presellList.presell_sumqty - presellList.buy_goodnum) {
609 644 var content = good.goods_name + '购买数量超出商品库存,请取消订单';
610 645 th.toast(content);
611 646 return false;
... ... @@ -652,39 +687,39 @@ Page({
652 687 }
653 688  
654 689 //商品的普通购买 ,不要进行判断
655   - if ((good.prom_type == 1 || good.prom_type == 2 || good.prom_type == 6 || good.prom_type == 4 || good.prom_type == 8)
656   - && !good.is_gift && !good.is_collocation && !good.is_integral_normal && !good.is_pd_normal) {
657   - if (gg.prom_type != good.prom_type && gg.prom_type>0) {
  690 + if ((good.prom_type == 1 || good.prom_type == 2 || good.prom_type == 6 || good.prom_type == 4 || good.prom_type == 8) &&
  691 + !good.is_gift && !good.is_collocation && !good.is_integral_normal && !good.is_pd_normal) {
  692 + if (gg.prom_type != good.prom_type && gg.prom_type > 0) {
658 693 var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买';
659 694 th.toast(content);
660 695 return false;
661 696 }
662 697  
663 698 } else {
664   - 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)
665   - && !good.is_collocation && !good.is_gift && !good.is_integral_normal && !good.is_pd_normal) {
666   - var prom = null;
  699 + 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) &&
  700 + !good.is_collocation && !good.is_gift && !good.is_integral_normal && !good.is_pd_normal) {
667 701 //---如果是活动的时候---
668   - var prom = null, th = this;
  702 + var prom = null,
  703 + th = this;
669 704 if (gg.prom_type == 1) {
670   - await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/"+ user_id + "/" + gg.prom_id, {}).then(res => {
  705 + await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + gg.prom_id, {}).then(res => {
  706 + if (res.data.code == 0) {
  707 + prom = res.data.data;
  708 + prom.price = prom.user_price;
  709 + }
  710 + })
  711 + }
  712 +
  713 + if (gg.prom_type == 2) {
  714 + await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + gg.goods_id + "/" + gg.prom_id, {}).then(res => {
671 715 if (res.data.code == 0) {
672 716 prom = res.data.data;
673   - prom.price=prom.user_price;
  717 + prom.price = prom.price;
674 718 }
675 719 })
676 720 }
677   -
678   - if (gg.prom_type == 2) {
679   - await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/"+ gg.goods_id + "/" + gg.prom_id, {}).then(res => {
680   - if (res.data.code == 0) {
681   - prom = res.data.data;
682   - prom.price=prom.price;
683   - }
684   - })
685   - }
686   -
687   -
  721 +
  722 +
688 723 if (gg.prom_type == 6) {
689 724 await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + gg.prom_id, {}).then(res => {
690 725 if (res.data.code == 0) {
... ... @@ -695,25 +730,34 @@ Page({
695 730  
696 731 if (gg.prom_type == 4) {
697 732 await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1", {
698   - data: {store_id: os.stoid, goods_id: gg.goods_id}
  733 + data: {
  734 + store_id: os.stoid,
  735 + goods_id: gg.goods_id
  736 + }
699 737 }).then(res => {
700 738 if (res.data.code == 0 && res.data.data && res.data.data.pageData) {
701 739 prom = res.data.data.pageData[0];
702 740 }
703 741 })
704 742 }
  743 + if (gg.prom_type == 10) {
  744 + var url = `/api/weshop/prom/ladderForm/getNew/${os.stoid}/${user_id}/${gg.prom_id}`;
  745 + await getApp().request.promiseGet(url, {}).then(res => {
  746 + if (res.data.code == 0 && res.data.data && !res.data.data.isuse || res.data.data.is_end == 1) {
  747 + prom = res.data.data;
  748 + }
  749 + })
  750 + }
705 751  
706 752 if (prom) {
707 753 var t_now = ut.gettimestamp();
708 754 if (prom.is_end == 0 && prom.start_time < t_now && prom.end_time > t_now) {
709   -
710 755 var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买';
711 756 th.toast(content);
712 757 return false;
713 758 }
714 759 }
715   - }
716   - else {
  760 + } else {
717 761 if (!good.is_gift && good.prom_type != 3) {
718 762 var t_ok = 1;
719 763 await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + good.goods_id + "/0", {}).then(res => {
... ... @@ -723,6 +767,7 @@ Page({
723 767 if (r_data.promGoodsLists) {
724 768 var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买';
725 769 th.toast(content);
  770 + console.log(3);
726 771 t_ok = 0;
727 772 }
728 773 }
... ... @@ -740,7 +785,7 @@ Page({
740 785 if (!good.is_gift && !good.is_collocation) {
741 786 if (card_field && gg[card_field] > 0) {
742 787 if (good.goods_price != gg[card_field] && good.offline_cut <= 0) isok = 0;
743   - if (good.goods_price > gg[card_field] && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过
  788 + if (good.goods_price > gg[card_field] && good.offline_cut > 0) isok = 0; //如果线下价格比较贵,则不通过
744 789  
745 790 } else {
746 791 if (good.goods_price != gg.shop_price && good.offline_cut <= 0) isok = 0;
... ... @@ -751,6 +796,7 @@ Page({
751 796  
752 797 var content = gg.goods_name + '商品的价格发生了变化,请取消订单重新购买1'
753 798 th.toast(content);
  799 + console.log(4);
754 800 return false;
755 801 }
756 802 }
... ... @@ -780,26 +826,28 @@ Page({
780 826 }
781 827  
782 828 //---如果是活动的时候---
783   - var prom = null, goodsinfo = good, th = this;
  829 + var prom = null,
  830 + goodsinfo = good,
  831 + th = this;
784 832 if (goodsinfo.prom_type == 1) {
785   - await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/"+ user_id + "/" + goodsinfo.prom_id, {}).then(res => {
  833 + await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + os.stoid + "/" + user_id + "/" + goodsinfo.prom_id, {}).then(res => {
786 834 if (res.data.code == 0) {
787 835 prom = res.data.data;
788   - prom.price=prom.user_price;
  836 + prom.price = prom.user_price;
789 837 }
790 838 })
791 839 }
792   -
793   - if (goodsinfo.prom_type == 2) {
794   - await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/"+ good.goods_id + "/" + goodsinfo.prom_id, {}).then(res => {
795   - if (res.data.code == 0) {
796   - prom = res.data.data;
797   - prom.price=prom.price;
798   - }
799   - })
800   - }
801   -
802   -
  840 +
  841 + if (goodsinfo.prom_type == 2) {
  842 + await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + good.goods_id + "/" + goodsinfo.prom_id, {}).then(res => {
  843 + if (res.data.code == 0) {
  844 + prom = res.data.data;
  845 + prom.price = prom.price;
  846 + }
  847 + })
  848 + }
  849 +
  850 +
803 851 if (goodsinfo.prom_type == 6 && !good.is_pd_normal) {
804 852 await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + goodsinfo.prom_id, {}).then(res => {
805 853 if (res.data.code == 0) {
... ... @@ -810,7 +858,10 @@ Page({
810 858  
811 859 if (goodsinfo.prom_type == 4 && !good.is_integral_normal) {
812 860 await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1", {
813   - data: {store_id: os.stoid, goods_id: goodsinfo.goods_id}
  861 + data: {
  862 + store_id: os.stoid,
  863 + goods_id: goodsinfo.goods_id
  864 + }
814 865 }).then(res => {
815 866 if (res.data.code == 0 && res.data.data && res.data.data.pageData) {
816 867 prom = res.data.data.pageData[0];
... ... @@ -836,18 +887,18 @@ Page({
836 887 }
837 888  
838 889 // --看一下会员的秒杀价格是不是发生了变化,因为会员的身份发生了变化
839   - if(goodsinfo.prom_type==1 && goodsinfo.goods_price!=prom.price){
840   - var content=goodsinfo.goods_name+'秒杀活动的价格发生了变化';
  890 + if (goodsinfo.prom_type == 1 && goodsinfo.goods_price != prom.price) {
  891 + var content = goodsinfo.goods_name + '秒杀活动的价格发生了变化';
  892 + th.toast(content);
  893 + return false;
  894 + }
  895 +
  896 + // --看一下会员的团购价格是不是发生了变化
  897 + if (goodsinfo.prom_type == 2 && goodsinfo.goods_price != prom.price) {
  898 + var content = goodsinfo.goods_name + '秒杀活动的价格发生了变化';
841 899 th.toast(content);
842 900 return false;
843 901 }
844   -
845   - // --看一下会员的团购价格是不是发生了变化
846   - if(goodsinfo.prom_type==2 && goodsinfo.goods_price!=prom.price){
847   - var content=goodsinfo.goods_name+'秒杀活动的价格发生了变化';
848   - th.toast(content);
849   - return false;
850   - }
851 902  
852 903 if (goodsinfo.prom_type == 4) {
853 904 if (good.goods_num > prom.limitqty - prom.buy_num) {
... ... @@ -856,12 +907,12 @@ Page({
856 907 th.toast(content);
857 908 return false;
858 909 }
859   - } else if(goodsinfo.prom_type == 1 || goodsinfo.prom_type == 2 || goodsinfo.prom_type == 6 ) {
860   - if(order.add_time+5*60<ut.gettimestamp()) {
  910 + } else if (goodsinfo.prom_type == 1 || goodsinfo.prom_type == 2 || goodsinfo.prom_type == 6) {
  911 + if (order.add_time + 5 * 60 < ut.gettimestamp()) {
861 912 var content = gg.goods_name + '该订单已经超时无法支付,请取消订单';
862 913 th.toast(content);
863 914 return false;
864   - }
  915 + }
865 916 }
866 917  
867 918 }
... ... @@ -875,14 +926,13 @@ Page({
875 926 if (!keyid) return false;
876 927 var offarr = null;
877 928 await getApp().request.promiseGet("/api/weshop/goods/listWarePrice", {
878   - data: {
879   - VIPId: encodeURIComponent(user_info.erpvipid),
880   - store_id: os.stoid,
881   - PickupId: keyid,
882   - WareIds: wlist
883   - },
  929 + data: {
  930 + VIPId: encodeURIComponent(user_info.erpvipid),
  931 + store_id: os.stoid,
  932 + PickupId: keyid,
  933 + WareIds: wlist
884 934 },
885   - ).then(res => {
  935 + }, ).then(res => {
886 936 if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
887 937 offarr = res.data.data;
888 938 }
... ... @@ -900,292 +950,337 @@ Page({
900 950  
901 951 var content = good.goods_name + '商品的价格发生了变化,请取消订单重新购买';
902 952 th.toast(content);
  953 + console.log(5);
903 954 return false;
904 955 }
905 956 }
906 957 }
907 958 th.pay_next(e, o_index);
908 959 },
909   -
910   -
911   - pay_next(e,o_index){
912   - var th=this;
913   - if (e.order_amount == 0) {
914   - var dd = {
915   - parent_sn: e.order_sn,
916   - store_id: e.store_id,
917   - type: 1,
918   - };
919   - getApp().request.post("/api/weshop/order/pay/createOrder", {
920   - data: dd,
921   - success: function(t) {
922   - if (t.data.code == 0) {
923   - th.onload();
924   - } else {
925   - getApp().confirmBox(t.data.msg + "请您取消该订单");
926   - }
927   - }
928   - })
929   - return false;
930   - }
931   -
932   - /*---
933   - a.jumpToCart4({
934   - order_sn: e.order_sn,
935   - order_amount: e.order_amount,
936   - type: 1 //正常单
937   - });--*/
938   -
939   - t.pay(e.order_sn, function() {
940   - wx.showToast({title: '支付成功'})
941   - th.data.orderList.splice(o_index,1);
942   - th.setData({orderList:th.data.orderList});
943   - },null,os.stoid,1);
944   -
945   -
946   - },
947   -
  960 +
  961 +
  962 + pay_next(e, o_index) {
  963 + var th = this;
  964 + if (e.order_amount == 0) {
  965 + var dd = {
  966 + parent_sn: e.order_sn,
  967 + store_id: e.store_id,
  968 + type: 1,
  969 + };
  970 + getApp().request.post("/api/weshop/order/pay/createOrder", {
  971 + data: dd,
  972 + success: function (t) {
  973 + if (t.data.code == 0) {
  974 + th.onload();
  975 + } else {
  976 + getApp().confirmBox(t.data.msg + "请您取消该订单");
  977 + }
  978 + }
  979 + })
  980 + return false;
  981 + }
  982 +
  983 + /*---
  984 + a.jumpToCart4({
  985 + order_sn: e.order_sn,
  986 + order_amount: e.order_amount,
  987 + type: 1 //正常单
  988 + });--*/
  989 +
  990 + t.pay(e.order_sn, function () {
  991 + wx.showToast({
  992 + title: '支付成功'
  993 + })
  994 + th.data.orderList.splice(o_index, 1);
  995 + th.setData({
  996 + orderList: th.data.orderList
  997 + });
  998 + }, null, os.stoid, 1);
  999 +
  1000 +
  1001 + },
  1002 +
948 1003 //---检验线下库存的数量的子函数---
949   - async check_down_line_next(gg,num,pick_id,func){
950   -
951   - var lock=0,pick_no,plist;
952   - //先读取门店的lock
953   - await getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{
954   - data:{store_id:os.stoid,wareId:gg.goods_id,storageId:pick_id}
955   - }).then(res=>{
956   - if(res.data.code==0 && res.data.data.total>0){
957   - for(var i in res.data.data.pageData)
958   - lock+=res.data.data.pageData[i].outQty;
959   - }
960   - })
961   - //先获取门店的编号
962   - await getApp().request.promiseGet("/api/weshop/pickup/get/"+os.stoid+"/"+pick_id,{
963   - data:{storeId:os.stoid,goodsId:gg.goods_id,pickupId:pick_id}
964   - }).then(res=>{
965   - if(res.data.code==0){
966   - pick_no=res.data.data.pickup_no;
967   - }
968   - })
969   - //读取线下的门店库存
970   - await getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{
971   - data:{storageNos:pick_no,wareIds:encodeURIComponent(gg.erpwareid),storeId:os.stoid}
972   - }).then(res=>{
973   - if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length>0){
974   - plist=res.data.data.pageData[0];
975   - }
976   - })
977   -
978   - var ob={}; ob.code=1;
979   - if(!plist){
980   - ob.code=-1; ob.CanOutQty=0;
981   - func(ob);return false;
982   - }
983   -
984   - if(num>plist.CanOutQty-lock){
985   - ob.code=-1;
986   - ob.CanOutQty=plist.CanOutQty-lock
987   - if(ob.CanOutQty<0) ob.CanOutQty=0;
988   - }
989   - func(ob)
  1004 + async check_down_line_next(gg, num, pick_id, func) {
  1005 +
  1006 + var lock = 0,
  1007 + pick_no, plist;
  1008 + //先读取门店的lock
  1009 + await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", {
  1010 + data: {
  1011 + store_id: os.stoid,
  1012 + wareId: gg.goods_id,
  1013 + storageId: pick_id
  1014 + }
  1015 + }).then(res => {
  1016 + if (res.data.code == 0 && res.data.data.total > 0) {
  1017 + for (var i in res.data.data.pageData)
  1018 + lock += res.data.data.pageData[i].outQty;
  1019 + }
  1020 + })
  1021 + //先获取门店的编号
  1022 + await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + pick_id, {
  1023 + data: {
  1024 + storeId: os.stoid,
  1025 + goodsId: gg.goods_id,
  1026 + pickupId: pick_id
  1027 + }
  1028 + }).then(res => {
  1029 + if (res.data.code == 0) {
  1030 + pick_no = res.data.data.pickup_no;
  1031 + }
  1032 + })
  1033 + //读取线下的门店库存
  1034 + await getApp().request.promiseGet("/api/weshop/goods/getWareStorages", {
  1035 + data: {
  1036 + storageNos: pick_no,
  1037 + wareIds: encodeURIComponent(gg.erpwareid),
  1038 + storeId: os.stoid
  1039 + }
  1040 + }).then(res => {
  1041 + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length > 0) {
  1042 + plist = res.data.data.pageData[0];
  1043 + }
  1044 + })
  1045 +
  1046 + var ob = {};
  1047 + ob.code = 1;
  1048 + if (!plist) {
  1049 + ob.code = -1;
  1050 + ob.CanOutQty = 0;
  1051 + func(ob);
  1052 + return false;
  1053 + }
  1054 +
  1055 + if (num > plist.CanOutQty - lock) {
  1056 + ob.code = -1;
  1057 + ob.CanOutQty = plist.CanOutQty - lock
  1058 + if (ob.CanOutQty < 0) ob.CanOutQty = 0;
  1059 + }
  1060 + func(ob)
990 1061 },
991   -
992   -
993   -
994   - //------图片失败,默认图片---------
995   - bind_bnerr: function(e) {
996   - var _errImg = e.currentTarget.dataset.errorimg;
997   - var _errObj = {};
998   - _errObj[_errImg] = "public/images/default_goods_image_240.gif";
999   - this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
1000   - },
1001   -
1002   - //--------跳转到退款详情-----------
1003   - gotoreturn: function(t) {
1004   - var e = t.currentTarget.dataset.recid;
1005   - var oid = t.currentTarget.dataset.oid;
1006   - var wh = "";
1007   - if (e != undefined && e != null && e != "") {
1008   - wh = "&goods_id=" + e;
1009   - }
1010   - wx.navigateTo({
1011   - url: "/pages/user/return_goods_info/return_goods_info?order_id=" + oid + wh,
1012   - });
1013   - },
1014   -
1015   - //-----支付尾款------
1016   - pay_wk: function(ee) {
1017   - console.log("pay_wk");
1018   - var order_id = ee.currentTarget.dataset.order_id;
1019   - wx.navigateTo({
1020   - url: "/pages/cart/cart_wk/cart_wk?order_id=" + order_id,
1021   - });
1022   -
1023   - },
1024   -
1025   - //--判断是不是可以单个商品退--
1026   - check_for_return_btn: function(item) {
1027   - if (item.coupon_no) return false; //有用优惠券
1028   - if (item.order_prom_id) return false; //有订单优惠
1029   - if (item.order_status >= 2) return false; //订单状态>2
1030   - var istrue = true;
1031   - //----判断是不是有优惠活动和赠送商品----
1032   - for (var g in item.goodslist) {
1033   - var g_item = item.goodslist[g];
1034   - if ((g_item.prom_type == 3 && g_item.discount_amount > 0) ||
1035   - (g_item.prom_type == 3 && g_item.goods_price <= 0)
1036   - ) {
1037   - istrue = false;
1038   - break
1039   - }
1040   - if (g_item.prom_type == 5) {
1041   - istrue = false;
1042   - break
1043   - }
1044   - }
1045   - if (!istrue) return false;
1046   - var conf = this.data.conf;
1047   - //判断是不是原路退回
1048   - if (conf.refund_type == 1) return true;
1049   - else {
1050   - if (item.order_amount == 0 || item.user_money == 0) return true;
1051   - }
1052   - return false;
1053   - },
1054   - //跳到首页
1055   - goto: function(e) {
1056   - wx.navigateTo({
1057   - url: '/pages/index/index/index',
1058   - })
1059   - },
1060   -
1061   - //显示核销码
1062   - code_show: function(e) {
1063   - var th = this;
1064   - //--获取成功的时候--
1065   - var no = e.currentTarget.dataset.order_sn;
1066   - var qc_com = th.selectComponent("#qc_com"); //组件的id
1067   - var obj = {
1068   - val: no,
1069   - content: "请将二维码展示给核销员,收货更快捷"
1070   - };
1071   - qc_com.open(obj)
1072   - },
1073   -
1074   - //再来一单的功能的实现
1075   - moreOrder:function(e){
1076   -
1077   - if(this.data.moring) return false;
1078   - this.data.moring=1;
1079   -
1080   - var th=this;
1081   - var index=e.currentTarget.dataset.index;
1082   - var item=th.data.orderList[index];
1083   - th.check_more_order(item);
1084   - },
1085   -
1086   -
1087   - check_more_order:async function(item){
1088   - var pickup=null,th=this;
1089   - var user_id=getApp().globalData.user_id;
  1062 +
  1063 +
  1064 +
  1065 + //------图片失败,默认图片---------
  1066 + bind_bnerr: function (e) {
  1067 + var _errImg = e.currentTarget.dataset.errorimg;
  1068 + var _errObj = {};
  1069 + _errObj[_errImg] = "public/images/default_goods_image_240.gif";
  1070 + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
  1071 + },
  1072 +
  1073 + //--------跳转到退款详情-----------
  1074 + gotoreturn: function (t) {
  1075 + var e = t.currentTarget.dataset.recid;
  1076 + var oid = t.currentTarget.dataset.oid;
  1077 + var wh = "";
  1078 + if (e != undefined && e != null && e != "") {
  1079 + wh = "&goods_id=" + e;
  1080 + }
  1081 + wx.navigateTo({
  1082 + url: "/pages/user/return_goods_info/return_goods_info?order_id=" + oid + wh,
  1083 + });
  1084 + },
  1085 +
  1086 + //-----支付尾款------
  1087 + pay_wk: function (ee) {
  1088 + console.log("pay_wk");
  1089 + var order_id = ee.currentTarget.dataset.order_id;
  1090 + wx.navigateTo({
  1091 + url: "/pages/cart/cart_wk/cart_wk?order_id=" + order_id,
  1092 + });
  1093 +
  1094 + },
  1095 +
  1096 + //--判断是不是可以单个商品退--
  1097 + check_for_return_btn: function (item) {
  1098 + if (item.coupon_no) return false; //有用优惠券
  1099 + if (item.order_prom_id) return false; //有订单优惠
  1100 + if (item.order_status >= 2) return false; //订单状态>2
  1101 + var istrue = true;
  1102 + //----判断是不是有优惠活动和赠送商品----
  1103 + for (var g in item.goodslist) {
  1104 + var g_item = item.goodslist[g];
  1105 + if ((g_item.prom_type == 3 && g_item.discount_amount > 0) ||
  1106 + (g_item.prom_type == 3 && g_item.goods_price <= 0)
  1107 + ) {
  1108 + istrue = false;
  1109 + break
  1110 + }
  1111 + if (g_item.prom_type == 5) {
  1112 + istrue = false;
  1113 + break
  1114 + }
  1115 + }
  1116 + if (!istrue) return false;
  1117 + var conf = this.data.conf;
  1118 + //判断是不是原路退回
  1119 + if (conf.refund_type == 1) return true;
  1120 + else {
  1121 + if (item.order_amount == 0 || item.user_money == 0) return true;
  1122 + }
  1123 + return false;
  1124 + },
  1125 + //跳到首页
  1126 + goto: function (e) {
  1127 + wx.navigateTo({
  1128 + url: '/pages/index/index/index',
  1129 + })
  1130 + },
  1131 +
  1132 + //显示核销码
  1133 + code_show: function (e) {
  1134 + var th = this;
  1135 + //--获取成功的时候--
  1136 + var no = e.currentTarget.dataset.order_sn;
  1137 + var qc_com = th.selectComponent("#qc_com"); //组件的id
  1138 + var obj = {
  1139 + val: no,
  1140 + content: "请将二维码展示给核销员,收货更快捷"
  1141 + };
  1142 + qc_com.open(obj)
  1143 + },
  1144 +
  1145 + //再来一单的功能的实现
  1146 + moreOrder: function (e) {
  1147 +
  1148 + if (this.data.moring) return false;
  1149 + this.data.moring = 1;
  1150 +
  1151 + var th = this;
  1152 + var index = e.currentTarget.dataset.index;
  1153 + var item = th.data.orderList[index];
  1154 + th.check_more_order(item);
  1155 + },
  1156 +
  1157 +
  1158 + check_more_order: async function (item) {
  1159 + console.log(item, 100000);
  1160 + var pickup = null,
  1161 + th = this;
  1162 + var user_id = getApp().globalData.user_id;
1090 1163 wx.showLoading();
1091 1164 //--------获取门店-----------
1092 1165 await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + item.pickup_id, {
1093 1166  
1094   - }).then(res=>{
  1167 + }).then(res => {
1095 1168 pickup = res.data.data;
1096 1169 })
1097 1170  
1098 1171 //--------获取商品----------
1099   - var goods_list=item.order_goods;
  1172 + var goods_list = item.order_goods;
1100 1173 //--- 返回的内容 ---
1101   - var back_goods_arr=[];
1102   - var err_text="";
1103   - for(var i in goods_list){
1104   - var g_item=goods_list[i];
  1174 + var back_goods_arr = [];
  1175 + var err_text = "";
  1176 + for (var i in goods_list) {
  1177 + var g_item = goods_list[i];
  1178 + var b_item = {}
1105 1179 //--如果是赠品,不加入购物车--
1106   - if(g_item['is_gift']) continue;
1107   - if(g_item['prom_type']==4 ){
1108   - err_text+= g_item['goods_name']+"积分购商品不加入购物车\n";
  1180 + if (g_item['is_gift']) continue;
  1181 + if (g_item['prom_type'] == 4) {
  1182 + err_text += g_item['goods_name'] + "积分购商品不加入购物车\n";
1109 1183 continue;
1110 1184 }
1111   - if(g_item['prom_type']==5){
1112   - err_text+= g_item['goods_name']+"搭配购商品不加入购物车\n";
  1185 + if (g_item['prom_type'] == 5) {
  1186 + err_text += g_item['goods_name'] + "搭配购商品不加入购物车\n";
1113 1187 continue;
1114 1188 }
1115   - if(g_item['prom_type']==6 ){
1116   - err_text+= g_item['goods_name']+"拼团商品不加入购物车\n";
  1189 + if (g_item['prom_type'] == 6) {
  1190 + err_text += g_item['goods_name'] + "拼团商品不加入购物车\n";
1117 1191 continue;
1118 1192 }
1119 1193  
1120 1194 //--获取商品--
1121   - var good=null;
  1195 + var good = null;
1122 1196 await getApp().request.promiseGet("/api/weshop/goods/get/" + os.stoid + "/" + g_item.goods_id, {
1123 1197  
1124   - }).then(res=>{
1125   - good=res.data.data;
1126   - })
  1198 + }).then(res => {
  1199 + good = res.data.data;
1127 1200  
1128   - if(!good){
1129   - err_text+= g_item['goods_name']+"未找到商品\n";
  1201 + })
  1202 + //调用接口判断订单优惠,
  1203 + const res = await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + g_item.goods_id + "/0", {})
  1204 + if (res.data.code == 0 && res.data.data) {
  1205 + var r_data = res.data.data;
  1206 + if (r_data.ladderLists) {
  1207 + var act_id = r_data.ladderLists[0].form_id;
  1208 + //-- 判断会员能不能参与阶梯促销 --
  1209 + const data = await getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid + "/" + user_id + "/" + act_id, {})
  1210 + if (data.data.code == 0 && data.data.data && data.data.data.isuse && data.data.data.is_end == 0) {
  1211 + b_item.prom_type = 10;
  1212 + b_item.prom_id = data.data.data.id;
  1213 + }
  1214 + }
  1215 + }
  1216 + if (!good) {
  1217 + err_text += g_item['goods_name'] + "未找到商品\n";
1130 1218 continue;
1131 1219 }
1132 1220 if (good.is_on_sale != 1) {
1133   - err_text+= g_item['goods_name']+"已经下架\n";
  1221 + err_text += g_item['goods_name'] + "已经下架\n";
1134 1222 continue;
1135 1223 }
1136 1224  
1137 1225 var timestamp = ut.gettimestamp();
1138 1226 if (good.on_time > timestamp) {
1139   - err_text+= g_item['goods_name']+"还未上架\n";
  1227 + err_text += g_item['goods_name'] + "还未上架\n";
1140 1228 continue;
1141 1229 }
1142 1230 if (good.down_time > 0) {
1143 1231 if (good.down_time < timestamp) {
1144   - err_text+=g_item['goods_name']+"已经下架\n";
  1232 + err_text += g_item['goods_name'] + "已经下架\n";
1145 1233 continue;
1146 1234 }
1147 1235 }
1148 1236  
1149 1237 //如果商品的配送方式和门店不匹配
1150   - if(good['distr_type']>0 && pickup['distr_type']>0 && good['distr_type']!=pickup['distr_type'] ){
1151   - err_text+= good['goods_name']+"配送方式不一致\n";
  1238 + if (good['distr_type'] > 0 && pickup['distr_type'] > 0 && good['distr_type'] != pickup['distr_type']) {
  1239 + err_text += good['goods_name'] + "配送方式不一致\n";
1152 1240 continue;
1153 1241 }
1154 1242  
1155   - var prom=null;
1156   - var b_item={}
1157   - b_item.goods_id=g_item.goods_id;
1158   - b_item.goods_name=g_item.goods_name;
1159   - b_item.goods_num=g_item.goods_num;
1160   - b_item.guide_id=g_item.guide_id;
1161   - b_item.guide_type=g_item.guide_type;
1162   - b_item.pickup_id=item.pickup_id;
1163   - b_item.price=good.shop_price;
1164   - b_item.goods_sn=good.goods_sn;
1165   - b_item.sku=good.sku;
1166   - b_item.is_integral_normal=g_item.is_integral_normal;
1167   -
  1243 + var prom = null;
  1244 + b_item.goods_id = g_item.goods_id;
  1245 + b_item.goods_name = g_item.goods_name;
  1246 + b_item.goods_num = g_item.goods_num;
  1247 + b_item.guide_id = g_item.guide_id;
  1248 + b_item.guide_type = g_item.guide_type;
  1249 + b_item.pickup_id = item.pickup_id;
  1250 + b_item.price = good.shop_price;
  1251 + b_item.goods_sn = good.goods_sn;
  1252 + b_item.sku = good.sku;
  1253 + b_item.is_integral_normal = g_item.is_integral_normal;
  1254 + console.log(b_item, 'b_item');
1168 1255 //-- 如果会员是等级卡的时候,同时商品也有设置相应的卡价格 --
1169   - var card_field=th.data.card_field;
1170   - if(card_field && good[card_field]>0){
1171   - b_item.price=good[card_field];
  1256 + var card_field = th.data.card_field;
  1257 + if (card_field && good[card_field] > 0) {
  1258 + b_item.price = good[card_field];
1172 1259 }
1173 1260  
1174   - var url="/api/weshop/activitylist/getGoodActInfo";
1175   - var req_data={
1176   - store_id:g_item.store_id,goodsidlist:g_item.goods_id,is_detail:1
  1261 + var url = "/api/weshop/activitylist/getGoodActInfo";
  1262 + var req_data = {
  1263 + store_id: g_item.store_id,
  1264 + goodsidlist: g_item.goods_id,
  1265 + is_detail: 1
1177 1266 };
1178   - await getApp().request.promiseGet(url, {data:req_data}).then(res=>{
1179   - if(res.data.code==0){
1180   - var list = res.data.data;
1181   - for(let i in list){
1182   - let item=list[i];
1183   - if(item.prom_type==1){ good.prom_type=1; good.prom_id=item.act_id; }
1184   - }
1185   - }
  1267 + await getApp().request.promiseGet(url, {
  1268 + data: req_data
  1269 + }).then(res => {
  1270 + if (res.data.code == 0) {
  1271 + var list = res.data.data;
  1272 + console.log('list', list);
  1273 + for (let i in list) {
  1274 + let item = list[i];
  1275 + if (item.prom_type == 1) {
  1276 + good.prom_type = 1;
  1277 + good.prom_id = item.act_id;
  1278 + }
  1279 + }
  1280 + }
1186 1281 })
1187 1282  
1188   - if(!prom) {
  1283 + if (!prom) {
1189 1284 //--判断商品当前的活动情况--
1190 1285 switch (good.prom_type) {
1191 1286 case 1:
... ... @@ -1195,29 +1290,29 @@ Page({
1195 1290 flash = res.data.data;
1196 1291 }
1197 1292 })
1198   - //----已经结束-----
  1293 + //----进行中-----
1199 1294 if (flash && flash.is_end == 0 && flash.end_time > timestamp && flash.start_time < timestamp) {
1200 1295 prom = flash;
1201 1296 prom.price = prom.user_price;
1202 1297 b_item.price = prom.user_price;
1203 1298 }
1204 1299 break;
1205   -
1206   - case 2:
1207   - var group = null;
1208   - await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + good.goods_id + "/" + good.prom_id, {}).then(res => {
1209   - if (res.data.code == 0) {
1210   - group = res.data.data;
1211   - }
1212   - })
1213   - //----已经结束-----
1214   - if (group && group.is_end == 0 && group.end_time > timestamp && group.start_time < timestamp) {
1215   - prom = group;
1216   - prom.price = prom.price;
1217   - b_item.price = prom.price;
1218   - }
1219   - break;
1220   -
  1300 +
  1301 + case 2:
  1302 + var group = null;
  1303 + await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + good.goods_id + "/" + good.prom_id, {}).then(res => {
  1304 + if (res.data.code == 0) {
  1305 + group = res.data.data;
  1306 + }
  1307 + })
  1308 + //----进行中-----
  1309 + if (group && group.is_end == 0 && group.end_time > timestamp && group.start_time < timestamp) {
  1310 + prom = group;
  1311 + prom.price = prom.price;
  1312 + b_item.price = prom.price;
  1313 + }
  1314 + break;
  1315 +
1221 1316 case 6:
1222 1317 b_item.is_pd_normal = 1;
1223 1318 break;
... ... @@ -1226,30 +1321,38 @@ Page({
1226 1321 var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + good.prom_id + "/" + getApp().globalData.userInfo.user_id;
1227 1322 await getApp().request.promiseGet(url, {}).then(res => {
1228 1323 if (res.data.code == 0 && res.data.data) {
1229   - if (res.data.data.is_show == 1 && res.data.data.is_end == 0
1230   - && ut.gettimestamp() < res.data.data.end_time
1231   - && ut.gettimestamp() > res.data.data.start_time
  1324 + if (res.data.data.is_show == 1 && res.data.data.is_end == 0 &&
  1325 + ut.gettimestamp() < res.data.data.end_time &&
  1326 + ut.gettimestamp() > res.data.data.start_time
1232 1327 ) {
1233 1328 b_item.prom_type = 7;
1234 1329 b_item.prom_id = res.data.data.id;
1235 1330 good.prom_type = 7;
1236 1331 good.prom_id = b_item.prom_id;
1237   -
1238 1332 }
1239 1333 }
1240 1334 })
1241 1335 break;
  1336 + case 10:
  1337 + let user_id = getApp().globalData.userInfo.user_id;
  1338 + var url = `/api/weshop/prom/ladderForm/getNew/${os.stoid}/${user_id}/${good.prom_id}`;
  1339 + await getApp().request.promiseGet(url, {}).then(res => {
  1340 + if (res.data.code == 0 && res.data.data && res.data.data.isuse && res.data.data.is_end == 0) {
  1341 + b_item.prom_type = 10;
  1342 + b_item.prom_id = res.data.data.id;
  1343 + }
  1344 + })
1242 1345 }
1243 1346 }
1244 1347  
1245 1348 //如果有优惠促销的时候,要看下商品的优惠活动有没有过期
1246   - if(g_item.prom_type==3 || good.prom_type==3){
  1349 + if (g_item.prom_type == 3 || good.prom_type == 3) {
1247 1350 await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + good.goods_id + "/1", {}).then(res => {
1248 1351 if (res.data.code == 0) {
1249 1352 var r_data = res.data.data;
1250 1353 if (r_data.promGoodsLists) {
1251   - b_item.prom_type=3;
1252   - b_item.prom_id=r_data.promGoodsLists[0].prom_id;
  1354 + b_item.prom_type = 3;
  1355 + b_item.prom_id = r_data.promGoodsLists[0].prom_id;
1253 1356 }
1254 1357 }
1255 1358 })
... ... @@ -1257,34 +1360,41 @@ Page({
1257 1360  
1258 1361  
1259 1362 //判断是不是线下库存的购买, 是不是秒杀活动
1260   - if(th.data.sales_rules==2 && !prom){
  1363 + if (th.data.sales_rules == 2 && !prom) {
1261 1364  
1262 1365 //-- 看一下购物车上有多少商品 --
1263   - var cart_num=0;
  1366 + var cart_num = 0;
1264 1367 await getApp().request.promiseGet("/api/weshop/cart/page", {
1265 1368 data: {
1266 1369 store_id: os.stoid,
1267 1370 user_id: getApp().globalData.user_id,
1268   - state:0, is_gift:0,
1269   - goods_id:good.goods_id,
  1371 + state: 0,
  1372 + is_gift: 0,
  1373 + goods_id: good.goods_id,
1270 1374 pick_id: b_item.pickup_id
1271 1375 }
1272   - }).then(res=>{
  1376 + }).then(res => {
1273 1377 var num = 0;
1274   - if(res.data.code==0 && res.data.data && res.data.data.pageData) {
  1378 + if (res.data.code == 0 && res.data.data && res.data.data.pageData) {
1275 1379 for (var i = 0; i < res.data.data.pageData.length; i++) {
1276 1380 num += res.data.data.pageData[i].goods_num;
1277 1381 }
1278 1382 }
1279   - cart_num=num;
  1383 + cart_num = num;
1280 1384 })
1281 1385  
1282   - var lock=0,plist=null;
  1386 + var lock = 0,
  1387 + plist = null;
1283 1388  
1284   - if(b_item.prom_type!=7) {
  1389 + if (b_item.prom_type != 7) {
1285 1390 //先读取门店的lock,
1286 1391 await getApp().request.promiseGet("/api/weshop/order/ware/lock/page", {
1287   - data: {store_id: os.stoid, wareId: good.goods_id, storageId: b_item.pickup_id, pageSize: 1000}
  1392 + data: {
  1393 + store_id: os.stoid,
  1394 + wareId: good.goods_id,
  1395 + storageId: b_item.pickup_id,
  1396 + pageSize: 1000
  1397 + }
1288 1398 }).then(res => {
1289 1399 if (res.data.code == 0 && res.data.data.total > 0) {
1290 1400 for (var i in res.data.data.pageData)
... ... @@ -1317,100 +1427,101 @@ Page({
1317 1427 b_item.goods_num = plist.CanOutQty - lock;
1318 1428 }
1319 1429 }
1320   - var req_data={
  1430 + var req_data = {
1321 1431 store_id: os.stoid,
1322 1432 user_id: getApp().globalData.user_id,
1323 1433 goods_id: good.goods_id,
1324 1434 };
1325   - if(b_item.prom_type==7){
1326   - req_data.prom_type=7;
1327   - req_data.prom_id=b_item.prom_id;
  1435 + if (b_item.prom_type == 7) {
  1436 + req_data.prom_type = 7;
  1437 + req_data.prom_id = b_item.prom_id;
1328 1438 }
1329 1439  
1330   - var buynum=0;
1331   - var promnum=0;
  1440 + var buynum = 0;
  1441 + var promnum = 0;
1332 1442 //---要获得商品,该用户买了多少件,同步应用---
1333 1443 await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
1334 1444 data: req_data,
1335 1445 }).then(res => {
1336   - if(res.data.code==0){
  1446 + if (res.data.code == 0) {
1337 1447 var buy_num_data = res.data.data;
1338 1448 buynum = buy_num_data.goodsbuynum;
1339   - if(buy_num_data.promgoodsbuynum){
1340   - promnum=buy_num_data.promgoodsbuynum;
  1449 + if (buy_num_data.promgoodsbuynum) {
  1450 + promnum = buy_num_data.promgoodsbuynum;
1341 1451 }
1342 1452 }
1343 1453 })
1344 1454  
1345 1455 //---- 要计算商品的限购 -----
1346   - if(good['viplimited']>0){
1347   - if(cart_num+buynum>good['viplimited']){
1348   - err_text+= good['goods_name']+"超出限购\n";
  1456 + if (good['viplimited'] > 0) {
  1457 + if (cart_num + buynum > good['viplimited']) {
  1458 + err_text += good['goods_name'] + "超出限购\n";
1349 1459 continue;
1350 1460 }
1351   - good['viplimited']-=(cart_num+buynum);
1352   - if(b_item.goods_num>good['viplimited']){
1353   - b_item.goods_num=good['viplimited'];
  1461 + good['viplimited'] -= (cart_num + buynum);
  1462 + if (b_item.goods_num > good['viplimited']) {
  1463 + b_item.goods_num = good['viplimited'];
1354 1464 }
1355 1465 }
1356 1466 //不需要计算组合购的限购
1357 1467  
1358   - back_goods_arr.push(b_item); //返回商品元素
  1468 + back_goods_arr.push(b_item); //返回商品元素
1359 1469  
1360   - }else{
  1470 + } else {
1361 1471  
1362 1472 //-- 看一下购物车上有多少商品 --
1363   - var cart_num=0;
  1473 + var cart_num = 0;
1364 1474 await getApp().request.promiseGet("/api/weshop/cart/page", {
1365 1475 data: {
1366 1476 store_id: os.stoid,
1367 1477 user_id: getApp().globalData.user_id,
1368   - state:0, is_gift:0,
1369   - goods_id:good.goods_id
  1478 + state: 0,
  1479 + is_gift: 0,
  1480 + goods_id: good.goods_id
1370 1481 }
1371   - }).then(res=>{
  1482 + }).then(res => {
1372 1483 var num = 0;
1373   - if(res.data.code==0 && res.data.data && res.data.data.pageData) {
  1484 + if (res.data.code == 0 && res.data.data && res.data.data.pageData) {
1374 1485 for (var i = 0; i < res.data.data.pageData.length; i++) {
1375 1486 num += res.data.data.pageData[i].goods_num;
1376 1487 }
1377 1488 }
1378   - cart_num=num;
  1489 + cart_num = num;
1379 1490 })
1380 1491  
1381 1492  
1382   - if(good.store_count<=0){
1383   - err_text+= good['goods_name']+"库存不足\n";
  1493 + if (good.store_count <= 0) {
  1494 + err_text += good['goods_name'] + "库存不足\n";
1384 1495 continue;
1385 1496 }
1386   - if(b_item.goods_num>good.store_count)
1387   - b_item.goods_num=good.store_count;
  1497 + if (b_item.goods_num > good.store_count)
  1498 + b_item.goods_num = good.store_count;
1388 1499  
1389   - var buynum=0; //商品已经购买多少件
1390   - var promgoodsbuynum=0; //活动已经购买多少件
1391   - var redis_num = 0; //redis库存
  1500 + var buynum = 0; //商品已经购买多少件
  1501 + var promgoodsbuynum = 0; //活动已经购买多少件
  1502 + var redis_num = 0; //redis库存
1392 1503  
1393   - var req_data={
  1504 + var req_data = {
1394 1505 store_id: os.stoid,
1395 1506 user_id: getApp().globalData.user_id,
1396 1507 goods_id: good.goods_id,
1397 1508 };
1398 1509  
1399   - if(prom){
1400   - req_data.prom_type= good.prom_type;
1401   - req_data.prom_id= good.prom_id;
1402   - b_item.prom_type=good.prom_type;
1403   - b_item.prom_id=good.prom_id;
  1510 + if (prom) {
  1511 + req_data.prom_type = good.prom_type;
  1512 + req_data.prom_id = good.prom_id;
  1513 + b_item.prom_type = good.prom_type;
  1514 + b_item.prom_id = good.prom_id;
1404 1515  
1405 1516 //------判断活动是否抢光-----
1406 1517 await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
1407 1518 os.stoid + "/" + good.prom_type + "/" + good.prom_id, {
1408   - 1: 1
1409   - }).then(res => {
  1519 + 1: 1
  1520 + }).then(res => {
1410 1521 redis_num = res.data.data;
1411 1522 });
1412   - if(redis_num<=0){
1413   - err_text+= good['goods_name']+"活动不足\n";
  1523 + if (redis_num <= 0) {
  1524 + err_text += good['goods_name'] + "活动不足\n";
1414 1525 continue;
1415 1526 }
1416 1527  
... ... @@ -1420,7 +1531,7 @@ Page({
1420 1531 await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
1421 1532 data: req_data,
1422 1533 }).then(res => {
1423   - if(res.data.code==0){
  1534 + if (res.data.code == 0) {
1424 1535 var buy_num_data = res.data.data;
1425 1536 if (buy_num_data.promgoodsbuynum) promgoodsbuynum = buy_num_data.promgoodsbuynum;
1426 1537 buynum = buy_num_data.goodsbuynum;
... ... @@ -1428,20 +1539,20 @@ Page({
1428 1539 })
1429 1540  
1430 1541 //---- 要计算商品的限购 -----
1431   - if(good['viplimited']>0){
1432   - if(cart_num+buynum>good['viplimited']){
1433   - err_text+= good['goods_name']+"超出限购\n";
  1542 + if (good['viplimited'] > 0) {
  1543 + if (cart_num + buynum > good['viplimited']) {
  1544 + err_text += good['goods_name'] + "超出限购\n";
1434 1545 continue;
1435 1546 }
1436   - good['viplimited']-=(cart_num+buynum);
1437   - if(b_item.goods_num>good['viplimited']){
1438   - b_item.goods_num=good['viplimited'];
  1547 + good['viplimited'] -= (cart_num + buynum);
  1548 + if (b_item.goods_num > good['viplimited']) {
  1549 + b_item.goods_num = good['viplimited'];
1439 1550 }
1440 1551  
1441 1552 }
1442 1553  
1443 1554 //-- 判断活动的库存 --
1444   - if(prom) {
  1555 + if (prom) {
1445 1556 if (prom['goods_num'] <= prom['buy_num']) {
1446 1557 err_text += good['goods_name'] + "超出活动库存\n";
1447 1558 continue;
... ... @@ -1466,367 +1577,378 @@ Page({
1466 1577 }
1467 1578 }
1468 1579 }
1469   -
1470   -
1471   - back_goods_arr.push(b_item); //返回商品元素
  1580 + back_goods_arr.push(b_item); //返回商品元素
1472 1581 }
1473 1582 }
1474 1583  
1475 1584 //有重新购买的数据是时候,就要重新生成订单
1476   - if(back_goods_arr.length>0){
1477   - th.setData({back_goods_arr:back_goods_arr});
1478   - if(!err_text){
  1585 + if (back_goods_arr.length > 0) {
  1586 + th.setData({
  1587 + back_goods_arr: back_goods_arr
  1588 + });
  1589 + if (!err_text) {
1479 1590 th.more_add_cart();
1480   - }else{
  1591 + } else {
1481 1592 wx.hideLoading();
1482 1593 // 如果没有获取用户信息
1483 1594 wx.showModal({
1484   - title:'确定',
1485   - content: err_text+',确定要买其他商品码?',
  1595 + title: '确定',
  1596 + content: err_text + ',确定要买其他商品吗?',
1486 1597 success(res) {
1487 1598 if (res.confirm) {
1488 1599 //跳转到登录页
1489 1600 th.more_add_cart();
1490   - }else{
1491   - th.data.moring=0;
  1601 + } else {
  1602 + th.data.moring = 0;
1492 1603 wx.hideLoading();
1493 1604 }
1494   - },fail(){
1495   - th.data.moring=0;
  1605 + },
  1606 + fail() {
  1607 + th.data.moring = 0;
1496 1608 wx.hideLoading();
1497 1609 }
1498 1610 });
1499 1611  
1500 1612 }
1501   - }else{
1502   - th.data.moring=0;
  1613 + } else {
  1614 + th.data.moring = 0;
1503 1615 wx.hideLoading();
1504 1616 getApp().confirmBox(err_text);
1505 1617 }
1506 1618 },
1507   -
1508   - more_add_cart:async function(){
1509   - var back_goods_arr=this.data.back_goods_arr;
1510   - var err_text="";
1511   - var ok_num=0;
1512   -
1513   - for(var i in back_goods_arr){
1514   - //商品ID
1515   - var g_item=back_goods_arr[i];
1516   - var newd = {
1517   - goods_id: g_item.goods_id,
1518   - goods_num: g_item.goods_num,
1519   - pick_id: g_item.pickup_id,
1520   - user_id: oo.user_id,
1521   - store_id: os.stoid,
1522   - goods_price: g_item.price,
1523   - member_goods_price: g_item.price,
1524   - goods_name: g_item.goods_name,
1525   - goods_sn: g_item.goods_sn,
1526   - sku: g_item.sku,
1527   - };
1528   -
1529   - if(g_item.guide_id){
1530   - newd['guide_id']=g_item.guide_id;
1531   - newd['guide_type']=g_item.guide_type;
1532   - }
1533   -
1534   - if(g_item.is_integral_normal){
1535   - newd['is_integral_normal']=g_item.is_integral_normal;
1536   - }
1537   - if(g_item.is_pd_normal){
1538   - newd['is_pd_normal']=g_item.is_pd_normal;
1539   - }
1540   -
1541   - if(g_item.prom_type){
1542   - newd['prom_type']=g_item.prom_type;
1543   - newd['prom_id']=g_item.prom_id;
1544   - }
1545   -
1546   -
1547   - var b_cart_goods=null;
1548   - await getApp().request.promiseGet("/api/weshop/cart/page", {
1549   - data: {
1550   - store_id: os.stoid,
1551   - user_id: oo.user_id,
1552   - goods_id: g_item.goods_id,
1553   - pick_id: g_item.pickup_id,
1554   - },
1555   - }).then(res=>{
1556   - //-------如果购物车中有相关的数据-------
1557   - if (res.data.data.total > 0) {
1558   - b_cart_goods= res.data.data.pageData[0];
1559   - }
1560   - })
1561   -
1562   - //-- 如果就加入过购物车 --
1563   - if(b_cart_goods){
1564   - var updata = {
1565   - id: b_cart_goods.id,
1566   - goods_num: newd.goods_num + b_cart_goods.goods_num,
1567   - goods_price: newd.goods_price,
1568   - member_goods_price:newd.goods_price,
1569   - store_id: os.stoid,
1570   - };
1571   - if(newd.guide_id){
1572   - updata.guide_id=newd.guide_id;
1573   - updata.guide_type=newd.guide_type;
1574   - }
1575   - if(newd.prom_type){
1576   - updata.prom_type=newd.prom_type;
1577   - updata.prom_id=newd.prom_id;
1578   - }
1579   -
1580   - await getApp().request.promisePut("/api/weshop/cart/update", {
1581   - data: updata
1582   - }).then(res=>{
1583   - if(res.data.code==0) {
1584   - ok_num++;
1585   - }else{
1586   - err_text+=newd.goods_name+"加入购物车失败\n";
1587   - }
1588   - })
1589   -
1590   - }else{
1591   - await getApp().request.promisePost("/api/weshop/cart/save", {
1592   - data: newd
1593   - }).then(res=>{
1594   - if(res.data.code==0) {
1595   - ok_num++;
1596   - }else{
1597   - err_text+=newd.goods_name+"加入购物车失败\n";
1598   - }
1599   - })
1600   - }
1601   - }
1602   - wx.hideLoading();
1603   - this.data.moring=0;
1604   - if(ok_num==0){
1605   - //-- 如果没有获取用户信息 --
1606   - wx.showModal({
1607   - title:'提示',
1608   - content: err_text,
1609   - success(res) {}
1610   - });
1611   - }else{
1612   - if(err_text==""){
1613   - getApp().goto("/pages/cart/cart/cart");
1614   - }else{
1615   - // 如果没有获取用户信息
1616   - wx.showModal({
1617   - title:'提示',
1618   - content: err_text,
1619   - success(res) {
1620   - if (res.confirm) {
1621   - //跳转到登录页
1622   - getApp().goto("/pages/cart/cart/cart");
1623   - }
1624   - }
1625   - });
1626   -
1627   - }
1628   - }
1629   - },
1630   -
1631   - request_list: function(data, callback){
1632   - // console.log('进入request_list');
1633   -
1634   - var th = this;
1635   - if(this.data.is_load2) return false; //-- 正在加载
1636   - if(this.data.is_no_data2) return false; //-- 没有数据
1637   - if(this.data.is_no_more2) return false; //-- 没有更多
1638   -
1639   - // 开启加载状态
1640   - this.data.is_load2=1;
1641   -
1642   - // var req_data = {
1643   - // page:th.data.currentPage2
1644   - // }
1645   -
1646   - app.request.promiseGet("/api/weshop/order/pagePosOrder", {
1647   - data: data
1648   - }).then(res=>{
1649   - // 关闭加载状态
1650   - th.data.is_load2=0;
1651   - // 请求成功
1652   - if(res.data.code==0) {
1653   - if(res.data.data.pageData.length>0) {
1654   - th.data.currentPage2++;
1655   - var data = res.data.data.pageData;
1656   - // 判断有无更多数据可以加载,如果大于则没有更多数据,反之则有
1657   - if(res.data.data.page*res.data.data.pageSize > res.data.data.total){th.setData({is_no_more2:1});}
1658   - var list=th.data.list2;
1659   - list=list.concat(data);
1660   - th.setData({list2:list});
1661   - } else {
1662   - if(th.data.currentPage2==1){
1663   - th.setData({is_no_data2:1});
1664   - } else {
1665   - th.setData({is_no_more2:1});
1666   - }
1667   - }
1668   - if(callback) callback(res);
1669   - } else {
1670   - wx.showToast({
1671   - title: res.data.msg,
1672   - icon: 'none',
1673   - duration: 2000
1674   - })
1675   - }
1676   - })
1677   - },
1678   -
1679   -
1680   - onClickTab(e) {
1681   - let currentIndex = e.target.dataset.index;
1682   - this.setData({
1683   - currentIndex: currentIndex
1684   - });
1685   - console.log(this.data.currentIndex);
1686   - this.setData({
1687   - is_no_data2: 0,
1688   - is_no_more2: 0,
1689   - currentPage2: 1,
1690   - });
1691   - if(currentIndex == 0) {
1692   - console.log('线上订单');
1693   - /*---
1694   - this.setData({
1695   - startDate: '选择开始时间',
1696   - endDate: '选择结束时间',
1697   - });--*/
1698   - } else if(currentIndex == 1) {
1699   - console.log('线下订单');
1700   - this.request_list({
1701   - store_id: os.stoid,
1702   - user_id: oo.user_id,
1703   - page: 1,
1704   - BeginDate: this.data.startDate,
1705   - EndDate: this.data.endDate
1706   - });
1707   - };
1708   - },
1709   -
1710   - bindDateChange1: function(e) {
1711   - console.log('picker发送选择改变,携带值为', e.detail.value)
1712   - this.setData({
1713   - startDate: e.detail.value
1714   - })
1715   - },
1716   -
1717   - bindDateChange2: function(e) {
1718   - console.log('picker发送选择改变,携带值为', e.detail.value)
1719   - this.setData({
1720   - endDate: e.detail.value
1721   - })
1722   - },
1723   -
1724   - bindInput(e) {
1725   - this.data.searchContent = e.detail.value;
1726   - },
1727   -
1728   - searchOnline() {
1729   - console.log('online',this.data.searchContent);
1730   - if(this.data.searchContent) {
1731   - console.log(this.data.searchContent);
1732   - this.resetData(), this.requestOrderList(this.data.activeCategoryId);
1733   - } else {
1734   - wx.showToast({
1735   - title: '您还没有输入搜索内容~',
1736   - icon: 'none',
1737   - })
1738   - };
1739   - },
1740   -
1741   - searchOffline() {
1742   - console.log('执行查询');
1743   - let th = this;
1744   - let startDate = this.data.startDate;
1745   - let endDate = this.data.endDate;
1746   -
1747   - // this.data.is_no_data2 = 0;
1748   - this.setData({
1749   - currentPage2: 1,
1750   - list2: [],
1751   - is_no_data2: 0,
1752   - });
1753   -
1754   -
1755   - if(startDate == '选择开始时间' || endDate == '选择结束时间') {
1756   - wx.showToast({
1757   - title: '请选择完整的查询时间~',
1758   - icon: 'none',
1759   - })
1760   - };
1761   -
1762   - if(new Date(startDate) > new Date(endDate)) {
1763   - wx.showToast({
1764   - title: '不对噢!开始时间不能晚于结束时间~',
1765   - icon: 'none',
1766   - })
1767   - return;
1768   - };
1769   -
1770   -
1771   - this.request_list({
1772   - store_id: os.stoid,
1773   - user_id: oo.user_id,
1774   - page: 1,
1775   - BeginDate: this.data.startDate,
1776   - EndDate: this.data.endDate
1777   - }, function(res) {
1778   - if(res.data.data.total == 0) {
1779   - wx.showToast({
1780   - title: '没有找到相关订单',
1781   - icon: 'none',
1782   - duration: 2000
1783   - })
1784   - } else {
1785   - th.setData({
1786   - total: res.data.data.total
1787   - });
1788   - }
1789   - });
1790   - },
1791   -
1792   - currentDate() {
1793   - var now = new Date();
1794   - var year = now.getFullYear(); //年
1795   - var month = now.getMonth() + 1; //月
1796   - var day = now.getDate(); //日
1797   -
1798   - var clock = year + "-";
1799   -
1800   - if(month < 10) month += "0";
1801   - clock += month + "-";
1802   -
1803   - if(day < 10) day += "0";
1804   - clock += day;
1805   -
1806   - // if(hh < 10)
1807   - // clock += "0";
1808   -
1809   - // clock += hh + ":";
1810   - // if (mm < 10) clock += '0';
1811   - // clock += mm + ":";
1812   -
1813   - // if (ss < 10) clock += '0';
1814   - // clock += ss;
1815   - return clock;
1816   - },
1817   -
1818   - toast(msg){
1819   - wx.showToast({
1820   - title: msg,
1821   - icon: 'none',
1822   - duration: 3000
1823   - })
1824   - },
1825   -
1826   - go_url(e){
1827   - var url=e.currentTarget.dataset.url;
1828   - getApp().goto(url);
  1619 +
  1620 + more_add_cart: async function () {
  1621 + var back_goods_arr = this.data.back_goods_arr;
  1622 + var err_text = "";
  1623 + var ok_num = 0;
  1624 +
  1625 + for (var i in back_goods_arr) {
  1626 + //商品ID
  1627 + var g_item = back_goods_arr[i];
  1628 + console.log(g_item, 'g_item');
  1629 + var newd = {
  1630 + goods_id: g_item.goods_id,
  1631 + goods_num: g_item.goods_num,
  1632 + pick_id: g_item.pickup_id,
  1633 + user_id: oo.user_id,
  1634 + store_id: os.stoid,
  1635 + goods_price: g_item.price,
  1636 + member_goods_price: g_item.price,
  1637 + goods_name: g_item.goods_name,
  1638 + goods_sn: g_item.goods_sn,
  1639 + sku: g_item.sku,
  1640 + };
  1641 +
  1642 + if (g_item.guide_id) {
  1643 + newd['guide_id'] = g_item.guide_id;
  1644 + newd['guide_type'] = g_item.guide_type;
  1645 + }
  1646 +
  1647 + if (g_item.is_integral_normal) {
  1648 + newd['is_integral_normal'] = g_item.is_integral_normal;
  1649 + }
  1650 + if (g_item.is_pd_normal) {
  1651 + newd['is_pd_normal'] = g_item.is_pd_normal;
  1652 + }
  1653 + if (g_item.prom_type) {
  1654 + newd['prom_type'] = g_item.prom_type;
  1655 + newd['prom_id'] = g_item.prom_id;
  1656 + }
  1657 +
  1658 +
  1659 + var b_cart_goods = null;
  1660 + await getApp().request.promiseGet("/api/weshop/cart/page", {
  1661 + data: {
  1662 + store_id: os.stoid,
  1663 + user_id: oo.user_id,
  1664 + goods_id: g_item.goods_id,
  1665 + pick_id: g_item.pickup_id,
  1666 + },
  1667 + }).then(res => {
  1668 + //-------如果购物车中有相关的数据-------
  1669 + if (res.data.data.total > 0) {
  1670 + b_cart_goods = res.data.data.pageData[0];
  1671 + }
  1672 + })
  1673 +
  1674 + //-- 如果就加入过购物车 --
  1675 + if (b_cart_goods) {
  1676 + var updata = {
  1677 + id: b_cart_goods.id,
  1678 + goods_num: newd.goods_num + b_cart_goods.goods_num,
  1679 + goods_price: newd.goods_price,
  1680 + member_goods_price: newd.goods_price,
  1681 + store_id: os.stoid,
  1682 + };
  1683 + if (newd.guide_id) {
  1684 + updata.guide_id = newd.guide_id;
  1685 + updata.guide_type = newd.guide_type;
  1686 + }
  1687 + if (newd.prom_type) {
  1688 + updata.prom_type = newd.prom_type;
  1689 + updata.prom_id = newd.prom_id;
  1690 + }
  1691 +
  1692 + await getApp().request.promisePut("/api/weshop/cart/update", {
  1693 + data: updata
  1694 + }).then(res => {
  1695 + if (res.data.code == 0) {
  1696 + ok_num++;
  1697 + } else {
  1698 + err_text += newd.goods_name + "加入购物车失败\n";
  1699 + }
  1700 + })
  1701 +
  1702 + } else {
  1703 + await getApp().request.promisePost("/api/weshop/cart/save", {
  1704 + data: newd
  1705 + }).then(res => {
  1706 + if (res.data.code == 0) {
  1707 + ok_num++;
  1708 + } else {
  1709 + err_text += newd.goods_name + "加入购物车失败\n";
  1710 + }
  1711 + })
  1712 + }
  1713 + }
  1714 + wx.hideLoading();
  1715 + this.data.moring = 0;
  1716 + if (ok_num == 0) {
  1717 + //-- 如果没有获取用户信息 --
  1718 + wx.showModal({
  1719 + title: '提示',
  1720 + content: err_text,
  1721 + success(res) {}
  1722 + });
  1723 + } else {
  1724 + if (err_text == "") {
  1725 + getApp().goto("/pages/cart/cart/cart");
  1726 + } else {
  1727 + // 如果没有获取用户信息
  1728 + wx.showModal({
  1729 + title: '提示',
  1730 + content: err_text,
  1731 + success(res) {
  1732 + if (res.confirm) {
  1733 + //跳转到登录页
  1734 + getApp().goto("/pages/cart/cart/cart");
  1735 + }
  1736 + }
  1737 + });
  1738 +
  1739 + }
  1740 + }
  1741 + },
  1742 +
  1743 + request_list: function (data, callback) {
  1744 + // console.log('进入request_list');
  1745 +
  1746 + var th = this;
  1747 + if (this.data.is_load2) return false; //-- 正在加载
  1748 + if (this.data.is_no_data2) return false; //-- 没有数据
  1749 + if (this.data.is_no_more2) return false; //-- 没有更多
  1750 +
  1751 + // 开启加载状态
  1752 + this.data.is_load2 = 1;
  1753 +
  1754 + // var req_data = {
  1755 + // page:th.data.currentPage2
  1756 + // }
  1757 +
  1758 + app.request.promiseGet("/api/weshop/order/pagePosOrder", {
  1759 + data: data
  1760 + }).then(res => {
  1761 + // 关闭加载状态
  1762 + th.data.is_load2 = 0;
  1763 + // 请求成功
  1764 + if (res.data.code == 0) {
  1765 + if (res.data.data.pageData.length > 0) {
  1766 + th.data.currentPage2++;
  1767 + var data = res.data.data.pageData;
  1768 + // 判断有无更多数据可以加载,如果大于则没有更多数据,反之则有
  1769 + if (res.data.data.page * res.data.data.pageSize > res.data.data.total) {
  1770 + th.setData({
  1771 + is_no_more2: 1
  1772 + });
  1773 + }
  1774 + var list = th.data.list2;
  1775 + list = list.concat(data);
  1776 + th.setData({
  1777 + list2: list
  1778 + });
  1779 + } else {
  1780 + if (th.data.currentPage2 == 1) {
  1781 + th.setData({
  1782 + is_no_data2: 1
  1783 + });
  1784 + } else {
  1785 + th.setData({
  1786 + is_no_more2: 1
  1787 + });
  1788 + }
  1789 + }
  1790 + if (callback) callback(res);
  1791 + } else {
  1792 + wx.showToast({
  1793 + title: res.data.msg,
  1794 + icon: 'none',
  1795 + duration: 2000
  1796 + })
  1797 + }
  1798 + })
  1799 + },
  1800 +
  1801 +
  1802 + onClickTab(e) {
  1803 + let currentIndex = e.target.dataset.index;
  1804 + this.setData({
  1805 + currentIndex: currentIndex
  1806 + });
  1807 + console.log(this.data.currentIndex);
  1808 + this.setData({
  1809 + is_no_data2: 0,
  1810 + is_no_more2: 0,
  1811 + currentPage2: 1,
  1812 + });
  1813 + if (currentIndex == 0) {
  1814 + console.log('线上订单');
  1815 + /*---
  1816 + this.setData({
  1817 + startDate: '选择开始时间',
  1818 + endDate: '选择结束时间',
  1819 + });--*/
  1820 + } else if (currentIndex == 1) {
  1821 + console.log('线下订单');
  1822 + this.request_list({
  1823 + store_id: os.stoid,
  1824 + user_id: oo.user_id,
  1825 + page: 1,
  1826 + BeginDate: this.data.startDate,
  1827 + EndDate: this.data.endDate
  1828 + });
  1829 + };
  1830 + },
  1831 +
  1832 + bindDateChange1: function (e) {
  1833 + console.log('picker发送选择改变,携带值为', e.detail.value)
  1834 + this.setData({
  1835 + startDate: e.detail.value
  1836 + })
  1837 + },
  1838 +
  1839 + bindDateChange2: function (e) {
  1840 + console.log('picker发送选择改变,携带值为', e.detail.value)
  1841 + this.setData({
  1842 + endDate: e.detail.value
  1843 + })
  1844 + },
  1845 +
  1846 + bindInput(e) {
  1847 + this.data.searchContent = e.detail.value;
  1848 + },
  1849 +
  1850 + searchOnline() {
  1851 + console.log('online', this.data.searchContent);
  1852 + if (this.data.searchContent) {
  1853 + console.log(this.data.searchContent);
  1854 + this.resetData(), this.requestOrderList(this.data.activeCategoryId);
  1855 + } else {
  1856 + wx.showToast({
  1857 + title: '您还没有输入搜索内容~',
  1858 + icon: 'none',
  1859 + })
  1860 + };
  1861 + },
  1862 +
  1863 + searchOffline() {
  1864 + console.log('执行查询');
  1865 + let th = this;
  1866 + let startDate = this.data.startDate;
  1867 + let endDate = this.data.endDate;
  1868 +
  1869 + // this.data.is_no_data2 = 0;
  1870 + this.setData({
  1871 + currentPage2: 1,
  1872 + list2: [],
  1873 + is_no_data2: 0,
  1874 + });
  1875 +
  1876 +
  1877 + if (startDate == '选择开始时间' || endDate == '选择结束时间') {
  1878 + wx.showToast({
  1879 + title: '请选择完整的查询时间~',
  1880 + icon: 'none',
  1881 + })
  1882 + };
  1883 +
  1884 + if (new Date(startDate) > new Date(endDate)) {
  1885 + wx.showToast({
  1886 + title: '不对噢!开始时间不能晚于结束时间~',
  1887 + icon: 'none',
  1888 + })
  1889 + return;
  1890 + };
  1891 +
  1892 +
  1893 + this.request_list({
  1894 + store_id: os.stoid,
  1895 + user_id: oo.user_id,
  1896 + page: 1,
  1897 + BeginDate: this.data.startDate,
  1898 + EndDate: this.data.endDate
  1899 + }, function (res) {
  1900 + if (res.data.data.total == 0) {
  1901 + wx.showToast({
  1902 + title: '没有找到相关订单',
  1903 + icon: 'none',
  1904 + duration: 2000
  1905 + })
  1906 + } else {
  1907 + th.setData({
  1908 + total: res.data.data.total
  1909 + });
  1910 + }
  1911 + });
  1912 + },
  1913 +
  1914 + currentDate() {
  1915 + var now = new Date();
  1916 + var year = now.getFullYear(); //年
  1917 + var month = now.getMonth() + 1; //月
  1918 + var day = now.getDate(); //日
  1919 +
  1920 + var clock = year + "-";
  1921 +
  1922 + if (month < 10) month += "0";
  1923 + clock += month + "-";
  1924 +
  1925 + if (day < 10) day += "0";
  1926 + clock += day;
  1927 +
  1928 + // if(hh < 10)
  1929 + // clock += "0";
  1930 +
  1931 + // clock += hh + ":";
  1932 + // if (mm < 10) clock += '0';
  1933 + // clock += mm + ":";
  1934 +
  1935 + // if (ss < 10) clock += '0';
  1936 + // clock += ss;
  1937 + return clock;
  1938 + },
  1939 +
  1940 + toast(msg) {
  1941 + wx.showToast({
  1942 + title: msg,
  1943 + icon: 'none',
  1944 + duration: 3000
  1945 + })
  1946 + },
  1947 +
  1948 + go_url(e) {
  1949 + var url = e.currentTarget.dataset.url;
  1950 + getApp().goto(url);
1829 1951 }
1830   -
1831   -
  1952 +
  1953 +
1832 1954 });
1833 1955 \ 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  
... ...