Commit 5b4a9bc70784de63c6fc26b8d4dabdb1ce8f329d
1 parent
5ed41758
不参与活动的优化
Showing
3 changed files
with
71 additions
and
6 deletions
packageE/pages/cart/cart2/cart2.js
| @@ -934,11 +934,11 @@ Page({ | @@ -934,11 +934,11 @@ Page({ | ||
| 934 | } | 934 | } |
| 935 | } | 935 | } |
| 936 | } | 936 | } |
| 937 | - | ||
| 938 | } | 937 | } |
| 938 | + | ||
| 939 | //按门店分类的数组 | 939 | //按门店分类的数组 |
| 940 | var arr = new Array(); | 940 | var arr = new Array(); |
| 941 | - | 941 | + |
| 942 | var th=this; | 942 | var th=this; |
| 943 | th.data.in_zhact_gdmap = {}; | 943 | th.data.in_zhact_gdmap = {}; |
| 944 | //---是不是购买等级卡成功的返回---等级卡显示的判断--- | 944 | //---是不是购买等级卡成功的返回---等级卡显示的判断--- |
| @@ -8342,8 +8342,69 @@ Page({ | @@ -8342,8 +8342,69 @@ Page({ | ||
| 8342 | }, | 8342 | }, |
| 8343 | 8343 | ||
| 8344 | //--- 不参与优惠促销的开关 --- | 8344 | //--- 不参与优惠促销的开关 --- |
| 8345 | - no_cj_prom:function (e){ | ||
| 8346 | - let can_cx_idx=e.currentTarget.dataset.can_cx_idx; | 8345 | + no_cj_prom: function (e) { |
| 8346 | + | ||
| 8347 | + let th=this; | ||
| 8348 | + let can_cx_idx = e.currentTarget.dataset.can_cx_idx; //多促销的索引 | ||
| 8349 | + let pidx = e.currentTarget.dataset.pidx; //订单索引 | ||
| 8350 | + let item = this.data.cartlist[pidx].show_can_cx[can_cx_idx]; //促销内容 | ||
| 8351 | + let pk=this.data.cartlist[pidx].pickup_id; //门店ID | ||
| 8352 | + | ||
| 8353 | + //给no_cj_prom进行赋值 | ||
| 8354 | + item.no_cj_prom = !item.no_cj_prom ? 1 : 0; | ||
| 8355 | + var txt = 'cartlist[' + pidx + '].show_can_cx'; | ||
| 8356 | + this.setData({ | ||
| 8357 | + [txt]: this.data.cartlist[pidx].show_can_cx, | ||
| 8358 | + }) | ||
| 8359 | + | ||
| 8360 | + let ck_prom_type=item.cur_act; | ||
| 8361 | + //处理一下商品 | ||
| 8362 | + let goods0 = JSON.parse(JSON.stringify(th.data.cartlist_y)); | ||
| 8363 | + let goods = []; | ||
| 8364 | + for (var ik = 0; ik < goods0.length; ik++) { | ||
| 8365 | + var item_c = goods0[ik]; | ||
| 8366 | + if (item_c.pick_id == pk && item_c.is_collocation) continue; | ||
| 8367 | + goods.push(item_c); | ||
| 8368 | + } | ||
| 8369 | + | ||
| 8370 | + //-- 此时要把购物车中的商品确定活动 -- | ||
| 8371 | + for (var b = 0; b < ck_prom_type.goods.length; b++) { | ||
| 8372 | + //-- 开始查找 -- | ||
| 8373 | + var fg = goods.findIndex(function (g_item) { | ||
| 8374 | + return g_item.goods_id == ck_prom_type.goods[b].goods_id | ||
| 8375 | + && [0, 3, 5, 7, 10].indexOf(g_item.prom_type) > -1 | ||
| 8376 | + && g_item.pick_id == pk && g_item.is_gift == 0; | ||
| 8377 | + }) | ||
| 8378 | + if (fg > -1) { | ||
| 8379 | + goods[fg].prom_type = ck_prom_type.prom_type; | ||
| 8380 | + goods[fg].prom_id = ck_prom_type.prom_id; | ||
| 8381 | + | ||
| 8382 | + //如果是不参与的话,商品的活动状态要清理 | ||
| 8383 | + if(item.no_cj_prom){ | ||
| 8384 | + goods[fg].prom_type=0; | ||
| 8385 | + goods[fg].prom_id=0; | ||
| 8386 | + } | ||
| 8387 | + | ||
| 8388 | + for (var ik = 0; ik < th.data.cartlist[pidx].goods.length; ik++) { | ||
| 8389 | + if (th.data.cartlist[pidx].goods[ik].id == goods[fg].id) { | ||
| 8390 | + th.data.cartlist[pidx].goods[ik].prom_type = goods[fg].prom_type; | ||
| 8391 | + th.data.cartlist[pidx].goods[ik].prom_id = goods[fg].prom_id; | ||
| 8392 | + } | ||
| 8393 | + } | ||
| 8394 | + } | ||
| 8395 | + } | ||
| 8396 | + | ||
| 8397 | + //原始数据要有深拷贝不能有地址的牵连 | ||
| 8398 | + th.data.cartlist_y = JSON.parse(JSON.stringify(goods)) | ||
| 8399 | + | ||
| 8400 | + | ||
| 8401 | + //重新调用cart_next,进行下一步计算 | ||
| 8402 | + wx.showLoading({ | ||
| 8403 | + title: "处理中.", | ||
| 8404 | + }) | ||
| 8405 | + this.get_cart_next(null, 1, {prom_type: 0, prom_id: 0}); | ||
| 8406 | + | ||
| 8407 | + | ||
| 8347 | } | 8408 | } |
| 8348 | 8409 | ||
| 8349 | 8410 |
packageE/pages/cart/cart2/cart2.wxml
| @@ -171,7 +171,7 @@ | @@ -171,7 +171,7 @@ | ||
| 171 | </block> | 171 | </block> |
| 172 | </block> | 172 | </block> |
| 173 | 173 | ||
| 174 | - <view class="set-mes" wx:if="{{items.prom_type==3 || items.cj_prom_type==3}}"> | 174 | + <view class="set-mes" wx:if="{{items.prom_type==3 || (items.prom_type==0 && item.show_can_cx[items.goods_id].no_cj_prom) }}"> |
| 175 | <view class="use-item" data-pidx="{{pidx}}" data-can_cx_idx="{{items.goods_id}}" bindtap='no_cj_prom'> | 175 | <view class="use-item" data-pidx="{{pidx}}" data-can_cx_idx="{{items.goods_id}}" bindtap='no_cj_prom'> |
| 176 | <icon color="{{!item.show_can_cx[items.goods_id].no_cj_prom?'red':'gray'}}" size="16" type="success"></icon> | 176 | <icon color="{{!item.show_can_cx[items.goods_id].no_cj_prom?'red':'gray'}}" size="16" type="success"></icon> |
| 177 | <view class="yu_er">参与优惠活动</view> | 177 | <view class="yu_er">参与优惠活动</view> |
| @@ -231,7 +231,7 @@ | @@ -231,7 +231,7 @@ | ||
| 231 | </view> | 231 | </view> |
| 232 | </block> | 232 | </block> |
| 233 | 233 | ||
| 234 | - <view class="set-mes" wx:if="{{(items.prom_type==3 || items.cj_prom_type==3) && util.check_is_last(index,items.goods_id) && pitem.is_duo_gd }}"> | 234 | + <view class="set-mes" wx:if="{{pitem.is_duo_gd && (items.prom_type==3 || items.cj_prom_type==3) && util.check_is_last(index,items.goods_id) }}"> |
| 235 | <view class="use-item" data-pidx="{{pidx}}" data-can_cx_idx="{{index}}" bindtap='no_cj_prom'> | 235 | <view class="use-item" data-pidx="{{pidx}}" data-can_cx_idx="{{index}}" bindtap='no_cj_prom'> |
| 236 | <icon color="{{!item.show_can_cx[items.goods_id].no_cj_prom?'red':'gray'}}" size="16" type="success"></icon> | 236 | <icon color="{{!item.show_can_cx[items.goods_id].no_cj_prom?'red':'gray'}}" size="16" type="success"></icon> |
| 237 | <view class="yu_er">参与优惠活动</view> | 237 | <view class="yu_er">参与优惠活动</view> |
packageE/pages/cart/cart2/filter.wxs
| @@ -27,6 +27,10 @@ function check_show(items,sele_prom_type){ | @@ -27,6 +27,10 @@ function check_show(items,sele_prom_type){ | ||
| 27 | //is_act_last 是不是最后一个 | 27 | //is_act_last 是不是最后一个 |
| 28 | 28 | ||
| 29 | function check_is_last(index,goods_id){ | 29 | function check_is_last(index,goods_id){ |
| 30 | + | ||
| 31 | + if(!index) index=''; | ||
| 32 | + index+=''; | ||
| 33 | + | ||
| 30 | var gd_arr=index.split(','); | 34 | var gd_arr=index.split(','); |
| 31 | var idx=-1; | 35 | var idx=-1; |
| 32 | //-- 判断有没有包含商品 -- | 36 | //-- 判断有没有包含商品 -- |