Commit 846498126701f77e62d3370fcc45b798b316165b
1 parent
b0cec5a2
1、赠品限量 超量的优化
2、多门店的时候,一起超出商品限购的时候,不能提交订单!
Showing
3 changed files
with
43 additions
and
12 deletions
packageE/pages/cart/cart2/cart2.js
| ... | ... | @@ -2333,6 +2333,7 @@ Page({ |
| 2333 | 2333 | if (get_data.gift_id && parseInt(get_data.zp_mode) != 1 |
| 2334 | 2334 | && get_data.zp_num * item_map.bs <= get_data.limit_num-other_gift |
| 2335 | 2335 | && get_data.zp_num * item_map.bs <= get_data.gift_storecount |
| 2336 | + && get_data.zp_num>get_data.must_num //增加一个超量 | |
| 2336 | 2337 | ) { |
| 2337 | 2338 | |
| 2338 | 2339 | item_map.gift_id = get_data.gift_id; |
| ... | ... | @@ -4711,6 +4712,8 @@ Page({ |
| 4711 | 4712 | |
| 4712 | 4713 | var order_prom_list_cart = th.data.order_prom_list_cart; |
| 4713 | 4714 | |
| 4715 | + //优惠商品限购的优化 | |
| 4716 | + var yh_lm_map={}; | |
| 4714 | 4717 | //--组装推送数据-- |
| 4715 | 4718 | for (var i = 0; i < order_prom_list_cart.length; i++) { |
| 4716 | 4719 | var t_item = order_prom_list_cart[i]; |
| ... | ... | @@ -4877,8 +4880,6 @@ Page({ |
| 4877 | 4880 | var check_map = {}; |
| 4878 | 4881 | let groupchat_ids=[] |
| 4879 | 4882 | |
| 4880 | - | |
| 4881 | - | |
| 4882 | 4883 | //-------------让商品添加到商品列表-------------------- |
| 4883 | 4884 | for (var k = 0; k < t_item.goods.length; k++) { |
| 4884 | 4885 | |
| ... | ... | @@ -4987,7 +4988,8 @@ Page({ |
| 4987 | 4988 | var mo_num=getApp().get_limit_qty(g_item,act.length); |
| 4988 | 4989 | var steep=getApp().get_limit_qty(g_item,act.length,1); |
| 4989 | 4990 | |
| 4990 | - if ([0,3,5,7,10].indexOf(goods.prom_type)>-1){ | |
| 4991 | + //赠品要排除之外,不进行判断 | |
| 4992 | + if ([0,3,5,7,10].indexOf(goods.prom_type)>-1 && !goods.is_gift){ | |
| 4991 | 4993 | if(mo_num>goods.goods_num){ |
| 4992 | 4994 | getApp().confirmBox(goods.goods_name + "的未达到起订数量"); |
| 4993 | 4995 | th.data.is_summit_ing = 0; |
| ... | ... | @@ -5026,12 +5028,22 @@ Page({ |
| 5026 | 5028 | pro_by_num=gd_limit_rs.data.data.promgoodsbuynum |
| 5027 | 5029 | } |
| 5028 | 5030 | |
| 5029 | - if(pro_gd_limit_num>0 && pro_gd_limit_num<pro_by_num+goods.goods_num){ | |
| 5031 | + var m_ky=goods.goods_id+'|'+goods.prom_id; | |
| 5032 | + | |
| 5033 | + var more_num=yh_lm_map[m_ky]?yh_lm_map[m_ky]:0; | |
| 5034 | + | |
| 5035 | + if(pro_gd_limit_num<pro_by_num+goods.goods_num+more_num){ | |
| 5030 | 5036 | getApp().confirmBox(goods.goods_name + "超优惠促销限购,无法购买"); |
| 5031 | 5037 | th.data.is_summit_ing = 0; |
| 5032 | 5038 | th.setData({ submit: 0 }) |
| 5033 | 5039 | return false; |
| 5034 | 5040 | } |
| 5041 | + | |
| 5042 | + //方便下一轮商品判断限购 | |
| 5043 | + if(!yh_lm_map[m_ky]) { | |
| 5044 | + yh_lm_map[m_ky]=0; | |
| 5045 | + } | |
| 5046 | + yh_lm_map[m_ky]+=goods.goods_num; | |
| 5035 | 5047 | } |
| 5036 | 5048 | } |
| 5037 | 5049 | |
| ... | ... | @@ -7245,7 +7257,7 @@ Page({ |
| 7245 | 7257 | var gift_id = discount.gift_id; |
| 7246 | 7258 | for (var i in alllist) { |
| 7247 | 7259 | var list_item = alllist[i]; |
| 7248 | - //-- 门店相同,活动相同的时候 -- | |
| 7260 | + //-- 门店相同,活动相同的时候,就continue掉 -- | |
| 7249 | 7261 | if (pick_id == list_item.pickup_id && prom_id == list_item.prom_id) continue; |
| 7250 | 7262 | for (var j in list_item.goods) { |
| 7251 | 7263 | //如果赠品的ID一样,要进行统计数量 |
| ... | ... | @@ -7254,7 +7266,7 @@ Page({ |
| 7254 | 7266 | all_num += list_item.goods[j].goods_num; |
| 7255 | 7267 | } |
| 7256 | 7268 | if (list_item.goods[j].is_gift == 1 && list_item.goods[j].gift_id == gift_id && list_item.goods[j].prom_id == prom_id) { |
| 7257 | - all_limit_num += list_item.goods[j].limit_num; | |
| 7269 | + all_limit_num += list_item.goods[j].goods_num; | |
| 7258 | 7270 | } |
| 7259 | 7271 | } |
| 7260 | 7272 | } |
| ... | ... | @@ -7268,7 +7280,8 @@ Page({ |
| 7268 | 7280 | }); |
| 7269 | 7281 | return false; |
| 7270 | 7282 | } |
| 7271 | - if (discount.limit_num < all_limit_num) { | |
| 7283 | + //-- 限购一定要大于0,否则就是不限的意思 -- | |
| 7284 | + if (discount.limit_num>0 && discount.limit_num < all_limit_num) { | |
| 7272 | 7285 | wx.showToast({ |
| 7273 | 7286 | title: "超出赠品限购", |
| 7274 | 7287 | icon: 'none', |
| ... | ... | @@ -7292,6 +7305,11 @@ Page({ |
| 7292 | 7305 | for (let i in giftsinfo) { |
| 7293 | 7306 | let item = giftsinfo[i]; |
| 7294 | 7307 | if (!item.selected) continue; |
| 7308 | + | |
| 7309 | + if(item.must_num>0 && item.goods_num<item.must_num){ | |
| 7310 | + ut.m_toast("活动赠品的超量数量不足"); | |
| 7311 | + return false; | |
| 7312 | + } | |
| 7295 | 7313 | all_num += item.goods_num; |
| 7296 | 7314 | } |
| 7297 | 7315 | if (all_num > zp_num) { |
| ... | ... | @@ -7323,7 +7341,6 @@ Page({ |
| 7323 | 7341 | var pos=this.find_pro_last(pk_list_goods,3,this.data.gf_prom_id); |
| 7324 | 7342 | var fd_gd=pk_list_goods[pos] |
| 7325 | 7343 | |
| 7326 | - | |
| 7327 | 7344 | var url = "/api/weshop/cart/delGift?store_id=" + os.stoid + "&user_id=" |
| 7328 | 7345 | + getApp().globalData.user_id + "&is_gift=1&pick_id=" + this.data.gift_pkid + "&prom_id=" + this.data.gf_prom_id; |
| 7329 | 7346 | await getApp().request.promiseDelete(url, {}); | ... | ... |
packageE/pages/cart/cart2/cart2.wxml
| ... | ... | @@ -1054,17 +1054,21 @@ |
| 1054 | 1054 | </view> |
| 1055 | 1055 | |
| 1056 | 1056 | <navigator class="goods-img rel" bindtap="go_gd" data-gd="{{items.goods_id}}"> |
| 1057 | - <image class="wh100" src="{{imgUrl+items.goodsinfo.original_img}}" binderror="bind_bnerr2" data-errorimg="gift_goods[{{idx}}].goodsinfo.original_img"></image> | |
| 1057 | + <image class="wh100" src="{{imgUrl+items.goodsinfo.original_img}}" binderror="cart_set_err1" data-err="giftsinfo[{{idx}}].goodsinfo.original_img"></image> | |
| 1058 | 1058 | </navigator> |
| 1059 | 1059 | <view class="goods-cont"> |
| 1060 | - <view class="goods-name"> | |
| 1061 | - <navigator bindtap="go_gd" class="ellipsis-2 fs30" data-gd="{{items.goods_id}}">{{items.goods_name}}</navigator> | |
| 1060 | + <view class="goods-name2"> | |
| 1061 | + <navigator bindtap="go_gd" class="ellipsis-2 fs30" data-gd="{{items.goods_id}}">{{items.goods_name}} | |
| 1062 | + </navigator> | |
| 1062 | 1063 | |
| 1063 | 1064 | <view class="specifications ellipsis-1"> |
| 1064 | 1065 | <view wx:if="{{items.goodsinfo.goods_color || items.goodsinfo.goods_spec}}"> |
| 1065 | 1066 | {{items.goodsinfo.goods_color}}{{items.goodsinfo.goods_color?"/":''}}{{items.goodsinfo.goods_spec}}</view> |
| 1066 | 1067 | <view wx:else>规格1</view> |
| 1067 | 1068 | </view> |
| 1069 | + <text class="c-red" wx:if="{{items.must_num>0 && items.limit_num>0 && items.must_num>items.limit_num}}">(超量不足)</text> | |
| 1070 | + <text class="c-red" wx:elif="{{items.must_num>0}}">必选{{items.must_num}}件</text> | |
| 1071 | + | |
| 1068 | 1072 | </view> |
| 1069 | 1073 | |
| 1070 | 1074 | <view class="flex alend jc_sb"> | ... | ... |
packageE/pages/cart/cart2/cart2.wxss
| ... | ... | @@ -130,7 +130,13 @@ page { |
| 130 | 130 | margin-bottom: 16rpx; |
| 131 | 131 | font-size: 28rpx; |
| 132 | 132 | color: #333; |
| 133 | - | |
| 133 | +} | |
| 134 | +.goods-name2 { | |
| 135 | + height: 74rpx; | |
| 136 | + line-height: 40rpx; | |
| 137 | + margin-bottom: 16rpx; | |
| 138 | + font-size: 28rpx; | |
| 139 | + color: #333; | |
| 134 | 140 | } |
| 135 | 141 | |
| 136 | 142 | .goods-color { |
| ... | ... | @@ -1228,6 +1234,10 @@ margin-left: 20rpx; |
| 1228 | 1234 | margin-top: 6rpx; |
| 1229 | 1235 | } |
| 1230 | 1236 | |
| 1237 | +.c-red { | |
| 1238 | + color: #f23030;vertical-align: top;position: relative;top: 3rpx;font-size: 21rpx;margin-left: 2rpx; | |
| 1239 | +} | |
| 1240 | + | |
| 1231 | 1241 | |
| 1232 | 1242 | |
| 1233 | 1243 | ... | ... |