Commit 9c8668fd4536ca8385af2b5b05279f5ed776fa32

Authored by yvan.ni
1 parent eed9f7a2

阶梯促销

pages/cart/cart/cart.js
... ... @@ -356,7 +356,6 @@ Page({
356 356 })
357 357 }
358 358 }
359   -
360 359 //--判断优惠活动有没有过期,--
361 360 else if (item.prom_type == 3) {
362 361 var isok = 1,is_g_prom=0;
... ... @@ -436,8 +435,6 @@ Page({
436 435  
437 436 if (!isok) continue;
438 437  
439   -
440   -
441 438 }
442 439 else if (item.prom_type == 7) {
443 440 if(!th.data.zuhe_map[item.prom_id]){
... ... @@ -599,9 +596,79 @@ Page({
599 596 });
600 597 item.prom_type=3;
601 598 item.prom_id=r_data.promGoodsLists[0].prom_id;
  599 + }else if(r_data.ladderLists){
  600 + var url = '/api/weshop/cart/update';
  601 + getApp().request.put(url, {
  602 + data:{id:item.id,store_id:oo.stoid,prom_type:10,prom_id:r_data.ladderLists[0].form_id}
  603 + });
  604 + item.prom_type=10;
  605 + item.prom_id=r_data.ladderLists[0].form_id;
  606 +
602 607 }
603 608 }
604 609 })
  610 +
  611 + //如果是阶梯购的时候
  612 + if(item.prom_type==10){
  613 + if(!th.data.ladder_map[item.prom_id]){
  614 + //如果有阶梯购,要判断身份
  615 + var isok = 1;
  616 + var is_flag=1;
  617 + var act=null;
  618 + var url="/api/weshop/prom/ladderForm/getNew/"+os.stoid+"/"+user_id+"/"+item.prom_id;
  619 + await getApp().request.promiseGet(url, {}).then(res => {
  620 + console.log(res,1000);
  621 + if(res.data.code==0 && res.data.data){
  622 + if(res.data.data.isuse!=1){
  623 + isok=0;
  624 + }
  625 + //如果活动已经结束
  626 + if(res.data.data.is_end==1){
  627 + isok=0;
  628 + }
  629 + //已经结束
  630 + if(ut.gettimestamp()>res.data.data.end_time){
  631 + isok=0;
  632 + }
  633 + //还未开始
  634 + if(ut.gettimestamp()<res.data.data.start_time){
  635 + isok=0;
  636 + }
  637 + act=res.data.data;
  638 +
  639 + }else{
  640 + //未找到商品的活动
  641 + isok = 0;
  642 + }
  643 + })
  644 + if (!isok){
  645 + item.prom_type=0;
  646 + item.prom_id=0;
  647 + continue;
  648 +
  649 + }
  650 + th.data.ladder_map[item.prom_id]=act;
  651 + //-- 获取阶梯规则 --
  652 + var url1 = "/api/weshop/prom/ladderList/list";
  653 + var req_data = {
  654 + store_id: os.stoid,
  655 + form_id: item.prom_id,
  656 + }
  657 + await getApp().request.promiseGet(url1, {
  658 + data: req_data
  659 + }).then(rs1 => {
  660 + if (rs1.data.code==0 && rs1.data.data) {
  661 + var gdlist = rs1.data.data;
  662 + th.data.ladder_map[item.prom_id].ladder_list=gdlist;
  663 + }
  664 + })
  665 + }
  666 + //直接把活动赋值给元素
  667 + if(th.data.ladder_map[item.prom_id] && th.data.ladder_map[item.prom_id]!=-1 ){
  668 + item.act=th.data.ladder_map[item.prom_id];
  669 + }
  670 + }
  671 +
605 672 }
606 673  
607 674 all_num += item.goods_num;
... ... @@ -1442,8 +1509,7 @@ Page({
1442 1509 if(car && car.length>0){
1443 1510 th.data.in_zhact_gdmap={};
1444 1511 for (var a = 0; a < car.length; a++) {
1445   - var item = car[a].goods,
1446   - is_s_sele = 1;
  1512 + var item = car[a].goods,is_s_sele = 1;
1447 1513 var offline_price=0;
1448 1514 var offline_num=0;
1449 1515 for (var c = 0; c < item.length; c++) {
... ...
pages/cart/cart2/ladder_calculate.js
... ... @@ -67,7 +67,8 @@ module.exports = {
67 67 //-- 单个文件新增 --
68 68 let new_g = JSON.parse(JSON.stringify(end.item));
69 69 new_g.goods_num = 1;
70   - new_g.account = account.toFixed(2);
  70 + //如果有平摊到单品的时候,account要显示
  71 + if(!th.data.ispt_goods) new_g.account = account.toFixed(2);
71 72 new_g.discount = item_j.discount;
72 73 new_g.goods_price =new_price;
73 74 new_g.ladder_list_id =item_j.id;
... ...
pages/user/order_detail/order_detail.js
... ... @@ -101,7 +101,25 @@ Page({
101 101 r.order_status_detail = "组团中";
102 102  
103 103  
104   - r['is_all_return'] = 0;
  104 + r['is_all_return'] = 0;
  105 +
  106 + var discount_price=r['discount_amount'];
  107 + var dis_json=r['prom_pt_json'];
  108 +
  109 + if(dis_json && discount_price){
  110 + var prom_pt_json=JSON.parse(dis_json);
  111 + var ladder_amount=0;
  112 + for (var ll_item of prom_pt_json) {
  113 + if(ll_item['ladder_prom_id']){
  114 + ladder_amount += ll_item['dis'];
  115 + }
  116 + }
  117 + r['ladder_amount']=ladder_amount;
  118 + r['discount_amount']=Math.floor((discount_price-ladder_amount)*100)/100;
  119 + }
  120 +
  121 +
  122 +
105 123  
106 124 //------获取订单商品-------
107 125 rq.get("/api/weshop/ordergoods/list",{
... ...
pages/user/order_detail/order_detail.wxml
... ... @@ -120,7 +120,12 @@
120 120  
121 121 <view class="item pnew" wx:if="{{order.discount_amount>0}}">
122 122 <view>优惠活动</view>
123   - <view>¥ {{order.discount_amount}}元</view>
  123 + <view>¥ {{filters.toFix(order.discount_amount,2)}}元</view>
  124 + </view>
  125 +
  126 + <view class="item pnew" wx:if="{{order.ladder_amount>0}}">
  127 + <view>阶梯优惠活动</view>
  128 + <view>¥ {{filters.toFix(order.ladder_amount,2)}}元</view>
124 129 </view>
125 130  
126 131 <view class="item pnew" wx:if="{{order.order_prom_amount>0}}">
... ...