Commit c227e66fd61dd8b4768fed2c910f2d4d3a9d94d2
1 parent
238fb183
组合购切换的问题
Showing
3 changed files
with
108 additions
and
33 deletions
packageE/pages/cart/cart2/cart2.wxml
| ... | ... | @@ -115,8 +115,9 @@ |
| 115 | 115 | </navigator> |
| 116 | 116 | </view> |
| 117 | 117 | |
| 118 | - <!-- 验证活动是不是多个,要不要显示切换 --> | |
| 119 | - <!-- 新增促销多活动的排版 --> | |
| 118 | + | |
| 119 | + <!-- 验证活动是不是多个,要不要显示切换 --> | |
| 120 | + <!-- 新增促销多活动的排版,单商品的时候 --> | |
| 120 | 121 | <block wx:if="{{(util.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)}}"> |
| 121 | 122 | <view class="bdb16" wx:if="{{util.check_show(items,item.show_can_cx[items.goods_id].cur_act.prom_type)}}"> |
| 122 | 123 | <view bindtap="switch_cx_group" |
| ... | ... | @@ -139,35 +140,62 @@ |
| 139 | 140 | </view> |
| 140 | 141 | </block> |
| 141 | 142 | |
| 143 | + <!--此时是多个商品参与活动的切换 验证活动是不是多个,要不要显示切换,同时要最后一个商品显示 --> | |
| 144 | + <!-- 新增促销多活动的排版,多商品的时候 --> | |
| 145 | + <block wx:if="{{item.show_can_cx}}"> | |
| 146 | + <block wx:for="{{item.show_can_cx}}" wx:for-item="pitem"> | |
| 147 | + <view class="bdb16" wx:if="{{pitem.is_duo_gd && pitem.act_arr.length>1 && util.check_is_last(index,items.goods_id,items.is_act_last,pitem.cur_act.prom_type) }}" > | |
| 148 | + | |
| 149 | + <view bindtap="switch_cx_group" | |
| 150 | + data-index="{{pidx}}" | |
| 151 | + data-gd_key="{{index}}" | |
| 152 | + class="cx-frame flex" style="position: relative"> | |
| 153 | + <view class="cx-sizs fs30">促销</view> | |
| 154 | + <view class="flex ai_c f1 pdh20"> | |
| 155 | + <view class="xc-coupon-fram" wx:for="{{pitem.act_arr}}" > | |
| 156 | + <view wx:if="{{item.prom_type==3}}" class="xc-coupon t-c four-level-word {{!item.sele?'gray':'' }} ">优惠促销</view> | |
| 157 | + <view wx:if="{{item.prom_type==5}}" class="xc-coupon t-c four-level-word {{!item.sele?'gray':'' }} ">搭配促销</view> | |
| 158 | + <view wx:if="{{item.prom_type==7}}" class="xc-coupon t-c four-level-word {{!item.sele?'gray':'' }} ">组合购</view> | |
| 159 | + <view wx:if="{{item.prom_type==10}}" class="xc-coupon t-c four-level-word {{!item.sele?'gray':'' }} ">阶梯促销</view> | |
| 160 | + </view> | |
| 161 | + </view> | |
| 162 | + <view class="cx-obtain-coupon wsize"> | |
| 163 | + <text class="bg_jj"></text> | |
| 164 | + </view> | |
| 165 | + </view> | |
| 166 | + </view> | |
| 167 | + </block> | |
| 168 | + </block> | |
| 142 | 169 | |
| 143 | 170 | </block> |
| 144 | 171 | |
| 145 | 172 | <!--此时是多个商品参与活动的切换 验证活动是不是多个,要不要显示切换 --> |
| 146 | 173 | <!-- 新增促销多活动的排版 --> |
| 147 | - <block wx:if="{{item.show_can_cx}}"> | |
| 148 | - | |
| 149 | - <block wx:for="{{item.show_can_cx}}" wx:for-item="pitem"> | |
| 150 | - <view class="bdb16" wx:if="{{pitem.is_duo_gd && pitem.act_arr.length>1}}" > | |
| 151 | - <view bindtap="switch_cx_group" | |
| 152 | - data-index="{{pidx}}" | |
| 153 | - data-gd_key="{{index}}" | |
| 154 | - class="cx-frame flex" style="position: relative"> | |
| 155 | - <view class="cx-sizs fs30">促销</view> | |
| 156 | - <view class="flex ai_c f1 pdh20"> | |
| 157 | - <view class="xc-coupon-fram" wx:for="{{pitem.act_arr}}" > | |
| 158 | - <view wx:if="{{item.prom_type==3}}" class="xc-coupon t-c four-level-word {{!item.sele?'gray':'' }} ">优惠促销</view> | |
| 159 | - <view wx:if="{{item.prom_type==5}}" class="xc-coupon t-c four-level-word {{!item.sele?'gray':'' }} ">搭配促销</view> | |
| 160 | - <view wx:if="{{item.prom_type==7}}" class="xc-coupon t-c four-level-word {{!item.sele?'gray':'' }} ">组合购</view> | |
| 161 | - <view wx:if="{{item.prom_type==10}}" class="xc-coupon t-c four-level-word {{!item.sele?'gray':'' }} ">阶梯促销</view> | |
| 162 | - </view> | |
| 163 | - </view> | |
| 164 | - <view class="cx-obtain-coupon wsize"> | |
| 165 | - <text class="bg_jj"></text> | |
| 166 | - </view> | |
| 167 | - </view> | |
| 168 | - </view> | |
| 169 | - </block> | |
| 170 | - </block> | |
| 174 | +<!-- <block wx:if="{{item.show_can_cx}}">--> | |
| 175 | +<!-- <block wx:for="{{item.show_can_cx}}" wx:for-item="pitem">--> | |
| 176 | +<!-- <view class="bdb16" wx:if="{{pitem.is_duo_gd && pitem.act_arr.length>1}}" >--> | |
| 177 | +<!-- <view bindtap="switch_cx_group"--> | |
| 178 | +<!-- data-index="{{pidx}}"--> | |
| 179 | +<!-- data-gd_key="{{index}}"--> | |
| 180 | +<!-- class="cx-frame flex" style="position: relative">--> | |
| 181 | +<!-- <view class="cx-sizs fs30">促销</view>--> | |
| 182 | +<!-- <view class="flex ai_c f1 pdh20">--> | |
| 183 | +<!-- <view class="xc-coupon-fram" wx:for="{{pitem.act_arr}}" >--> | |
| 184 | +<!-- <view wx:if="{{item.prom_type==3}}" class="xc-coupon t-c four-level-word {{!item.sele?'gray':'' }} ">优惠促销</view>--> | |
| 185 | +<!-- <view wx:if="{{item.prom_type==5}}" class="xc-coupon t-c four-level-word {{!item.sele?'gray':'' }} ">搭配促销</view>--> | |
| 186 | +<!-- <view wx:if="{{item.prom_type==7}}" class="xc-coupon t-c four-level-word {{!item.sele?'gray':'' }} ">组合购</view>--> | |
| 187 | +<!-- <view wx:if="{{item.prom_type==10}}" class="xc-coupon t-c four-level-word {{!item.sele?'gray':'' }} ">阶梯促销</view>--> | |
| 188 | +<!-- </view>--> | |
| 189 | +<!-- </view>--> | |
| 190 | +<!-- <view class="cx-obtain-coupon wsize">--> | |
| 191 | +<!-- <text class="bg_jj"></text>--> | |
| 192 | +<!-- </view>--> | |
| 193 | +<!-- </view>--> | |
| 194 | +<!-- </view>--> | |
| 195 | +<!-- </block>--> | |
| 196 | +<!-- </block>--> | |
| 197 | + | |
| 198 | + | |
| 171 | 199 | |
| 172 | 200 | <!-- 使用搭配 --> |
| 173 | 201 | <cart_collect_temp id="col{{pidx}}" | ... | ... |
packageE/pages/cart/cart2/filter.wxs
| ... | ... | @@ -21,8 +21,43 @@ function check_show(items,sele_prom_type){ |
| 21 | 21 | return true; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | +//prom_type活动类型 | |
| 25 | +//goods_id 商品的id | |
| 26 | +//index多活动的索引 | |
| 27 | +//is_act_last 是不是最后一个 | |
| 28 | + | |
| 29 | +function check_is_last(index,goods_id,is_act_last,prom_type){ | |
| 30 | + var gd_arr=index.split(','); | |
| 31 | + var idx=-1; | |
| 32 | + //-- 判断有没有包含商品 -- | |
| 33 | + for(var i=0;i<gd_arr.length;i++){ | |
| 34 | + var ch=gd_arr[i]; | |
| 35 | + if(parseFloat(ch)==parseFloat(goods_id)){ | |
| 36 | + idx=i; | |
| 37 | + break | |
| 38 | + } | |
| 39 | + } | |
| 40 | + if(idx<0){ | |
| 41 | + return false; | |
| 42 | + } | |
| 43 | + //阶梯促销和组合购有判断活动的最后一个商品 | |
| 44 | + if([7,10].indexOf(prom_type)>-1){ | |
| 45 | + if(is_act_last==0) return false; | |
| 46 | + return true | |
| 47 | + } | |
| 48 | + //-- 判断是不是活动的最后一个商品 -- | |
| 49 | + if(idx==gd_arr.length-1){ | |
| 50 | + return true; | |
| 51 | + } | |
| 52 | + return false; | |
| 53 | + | |
| 54 | +} | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 24 | 58 | module.exports = { |
| 25 | 59 | format: format, |
| 26 | 60 | is_more_act:is_more_act, |
| 27 | - check_show:check_show | |
| 61 | + check_show:check_show, | |
| 62 | + check_is_last:check_is_last | |
| 28 | 63 | } | ... | ... |
packageE/pages/cart/cart2/zh_calculate.js
| ... | ... | @@ -253,6 +253,10 @@ module.exports = { |
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | + | |
| 257 | + | |
| 258 | + //-- 暂存的数组 -- | |
| 259 | + var temp_arr=[]; | |
| 256 | 260 | if (Object.keys(goods_map).length) { |
| 257 | 261 | //这里就开始拆分提交订单时的列表 |
| 258 | 262 | for (let j in goods_map) { |
| ... | ... | @@ -270,8 +274,8 @@ module.exports = { |
| 270 | 274 | new_g.prom_type = 0; |
| 271 | 275 | new_g.prom_id = 0; |
| 272 | 276 | new_g.is_zh_split = 1; //-- 是组合购拆分出去的 -- |
| 273 | - goods.push(new_g); | |
| 274 | - | |
| 277 | + //暂时存储一下 | |
| 278 | + temp_arr.push(new_g); | |
| 275 | 279 | //如果商品的数量已经为空了 |
| 276 | 280 | if (goods[idx].goods_num <= 0) { |
| 277 | 281 | goods.splice(idx, 1); |
| ... | ... | @@ -279,18 +283,26 @@ module.exports = { |
| 279 | 283 | } |
| 280 | 284 | } |
| 281 | 285 | |
| 282 | - | |
| 286 | + var ls=-1; | |
| 283 | 287 | //-- 只统计是参与活动的商品 -- |
| 284 | 288 | for (var ij in goods) { |
| 285 | - goods[ij].is_act_last=0; | |
| 286 | 289 | var iter = goods[ij]; |
| 287 | 290 | if (iter.prom_type != 7 || iter.prom_id != act.id) { |
| 288 | 291 | continue; |
| 289 | 292 | } |
| 293 | + goods[ij].is_act_last=0; | |
| 290 | 294 | all_price0 += iter.goods_num * iter.goods_price; |
| 295 | + ls= parseInt(ij); | |
| 291 | 296 | } |
| 292 | - | |
| 293 | - goods[goods.length-1].is_act_last=1; | |
| 297 | + //-- 要在特定的位置插入商品 -- | |
| 298 | + if(temp_arr){ | |
| 299 | + for(var gh=0;gh<temp_arr.length;gh++){ | |
| 300 | + var idx=gh+ls+1; | |
| 301 | + goods.splice(idx, 0,temp_arr[gh]); | |
| 302 | + } | |
| 303 | + ls+=temp_arr.length; | |
| 304 | + } | |
| 305 | + goods[ls].is_act_last=1; | |
| 294 | 306 | |
| 295 | 307 | //-- 活动的条件已经满足 -- |
| 296 | 308 | c_item.zh_prom_goods[act.id].is_has_zh = 1; | ... | ... |