Commit c2504e37a03596afe047c3d9a92e3704755f9fda

Authored by yvan.ni
1 parent 526461dc

优惠促销 多活动

components/promate_pop/promate_pop.js
  1 +const ut = require("../../utils/util.js");
1 Component({ 2 Component({
2 /*** 页面的初始数据***/ 3 /*** 页面的初始数据***/
3 data: { 4 data: {
@@ -8,7 +9,9 @@ Component({ @@ -8,7 +9,9 @@ Component({
8 }, 9 },
9 methods: { 10 methods: {
10 //-- 初始化弹出框 -- 11 //-- 初始化弹出框 --
11 - set_init(type,cx_prom_group,is_cart){ 12 + set_init(type,cx_prom_group0,is_cart){
  13 +
  14 + var cx_prom_group=JSON.parse(JSON.stringify(cx_prom_group0));
12 if(!type) type=0; 15 if(!type) type=0;
13 if(!is_cart) is_cart=0; 16 if(!is_cart) is_cart=0;
14 17
@@ -18,6 +21,33 @@ Component({ @@ -18,6 +21,33 @@ Component({
18 if(fd==-1){ 21 if(fd==-1){
19 cx_prom_group[0].sele=1; 22 cx_prom_group[0].sele=1;
20 } 23 }
  24 +
  25 + //-- 优惠促销要重新组装 --
  26 + var yh_index=cx_prom_group.findIndex(function (p_time){
  27 + return p_time.prom_type==3;
  28 + })
  29 + if(yh_index>-1){
  30 + var prom_list=cx_prom_group[yh_index].promGoodsListsDtos;
  31 + //规格参数
  32 + cx_prom_group[yh_index].more=ut.format_yh_act(prom_list[0]);
  33 + cx_prom_group[yh_index].yh_index=0; //优惠阶梯
  34 +
  35 +
  36 + if(prom_list.length){
  37 + for(var i=1;i<prom_list.length;i++){
  38 + var copy_obj=JSON.parse(JSON.stringify(cx_prom_group[yh_index]));
  39 + delete copy_obj.promGoodsListsDtos
  40 + copy_obj.more=ut.format_yh_act(prom_list[i]);
  41 + copy_obj.is_no_sele=1;
  42 + copy_obj.condition=prom_list[i].condition + (prom_list[i].prom_type == 1 ? '件' : '元'),
  43 + copy_obj.limit='每人' + (copy_obj.limit_num ? '限参与' + copy_obj.limit_num + '次' : '参与不限次'),
  44 + copy_obj.yh_index=i; //优惠阶梯
  45 + cx_prom_group.splice(yh_index+i,0,copy_obj);
  46 + }
  47 + }
  48 +
  49 + }
  50 +
21 this.setData({ 51 this.setData({
22 type:type,pro_pop:1,cx_prom_group,is_cart:is_cart 52 type:type,pro_pop:1,cx_prom_group,is_cart:is_cart
23 }) 53 })
@@ -27,10 +57,10 @@ Component({ @@ -27,10 +57,10 @@ Component({
27 close_pro_pop: async function (e) { 57 close_pro_pop: async function (e) {
28 this.setData({pro_pop: 0}); 58 this.setData({pro_pop: 0});
29 if(!this.data.type) return false; 59 if(!this.data.type) return false;
30 - var idx=this.data.cx_prom_group.findIndex(function (e){ 60 + var obj=this.data.cx_prom_group.find(function (e){
31 return e.sele==1; 61 return e.sele==1;
32 }) 62 })
33 - this.triggerEvent('sure_cx_group',{sele_idx:idx},{bubbles: true}); 63 + this.triggerEvent('sure_cx_group',{sele_prom_type:obj.prom_type},{bubbles: true});
34 }, 64 },
35 65
36 go_the_url:function (e){ 66 go_the_url:function (e){
components/promate_pop/promate_pop.wxml
@@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
33 <text wx:if="{{bm.is_fir}}" class="tick pdr20" >{{bm.text}}</text> 33 <text wx:if="{{bm.is_fir}}" class="tick pdr20" >{{bm.text}}</text>
34 <view wx:if="{{bm.is_quan}}">{{bm.text}}</view> 34 <view wx:if="{{bm.is_quan}}">{{bm.text}}</view>
35 <view wx:if="{{bm.is_gift}}" bindtap="show_zp" 35 <view wx:if="{{bm.is_gift}}" bindtap="show_zp"
36 - data-index="0" data-prom="{{bm.prom_id}}" >{{bm.text}}</view> 36 + data-index="{{item.yh_index}}" data-prom="{{bm.prom_id}}" >{{bm.text}}</view>
37 <!-- 旧礼包 --> 37 <!-- 旧礼包 -->
38 <view wx:if="{{bm.lb_id}}" 38 <view wx:if="{{bm.lb_id}}"
39 data-id="{{bm.lb_id}}" bindtap="viewLbDetails">{{bm.text}}</view> 39 data-id="{{bm.lb_id}}" bindtap="viewLbDetails">{{bm.text}}</view>
@@ -54,7 +54,7 @@ @@ -54,7 +54,7 @@
54 <view class="r_item_pro"> 54 <view class="r_item_pro">
55 <view style="text-align: center"> 55 <view style="text-align: center">
56 <!-- 如果是弹出框进行选择的时候 --> 56 <!-- 如果是弹出框进行选择的时候 -->
57 - <block wx:if="{{type==1}}"> 57 + <block wx:if="{{type==1 && !item.is_no_sele}}">
58 <view wx:if="{{item.sele}}" class="circle white xc-hook on"> 58 <view wx:if="{{item.sele}}" class="circle white xc-hook on">
59 <text>Γ</text> 59 <text>Γ</text>
60 </view> 60 </view>
components/promate_pop/promate_pop.wxss
@@ -24,6 +24,8 @@ @@ -24,6 +24,8 @@
24 display: flex; 24 display: flex;
25 justify-content: center; 25 justify-content: center;
26 overflow: hidden; */ 26 overflow: hidden; */
  27 + max-height: 580rpx;
  28 + overflow-y: auto;
27 } 29 }
28 30
29 .xc-top-content { 31 .xc-top-content {
packageE/pages/cart/cart2/cart2.js
@@ -7749,10 +7749,11 @@ Page({ @@ -7749,10 +7749,11 @@ Page({
7749 //--- 选择回来时候的选择 --- 7749 //--- 选择回来时候的选择 ---
7750 sure_cx_group:function(e){ 7750 sure_cx_group:function(e){
7751 var th=this; 7751 var th=this;
7752 - var sele_idx=e.detail.sele_idx; 7752 + //选中的活动类型
  7753 + var sele_prom_type=e.detail.sele_prom_type;
  7754 + //-- 获取到当前的show_can_cx--
7753 var idx=this.data.sele_cx_group_cidx; 7755 var idx=this.data.sele_cx_group_cidx;
7754 var gd_key= this.data.cx_group_gd_key; 7756 var gd_key= this.data.cx_group_gd_key;
7755 - //-- 获取到--  
7756 var cx_prom_group=this.data.cartlist[idx].show_can_cx[gd_key].act_arr; 7757 var cx_prom_group=this.data.cartlist[idx].show_can_cx[gd_key].act_arr;
7757 var pk=this.data.cartlist[idx].pickup_id; 7758 var pk=this.data.cartlist[idx].pickup_id;
7758 7759
@@ -7764,10 +7765,12 @@ Page({ @@ -7764,10 +7765,12 @@ Page({
7764 7765
7765 th.data.prom_goods_map={}; 7766 th.data.prom_goods_map={};
7766 7767
  7768 + //-- 获取第一次选中的 --
7767 var fir_sele=0; 7769 var fir_sele=0;
7768 for(var dx=0;dx<cx_prom_group.length;dx++){ 7770 for(var dx=0;dx<cx_prom_group.length;dx++){
7769 if(cx_prom_group[dx].sele) fir_sele=dx; 7771 if(cx_prom_group[dx].sele) fir_sele=dx;
7770 - if(dx!=sele_idx) cx_prom_group[dx].sele=0; 7772 + //如果活动不是选择的
  7773 + if(cx_prom_group[dx].prom_type!=sele_prom_type) cx_prom_group[dx].sele=0;
7771 else cx_prom_group[dx].sele=1; 7774 else cx_prom_group[dx].sele=1;
7772 } 7775 }
7773 //选择后就要把活动确定下来 7776 //选择后就要把活动确定下来
@@ -7776,7 +7779,6 @@ Page({ @@ -7776,7 +7779,6 @@ Page({
7776 return el.sele; 7779 return el.sele;
7777 }) 7780 })
7778 7781
7779 -  
7780 this.cx_check_ok2(function (ck_res){ 7782 this.cx_check_ok2(function (ck_res){
7781 7783
7782 if(ck_res.code==0){ 7784 if(ck_res.code==0){
@@ -7800,6 +7802,9 @@ Page({ @@ -7800,6 +7802,9 @@ Page({
7800 th.data.cartlist[idx].goods[ik].prom_id= goods[fg].prom_id; 7802 th.data.cartlist[idx].goods[ik].prom_id= goods[fg].prom_id;
7801 } 7803 }
7802 } 7804 }
  7805 +
  7806 + //原始数据要有深拷贝不能有地址的牵连
  7807 + th.data.cartlist_y=JSON.parse(JSON.stringify(goods))
7803 } 7808 }
7804 } 7809 }
7805 7810
pages/cart/cart/cart.js
@@ -1152,7 +1152,7 @@ Page({ @@ -1152,7 +1152,7 @@ Page({
1152 var th = this; 1152 var th = this;
1153 1153
1154 if (a = isNaN(t.detail.value) || t.detail.value < 1 ? 1 : parseInt(t.detail.value)) { 1154 if (a = isNaN(t.detail.value) || t.detail.value < 1 ? 1 : parseInt(t.detail.value)) {
1155 - this.clear_req(); 1155 + //this.clear_req();
1156 1156
1157 var s = { 1157 var s = {
1158 goods_num: a, 1158 goods_num: a,
@@ -1218,7 +1218,7 @@ Page({ @@ -1218,7 +1218,7 @@ Page({
1218 } 1218 }
1219 } 1219 }
1220 1220
1221 - this.clear_req(); 1221 + //this.clear_req();
1222 1222
1223 var e = { 1223 var e = {
1224 goods_num: a.goods_num + add_num, 1224 goods_num: a.goods_num + add_num,
@@ -1247,7 +1247,7 @@ Page({ @@ -1247,7 +1247,7 @@ Page({
1247 } 1247 }
1248 1248
1249 if (1 != a.goods_num) { 1249 if (1 != a.goods_num) {
1250 - this.clear_req(); 1250 + //this.clear_req();
1251 var add_num = 1; 1251 var add_num = 1;
1252 if ([0, 3, 5, 7, 10].indexOf(a.prom_type) > -1) { 1252 if ([0, 3, 5, 7, 10].indexOf(a.prom_type) > -1) {
1253 var cx_arr = await getApp().get_has_cx_act(a.goods_id); 1253 var cx_arr = await getApp().get_has_cx_act(a.goods_id);
@@ -4066,7 +4066,7 @@ Page({ @@ -4066,7 +4066,7 @@ Page({
4066 } 4066 }
4067 4067
4068 var t_zp_num = parseInt(discount.zp_num) * parseInt(discount.bs); 4068 var t_zp_num = parseInt(discount.zp_num) * parseInt(discount.bs);
4069 - if (th.data.duo_zp_num_arr[prom.id]) { 4069 + if (th.data.duo_zp_num_arr && th.data.duo_zp_num_arr[prom.id]) {
4070 t_zp_num += th.data.duo_zp_num_arr[prom.id]; 4070 t_zp_num += th.data.duo_zp_num_arr[prom.id];
4071 } 4071 }
4072 4072
@@ -4075,6 +4075,7 @@ Page({ @@ -4075,6 +4075,7 @@ Page({
4075 json.prom_id = prom.id; 4075 json.prom_id = prom.id;
4076 json.prom_name = prom.name; 4076 json.prom_name = prom.name;
4077 send_gift_arr.push(json); 4077 send_gift_arr.push(json);
  4078 + if(!th.data.duo_zp_num_arr) th.data.duo_zp_num_arr={};
4078 th.data.duo_zp_num_arr[prom.id] = t_zp_num; 4079 th.data.duo_zp_num_arr[prom.id] = t_zp_num;
4079 } 4080 }
4080 4081
@@ -4656,17 +4657,16 @@ Page({ @@ -4656,17 +4657,16 @@ Page({
4656 //--- 选择回来时候的选择 --- 4657 //--- 选择回来时候的选择 ---
4657 sure_cx_group: function (e) { 4658 sure_cx_group: function (e) {
4658 var th = this; 4659 var th = this;
4659 - var sele_idx = e.detail.sele_idx; 4660 + var sele_prom_type=e.detail.sele_prom_type;
  4661 + //-- 获取到当前的 show_can_cx--
4660 var idx = this.data.sele_cx_group_cidx; 4662 var idx = this.data.sele_cx_group_cidx;
4661 var gd_key = this.data.cx_group_gd_key; 4663 var gd_key = this.data.cx_group_gd_key;
4662 - //-- 获取到--  
4663 var cx_prom_group = this.data.requestData[idx].show_can_cx[gd_key].act_arr; 4664 var cx_prom_group = this.data.requestData[idx].show_can_cx[gd_key].act_arr;
4664 4665
4665 var fir_sele = 0; 4666 var fir_sele = 0;
4666 -  
4667 for (var dx = 0; dx < cx_prom_group.length; dx++) { 4667 for (var dx = 0; dx < cx_prom_group.length; dx++) {
4668 if (cx_prom_group[dx].sele) fir_sele = dx; 4668 if (cx_prom_group[dx].sele) fir_sele = dx;
4669 - if (dx != sele_idx) cx_prom_group[dx].sele = 0; 4669 + if (cx_prom_group[dx].prom_type!= sele_prom_type) cx_prom_group[dx].sele = 0;
4670 else cx_prom_group[dx].sele = 1; 4670 else cx_prom_group[dx].sele = 1;
4671 } 4671 }
4672 4672
pages/goods/goodsInfo/goodsInfo.js
@@ -7619,84 +7619,85 @@ Page({ @@ -7619,84 +7619,85 @@ Page({
7619 await this.getUserBuyPromNum_pre(fir_act.prom_id); 7619 await this.getUserBuyPromNum_pre(fir_act.prom_id);
7620 7620
7621 if (!fir_act.limit_num || th.data.user_pre_buynum < fir_act.limit_num) { 7621 if (!fir_act.limit_num || th.data.user_pre_buynum < fir_act.limit_num) {
7622 - var more_arr = [];  
7623 - //减价  
7624 - if (fir_act.money > 0){  
7625 -  
7626 - more_arr.push({  
7627 - text:'减价' + fir_act.money + '元',  
7628 - is_fir:1  
7629 - });  
7630 - }  
7631 - if (fir_act.sale > 0) {  
7632 - more_arr.push({  
7633 - text:'打' + fir_act.sale + '折',  
7634 - is_fir:1  
7635 - });  
7636 - }  
7637 - if (fir_act.past == 1) {  
7638 - more_arr.push({  
7639 - text:'包邮',  
7640 - is_fir:1  
7641 - });  
7642 - }  
7643 - if (fir_act.intValue > 0){  
7644 - more_arr.push({  
7645 - text:'送' + fir_act.intValue + '积分',  
7646 - is_fir:1  
7647 - });  
7648 - }  
7649 - if (fir_act.couponId > 0) {  
7650 - more_arr.push({  
7651 - text:'送' + fir_act.couponMoney + '元优惠券',  
7652 - is_quan:1  
7653 - });  
7654 - }  
7655 -  
7656 - if (fir_act.gift_id) {  
7657 - var is_more_gf = fir_act.gift_id.split(',')  
7658 - if (is_more_gf.length > 1) {  
7659 - more_arr.push({  
7660 - text:'送赠品',  
7661 - is_gift:1,  
7662 - prom_id:fir_act.prom_id  
7663 - });  
7664 - } else {  
7665 - more_arr.push({  
7666 - text:'送' + fir_act.goods_name + ' x' + fir_act.zp_num,  
7667 - is_gift:1,  
7668 - prom_id:fir_act.prom_id  
7669 - });  
7670 - }  
7671 - }  
7672 - if (fir_act.lb_id){  
7673 - more_arr.push({  
7674 - text:'送' + fir_act.lbtitle,  
7675 - lb_id:fir_act.lb_id  
7676 - });  
7677 - }  
7678 - if (fir_act.zxlb_id){  
7679 - more_arr.push({  
7680 - text:'送' + fir_act.zxlbtitle,  
7681 - zxlb_id:fir_act.zxlb_id  
7682 - });  
7683 - }  
7684 - if (fir_act.monthgiftbag_id){  
7685 - more_arr.push({  
7686 - text:'送' + fir_act.monthgiftbag_title,  
7687 - monthgiftbag_id:fir_act.monthgiftbag_id  
7688 - });  
7689 - }  
7690 - 7622 + // var more_arr = [];
  7623 + // //减价
  7624 + // if (fir_act.money > 0){
  7625 + //
  7626 + // more_arr.push({
  7627 + // text:'减价' + fir_act.money + '元',
  7628 + // is_fir:1
  7629 + // });
  7630 + // }
  7631 + // if (fir_act.sale > 0) {
  7632 + // more_arr.push({
  7633 + // text:'打' + fir_act.sale + '折',
  7634 + // is_fir:1
  7635 + // });
  7636 + // }
  7637 + // if (fir_act.past == 1) {
  7638 + // more_arr.push({
  7639 + // text:'包邮',
  7640 + // is_fir:1
  7641 + // });
  7642 + // }
  7643 + // if (fir_act.intValue > 0){
  7644 + // more_arr.push({
  7645 + // text:'送' + fir_act.intValue + '积分',
  7646 + // is_fir:1
  7647 + // });
  7648 + // }
  7649 + // if (fir_act.couponId > 0) {
  7650 + // more_arr.push({
  7651 + // text:'送' + fir_act.couponMoney + '元优惠券',
  7652 + // is_quan:1
  7653 + // });
  7654 + // }
  7655 + //
  7656 + // if (fir_act.gift_id) {
  7657 + // var is_more_gf = fir_act.gift_id.split(',')
  7658 + // if (is_more_gf.length > 1) {
  7659 + // more_arr.push({
  7660 + // text:'送赠品',
  7661 + // is_gift:1,
  7662 + // prom_id:fir_act.prom_id
  7663 + // });
  7664 + // } else {
  7665 + // more_arr.push({
  7666 + // text:'送' + fir_act.goods_name + ' x' + fir_act.zp_num,
  7667 + // is_gift:1,
  7668 + // prom_id:fir_act.prom_id
  7669 + // });
  7670 + // }
  7671 + // }
  7672 + // if (fir_act.lb_id){
  7673 + // more_arr.push({
  7674 + // text:'送' + fir_act.lbtitle,
  7675 + // lb_id:fir_act.lb_id
  7676 + // });
  7677 + // }
  7678 + // if (fir_act.zxlb_id){
  7679 + // more_arr.push({
  7680 + // text:'送' + fir_act.zxlbtitle,
  7681 + // zxlb_id:fir_act.zxlb_id
  7682 + // });
  7683 + // }
  7684 + // if (fir_act.monthgiftbag_id){
  7685 + // more_arr.push({
  7686 + // text:'送' + fir_act.monthgiftbag_title,
  7687 + // monthgiftbag_id:fir_act.monthgiftbag_id
  7688 + // });
  7689 + // }
  7690 + var more_arr=ut.format_yh_act(fir_act);
7691 //-- 开始组装数据 -- 7691 //-- 开始组装数据 --
7692 th.add_cx_prom_group({ 7692 th.add_cx_prom_group({
7693 id: fir_act.prom_id, 7693 id: fir_act.prom_id,
7694 condition: fir_act.condition + (fir_act.prom_type == 1 ? '件' : '元'), 7694 condition: fir_act.condition + (fir_act.prom_type == 1 ? '件' : '元'),
7695 limit: '每人' + (fir_act.limit_num ? '限参与' + fir_act.limit_num + '次' : '参与不限次'), 7695 limit: '每人' + (fir_act.limit_num ? '限参与' + fir_act.limit_num + '次' : '参与不限次'),
7696 more: more_arr, 7696 more: more_arr,
7697 - prom_type: 3  
7698 - 7697 + prom_type: 3,
  7698 + promGoodsListsDtos:r_data.promGoodsLists
7699 }); 7699 });
  7700 +
7700 } 7701 }
7701 7702
7702 } 7703 }
utils/util.js
@@ -799,6 +799,80 @@ module.exports = { @@ -799,6 +799,80 @@ module.exports = {
799 return false 799 return false
800 }, 800 },
801 801
  802 + //优惠促销的数据的格式话
  803 + format_yh_act(fir_act){
  804 + var more_arr = [];
  805 + if(fir_act){
  806 + //减价
  807 + if (fir_act.money > 0){
  808 +
  809 + more_arr.push({
  810 + text:'减价' + fir_act.money + '元',
  811 + is_fir:1
  812 + });
  813 + }
  814 + if (fir_act.sale > 0) {
  815 + more_arr.push({
  816 + text:'打' + fir_act.sale + '折',
  817 + is_fir:1
  818 + });
  819 + }
  820 + if (fir_act.past == 1) {
  821 + more_arr.push({
  822 + text:'包邮',
  823 + is_fir:1
  824 + });
  825 + }
  826 + if (fir_act.intValue > 0){
  827 + more_arr.push({
  828 + text:'送' + fir_act.intValue + '积分',
  829 + is_fir:1
  830 + });
  831 + }
  832 + if (fir_act.couponId > 0) {
  833 + more_arr.push({
  834 + text:'送' + fir_act.couponMoney + '元优惠券',
  835 + is_quan:1
  836 + });
  837 + }
  838 +
  839 + if (fir_act.gift_id) {
  840 + var is_more_gf = fir_act.gift_id.split(',')
  841 + if (is_more_gf.length > 1) {
  842 + more_arr.push({
  843 + text:'送赠品',
  844 + is_gift:1,
  845 + prom_id:fir_act.prom_id
  846 + });
  847 + } else {
  848 + more_arr.push({
  849 + text:'送' + fir_act.goods_name + ' x' + fir_act.zp_num,
  850 + is_gift:1,
  851 + prom_id:fir_act.prom_id
  852 + });
  853 + }
  854 + }
  855 + if (fir_act.lb_id){
  856 + more_arr.push({
  857 + text:'送' + fir_act.lbtitle,
  858 + lb_id:fir_act.lb_id
  859 + });
  860 + }
  861 + if (fir_act.zxlb_id){
  862 + more_arr.push({
  863 + text:'送' + fir_act.zxlbtitle,
  864 + zxlb_id:fir_act.zxlb_id
  865 + });
  866 + }
  867 + if (fir_act.monthgiftbag_id){
  868 + more_arr.push({
  869 + text:'送' + fir_act.monthgiftbag_title,
  870 + monthgiftbag_id:fir_act.monthgiftbag_id
  871 + });
  872 + }
  873 + }
  874 + return more_arr
  875 + },
802 876
803 unserialize: unserialize, 877 unserialize: unserialize,
804 _throttle:_throttle, 878 _throttle:_throttle,