Commit 7d79bebf51f1fc9786c2a15a3efbe287d3ad45f6
1 parent
78a54b8f
赠品的超量和限量不限的优化
Showing
3 changed files
with
36 additions
and
12 deletions
packageE/pages/cart/cart2/cart2.js
| @@ -2373,11 +2373,16 @@ Page({ | @@ -2373,11 +2373,16 @@ Page({ | ||
| 2373 | for (let iy in get_data.giftsinfo) { | 2373 | for (let iy in get_data.giftsinfo) { |
| 2374 | let item = get_data.giftsinfo[iy]; | 2374 | let item = get_data.giftsinfo[iy]; |
| 2375 | 2375 | ||
| 2376 | + var c_zp=0; | ||
| 2376 | if(parseInt(item.limit_num)>0){ | 2377 | if(parseInt(item.limit_num)>0){ |
| 2377 | - can_zp_num += parseInt(item.gift_storecount) > parseInt(item.limit_num) ? parseInt(item.limit_num) : parseInt(item.gift_storecount); | 2378 | + c_zp= parseInt(item.gift_storecount) > parseInt(item.can_num) ? parseInt(item.can_num) : parseInt(item.gift_storecount); |
| 2378 | }else{ | 2379 | }else{ |
| 2379 | - can_zp_num += parseInt(item.gift_storecount); | 2380 | + c_zp= parseInt(item.gift_storecount); |
| 2380 | } | 2381 | } |
| 2382 | + | ||
| 2383 | + if(c_zp<0) c_zp=0; | ||
| 2384 | + can_zp_num +=c_zp; | ||
| 2385 | + | ||
| 2381 | } | 2386 | } |
| 2382 | 2387 | ||
| 2383 | var t_zp_num = parseInt(get_data.zp_num) * parseInt(get_data.bs); | 2388 | var t_zp_num = parseInt(get_data.zp_num) * parseInt(get_data.bs); |
| @@ -7286,7 +7291,7 @@ Page({ | @@ -7286,7 +7291,7 @@ Page({ | ||
| 7286 | return false; | 7291 | return false; |
| 7287 | } | 7292 | } |
| 7288 | //-- 限购一定要大于0,否则就是不限的意思 -- | 7293 | //-- 限购一定要大于0,否则就是不限的意思 -- |
| 7289 | - if (discount.limit_num>0 && discount.limit_num < all_limit_num) { | 7294 | + if (discount.limit_num>0 && discount.can_num < all_limit_num) { |
| 7290 | wx.showToast({ | 7295 | wx.showToast({ |
| 7291 | title: "超出赠品限购", | 7296 | title: "超出赠品限购", |
| 7292 | icon: 'none', | 7297 | icon: 'none', |
| @@ -7309,12 +7314,17 @@ Page({ | @@ -7309,12 +7314,17 @@ Page({ | ||
| 7309 | var all_num = 0; | 7314 | var all_num = 0; |
| 7310 | for (let i in giftsinfo) { | 7315 | for (let i in giftsinfo) { |
| 7311 | let item = giftsinfo[i]; | 7316 | let item = giftsinfo[i]; |
| 7312 | - if (!item.selected) continue; | ||
| 7313 | - | ||
| 7314 | - if(item.must_num>0 && item.goods_num<item.must_num){ | 7317 | + if(item.must_num>0 ){ |
| 7318 | + if(!item.selected){ | ||
| 7319 | + ut.m_toast("必送的赠品没有选中"); | ||
| 7320 | + return false; | ||
| 7321 | + } | ||
| 7322 | + if(item.goods_num<item.must_num){ | ||
| 7315 | ut.m_toast("活动赠品的超量数量不足"); | 7323 | ut.m_toast("活动赠品的超量数量不足"); |
| 7316 | return false; | 7324 | return false; |
| 7325 | + } | ||
| 7317 | } | 7326 | } |
| 7327 | + if (!item.selected) continue; | ||
| 7318 | all_num += item.goods_num; | 7328 | all_num += item.goods_num; |
| 7319 | } | 7329 | } |
| 7320 | if (all_num > zp_num) { | 7330 | if (all_num > zp_num) { |
| @@ -7515,14 +7525,18 @@ Page({ | @@ -7515,14 +7525,18 @@ Page({ | ||
| 7515 | var gf_pr_name = item_arr[ip].gf_pr_name; | 7525 | var gf_pr_name = item_arr[ip].gf_pr_name; |
| 7516 | var zp_num = item_arr[ip].zp_num; | 7526 | var zp_num = item_arr[ip].zp_num; |
| 7517 | var giftsinfo = item_arr[ip].giftsinfo; | 7527 | var giftsinfo = item_arr[ip].giftsinfo; |
| 7528 | + | ||
| 7518 | var limit_all = 0; | 7529 | var limit_all = 0; |
| 7519 | var stock_all = 0; | 7530 | var stock_all = 0; |
| 7531 | + var no_limit=0; | ||
| 7532 | + | ||
| 7520 | for (let iu in giftsinfo) { | 7533 | for (let iu in giftsinfo) { |
| 7521 | let gf_item = giftsinfo[iu]; | 7534 | let gf_item = giftsinfo[iu]; |
| 7522 | - limit_all += gf_item.limit_num; | 7535 | + limit_all += gf_item.can_num>0?gf_item.can_num:0; |
| 7523 | stock_all += gf_item.gift_storecount; | 7536 | stock_all += gf_item.gift_storecount; |
| 7537 | + if(gf_item.limit_num<=0) no_limit=1; | ||
| 7524 | } | 7538 | } |
| 7525 | - if (limit_all < zp_num) { | 7539 | + if (!no_limit && limit_all < zp_num) { |
| 7526 | error_arr.push(gf_pr_name + "限购不足"); | 7540 | error_arr.push(gf_pr_name + "限购不足"); |
| 7527 | } | 7541 | } |
| 7528 | if (stock_all < zp_num) { | 7542 | if (stock_all < zp_num) { |
packageE/pages/cart/cart2/cart2.wxml
| @@ -1066,7 +1066,7 @@ | @@ -1066,7 +1066,7 @@ | ||
| 1066 | {{items.goodsinfo.goods_color}}{{items.goodsinfo.goods_color?"/":''}}{{items.goodsinfo.goods_spec}}</view> | 1066 | {{items.goodsinfo.goods_color}}{{items.goodsinfo.goods_color?"/":''}}{{items.goodsinfo.goods_spec}}</view> |
| 1067 | <view wx:else>规格1</view> | 1067 | <view wx:else>规格1</view> |
| 1068 | </view> | 1068 | </view> |
| 1069 | - <text class="c-red" wx:if="{{items.must_num>0 && items.limit_num>0 && items.must_num>items.limit_num}}">(超量不足)</text> | 1069 | + <text class="c-red" wx:if="{{items.must_num>0 && items.limit_num>0 && items.must_num>items.can_num}}">(超量不足)</text> |
| 1070 | <text class="c-red" wx:elif="{{items.must_num>0}}">必选{{items.must_num}}件</text> | 1070 | <text class="c-red" wx:elif="{{items.must_num>0}}">必选{{items.must_num}}件</text> |
| 1071 | 1071 | ||
| 1072 | </view> | 1072 | </view> |
pages/cart/cart/cart.js
| @@ -4154,11 +4154,14 @@ Page({ | @@ -4154,11 +4154,14 @@ Page({ | ||
| 4154 | for (let iy in discount.giftsinfo) { | 4154 | for (let iy in discount.giftsinfo) { |
| 4155 | let item = discount.giftsinfo[iy]; | 4155 | let item = discount.giftsinfo[iy]; |
| 4156 | 4156 | ||
| 4157 | + var c_zp=0; | ||
| 4157 | if(parseInt(item.limit_num)>0){ | 4158 | if(parseInt(item.limit_num)>0){ |
| 4158 | - can_zp_num += parseInt(item.gift_storecount) > parseInt(item.limit_num) ? parseInt(item.limit_num) : parseInt(item.gift_storecount); | 4159 | + c_zp= parseInt(item.gift_storecount) > parseInt(item.can_num) ? parseInt(item.can_num) : parseInt(item.gift_storecount); |
| 4159 | }else{ | 4160 | }else{ |
| 4160 | - can_zp_num += parseInt(item.gift_storecount); | 4161 | + c_zp= parseInt(item.gift_storecount); |
| 4161 | } | 4162 | } |
| 4163 | + if(c_zp<0) c_zp=0; | ||
| 4164 | + can_zp_num +=c_zp; | ||
| 4162 | } | 4165 | } |
| 4163 | 4166 | ||
| 4164 | var t_zp_num = parseInt(discount.zp_num) * parseInt(discount.bs); | 4167 | var t_zp_num = parseInt(discount.zp_num) * parseInt(discount.bs); |
| @@ -4480,7 +4483,14 @@ Page({ | @@ -4480,7 +4483,14 @@ Page({ | ||
| 4480 | var a_limit_num = 0; | 4483 | var a_limit_num = 0; |
| 4481 | for (let iy in discount.giftsinfo) { | 4484 | for (let iy in discount.giftsinfo) { |
| 4482 | let item = discount.giftsinfo[iy]; | 4485 | let item = discount.giftsinfo[iy]; |
| 4483 | - can_zp_num += parseInt(item.gift_storecount) > parseInt(item.limit_num) ? parseInt(item.limit_num) : parseInt(item.gift_storecount); | 4486 | + var c_zp=0; |
| 4487 | + if(parseInt(item.limit_num)>0) { | ||
| 4488 | + c_zp= parseInt(item.gift_storecount) > parseInt(item.can_num) ? parseInt(item.can_num) : parseInt(item.gift_storecount); | ||
| 4489 | + }else{ | ||
| 4490 | + c_zp= parseInt(item.gift_storecount) | ||
| 4491 | + } | ||
| 4492 | + if(c_zp<0) c_zp=0; | ||
| 4493 | + can_zp_num +=c_zp; | ||
| 4484 | } | 4494 | } |
| 4485 | 4495 | ||
| 4486 | var t_zp_num = parseInt(discount.zp_num) * parseInt(discount.bs); | 4496 | var t_zp_num = parseInt(discount.zp_num) * parseInt(discount.bs); |