Commit b7299f21a10f36ef698027d8c6b3aa677e5f01df
1 parent
11466af4
购物车多促销再切换活动的优化
Showing
6 changed files
with
243 additions
and
38 deletions
components/promate_pop/promate_pop.js
| ... | ... | @@ -4,23 +4,35 @@ Component({ |
| 4 | 4 | type:0, //0只显示再商品详情页面 1显示再有选择按钮 |
| 5 | 5 | pro_pop:0, //是否弹出 |
| 6 | 6 | cx_prom_group:[], //弹出框的内容展示 |
| 7 | + is_cart:0 | |
| 7 | 8 | }, |
| 8 | 9 | methods: { |
| 9 | 10 | //-- 初始化弹出框 -- |
| 10 | - set_init(type,cx_prom_group){ | |
| 11 | + set_init(type,cx_prom_group,is_cart){ | |
| 11 | 12 | if(!type) type=0; |
| 13 | + if(!is_cart) is_cart=0; | |
| 12 | 14 | |
| 15 | + var fd=cx_prom_group.findIndex(function (gh){ | |
| 16 | + return gh.sele | |
| 17 | + }) | |
| 18 | + if(fd==-1){ | |
| 19 | + cx_prom_group[0].sele=1; | |
| 20 | + } | |
| 13 | 21 | this.setData({ |
| 14 | - type:type,pro_pop:1,cx_prom_group | |
| 22 | + type:type,pro_pop:1,cx_prom_group,is_cart:is_cart | |
| 15 | 23 | }) |
| 16 | 24 | }, |
| 17 | 25 | |
| 18 | - /*----pop的开关---*/ | |
| 26 | + /*----pop的开关,如果按钮是‘确定’,就要返回参数给父层组件---*/ | |
| 19 | 27 | close_pro_pop: async function (event) { |
| 20 | - this.setData({pro_pop: 0}); | |
| 28 | + this.setData({pro_pop: 0}); | |
| 29 | + if(!this.data.type) return false; | |
| 30 | + var idx=this.data.cx_prom_group.findIndex(function (e){ | |
| 31 | + return e.sele==1; | |
| 32 | + }) | |
| 33 | + this.triggerEvent('sure_cx_group',{sele_idx:idx},{bubbles: true}); | |
| 21 | 34 | }, |
| 22 | 35 | |
| 23 | - | |
| 24 | 36 | go_the_url:function (e){ |
| 25 | 37 | var prom_id = e.currentTarget.dataset.id; |
| 26 | 38 | var prom_type = e.currentTarget.dataset.prom_type; |
| ... | ... | @@ -37,15 +49,24 @@ Component({ |
| 37 | 49 | } |
| 38 | 50 | break; |
| 39 | 51 | case 7: |
| 40 | - url="/packageB/pages/zuhegou/index/index?id=" + id | |
| 52 | + url="/packageB/pages/zuhegou/index/index?id=" + prom_id | |
| 41 | 53 | break; |
| 42 | 54 | case 10: |
| 43 | 55 | url="/pages/goods/goodsList/goodsList?ladder_id=" + prom_id; |
| 44 | 56 | break; |
| 45 | 57 | } |
| 46 | 58 | getApp().goto(url); |
| 59 | + }, | |
| 47 | 60 | |
| 48 | - | |
| 61 | + //-- 选择活动 -- | |
| 62 | + sele_act:function (e){ | |
| 63 | + var index=e.currentTarget.dataset.index; | |
| 64 | + var cx_prom_group=this.data.cx_prom_group; | |
| 65 | + for (var idx=0;idx<cx_prom_group.length;idx++){ | |
| 66 | + if(idx!=index) cx_prom_group[idx].sele=0; | |
| 67 | + else cx_prom_group[idx].sele=1; | |
| 68 | + } | |
| 69 | + this.setData({cx_prom_group}) | |
| 49 | 70 | } |
| 50 | 71 | |
| 51 | 72 | } | ... | ... |
components/promate_pop/promate_pop.wxml
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | <!-- --弹起领券-- --> |
| 3 | 3 | <view wx:if='{{pro_pop==1}}'> |
| 4 | 4 | <view class="cover-layer flex-center" bindtap="close_pro_pop"></view> |
| 5 | - <view class="cx-popup {{pro_pop== true ? 'up_pro' : 'down_pro'}} "> | |
| 5 | + <view class="cx-popup {{pro_pop== true ? 'up_pro' : 'down_pro'}} {{is_cart?'cart_show':''}}" style="z-index: 3500" > | |
| 6 | 6 | <view class="top-frame"> |
| 7 | 7 | <view class="top t-c">促销列表</view> |
| 8 | 8 | </view> |
| ... | ... | @@ -10,7 +10,6 @@ |
| 10 | 10 | <view class="xc-frame"> |
| 11 | 11 | <view class="top-frame"> |
| 12 | 12 | <view class="xc-coupon-frame "> |
| 13 | - | |
| 14 | 13 | <!-- for循环显示内容 --> |
| 15 | 14 | <view wx:for="{{cx_prom_group}}" class="item_pro flex ai-center"> |
| 16 | 15 | <view class="tab_bx fs24">{{p_fil.set_tab_title(item)}}</view> |
| ... | ... | @@ -23,7 +22,7 @@ |
| 23 | 22 | <view wx:else class="fs26">{{item.title}} |
| 24 | 23 | 消费满<text class="c-red">{{item.condition}}</text>享优惠({{item.limit}}) |
| 25 | 24 | </view> |
| 26 | - <view wx:if="{{item.prom_type!=5}}" class="fs26">搭配价:<text class="c-red">{{item.show_price}}</text></view> | |
| 25 | + <view wx:if="{{item.prom_type==5}}" class="fs26">搭配价:<text class="c-red">{{item.show_price}}</text></view> | |
| 27 | 26 | |
| 28 | 27 | <view wx:if="{{item.prom_type!=3}}" class="fs22" style="color: #b9b6b6"> |
| 29 | 28 | {{item.show_time}} |
| ... | ... | @@ -31,14 +30,30 @@ |
| 31 | 30 | <view wx:else class="fs22" style="max-width: 430rpx; color: #b9b6b6"> |
| 32 | 31 | <text wx:for="{{item.more}}" wx:for-item="bm" class="tick pdr20" >{{bm}}</text> |
| 33 | 32 | </view> |
| 33 | + </view> | |
| 34 | + | |
| 35 | + | |
| 36 | + <view class="r_item_pro"> | |
| 37 | + <view style="text-align: center"> | |
| 38 | + <!-- 如果是弹出框进行选择的时候 --> | |
| 39 | + <block wx:if="{{type==1}}"> | |
| 40 | + <view wx:if="{{item.sele}}" class="circle white xc-hook on"> | |
| 41 | + <text>Γ</text> | |
| 42 | + </view> | |
| 43 | + <view bindtap="sele_act" data-index="{{index}}" wx:else class="circle white xc-hook"></view> | |
| 34 | 44 | |
| 45 | + <view style="height: 12rpx"></view> | |
| 46 | + </block> | |
| 47 | + <view bindtap="go_the_url" data-id="{{item.id}}" data-prom_type="{{item.prom_type}}" class="xq_btn fs30">详情</view> | |
| 48 | + </view> | |
| 35 | 49 | </view> |
| 36 | - <view bindtap="go_the_url" data-id="{{item.id}}" data-prom_type="{{item.prom_type}}" class="xq_btn fs30">详情</view> | |
| 50 | + | |
| 37 | 51 | </view> |
| 38 | 52 | |
| 39 | 53 | </view> |
| 40 | 54 | </view> |
| 41 | 55 | </view> |
| 56 | + | |
| 42 | 57 | <view class="cx-confirm pd20" bindtap="close_pro_pop"> |
| 43 | 58 | <view wx:if="{{type==0}}" class="confirm t-c">我知道了</view> |
| 44 | 59 | <view wx:if="{{type==1}}" class="confirm t-c">确定</view> | ... | ... |
components/promate_pop/promate_pop.wxss
| ... | ... | @@ -8,6 +8,9 @@ |
| 8 | 8 | position: fixed; |
| 9 | 9 | bottom: 0; |
| 10 | 10 | } |
| 11 | +.cx-popup.cart_show{ | |
| 12 | + bottom:100rpx | |
| 13 | +} | |
| 11 | 14 | |
| 12 | 15 | .cx-popup .top { |
| 13 | 16 | font-size: 32rpx; |
| ... | ... | @@ -201,10 +204,17 @@ |
| 201 | 204 | background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAMAAADzapwJAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAABCUExURUdwTPInDPInDPgoDfMnDPYqEvInDPInDPInDP87NPUoDv8vEvMoDPInDPIoDPMnDvInDPInDPInDPIoDPQoDfInDEON4KMAAAAVdFJOUwD45yawG4zz3gQ0DmLOfECQZpPlS54kMQ4AAAC0SURBVBjTbZFREoMgDERDS0xQQNHu/a/alEGtaIYfHrBhs0S1pujVifo40VkhC+BUHSDzQTlBhjHY8bjogXmDZ+orJKwXwMUeUoa/0PeGbH8Q4Y5CJopYOjosiOQxdpRGk1UXOkrBKdkimtN8UrKrJBVXdzsllSYSjR/0J9JaGn81WluWtonYKQ0op51P3M2L2bmZN9n8MKoVqTph/RsseyjfYxAkfgot/82CpuJVLOLSIv4Cd5AJ37BgpFwAAAAASUVORK5CYII=) no-repeat; |
| 202 | 205 | background-size: 22rpx auto; |
| 203 | 206 | } |
| 204 | -.xq_btn{ | |
| 207 | + | |
| 208 | +.r_item_pro{ | |
| 205 | 209 | position: absolute; |
| 206 | 210 | right: 18rpx; |
| 207 | - top:52rpx; | |
| 211 | + height: 100%; | |
| 212 | + display: flex; | |
| 213 | + align-items: center; | |
| 214 | + justify-content: center; | |
| 215 | +} | |
| 216 | + | |
| 217 | +.xq_btn{ | |
| 208 | 218 | width: 100rpx; |
| 209 | 219 | height: 60rpx; |
| 210 | 220 | background-color: #e03033; |
| ... | ... | @@ -220,4 +230,21 @@ |
| 220 | 230 | } |
| 221 | 231 | |
| 222 | 232 | |
| 233 | +/*选择的圆圈*/ | |
| 234 | +.xc-hook { | |
| 235 | + width: 30rpx; | |
| 236 | + height: 30rpx; | |
| 237 | + line-height: 30rpx; | |
| 238 | + text-align: center; | |
| 239 | + border: 1rpx solid #999; | |
| 240 | + display: inline-block; | |
| 241 | +} | |
| 242 | +/*选中的时候*/ | |
| 243 | +.xc-hook.on { | |
| 244 | + transform: rotate(-135deg); | |
| 245 | + background-color: #d60021; | |
| 246 | +} | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 223 | 250 | @import '../../app.wxss'; | ... | ... |
pages/cart/cart/cart.js
| ... | ... | @@ -199,7 +199,13 @@ Page({ |
| 199 | 199 | //判断组合购活动是不是满足 |
| 200 | 200 | if(is_zh_ok){ |
| 201 | 201 | if(!item1.more_cx) item1.more_cx=[]; |
| 202 | - item1.more_cx.push({prom_type:7,prom_id:zh_id,gdlist:gdlist}) | |
| 202 | + var show_time=ut.formatTime(zh_pro0.start_time)+"至"+ ut.formatTime(zh_pro0.end_time); | |
| 203 | + item1.more_cx.push({ | |
| 204 | + prom_type:7,prom_id:zh_id,gdlist:gdlist, | |
| 205 | + title: zh_pro0.name, | |
| 206 | + show_time: show_time, | |
| 207 | + id:zh_id | |
| 208 | + }) | |
| 203 | 209 | } |
| 204 | 210 | } |
| 205 | 211 | } |
| ... | ... | @@ -214,7 +220,16 @@ Page({ |
| 214 | 220 | //-- 如果是搭配购的时候 -- |
| 215 | 221 | if (r_data.collocationList) { |
| 216 | 222 | if(!item1.more_cx) item1.more_cx=[]; |
| 217 | - item1.more_cx.push({prom_type:5,prom_id: r_data.collocationPromList.id}); | |
| 223 | + | |
| 224 | + var show_price= '¥'+r_data.collocationPromList.max+'-'+ r_data.collocationPromList.min; | |
| 225 | + var show_time=ut.formatTime(r_data.collocationPromList.start_time)+"至"+ ut.formatTime(r_data.collocationPromList.end_time); | |
| 226 | + | |
| 227 | + item1.more_cx.push({ | |
| 228 | + prom_type:5,prom_id: r_data.collocationPromList.id, | |
| 229 | + title: r_data.collocationPromList.title, | |
| 230 | + show_time: show_time, | |
| 231 | + id:r_data.collocationPromList.id, | |
| 232 | + }); | |
| 218 | 233 | } |
| 219 | 234 | //-- 如果是阶梯促销的时候 -- |
| 220 | 235 | if (r_data.ladderLists) { |
| ... | ... | @@ -224,7 +239,27 @@ Page({ |
| 224 | 239 | if (res.data.code == 0 && res.data.data) { |
| 225 | 240 | th.data.ladder_map[act_id] = res.data.data; |
| 226 | 241 | if(!item1.more_cx) item1.more_cx=[]; |
| 227 | - item1.more_cx.push({prom_type:10,prom_id: act_id}); | |
| 242 | + | |
| 243 | + var prom_content = ""; | |
| 244 | + | |
| 245 | + for (let jj in r_data.ladderLists) { | |
| 246 | + if (r_data.ladderLists[jj].discount == 10) { | |
| 247 | + prom_content += "第" + (parseInt(jj) + 1) + "件原价,"; | |
| 248 | + } else { | |
| 249 | + prom_content += "第" + (parseInt(jj) + 1) + "件" + r_data.ladderLists[jj].discount + "折,"; | |
| 250 | + } | |
| 251 | + } | |
| 252 | + prom_content = ut.sub_last(prom_content); | |
| 253 | + | |
| 254 | + var s_time=res.data.data.start_time; | |
| 255 | + var e_time=res.data.data.end_time; | |
| 256 | + | |
| 257 | + item1.more_cx.push({ | |
| 258 | + prom_type:10,prom_id: act_id, | |
| 259 | + title: prom_content, | |
| 260 | + show_time: ut.formatTime(s_time) + "至" + ut.formatTime(e_time), | |
| 261 | + id:act_id | |
| 262 | + }); | |
| 228 | 263 | } |
| 229 | 264 | }) |
| 230 | 265 | |
| ... | ... | @@ -259,7 +294,33 @@ Page({ |
| 259 | 294 | //--- 这个地方是在计算优惠促销的限购 --- |
| 260 | 295 | if(!fir_act.limit_num || th.data.user_pre_buynum<fir_act.limit_num){ |
| 261 | 296 | |
| 262 | - var push_item={prom_type:3,prom_id: fir_act.prom_id,fir_act:fir_act}; | |
| 297 | + | |
| 298 | + var more_arr = []; | |
| 299 | + //减价 | |
| 300 | + if (fir_act.money > 0) more_arr.push('减价'+fir_act.money+'元'); | |
| 301 | + if (fir_act.sale > 0) more_arr.push('打'+fir_act.sale+'折'); | |
| 302 | + if (fir_act.past ==1) more_arr.push('包邮'); | |
| 303 | + if (fir_act.intValue > 0) more_arr.push('送'+fir_act.intValue+'积分'); | |
| 304 | + if (fir_act.couponId > 0) more_arr.push('送'+fir_act.couponMoney+'元优惠券'); | |
| 305 | + if (fir_act.gift_id) { | |
| 306 | + var is_more_gf=fir_act.gift_id.split(',') | |
| 307 | + if(is_more_gf.length>1){ | |
| 308 | + more_arr.push('送赠品'); | |
| 309 | + }else{ | |
| 310 | + more_arr.push('送'+fir_act.goods_name+' x'+fir_act.zp_num); | |
| 311 | + } | |
| 312 | + } | |
| 313 | + if (fir_act.lb_id) more_arr.push('送'+fir_act.lbtitle); | |
| 314 | + if (fir_act.zxlb_id) more_arr.push('送'+fir_act.zxlbtitle); | |
| 315 | + | |
| 316 | + var push_item={ | |
| 317 | + prom_type:3,prom_id: fir_act.prom_id,fir_act:fir_act, | |
| 318 | + condition: fir_act.condition + (fir_act.prom_type == 1 ? '件' : '元'), | |
| 319 | + limit: '每人' + (fir_act.limit_num ? '限参与' + fir_act.limit_num + '次' : '参与不限次'), | |
| 320 | + more: more_arr, | |
| 321 | + id:fir_act.prom_id | |
| 322 | + }; | |
| 323 | + | |
| 263 | 324 | //--- 如果是一件商品的时候,那么就要判断这个商品。同时商品的购买数量有没有满足 --- |
| 264 | 325 | if (is_state == 1) { |
| 265 | 326 | //-- 按件进行计算 -- |
| ... | ... | @@ -311,7 +372,6 @@ Page({ |
| 311 | 372 | this.getTabBar().setData({ |
| 312 | 373 | active: index //数字是当前页面在tabbar的索引 |
| 313 | 374 | }) |
| 314 | - | |
| 315 | 375 | getApp().requestCardNum(this); |
| 316 | 376 | } |
| 317 | 377 | |
| ... | ... | @@ -2133,10 +2193,9 @@ Page({ |
| 2133 | 2193 | } |
| 2134 | 2194 | } |
| 2135 | 2195 | }); |
| 2136 | - | |
| 2137 | - | |
| 2138 | - | |
| 2139 | 2196 | } |
| 2197 | + //-- 切换活动的按钮要把他返回 -- | |
| 2198 | + this.data.change_act=0; | |
| 2140 | 2199 | } |
| 2141 | 2200 | |
| 2142 | 2201 | //-- 服务卡 -- |
| ... | ... | @@ -3223,7 +3282,9 @@ Page({ |
| 3223 | 3282 | var data = { |
| 3224 | 3283 | id: g_arr[i].id, |
| 3225 | 3284 | selected: 1, |
| 3226 | - store_id: oo.stoid | |
| 3285 | + store_id: oo.stoid, | |
| 3286 | + prom_type:g_arr[i].prom_type, | |
| 3287 | + prom_id:g_arr[i].prom_id, | |
| 3227 | 3288 | }; |
| 3228 | 3289 | let gitem = checkArr7.find(item => item.goods_id == g_arr[i].goods_id) |
| 3229 | 3290 | if (gitem) { |
| ... | ... | @@ -3253,6 +3314,8 @@ Page({ |
| 3253 | 3314 | wx.hideLoading(); |
| 3254 | 3315 | return false; |
| 3255 | 3316 | } |
| 3317 | + | |
| 3318 | + | |
| 3256 | 3319 | wx.hideLoading(); |
| 3257 | 3320 | wx.navigateTo({ |
| 3258 | 3321 | url: "/packageE/pages/cart/cart2/cart2" |
| ... | ... | @@ -3413,7 +3476,9 @@ Page({ |
| 3413 | 3476 | var data = { |
| 3414 | 3477 | id: g_arr[i].id, |
| 3415 | 3478 | selected: 1, |
| 3416 | - store_id: oo.stoid | |
| 3479 | + store_id: oo.stoid, | |
| 3480 | + prom_type:g_arr[i].prom_type, | |
| 3481 | + prom_id:g_arr[i].prom_id, | |
| 3417 | 3482 | }; |
| 3418 | 3483 | |
| 3419 | 3484 | //-- 如果有线下取价的时候 -- |
| ... | ... | @@ -4339,11 +4404,9 @@ Page({ |
| 4339 | 4404 | //-- 判读一下促销分组的问题 -- |
| 4340 | 4405 | async cart_cx_group(goods,car_item,func){ |
| 4341 | 4406 | |
| 4342 | - if(car_item.change_act){ | |
| 4343 | - | |
| 4344 | - car_item.change_act=0; | |
| 4407 | + //更改活动的时候,就不能再重新计算活动,只有再加减数量和选择商品的时候,就要重新计算活动 | |
| 4408 | + if(this.data.change_act){ | |
| 4345 | 4409 | var show_can_cx=car_item.show_can_cx; |
| 4346 | - | |
| 4347 | 4410 | for(var k in show_can_cx){ |
| 4348 | 4411 | var k_item=show_can_cx[k]; |
| 4349 | 4412 | var ck_prom_type=null; |
| ... | ... | @@ -4394,7 +4457,6 @@ Page({ |
| 4394 | 4457 | } |
| 4395 | 4458 | |
| 4396 | 4459 | } |
| 4397 | - | |
| 4398 | 4460 | func(show_can_cx); |
| 4399 | 4461 | } |
| 4400 | 4462 | |
| ... | ... | @@ -4479,6 +4541,7 @@ Page({ |
| 4479 | 4541 | can_calc_cx.push(item_act_map) |
| 4480 | 4542 | } |
| 4481 | 4543 | break |
| 4544 | + | |
| 4482 | 4545 | case 7: |
| 4483 | 4546 | //-- 活动列表 -- |
| 4484 | 4547 | var zhact_gdlist=item_act_map.act.gdlist; |
| ... | ... | @@ -4529,6 +4592,7 @@ Page({ |
| 4529 | 4592 | //-- 同时相同商品数量的活动,还要看取那一个来进行计算金额。 默认的时候是按照后台的顺序。-- |
| 4530 | 4593 | //-- 有选择的时候,就按照切换选择了什么就按照什么来计算 -- |
| 4531 | 4594 | var show_can_cx={}; |
| 4595 | + | |
| 4532 | 4596 | if(can_calc_cx.length){ |
| 4533 | 4597 | for(var p=0;p<can_calc_cx.length;p++){ |
| 4534 | 4598 | var ch_map=[]; |
| ... | ... | @@ -4543,6 +4607,9 @@ Page({ |
| 4543 | 4607 | fd.act_arr.push(can_calc_cx[p]) |
| 4544 | 4608 | }else{ |
| 4545 | 4609 | var e={ch_map:ch_map,act_arr:[]}; |
| 4610 | + if(ch_map.length>1){ | |
| 4611 | + e.is_duo_gd=1; | |
| 4612 | + } | |
| 4546 | 4613 | e.act_arr.push(can_calc_cx[p]); |
| 4547 | 4614 | show_can_cx[ch_map.join()]=e; |
| 4548 | 4615 | } |
| ... | ... | @@ -4585,7 +4652,6 @@ Page({ |
| 4585 | 4652 | } |
| 4586 | 4653 | //-- 此时已经确定了商品的活动是什么类型的,可以确定购物车中商品的具体活动进行金额的计算 -- |
| 4587 | 4654 | if(!ck_prom_type) ck_prom_type=k_item.act_arr[0]; |
| 4588 | - | |
| 4589 | 4655 | //-- 此时要把购物车中的商品确定活动 -- |
| 4590 | 4656 | for (var b=0; b<ck_prom_type.goods.length;b++){ |
| 4591 | 4657 | //-- 开始查找 -- |
| ... | ... | @@ -4597,7 +4663,6 @@ Page({ |
| 4597 | 4663 | goods[fg].prom_id=ck_prom_type.prom_id; |
| 4598 | 4664 | } |
| 4599 | 4665 | } |
| 4600 | - | |
| 4601 | 4666 | } |
| 4602 | 4667 | |
| 4603 | 4668 | //-- 显示到前端,并切换 -- |
| ... | ... | @@ -4635,6 +4700,50 @@ Page({ |
| 4635 | 4700 | if(idx>-1) num++; |
| 4636 | 4701 | }) |
| 4637 | 4702 | return num; |
| 4703 | + }, | |
| 4704 | + | |
| 4705 | + //-- 开始显示活动的弹出 -- | |
| 4706 | + switch_cx_group:function (e){ | |
| 4707 | + var idx=e.currentTarget.dataset.index; | |
| 4708 | + var gd_key=e.currentTarget.dataset.gd_key; | |
| 4709 | + this.data.sele_cx_group_cidx=idx; | |
| 4710 | + this.data.cx_group_gd_key=gd_key; | |
| 4711 | + //-- 获取到-- | |
| 4712 | + var cx_prom_group=this.data.requestData[idx].show_can_cx[gd_key].act_arr; | |
| 4713 | + | |
| 4714 | + var cx_arr=[]; | |
| 4715 | + var find_sele=0; | |
| 4716 | + for (var h=0;h<cx_prom_group.length;h++){ | |
| 4717 | + //-- 看有没有选中的活动 -- | |
| 4718 | + if(cx_prom_group[h].sele){ | |
| 4719 | + find_sele=1; | |
| 4720 | + } | |
| 4721 | + cx_arr.push(cx_prom_group[h].act); | |
| 4722 | + } | |
| 4723 | + //-- 如果没有,就默认第一个为选中 -- | |
| 4724 | + //-- if(!find_sele) cx_arr[0].sele=1; -- | |
| 4725 | + var cp_arr=JSON.parse(JSON.stringify(cx_arr)); | |
| 4726 | + var pro_pop = this.selectComponent("#pro_pop"); //组件的id | |
| 4727 | + pro_pop.set_init(1,cx_arr,1); | |
| 4728 | + }, | |
| 4729 | + | |
| 4730 | + //--- 选择回来时候的选择 --- | |
| 4731 | + sure_cx_group:function(e){ | |
| 4732 | + var sele_idx=e.detail.sele_idx; | |
| 4733 | + var idx=this.data.sele_cx_group_cidx; | |
| 4734 | + var gd_key= this.data.cx_group_gd_key; | |
| 4735 | + //-- 获取到-- | |
| 4736 | + var cx_prom_group=this.data.requestData[idx].show_can_cx[gd_key].act_arr; | |
| 4737 | + | |
| 4738 | + for(var dx=0;dx<cx_prom_group.length;dx++){ | |
| 4739 | + if(dx!=sele_idx) cx_prom_group[dx].sele=0; | |
| 4740 | + else cx_prom_group[dx].sele=1; | |
| 4741 | + } | |
| 4742 | + | |
| 4743 | + this.data.change_act=1; | |
| 4744 | + this.doCheckAll(); | |
| 4745 | + | |
| 4638 | 4746 | } |
| 4639 | 4747 | |
| 4748 | + | |
| 4640 | 4749 | }); |
| 4641 | 4750 | \ No newline at end of file | ... | ... |
pages/cart/cart/cart.json
| ... | ... | @@ -2,6 +2,7 @@ |
| 2 | 2 | "navigationBarTitleText": "购物车", |
| 3 | 3 | "usingComponents": { |
| 4 | 4 | "warn": "/components/long_warn/long_warn", |
| 5 | - "goods_recommend":"/components/goods_list/goods_list" | |
| 5 | + "goods_recommend":"/components/goods_list/goods_list", | |
| 6 | + "pro_pop": "/components/promate_pop/promate_pop" | |
| 6 | 7 | } |
| 7 | 8 | } |
| 8 | 9 | \ No newline at end of file | ... | ... |
pages/cart/cart/cart.wxml
| 1 | +<!-- 促销弹出框 --> | |
| 2 | +<pro_pop id="pro_pop" bind:sure_cx_group="sure_cx_group"></pro_pop> | |
| 3 | + | |
| 1 | 4 | <wxs module="g_filter" src="g_filter.wxs"></wxs> |
| 2 | 5 | |
| 3 | 6 | <block wx:if="{{ad_data}}"> |
| ... | ... | @@ -38,7 +41,7 @@ |
| 38 | 41 | |
| 39 | 42 | <!-- 商品的列表 --> |
| 40 | 43 | <block wx:if="{{requestData && requestData.length>0}}"> |
| 41 | - <block wx:for="{{requestData}}" wx:key="{{index}}" wx:for-item="item" wx:for-index="pidx"> | |
| 44 | + <block wx:for="{{requestData}}" wx:key="{{pidx}}" wx:for-item="item" wx:for-index="pidx"> | |
| 42 | 45 | <!-- 门店底下的商品 --> |
| 43 | 46 | <view class="store"> |
| 44 | 47 | <view class="shmd_m"> |
| ... | ... | @@ -54,7 +57,7 @@ |
| 54 | 57 | |
| 55 | 58 | </view> |
| 56 | 59 | |
| 57 | - <block wx:for="{{item.goods}}" wx:for-item="items" wx:for-index="idx" wx:key="{{index}}"> | |
| 60 | + <block wx:for="{{item.goods}}" wx:for-item="items" wx:for-index="idx" wx:key="{{idx}}"> | |
| 58 | 61 | <view class="order-item" data-item="{{idx}}"> |
| 59 | 62 | <block wx:if="{{!items.is_gift}}"> |
| 60 | 63 | <view bindtap="check_th_item" class="order-raido flex-vertical " data-check="{{items.selected}}" data-item="{{idx}}" data-pitems="{{pidx}}"> |
| ... | ... | @@ -129,7 +132,10 @@ |
| 129 | 132 | <!-- 新增促销多活动的排版 --> |
| 130 | 133 | <view class="bdt16" |
| 131 | 134 | wx:if="{{g_filter.is_more_act(items,item.show_can_cx) && item.show_can_cx[items.goods_id] && item.show_can_cx[items.goods_id].act_arr.length>1}}"> |
| 132 | - <view data-coupon="1" bindtap="switch_cx_group" class="cx-frame flex" style="position: relative"> | |
| 135 | + <view bindtap="switch_cx_group" | |
| 136 | + data-index="{{pidx}}" | |
| 137 | + data-gd_key="{{items.goods_id}}" | |
| 138 | + class="cx-frame flex" style="position: relative"> | |
| 133 | 139 | <view class="cx-sizs fs30">促销</view> |
| 134 | 140 | <view class="flex ai_c f1 pdh20"> |
| 135 | 141 | <view class="xc-coupon-fram" wx:for="{{item.show_can_cx[items.goods_id].act_arr}}" > |
| ... | ... | @@ -148,11 +154,37 @@ |
| 148 | 154 | </block > |
| 149 | 155 | |
| 150 | 156 | |
| 157 | + <!--此时是多个商品参与活动的切换 验证活动是不是多个,要不要显示切换 --> | |
| 158 | + <!-- 新增促销多活动的排版 --> | |
| 159 | + <block wx:if="{{item.show_can_cx}}"> | |
| 160 | + <block wx:for="{{item.show_can_cx}}" wx:for-item="pitem"> | |
| 161 | + <view class="bdt16" wx:if="{{pitem.is_duo_gd}}" > | |
| 162 | + <view bindtap="switch_cx_group" | |
| 163 | + data-index="{{pidx}}" | |
| 164 | + data-gd_key="{{index}}" | |
| 165 | + class="cx-frame flex" style="position: relative"> | |
| 166 | + <view class="cx-sizs fs30">促销</view> | |
| 167 | + <view class="flex ai_c f1 pdh20"> | |
| 168 | + <view class="xc-coupon-fram" wx:for="{{item.show_can_cx[items.goods_id].act_arr}}" > | |
| 169 | + <view wx:if="{{item.prom_type==3}}" class="xc-coupon t-c four-level-word">优惠促销</view> | |
| 170 | + <view wx:if="{{item.prom_type==5}}" class="xc-coupon t-c four-level-word">搭配促销</view> | |
| 171 | + <view wx:if="{{item.prom_type==7}}" class="xc-coupon t-c four-level-word">组合购</view> | |
| 172 | + <view wx:if="{{item.prom_type==10}}" class="xc-coupon t-c four-level-word">阶梯促销</view> | |
| 173 | + </view> | |
| 174 | + </view> | |
| 175 | + <view class="cx-obtain-coupon wsize"> | |
| 176 | + <text class="bg_jj"></text> | |
| 177 | + </view> | |
| 178 | + </view> | |
| 179 | + </view> | |
| 180 | + </block> | |
| 181 | + </block> | |
| 182 | + | |
| 151 | 183 | </view> |
| 152 | - <!--- 去凑单 --> | |
| 153 | - <view style="margin-top: 20rpx; padding: 0 30rpx"> | |
| 184 | + <!--- 去凑单 --> | |
| 154 | 185 | <block wx:if="{{item.make_up_arr}}"> |
| 155 | - <view class="flex jc_sb fs28" wx:for="{{item.make_up_arr}}" style="margin-bottom: 20rpx" > | |
| 186 | + <view style="margin-top: 20rpx; padding: 0 30rpx"> | |
| 187 | + <view class="flex jc_sb fs28" wx:for="{{item.make_up_arr}}" style="margin-bottom: 20rpx" > | |
| 156 | 188 | <view class="ellipsis-1" style="width: 80%">再买<text class="co-red">{{item.diff}}<text wx:if="{{item.diff_type==0}}">元</text> |
| 157 | 189 | <text wx:if="{{item.diff_type==1}}">件</text> |
| 158 | 190 | </text>, |
| ... | ... | @@ -168,8 +200,8 @@ |
| 168 | 200 | </view> |
| 169 | 201 | <view class="co-red" data-prom_id="{{item.prom_id}}" bindtap="go_cou_dang">去凑单></view> |
| 170 | 202 | </view> |
| 203 | + </view> | |
| 171 | 204 | </block> |
| 172 | - </view> | |
| 173 | 205 | <!-- 还差多少件立即享受组合购 --> |
| 174 | 206 | <block wx:if="{{item.need_list && item.need_list.length>0 && !is_edit}}"> |
| 175 | 207 | <view class="fs28 pdr20 pdl20 pdb20 c-red2 flex jc_sb" wx:for="{{item.need_list}}"> | ... | ... |