Commit 5c70b1f01196f7e35f3e7cf228c44f703580d775
Merge branch 'dev' of http://git.vipzhuang.cn/wxd/MShopWeApp into test
Showing
11 changed files
with
385 additions
and
329 deletions
app.js
packageC/pages/luckyGo/luckyGo_goodsInfo/buy_pt.wxml
| ... | ... | @@ -25,15 +25,14 @@ |
| 25 | 25 | <block wx:if="{{is_normal==1}}"> |
| 26 | 26 | <view class="flex"> |
| 27 | 27 | <view class="spec-goods-stock">已售:{{sele_g.sales_sum}}</view> |
| 28 | - | |
| 29 | - <block wx:if="{{!filters.is_virtual_gd(sele_g.is_virtual)}}"> | |
| 30 | 28 | <block wx:if="{{sales_rules>=2}}"> |
| 31 | - <view class="spec-goods-stock" wx:if="{{def_pick_store && def_pick_store.CanOutQty}}">可售:{{def_pick_store.CanOutQty}}</view> | |
| 32 | - <view class="spec-goods-stock" wx:else>可售:0</view> | |
| 29 | + <block wx:if="{{!filters.is_virtual_gd(sele_g.is_virtual)}}"> | |
| 30 | + <view class="spec-goods-stock" wx:if="{{def_pick_store && def_pick_store.CanOutQty}}">可售:{{def_pick_store.CanOutQty}}</view> | |
| 31 | + <view class="spec-goods-stock" wx:else>可售:0</view> | |
| 32 | + </block> | |
| 33 | 33 | </block> |
| 34 | 34 | <block wx:else><view class="spec-goods-stock">可售:{{sele_g.store_count}}</view></block> |
| 35 | - </block> | |
| 36 | - </view> | |
| 35 | + </view> | |
| 37 | 36 | </block> |
| 38 | 37 | <!-- <block wx:if="{{is_normal==0}}"> |
| 39 | 38 | <view class="flex"> | ... | ... |
packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js
| ... | ... | @@ -2195,6 +2195,9 @@ Page({ |
| 2195 | 2195 | |
| 2196 | 2196 | this.get_buy_num(this.data.sele_g, async function () { |
| 2197 | 2197 | |
| 2198 | + | |
| 2199 | + var is_show_bs=0; | |
| 2200 | + var l_num=-1; | |
| 2198 | 2201 | //--判断商品是否超出限购-- |
| 2199 | 2202 | if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { |
| 2200 | 2203 | |
| ... | ... | @@ -2205,10 +2208,11 @@ Page({ |
| 2205 | 2208 | // title: '超出商品限购', |
| 2206 | 2209 | // }); |
| 2207 | 2210 | getApp().my_warnning('超出商品限购', 0, th); |
| 2208 | - var num = th.data.sele_g.viplimited - gd_buy_num; | |
| 2209 | - if (num < 0) num = 0; | |
| 2210 | - th.setData({ goodsInputNum: num }) | |
| 2211 | - return false; | |
| 2211 | + l_num = th.data.sele_g.viplimited - gd_buy_num; | |
| 2212 | + if (l_num < 0) l_num = 0; | |
| 2213 | + //th.setData({ goodsInputNum: num }) | |
| 2214 | + //return false; | |
| 2215 | + is_show_bs=1; | |
| 2212 | 2216 | } |
| 2213 | 2217 | } |
| 2214 | 2218 | |
| ... | ... | @@ -2263,22 +2267,41 @@ Page({ |
| 2263 | 2267 | } |
| 2264 | 2268 | } |
| 2265 | 2269 | |
| 2270 | + //-- 限购数量也要进行计算一下 -- | |
| 2271 | + if(l_num>-1){ | |
| 2272 | + if(e>l_num) e=l_num; | |
| 2273 | + } | |
| 2274 | + | |
| 2275 | + //提示了一个,就不要提示第二个 | |
| 2276 | + var is_show_bs=0; | |
| 2266 | 2277 | //--- 促销活动也不控制起订量, 这里很重要的一个控制,起订量的 ---- |
| 2267 | 2278 | if(th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1){ |
| 2268 | - if(t<mo_num) t=mo_num; | |
| 2279 | + if(t<mo_num){ | |
| 2280 | + t=mo_num; | |
| 2281 | + if(!is_show_bs){ | |
| 2282 | + wx.showToast({ | |
| 2283 | + title: '购买数未达到起订量', | |
| 2284 | + icon: 'none', | |
| 2285 | + }); | |
| 2286 | + } | |
| 2287 | + is_show_bs=1; | |
| 2288 | + } | |
| 2269 | 2289 | if(t>mo_num && (t-mo_num)%steep!=0){ |
| 2270 | - wx.showToast({ | |
| 2271 | - title: '购买数必须是起订量的倍数', | |
| 2272 | - icon: 'none', | |
| 2273 | - }); | |
| 2290 | + if(!is_show_bs) { | |
| 2291 | + wx.showToast({ | |
| 2292 | + title: '购买数必须是起订量的倍数', | |
| 2293 | + icon: 'none', | |
| 2294 | + }); | |
| 2295 | + } | |
| 2274 | 2296 | t=mo_num+ parseInt((t-mo_num)/steep)*steep+steep; |
| 2297 | + is_show_bs=1; | |
| 2275 | 2298 | } |
| 2276 | 2299 | } |
| 2277 | 2300 | |
| 2278 | 2301 | if (!e) e = 0; |
| 2279 | 2302 | //库存不足,不增加 |
| 2280 | 2303 | if (e < t) { |
| 2281 | - wx.showModal({ title: '库存不足', }); | |
| 2304 | + if(!is_show_bs) wx.showModal({ title: '库存不足', }); | |
| 2282 | 2305 | if (e < 0) e = 0; |
| 2283 | 2306 | |
| 2284 | 2307 | if(th.data.is_normal == 1){ |
| ... | ... | @@ -4469,9 +4492,7 @@ Page({ |
| 4469 | 4492 | |
| 4470 | 4493 | //-----------------拼单生成方法--------------------- |
| 4471 | 4494 | addCart_pt: function () { |
| 4472 | - this.setData({ | |
| 4473 | - openSpecModal_pt: 0, | |
| 4474 | - }); | |
| 4495 | + | |
| 4475 | 4496 | if (this.data.is_normal == 0) { |
| 4476 | 4497 | //看一下有没有起购数,如果有起购数,要计算起购数 |
| 4477 | 4498 | // var qnum = parseFloat(th.data.prom_act.minbuynum); | ... | ... |
packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.wxml
| ... | ... | @@ -1186,7 +1186,7 @@ |
| 1186 | 1186 | <block wx:else> |
| 1187 | 1187 | <!-- 如果是线下库存购买的时候,且是普通商品购买的时候 --> |
| 1188 | 1188 | <block wx:if="{{sales_rules>=2 && prom_type==0}}"> |
| 1189 | - <block wx:if="{{!def_pick_store.CanOutQty || def_pick_store.CanOutQty<mo_num}}"> | |
| 1189 | + <block wx:if="{{!def_pick_store.CanOutQty || def_pick_store.CanOutQty<1}}"> | |
| 1190 | 1190 | <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999"> |
| 1191 | 1191 | 库存不足 |
| 1192 | 1192 | </view> |
| ... | ... | @@ -1202,7 +1202,7 @@ |
| 1202 | 1202 | </block> |
| 1203 | 1203 | <!-- 线上销售 --> |
| 1204 | 1204 | <block wx:else> |
| 1205 | - <block wx:if="{{sele_g.store_count<(mo_num?mo_num:1)}}"> | |
| 1205 | + <block wx:if="{{sele_g.store_count<1}}"> | |
| 1206 | 1206 | <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999"> |
| 1207 | 1207 | 库存不足 |
| 1208 | 1208 | </view> | ... | ... |
packageE/pages/cart/cart2/cart2.js
| ... | ... | @@ -4069,7 +4069,7 @@ Page({ |
| 4069 | 4069 | |
| 4070 | 4070 | if ([0,3,5,7,10].indexOf(goods.prom_type)>-1){ |
| 4071 | 4071 | if(mo_num>goods.goods_num){ |
| 4072 | - getApp().confirmBox(goods.goods_name + "的未到达起订数量"); | |
| 4072 | + getApp().confirmBox(goods.goods_name + "的未达到起订数量"); | |
| 4073 | 4073 | th.data.is_summit_ing = 0; |
| 4074 | 4074 | return false; |
| 4075 | 4075 | } |
| ... | ... | @@ -4452,7 +4452,7 @@ Page({ |
| 4452 | 4452 | |
| 4453 | 4453 | if ([0,3,5,7,10].indexOf(goods.prom_type)>-1){ |
| 4454 | 4454 | if(mo_num>goods.goods_num){ |
| 4455 | - getApp().confirmBox(goods.goods_name + "的未到达起订数量"); | |
| 4455 | + getApp().confirmBox(goods.goods_name + "的未达到起订数量"); | |
| 4456 | 4456 | th.data.is_summit_ing = 0; |
| 4457 | 4457 | return false; |
| 4458 | 4458 | } | ... | ... |
pages/cart/cart/cart.js
| ... | ... | @@ -1559,9 +1559,9 @@ Page({ |
| 1559 | 1559 | valueToNum: function (t) { |
| 1560 | 1560 | if (!this.data.is_load) return false; |
| 1561 | 1561 | //控制住,避免事件响应冲突,只有input有输入的时候,才刷新 |
| 1562 | - if (this.data.btn_click) { | |
| 1563 | - return false; | |
| 1564 | - } | |
| 1562 | + // if (this.data.btn_click) { | |
| 1563 | + // return false; | |
| 1564 | + // } | |
| 1565 | 1565 | this.data.btn_click = 1; |
| 1566 | 1566 | |
| 1567 | 1567 | var a = t.currentTarget.dataset.item; |
| ... | ... | @@ -1848,7 +1848,7 @@ Page({ |
| 1848 | 1848 | //-- 判断起购数量 -- |
| 1849 | 1849 | if(!e.data.checkAllToggle){ |
| 1850 | 1850 | //判断是不是有促销活动 |
| 1851 | - var act=await getApp().get_has_cx_act(gd_info.goods_id); | |
| 1851 | + var act=await getApp().get_has_cx_act(obj.goods_id); | |
| 1852 | 1852 | th.click_set_limit(obj,i,j,act); |
| 1853 | 1853 | } |
| 1854 | 1854 | |
| ... | ... | @@ -2102,7 +2102,7 @@ Page({ |
| 2102 | 2102 | th.click_set_limit(gd_info,pitems,i,act) |
| 2103 | 2103 | } |
| 2104 | 2104 | |
| 2105 | - if (!gd_info.whsle_id && [1, 2, 4, 6, 8, 9].indexOf(gd_info.prom_type) == -1 && !gd_info.selected) { | |
| 2105 | + if(!gd_info.whsle_id && [1, 2, 4, 6, 8, 9].indexOf(gd_info.prom_type) == -1 && !gd_info.selected && th.data.sales_rules >= 2 ) { | |
| 2106 | 2106 | var ob = {}; |
| 2107 | 2107 | await th.check_down_line_next(gd_info, pitems, i, gd_info.erpwareid, function (res) { |
| 2108 | 2108 | ob = res; |
| ... | ... | @@ -2599,58 +2599,56 @@ Page({ |
| 2599 | 2599 | }); |
| 2600 | 2600 | }, |
| 2601 | 2601 | |
| 2602 | - //----------------------更新购物数量,加减,调用接口--------------------- | |
| 2603 | - postCardList: function (t, item, pitem) { | |
| 2604 | - var e = this, | |
| 2605 | - th = e, | |
| 2606 | - user_id = getApp().globalData.user_id; | |
| 2607 | - | |
| 2608 | - function normal_check(store_count, goodsinfo, wareIds,cx_arr) { | |
| 2609 | - | |
| 2610 | - | |
| 2611 | - // getApp().my_warnning('购买数量超出商品库存', 0, th); | |
| 2612 | - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | |
| 2613 | - //-- 要判断是不是起订量不购 -- | |
| 2614 | - if([0,3,5,7,10].indexOf(goodsinfo.prom_type)>-1){ | |
| 2615 | - var mo_num=getApp().get_limit_qty(goodsinfo,cx_arr.length); | |
| 2616 | - var steep=getApp().get_limit_qty(goodsinfo,cx_arr.length,1); | |
| 2617 | - if(mo_num>1 && t.goods_num<mo_num){ | |
| 2618 | - wx.showToast({ | |
| 2619 | - title: '购买数量小于商品的起订量', | |
| 2620 | - icon: 'none', | |
| 2621 | - }); | |
| 2622 | - t.goods_num =mo_num; | |
| 2623 | - } | |
| 2624 | - if(steep>1 && t.goods_num>mo_num && (t.goods_num-mo_num)%steep!=0 ){ | |
| 2625 | - | |
| 2626 | - wx.showToast({ | |
| 2627 | - title: '购买数量必须是起订量的倍数', | |
| 2628 | - icon: 'none', | |
| 2629 | - }); | |
| 2630 | - t.goods_num =mo_num+parseInt((t.goods_num-mo_num)/steep+'')*steep+steep; | |
| 2602 | + //-- 循环汇总其他门店,其他活动有此商品的购买数量的汇总,不包含赠品 -- | |
| 2603 | + get_goods_other(item, pitem,only){ | |
| 2604 | + var goods_id = this.data.requestData[pitem].goods[item].goods_id; | |
| 2605 | + var prom_type = this.data.requestData[pitem].goods[item].prom_type; | |
| 2606 | + var prom_id = this.data.requestData[pitem].goods[item].prom_id; | |
| 2607 | + | |
| 2608 | + var num=0; | |
| 2609 | + //-- 相同活动的商品汇总,秒杀,团购 -- | |
| 2610 | + if(only==2){ | |
| 2611 | + for (let j = 0; j < this.data.requestData.length;j++){ | |
| 2612 | + if(j!=pitem){ | |
| 2613 | + var goods=this.data.requestData[j].goods; | |
| 2614 | + for (let k = 0; k <goods.length ; k++) { | |
| 2615 | + var m_item=goods[k]; | |
| 2616 | + if(m_item.goods_id==goods_id && m_item.is_gift==0 | |
| 2617 | + && m_item.prom_id==prom_id && m_item.prom_type==prom_type ){ | |
| 2618 | + num+=m_item.goods_num | |
| 2619 | + } | |
| 2620 | + } | |
| 2631 | 2621 | } |
| 2632 | 2622 | } |
| 2623 | + return num; | |
| 2624 | + } | |
| 2633 | 2625 | |
| 2634 | - | |
| 2635 | - //--- 看一下是不是线下库存 --- | |
| 2636 | - if (th.data.sales_rules >= 2 && !goodsinfo.whsle_id) { | |
| 2637 | - th.check_down_line(t, pitem, item, wareIds); | |
| 2638 | - } else { | |
| 2639 | - if (t.goods_num > store_count) { | |
| 2640 | - wx.showToast({ | |
| 2641 | - title: '购买数量超出商品库存', | |
| 2642 | - icon: 'none', | |
| 2643 | - }); | |
| 2644 | - e.setData({ | |
| 2645 | - [txt]: store_count | |
| 2646 | - }); | |
| 2647 | - e.doCheckAll(); | |
| 2648 | - t.goods_num = store_count; | |
| 2626 | + for (let i = 0; i < this.data.requestData[pitem].goods.length; i++) { | |
| 2627 | + var t_item=this.data.requestData[pitem].goods[i] | |
| 2628 | + if(i!=item && t_item.goods_id==goods_id && t_item.is_gift==0){ | |
| 2629 | + num+=t_item.goods_num | |
| 2630 | + } | |
| 2631 | + } | |
| 2632 | + if(only) return num; | |
| 2633 | + for (let j = 0; j < this.data.requestData.length;j++){ | |
| 2634 | + if(j!=pitem){ | |
| 2635 | + var goods=this.data.requestData[j].goods; | |
| 2636 | + for (let k = 0; k <goods.length ; k++) { | |
| 2637 | + var m_item=goods[k]; | |
| 2638 | + if(m_item.goods_id==goods_id && m_item.is_gift==0){ | |
| 2639 | + num+=m_item.goods_num | |
| 2640 | + } | |
| 2641 | + } | |
| 2649 | 2642 | } |
| 2650 | - e.update_cart(t, pitem, item); | |
| 2651 | - } | |
| 2652 | 2643 | } |
| 2653 | 2644 | |
| 2645 | + return num; | |
| 2646 | + }, | |
| 2647 | + | |
| 2648 | + //----------------------更新购物数量,加减,调用接口--------------------- | |
| 2649 | + postCardList: function (t, item, pitem) { | |
| 2650 | + var e = this,th = e,user_id = getApp().globalData.user_id; | |
| 2651 | + | |
| 2654 | 2652 | // console.log('update'); |
| 2655 | 2653 | // console.log('9995959595959',t); |
| 2656 | 2654 | var e = this, th = e; |
| ... | ... | @@ -2666,7 +2664,8 @@ Page({ |
| 2666 | 2664 | var promgoodsbuynum = 0; |
| 2667 | 2665 | var goodsbuynum = 0; |
| 2668 | 2666 | |
| 2669 | - //--要获得商品,该用户买了多少件,同步应用-- | |
| 2667 | + var is_showing=0; | |
| 2668 | + //--要获得商品,该用户买了多少件,同步应用,用于限购的计算-- | |
| 2670 | 2669 | await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", { |
| 2671 | 2670 | data: { |
| 2672 | 2671 | store_id: oo.stoid, |
| ... | ... | @@ -2686,279 +2685,280 @@ Page({ |
| 2686 | 2685 | } |
| 2687 | 2686 | goodsbuynum = buy_num_data.goodsbuynum; |
| 2688 | 2687 | |
| 2689 | - | |
| 2690 | 2688 | }) |
| 2691 | 2689 | |
| 2692 | 2690 | //--> by ty |
| 2693 | 2691 | // var buyed_mum2 = t.goods_num + goodsbuynum; |
| 2694 | 2692 | var buyed_mum2 = t.goods_num; |
| 2695 | 2693 | //<-- |
| 2694 | + // 判断当前预购买的数量是否超过可购买的数量,限购还要考虑到商品的库存 | |
| 2695 | + if (limit > 0) { | |
| 2696 | 2696 | |
| 2697 | - // 判断当前预购买的数量是否超过可购买的数量 | |
| 2698 | - if (buyed_mum2 > (limit - goodsbuynum) && limit > 0) { | |
| 2699 | - wx.showToast({ | |
| 2700 | - title: '购买数量超出商品限购', | |
| 2701 | - icon: 'none', | |
| 2702 | - }); | |
| 2703 | 2697 | //getApp().my_warnning('购买数量超出商品限购', 0, th); |
| 2704 | 2698 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; |
| 2705 | - | |
| 2706 | - //--> by ty | |
| 2707 | - var cbuy = limit - goodsbuynum; | |
| 2708 | - // var cbuy = limit - buyed_mum2 + 1; | |
| 2709 | - //<-- | |
| 2710 | - | |
| 2711 | - e.setData({ | |
| 2712 | - // [txt]: cbuy > 0 ? cbuy : 0, | |
| 2713 | - [txt]: cbuy > 0 ? cbuy : limit, | |
| 2714 | - }); | |
| 2715 | - e.doCheckAll(); | |
| 2716 | - | |
| 2717 | - t.goods_num = cbuy > 0 ? cbuy : limit; | |
| 2718 | - | |
| 2719 | - if([0,3,5,7,10].indexOf(goodsinfo.prom_type)>-1){ | |
| 2720 | - | |
| 2721 | - //-- 判断商品是不是 -- | |
| 2722 | - var cx_arr=await getApp().get_has_cx_act(goodsinfo.goods_id); | |
| 2723 | - | |
| 2724 | - var mo_num=getApp().get_limit_qty(goodsinfo,cx_arr.length); | |
| 2725 | - var steep=getApp().get_limit_qty(goodsinfo,cx_arr.length,1); | |
| 2726 | - | |
| 2727 | - if(mo_num>1 && t.goods_num<mo_num){ | |
| 2728 | - wx.showToast({ | |
| 2729 | - title: '购买数量小于商品的起订量', | |
| 2730 | - icon: 'none', | |
| 2731 | - }); | |
| 2732 | - t.goods_num=0; | |
| 2733 | - } | |
| 2734 | - | |
| 2735 | - if(steep>1 && t.goods_num>mo_num && (t.goods_num-mo_num)%steep!=0 ){ | |
| 2736 | - | |
| 2737 | - wx.showToast({ | |
| 2738 | - title: '购买数量必须是起订量的倍数', | |
| 2739 | - icon: 'none', | |
| 2740 | - }); | |
| 2741 | - | |
| 2742 | - t.goods_num=mo_num+parseInt((t.goods_num-mo_num)/steep+'')*steep | |
| 2743 | - } | |
| 2699 | + limit = limit - goodsbuynum; | |
| 2700 | + if(limit<0) limit=0; | |
| 2701 | + | |
| 2702 | + if(buyed_mum2>limit){ | |
| 2703 | + wx.showToast({ | |
| 2704 | + title: '购买数量超出商品限购', | |
| 2705 | + icon: 'none', | |
| 2706 | + }); | |
| 2707 | + is_showing=1; | |
| 2744 | 2708 | } |
| 2745 | - // t.goods_num = cbuy > 0 ? cbuy : 0, | |
| 2746 | - e.update_cart(t, pitem, item); | |
| 2747 | - return false; | |
| 2748 | - } | |
| 2749 | 2709 | |
| 2710 | + // e.setData({ | |
| 2711 | + // // [txt]: cbuy > 0 ? cbuy : 0, | |
| 2712 | + // [txt]: cbuy > 0 ? cbuy : limit, | |
| 2713 | + // }); | |
| 2714 | + //e.doCheckAll(); | |
| 2715 | + // t.goods_num = cbuy > 0 ? cbuy : limit; | |
| 2716 | + // | |
| 2717 | + // if([0,3,5,7,10].indexOf(goodsinfo.prom_type)>-1){ | |
| 2718 | + // | |
| 2719 | + // //-- 判断商品是不是 -- | |
| 2720 | + // var cx_arr=await getApp().get_has_cx_act(goodsinfo.goods_id); | |
| 2721 | + // var mo_num=getApp().get_limit_qty(goodsinfo,cx_arr.length); | |
| 2722 | + // var steep=getApp().get_limit_qty(goodsinfo,cx_arr.length,1); | |
| 2723 | + // | |
| 2724 | + // if(mo_num>1 && t.goods_num<mo_num){ | |
| 2725 | + // wx.showToast({ | |
| 2726 | + // title: '购买数量小于商品的起订量', | |
| 2727 | + // icon: 'none', | |
| 2728 | + // }); | |
| 2729 | + // t.goods_num=0; | |
| 2730 | + // } | |
| 2731 | + // | |
| 2732 | + // if(steep>1 && t.goods_num>mo_num && (t.goods_num-mo_num)%steep!=0 ){ | |
| 2733 | + // | |
| 2734 | + // wx.showToast({ | |
| 2735 | + // title: '购买数量必须是起订量的倍数', | |
| 2736 | + // icon: 'none', | |
| 2737 | + // }); | |
| 2738 | + // | |
| 2739 | + // t.goods_num=mo_num+parseInt((t.goods_num-mo_num)/steep+'')*steep | |
| 2740 | + // } | |
| 2741 | + // } | |
| 2742 | + // // t.goods_num = cbuy > 0 ? cbuy : 0, | |
| 2743 | + // e.update_cart(t, pitem, item); | |
| 2744 | + // return false; | |
| 2745 | + } | |
| 2746 | + else limit=100000; | |
| 2750 | 2747 | |
| 2751 | 2748 | switch (goodsinfo.prom_type) { |
| 2752 | 2749 | case 1: |
| 2753 | - //-- 读取秒杀 -- | |
| 2754 | - rq.get("/api/ms/flash_sale/getFlashSaleOne/" + oo.stoid + "/" + goodsinfo.prom_id, { | |
| 2755 | - isShowLoading: 0, | |
| 2756 | - success: function (res_d) { | |
| 2757 | - if (res_d.data.code == 0 && res_d.data.data) { | |
| 2758 | - if (t.goods_num > store_count) { | |
| 2759 | - // wx.showModal({ | |
| 2760 | - // title: '提示', | |
| 2761 | - // content: '购买数量超出商品库存' | |
| 2762 | - // }); | |
| 2750 | + //-- 读取秒杀 -- | |
| 2751 | + var res_d= await getApp().promiseGet("/api/ms/flash_sale/getFlashSaleOne/" + oo.stoid + "/" + goodsinfo.prom_id, {}); | |
| 2752 | + if (res_d.data.code == 0 && res_d.data.data) { | |
| 2753 | + | |
| 2754 | + var cbuy=limit; | |
| 2755 | + if (t.goods_num> store_count && !is_showing) { | |
| 2763 | 2756 | wx.showToast({ |
| 2764 | 2757 | title: '购买数量超出商品库存', |
| 2765 | 2758 | icon: 'none', |
| 2766 | 2759 | }); |
| 2767 | - // getApp().my_warnning('购买数量超出商品库存', 0, th); | |
| 2768 | - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | |
| 2769 | - e.setData({ | |
| 2770 | - [txt]: store_count | |
| 2771 | - }); | |
| 2772 | - e.doCheckAll(); | |
| 2773 | - | |
| 2774 | - t.goods_num = store_count; | |
| 2775 | - e.update_cart(t, pitem, item); | |
| 2776 | - | |
| 2777 | - return false; | |
| 2760 | + is_showing=1; | |
| 2778 | 2761 | } |
| 2762 | + //一直都要给一个最小值,和库存比较 | |
| 2763 | + if(cbuy>store_count) cbuy=store_count; | |
| 2779 | 2764 | |
| 2780 | 2765 | var false_data = res_d.data.data; |
| 2781 | 2766 | //--判断库存-- |
| 2782 | - if (t.goods_num > false_data.goods_num - false_data.buy_num) { | |
| 2783 | - // wx.showModal({ | |
| 2784 | - // title: '提示', | |
| 2785 | - // content: '购买数量超出活动库存' | |
| 2786 | - // }); | |
| 2767 | + if (t.goods_num > false_data.goods_num - false_data.buy_num && !is_showing) { | |
| 2787 | 2768 | wx.showToast({ |
| 2788 | 2769 | title: '购买数量超出活动库存', |
| 2789 | 2770 | icon: 'none', |
| 2790 | 2771 | }); |
| 2791 | - // getApp().my_warnning('购买数量超出活动库存', 0, th); | |
| 2792 | - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | |
| 2793 | - e.setData({ | |
| 2794 | - [txt]: false_data.goods_num - false_data.buy_num | |
| 2795 | - }); | |
| 2796 | - e.doCheckAll(); | |
| 2797 | - | |
| 2798 | - t.goods_num = false_data.goods_num - false_data.buy_num; | |
| 2799 | - e.update_cart(t, pitem, item); | |
| 2800 | - | |
| 2801 | - return false; | |
| 2772 | + is_showing=1; | |
| 2802 | 2773 | } |
| 2803 | 2774 | |
| 2775 | + //一直都要给一个最小值,和活动库存比较 | |
| 2776 | + if(cbuy>false_data.goods_num - false_data.buy_num) | |
| 2777 | + cbuy=false_data.goods_num - false_data.buy_num; | |
| 2778 | + | |
| 2804 | 2779 | //--判断redis数量是否已经超出-- |
| 2805 | - if (t.goods_num > false_data.redisnum) { | |
| 2806 | - // wx.showModal({ | |
| 2807 | - // title: '提示', | |
| 2808 | - // content: '购买数量超出商品库存' | |
| 2809 | - // }); | |
| 2780 | + if (t.goods_num > false_data.redisnum && !is_showing) { | |
| 2810 | 2781 | wx.showToast({ |
| 2811 | 2782 | title: '购买数量超出商品库存', |
| 2812 | 2783 | icon: 'none', |
| 2813 | 2784 | }); |
| 2814 | - //getApp().my_warnning('购买数量超出商品库存', 0, th); | |
| 2815 | - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | |
| 2816 | - e.setData({ | |
| 2817 | - [txt]: false_data.redisnum | |
| 2818 | - }); | |
| 2819 | - e.doCheckAll(); | |
| 2820 | - | |
| 2821 | - t.goods_num = false_data.redisnum; | |
| 2822 | - e.update_cart(t, pitem, item); | |
| 2823 | - return false; | |
| 2785 | + is_showing=1; | |
| 2824 | 2786 | } |
| 2825 | 2787 | |
| 2788 | + //一直都要给一个最小值,和活动库存比较 | |
| 2789 | + if(cbuy>false_data.redisnum) cbuy=false_data.redisnum; | |
| 2790 | + | |
| 2826 | 2791 | //--活动的限购是不是要判断-- |
| 2827 | - if (t.goods_num + promgoodsbuynum > false_data.buy_limit && false_data.buy_limit > 0) { | |
| 2828 | - // wx.showModal({ | |
| 2829 | - // title: '提示', | |
| 2830 | - // content: '购买数量超出秒杀限购' | |
| 2831 | - // }); | |
| 2832 | - wx.showToast({ | |
| 2833 | - title: '购买数量超出秒杀限购', | |
| 2834 | - icon: 'none', | |
| 2835 | - }); | |
| 2836 | - // getApp().my_warnning('购买数量超出秒杀限购', 0, th); | |
| 2837 | - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | |
| 2838 | - e.setData({ | |
| 2839 | - [txt]: false_data.buy_limit | |
| 2840 | - }); | |
| 2841 | - e.doCheckAll(); | |
| 2842 | - t.goods_num = (false_data.buy_limit - promgoodsbuynum) ? false_data.buy_limit - promgoodsbuynum : 0; | |
| 2843 | - e.update_cart(t, pitem, item); | |
| 2844 | - return false; | |
| 2792 | + if(false_data.buy_limit > 0) { | |
| 2793 | + if(t.goods_num + promgoodsbuynum > false_data.buy_limit && !is_showing){ | |
| 2794 | + wx.showToast({ | |
| 2795 | + title: '购买数量超出秒杀限购', | |
| 2796 | + icon: 'none', | |
| 2797 | + }); | |
| 2798 | + } | |
| 2799 | + var act_limit=false_data.buy_limit-promgoodsbuynum; | |
| 2800 | + if(!act_limit) act_limit=0; | |
| 2801 | + if(cbuy>act_limit) cbuy=act_limit; | |
| 2802 | + | |
| 2845 | 2803 | } |
| 2804 | + | |
| 2805 | + if(t.goods_num>cbuy) t.goods_num=cbuy; | |
| 2806 | + | |
| 2846 | 2807 | e.update_cart(t, pitem, item); |
| 2847 | 2808 | |
| 2848 | - } else { | |
| 2849 | - normal_check(store_count, goodsinfo, wareIds); | |
| 2850 | - } | |
| 2851 | - } | |
| 2852 | - }) | |
| 2853 | - break; | |
| 2809 | + } else { | |
| 2810 | + e.normal_check(t, item, pitem,store_count,limit,goodsinfo, wareIds); //普通商品的调用和计算 | |
| 2811 | + } | |
| 2812 | + break; | |
| 2854 | 2813 | case 2: |
| 2855 | - getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + goodsinfo.goods_id + "/" + goodsinfo.prom_id, {}).then(res => { | |
| 2814 | + | |
| 2815 | + //-- 读取团购 -- | |
| 2816 | + var res= await getApp().promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/" + goodsinfo.goods_id + "/" + goodsinfo.prom_id, {}); | |
| 2856 | 2817 | if (res.data.code == 0 && res.data.data) { |
| 2857 | - if (t.goods_num > store_count) { | |
| 2858 | - // wx.showModal({ | |
| 2859 | - // title: '提示', | |
| 2860 | - // content: '购买数量超出商品库存' | |
| 2861 | - // }); | |
| 2818 | + | |
| 2819 | + var cbuy=limit; | |
| 2820 | + if (t.goods_num > store_count && !is_showing) { | |
| 2862 | 2821 | wx.showToast({ |
| 2863 | 2822 | title: '购买数量超出商品库存', |
| 2864 | 2823 | icon: 'none', |
| 2865 | 2824 | }); |
| 2866 | - // getApp().my_warnning('购买数量超出商品库存', 0, th); | |
| 2867 | - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | |
| 2868 | - e.setData({ | |
| 2869 | - [txt]: store_count | |
| 2870 | - }); | |
| 2871 | - e.doCheckAll(); | |
| 2872 | - | |
| 2873 | - t.goods_num = store_count; | |
| 2874 | - e.update_cart(t, pitem, item); | |
| 2875 | - | |
| 2876 | - return false; | |
| 2825 | + is_showing=1; | |
| 2877 | 2826 | } |
| 2827 | + //一直都要给一个最小值,和库存比较 | |
| 2828 | + if(cbuy>store_count) cbuy=store_count; | |
| 2878 | 2829 | |
| 2879 | 2830 | var gr_data = res.data.data; |
| 2880 | 2831 | //--判断库存-- |
| 2881 | - if (t.goods_num > gr_data.goods_num - gr_data.buy_num) { | |
| 2882 | - // wx.showModal({ | |
| 2883 | - // title: '提示', | |
| 2884 | - // content: '购买数量超出活动库存' | |
| 2885 | - // }); | |
| 2832 | + if (t.goods_num > gr_data.goods_num - gr_data.buy_num && !is_showing) { | |
| 2886 | 2833 | wx.showToast({ |
| 2887 | 2834 | title: '购买数量超出活动库存', |
| 2888 | 2835 | icon: 'none', |
| 2889 | 2836 | }); |
| 2890 | - // getApp().my_warnning('购买数量超出活动库存', 0, th); | |
| 2891 | - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | |
| 2892 | - e.setData({ | |
| 2893 | - [txt]: gr_data.goods_num - gr_data.buy_num | |
| 2894 | - }); | |
| 2895 | - e.doCheckAll(); | |
| 2896 | - | |
| 2897 | - t.goods_num = gr_data.goods_num - gr_data.buy_num; | |
| 2898 | - e.update_cart(t, pitem, item); | |
| 2899 | - | |
| 2900 | - return false; | |
| 2837 | + is_showing=1; | |
| 2901 | 2838 | } |
| 2839 | + //一直都要给一个最小值,和库存比较 | |
| 2840 | + if(cbuy>gr_data.goods_num - gr_data.buy_num ) cbuy=gr_data.goods_num - gr_data.buy_num; | |
| 2902 | 2841 | |
| 2903 | 2842 | //--判断redis数量是否已经超出-- |
| 2904 | - if (t.goods_num > gr_data.redisnum) { | |
| 2905 | - // wx.showModal({ | |
| 2906 | - // title: '提示', | |
| 2907 | - // content: '购买数量超出商品库存' | |
| 2908 | - // }); | |
| 2843 | + if (t.goods_num > gr_data.redisnum && !is_showing) { | |
| 2909 | 2844 | wx.showToast({ |
| 2910 | 2845 | title: '购买数量超出商品库存', |
| 2911 | 2846 | icon: 'none', |
| 2912 | 2847 | }); |
| 2913 | - // getApp().my_warnning('购买数量超出商品库存', 0, th); | |
| 2914 | - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | |
| 2915 | - e.setData({ | |
| 2916 | - [txt]: gr_data.redisnum | |
| 2917 | - }); | |
| 2918 | - e.doCheckAll(); | |
| 2919 | - | |
| 2920 | - t.goods_num = gr_data.redisnum; | |
| 2921 | - e.update_cart(t, pitem, item); | |
| 2922 | - return false; | |
| 2848 | + is_showing=1; | |
| 2923 | 2849 | } |
| 2850 | + if(cbuy>gr_data.redisnum) cbuy=gr_data.redisnum; | |
| 2924 | 2851 | |
| 2925 | 2852 | //--活动的限购是不是要判断-- |
| 2926 | - if (t.goods_num + promgoodsbuynum > gr_data.buy_limit && gr_data.buy_limit > 0) { | |
| 2927 | - // wx.showModal({ | |
| 2928 | - // title: '提示', | |
| 2929 | - // content: '购买数量超出团购限购' | |
| 2930 | - // }); | |
| 2931 | - wx.showToast({ | |
| 2932 | - title: '购买数量超出团购限购', | |
| 2933 | - icon: 'none', | |
| 2934 | - }); | |
| 2935 | - // getApp().my_warnning('购买数量超出团购限购', 0, th); | |
| 2936 | - var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | |
| 2937 | - e.setData({ | |
| 2938 | - [txt]: gr_data.buy_limit | |
| 2939 | - }); | |
| 2940 | - e.doCheckAll(); | |
| 2853 | + if (gr_data.buy_limit > 0) { | |
| 2854 | + if(t.goods_num + promgoodsbuynum > gr_data.buy_limit && !is_showing){ | |
| 2855 | + wx.showToast({ | |
| 2856 | + title: '购买数量超出团购限购', | |
| 2857 | + icon: 'none', | |
| 2858 | + }); | |
| 2859 | + is_showing=1; | |
| 2860 | + } | |
| 2941 | 2861 | |
| 2942 | - t.goods_num = (gr_data.buy_limit - promgoodsbuynum) ? gr_data.buy_limit - promgoodsbuynum : 0; | |
| 2943 | - e.update_cart(t, pitem, item); | |
| 2944 | - return false; | |
| 2862 | + var act_limit=gr_data.buy_limit-promgoodsbuynum; | |
| 2863 | + if(!act_limit) act_limit=0; | |
| 2864 | + | |
| 2865 | + if(cbuy>act_limit) cbuy=act_limit; | |
| 2945 | 2866 | } |
| 2867 | + | |
| 2868 | + if(t.goods_num>cbuy) t.goods_num=cbuy; | |
| 2869 | + | |
| 2946 | 2870 | e.update_cart(t, pitem, item); |
| 2947 | 2871 | |
| 2948 | 2872 | } else { |
| 2949 | - normal_check(store_count, goodsinfo, wareIds); | |
| 2873 | + e.normal_check(t, item, pitem,store_count,limit,goodsinfo, wareIds); //普通商品的调用和计算 | |
| 2950 | 2874 | } |
| 2951 | - }) | |
| 2952 | - break; | |
| 2875 | + break; | |
| 2953 | 2876 | default: |
| 2954 | - var cx_arr=await getApp().get_has_cx_act(goodsinfo.goods_id); | |
| 2955 | - normal_check(store_count, goodsinfo, wareIds,cx_arr); | |
| 2877 | + e.normal_check(t, item, pitem,store_count,limit,goodsinfo, wareIds); //普通商品的调用和计算 | |
| 2956 | 2878 | break |
| 2957 | 2879 | } |
| 2958 | 2880 | } |
| 2959 | 2881 | }); |
| 2960 | 2882 | }, |
| 2961 | 2883 | |
| 2884 | + //-- 这个函数在计算的时候,要包含限购的那一部分 -- | |
| 2885 | + async normal_check(t, item, pitem,store_count,limit,goodsinfo, wareIds){ | |
| 2886 | + | |
| 2887 | + var cx_arr=await getApp().get_has_cx_act(goodsinfo.goods_id); | |
| 2888 | + | |
| 2889 | + var th=this; | |
| 2890 | + // getApp().my_warnning('购买数量超出商品库存', 0, th); | |
| 2891 | + var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | |
| 2892 | + | |
| 2893 | + | |
| 2894 | + var cQty=store_count; | |
| 2895 | + //--- 看一下是不是线下库存 --- | |
| 2896 | + if (th.data.sales_rules >= 2 && !goodsinfo.whsle_id) { | |
| 2897 | + //th.check_down_line(t, pitem, item, wareIds,limit); | |
| 2898 | + var ob = {}; | |
| 2899 | + await th.check_down_line_next(t, pitem, item, wareIds, function (res) { | |
| 2900 | + ob = res; | |
| 2901 | + }); | |
| 2902 | + cQty=ob.CanOutQty; | |
| 2903 | + //-- 只获取相同门店,2的时候,因为是线下不同的门店,所以库存再不同门店是不一样的 -- | |
| 2904 | + if(th.data.sales_rules== 2) other_gd_num=th.get_goods_other(item, pitem,1); | |
| 2905 | + } | |
| 2906 | + | |
| 2907 | + var is_showing=0; | |
| 2908 | + var cbuy=limit; | |
| 2909 | + if (t.goods_num > limit) { | |
| 2910 | + wx.showToast({ | |
| 2911 | + title: '购买数量超出商品限购', | |
| 2912 | + icon: 'none', | |
| 2913 | + }); | |
| 2914 | + is_showing=1; | |
| 2915 | + } | |
| 2916 | + | |
| 2917 | + if (t.goods_num > cQty) { | |
| 2918 | + if(!is_showing){ | |
| 2919 | + wx.showToast({ | |
| 2920 | + title: '购买数量超出商品库存', | |
| 2921 | + icon: 'none', | |
| 2922 | + }); | |
| 2923 | + is_showing=1; | |
| 2924 | + } | |
| 2925 | + } | |
| 2926 | + if(cbuy>cQty) cbuy=cQty; | |
| 2927 | + | |
| 2928 | + if(t.goods_num>cbuy) t.goods_num=cbuy; | |
| 2929 | + | |
| 2930 | + if([0,3,5,7,10].indexOf(goodsinfo.prom_type)>-1){ | |
| 2931 | + var mo_num=getApp().get_limit_qty(goodsinfo,cx_arr.length); | |
| 2932 | + var steep=getApp().get_limit_qty(goodsinfo,cx_arr.length,1); | |
| 2933 | + | |
| 2934 | + if(mo_num>1 && t.goods_num<mo_num){ | |
| 2935 | + if(!is_showing) { | |
| 2936 | + wx.showToast({ | |
| 2937 | + title: '购买数量小于商品的起订量', | |
| 2938 | + icon: 'none', | |
| 2939 | + }); | |
| 2940 | + } | |
| 2941 | + t.goods_num=mo_num; | |
| 2942 | + } | |
| 2943 | + | |
| 2944 | + if(steep>1 && t.goods_num>mo_num && (t.goods_num-mo_num)%steep!=0){ | |
| 2945 | + if(!is_showing) { | |
| 2946 | + wx.showToast({ | |
| 2947 | + title: '购买数量必须是起订量的倍数', | |
| 2948 | + icon: 'none', | |
| 2949 | + }); | |
| 2950 | + } | |
| 2951 | + if(t.goods_num<mo_num) t.goods_num=mo_num; | |
| 2952 | + else{ | |
| 2953 | + t.goods_num=mo_num+parseInt((t.goods_num-mo_num)/steep+'')*steep | |
| 2954 | + } | |
| 2955 | + } | |
| 2956 | + } | |
| 2957 | + | |
| 2958 | + th.update_cart(t, pitem, item); | |
| 2959 | + | |
| 2960 | + }, | |
| 2961 | + | |
| 2962 | 2962 | //----------------------更新购物数量,加减,调用接口--------------------- |
| 2963 | 2963 | postCardList_ser: async function (t, item, pitem) { |
| 2964 | 2964 | var e = this, |
| ... | ... | @@ -3095,18 +3095,14 @@ Page({ |
| 3095 | 3095 | await th.doCheckAll(); |
| 3096 | 3096 | await th.update_cart_ser(t, pitem, item); |
| 3097 | 3097 | return false; |
| 3098 | - }; | |
| 3099 | - | |
| 3098 | + } | |
| 3100 | 3099 | } |
| 3101 | 3100 | |
| 3102 | - | |
| 3103 | 3101 | } |
| 3104 | 3102 | |
| 3105 | 3103 | |
| 3106 | 3104 | await e.doCheckAll(); |
| 3107 | 3105 | await e.update_cart_ser(t, pitem, item); |
| 3108 | - | |
| 3109 | - | |
| 3110 | 3106 | }, |
| 3111 | 3107 | |
| 3112 | 3108 | |
| ... | ... | @@ -3156,11 +3152,10 @@ Page({ |
| 3156 | 3152 | promcardbuynum: tt.data.data.promcardbuynum, |
| 3157 | 3153 | cardbuynum: tt.data.data.cardbuynum, |
| 3158 | 3154 | }); |
| 3159 | - }; | |
| 3155 | + } | |
| 3160 | 3156 | }); |
| 3161 | 3157 | |
| 3162 | 3158 | |
| 3163 | - | |
| 3164 | 3159 | var buylimit = 0 |
| 3165 | 3160 | await getApp().request.promiseGet("/api/ms/flash_sale/getNew/" + t.store_id + "/" + getApp().globalData.user_id + "/" + t.prom_id, { |
| 3166 | 3161 | |
| ... | ... | @@ -3170,7 +3165,7 @@ Page({ |
| 3170 | 3165 | th.data.sele_g = res.data.data; |
| 3171 | 3166 | th.data.sele_g.viplimited = res.data.data.buy_limit; |
| 3172 | 3167 | buylimit = res.data.data.buy_limit; |
| 3173 | - }; | |
| 3168 | + } | |
| 3174 | 3169 | }); |
| 3175 | 3170 | |
| 3176 | 3171 | |
| ... | ... | @@ -3188,18 +3183,15 @@ Page({ |
| 3188 | 3183 | }); |
| 3189 | 3184 | // getApp().my_warnning('超出活动限购', 0, th); |
| 3190 | 3185 | th.setData({ [txt]: buylimit }); |
| 3191 | - | |
| 3192 | 3186 | }; |
| 3193 | 3187 | |
| 3194 | 3188 | } |
| 3195 | 3189 | |
| 3196 | - | |
| 3197 | 3190 | th.doCheckAll(); |
| 3198 | 3191 | th.update_cart_ser(t, pitem, item); |
| 3199 | 3192 | |
| 3200 | 3193 | |
| 3201 | - | |
| 3202 | - }; | |
| 3194 | + } | |
| 3203 | 3195 | }, |
| 3204 | 3196 | |
| 3205 | 3197 | |
| ... | ... | @@ -3232,11 +3224,9 @@ Page({ |
| 3232 | 3224 | |
| 3233 | 3225 | var this_obj = this.data.requestData[pitem].goods[item]; |
| 3234 | 3226 | |
| 3235 | - if (th.data.sales_rules == 3 && this_obj.selected) { | |
| 3236 | - | |
| 3227 | + if (th.data.sales_rules >= 2 && this_obj.selected) { | |
| 3237 | 3228 | |
| 3238 | 3229 | var goods_id = this_obj.goods_id; |
| 3239 | - | |
| 3240 | 3230 | var num = 0; |
| 3241 | 3231 | |
| 3242 | 3232 | for (let i = 0; i < this.data.requestData.length; i++) { |
| ... | ... | @@ -3257,17 +3247,15 @@ Page({ |
| 3257 | 3247 | return false; |
| 3258 | 3248 | } |
| 3259 | 3249 | |
| 3260 | - | |
| 3261 | - | |
| 3262 | 3250 | } |
| 3263 | 3251 | } |
| 3264 | 3252 | |
| 3265 | 3253 | |
| 3266 | - | |
| 3267 | - | |
| 3268 | 3254 | this.update_cart(t, pitem, item); |
| 3269 | 3255 | }, |
| 3270 | 3256 | |
| 3257 | + | |
| 3258 | + | |
| 3271 | 3259 | //---检验线下库存的数量的子函数--- |
| 3272 | 3260 | async check_down_line_next(t, pitem, item, erpwareid, func) { |
| 3273 | 3261 | |
| ... | ... | @@ -3408,7 +3396,6 @@ Page({ |
| 3408 | 3396 | |
| 3409 | 3397 | //--------------去结算------------ |
| 3410 | 3398 | async checkout() { |
| 3411 | - | |
| 3412 | 3399 | if (getApp().is_sp_hao()) { |
| 3413 | 3400 | wx.showToast({ |
| 3414 | 3401 | title: "视频号不支持购物车购买", |
| ... | ... | @@ -3511,7 +3498,7 @@ Page({ |
| 3511 | 3498 | if([0,3,5,7,10].indexOf(py_type)>-1){ |
| 3512 | 3499 | |
| 3513 | 3500 | if(mo_num>i_arr[j].goods_num){ |
| 3514 | - getApp().confirmBox(i_arr[j].goods_name + "的未到达起订数量"); | |
| 3501 | + getApp().confirmBox(i_arr[j].goods_name + "的未达到起订数量"); | |
| 3515 | 3502 | wx.hideLoading(); |
| 3516 | 3503 | return false; |
| 3517 | 3504 | } |
| ... | ... | @@ -3534,7 +3521,6 @@ Page({ |
| 3534 | 3521 | } |
| 3535 | 3522 | |
| 3536 | 3523 | |
| 3537 | - | |
| 3538 | 3524 | //--普通商品,如果有开启线下库存的功能,要调用线下库存进行计算,赠品不要进行调用线下库存--- |
| 3539 | 3525 | if ((i_arr[j].prom_type == 0 || i_arr[j].prom_type == 3 || i_arr[j].prom_type == 5 || i_arr[j].prom_type == 7 || i_arr[j].prom_type == 10 || |
| 3540 | 3526 | i_arr[j].need_downlow_num) && th.data.sales_rules >= 2 && i_arr[j].is_gift != 1 && !i_arr[j].whsle_id) { |
| ... | ... | @@ -3644,9 +3630,6 @@ Page({ |
| 3644 | 3630 | return false |
| 3645 | 3631 | } |
| 3646 | 3632 | |
| 3647 | - | |
| 3648 | - | |
| 3649 | - | |
| 3650 | 3633 | if (checkArr7.length > 0) { |
| 3651 | 3634 | let checkStr = [] |
| 3652 | 3635 | checkArr7.map(item => { | ... | ... |
pages/goods/goodsInfo/buy_com_pop.wxml
| ... | ... | @@ -141,7 +141,7 @@ |
| 141 | 141 | </block> |
| 142 | 142 | <block wx:else> |
| 143 | 143 | <block wx:if="{{sales_rules>=2 && !sele_g.whsle_id }}"> |
| 144 | - <view wx:if="{{!def_pick_store.CanOutQty || def_pick_store.CanOutQty<mo_num }}" class="spec-cart-btn fs32" data-action="add" | |
| 144 | + <view wx:if="{{!def_pick_store.CanOutQty || def_pick_store.CanOutQty<1 }}" class="spec-cart-btn fs32" data-action="add" | |
| 145 | 145 | style="background-color: #dcdcdc;color: #999">库存不足 |
| 146 | 146 | </view> |
| 147 | 147 | <block wx:else> |
| ... | ... | @@ -156,7 +156,7 @@ |
| 156 | 156 | </block> |
| 157 | 157 | </block> |
| 158 | 158 | |
| 159 | - <block wx:elif="{{data.store_count<(mo_num?mo_num:1)}}"> | |
| 159 | + <block wx:elif="{{data.store_count<1}}"> | |
| 160 | 160 | <view class="spec-cart-btn fs32" data-action="add" |
| 161 | 161 | style="background-color: #dcdcdc;color: #999">库存不足 |
| 162 | 162 | </view> | ... | ... |
pages/goods/goodsInfo/buy_integral.wxml
| ... | ... | @@ -48,7 +48,7 @@ |
| 48 | 48 | <block wx:else> |
| 49 | 49 | <view class="no_store" wx:if="{{def_pick_store.is_no_dis}}">(配送不匹配)</view> |
| 50 | 50 | <view wx:elif="{{def_pick_store && sales_rules>=2 && prom_type==0}}"> |
| 51 | - <block wx:if="{{!def_pick_store.CanOutQty || def_pick_store.CanOutQty<mo_num}}">(库存不足)</block> | |
| 51 | + <block wx:if="{{!def_pick_store.CanOutQty || def_pick_store.CanOutQty<1}}">(库存不足)</block> | |
| 52 | 52 | </view> |
| 53 | 53 | </block> |
| 54 | 54 | </block> | ... | ... |
pages/goods/goodsInfo/buy_pt.wxml
| ... | ... | @@ -183,7 +183,7 @@ |
| 183 | 183 | <block wx:else> |
| 184 | 184 | <!-- 如果是线下库存购买的时候,且是普通商品购买的时候 --> |
| 185 | 185 | <block wx:if="{{sales_rules>=2 && !sele_g.whsle_id}}"> |
| 186 | - <block wx:if="{{!def_pick_store.CanOutQty || def_pick_store.CanOutQty<mo_num}}"> | |
| 186 | + <block wx:if="{{!def_pick_store.CanOutQty || def_pick_store.CanOutQty<1}}"> | |
| 187 | 187 | <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999"> |
| 188 | 188 | 库存不足 |
| 189 | 189 | </view> |
| ... | ... | @@ -194,7 +194,7 @@ |
| 194 | 194 | </block> |
| 195 | 195 | <!-- 线上销售 --> |
| 196 | 196 | <block wx:else> |
| 197 | - <block wx:if="{{sele_g.store_count<(mo_num?mo_num:1) && is_no_new}}"> | |
| 197 | + <block wx:if="{{sele_g.store_count<1 && is_no_new}}"> | |
| 198 | 198 | <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999"> |
| 199 | 199 | 库存不足 |
| 200 | 200 | </view> | ... | ... |
pages/goods/goodsInfo/goodsInfo.js
| ... | ... | @@ -2407,12 +2407,18 @@ Page({ |
| 2407 | 2407 | }, |
| 2408 | 2408 | //----------减少购买数量----------- |
| 2409 | 2409 | subCartNum: function (t) { |
| 2410 | - | |
| 2411 | 2410 | var add_num=1; |
| 2412 | 2411 | var p_type=parseInt(this.data.prom_type) |
| 2413 | 2412 | if([1,2,4,6,8,9].indexOf(p_type)==-1 || this.data.openSpecModal_inte_normal == 1 || this.data.is_normal == 1){ |
| 2414 | 2413 | add_num = getApp().get_limit_qty(this.data.sele_g, this.data.is_act, 1); |
| 2415 | - | |
| 2414 | + var mo_num = getApp().get_limit_qty(this.data.sele_g, this.data.is_act); | |
| 2415 | + if(this.data.goodsInputNum - add_num<mo_num){ | |
| 2416 | + wx.showToast({ | |
| 2417 | + title: '购买数量不能小于起订量', | |
| 2418 | + icon: 'none', | |
| 2419 | + }); | |
| 2420 | + return false; | |
| 2421 | + } | |
| 2416 | 2422 | } |
| 2417 | 2423 | this.checkCartNum(this.data.goodsInputNum - add_num); |
| 2418 | 2424 | }, |
| ... | ... | @@ -2438,11 +2444,14 @@ Page({ |
| 2438 | 2444 | //------检查数量是不是超出限购------ |
| 2439 | 2445 | checkCartNum: function (t) { |
| 2440 | 2446 | var th = this; |
| 2447 | + | |
| 2441 | 2448 | var mo_num=getApp().get_limit_qty(th.data.sele_g,th.data.is_act); |
| 2442 | 2449 | var steep=getApp().get_limit_qty(th.data.sele_g,th.data.is_act,1); |
| 2443 | - | |
| 2444 | 2450 | this.get_buy_num(this.data.sele_g, async function () { |
| 2445 | 2451 | |
| 2452 | + var is_show_bs=0; | |
| 2453 | + var l_num=-1; | |
| 2454 | + | |
| 2446 | 2455 | //--判断商品是否超出限购-- |
| 2447 | 2456 | if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { |
| 2448 | 2457 | |
| ... | ... | @@ -2453,13 +2462,16 @@ Page({ |
| 2453 | 2462 | title: '超出商品限购', |
| 2454 | 2463 | icon: 'none', |
| 2455 | 2464 | }); |
| 2465 | + | |
| 2466 | + is_show_bs=1; | |
| 2467 | + | |
| 2456 | 2468 | // s.my_warnning('超出商品限购', 0, th); |
| 2457 | - var num = th.data.sele_g.viplimited - gd_buy_num; | |
| 2458 | - if (num < 0) num = 0; | |
| 2459 | - th.setData({ | |
| 2460 | - goodsInputNum: num | |
| 2461 | - }) | |
| 2462 | - return false; | |
| 2469 | + l_num = th.data.sele_g.viplimited - gd_buy_num; | |
| 2470 | + if (l_num < 0) l_num = 0; | |
| 2471 | + // th.setData({ | |
| 2472 | + // goodsInputNum: num | |
| 2473 | + // }) | |
| 2474 | + // return false; | |
| 2463 | 2475 | } |
| 2464 | 2476 | } |
| 2465 | 2477 | |
| ... | ... | @@ -2527,25 +2539,47 @@ Page({ |
| 2527 | 2539 | } |
| 2528 | 2540 | } |
| 2529 | 2541 | |
| 2542 | + //-- 限购数量也要进行计算一下 -- | |
| 2543 | + if(l_num>-1){ | |
| 2544 | + if(e>l_num) e=l_num; | |
| 2545 | + } | |
| 2546 | + | |
| 2530 | 2547 | //--- 促销活动也不控制起订量, 这里很重要的一个控制,起订量的 ---- |
| 2531 | 2548 | if([0,3,5,7,10].indexOf(p_type)>-1 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1){ |
| 2532 | - if(t<mo_num) t=mo_num; | |
| 2549 | + if(t<mo_num) { | |
| 2550 | + t=mo_num; | |
| 2551 | + if(!is_show_bs) { | |
| 2552 | + wx.showToast({ | |
| 2553 | + title: '购买数未达到起订量', | |
| 2554 | + icon: 'none', | |
| 2555 | + }); | |
| 2556 | + } | |
| 2557 | + is_show_bs=1; | |
| 2558 | + } | |
| 2533 | 2559 | if(t>mo_num && (t-mo_num)%steep!=0){ |
| 2534 | - wx.showToast({ | |
| 2535 | - title: '购买数必须是起订量的倍数', | |
| 2536 | - icon: 'none', | |
| 2537 | - }); | |
| 2560 | + | |
| 2561 | + if(!is_show_bs){ | |
| 2562 | + wx.showToast({ | |
| 2563 | + title: '购买数必须是起订量的倍数', | |
| 2564 | + icon: 'none', | |
| 2565 | + }); | |
| 2566 | + } | |
| 2567 | + | |
| 2538 | 2568 | t=mo_num+ parseInt((t-mo_num)/steep)*steep+steep; |
| 2569 | + is_show_bs=1; | |
| 2539 | 2570 | } |
| 2540 | 2571 | } |
| 2541 | 2572 | |
| 2542 | 2573 | if (!e) e = 0; |
| 2543 | 2574 | //库存不足,不增加 |
| 2544 | 2575 | if (e < t) { |
| 2545 | - wx.showToast({ | |
| 2546 | - title: '库存不足', | |
| 2547 | - icon: 'none', | |
| 2548 | - }); | |
| 2576 | + if(!is_show_bs){ | |
| 2577 | + wx.showToast({ | |
| 2578 | + title: '库存不足', | |
| 2579 | + icon: 'none', | |
| 2580 | + }); | |
| 2581 | + } | |
| 2582 | + | |
| 2549 | 2583 | // wx.showModal({title: '库存不足',}); |
| 2550 | 2584 | if (e < 0) e = 0; |
| 2551 | 2585 | |
| ... | ... | @@ -3362,6 +3396,18 @@ Page({ |
| 3362 | 3396 | }) |
| 3363 | 3397 | } |
| 3364 | 3398 | |
| 3399 | + //拼团在点击回来的时候,还是只能是立即购买,不能有购物车的情况 | |
| 3400 | + if(this.data.base_nor_prom_type==6 && parseInt(gid+'')==parseInt(this.data.base_nor_goods_id+'')){ | |
| 3401 | + this.setData({ | |
| 3402 | + openSpecModal_pt:1, | |
| 3403 | + openSpecModal:0, | |
| 3404 | + sku_g:this.data.sku_g_pt, | |
| 3405 | + is_normal:1 | |
| 3406 | + }) | |
| 3407 | + nor=1; | |
| 3408 | + } | |
| 3409 | + | |
| 3410 | + | |
| 3365 | 3411 | //that.data.change=1; |
| 3366 | 3412 | var item = null; |
| 3367 | 3413 | for (var i in sku_g) { |
| ... | ... | @@ -3392,10 +3438,12 @@ Page({ |
| 3392 | 3438 | }); |
| 3393 | 3439 | |
| 3394 | 3440 | |
| 3441 | + | |
| 3395 | 3442 | if (nor) that.get_sto(1); |
| 3396 | 3443 | else that.get_sto(); |
| 3397 | 3444 | |
| 3398 | - if (!item.whsle_id && [1,2,4,6].indexOf(item.prom_type)==-1) that.check_is_youhui(gid, that.data.is_normal); | |
| 3445 | + if (!item.whsle_id && ([1,2,4,6].indexOf(item.prom_type)==-1 || this.data.is_normal==1)) | |
| 3446 | + that.check_is_youhui(gid, that.data.is_normal); | |
| 3399 | 3447 | |
| 3400 | 3448 | //默认门店要拿下门店库存 |
| 3401 | 3449 | if (that.data.sales_rules >= 2 && that.data.def_pick_store && !that.data.sele_g.whsle_id && [1,2,4,6].indexOf(item.prom_type)==-1) { |
| ... | ... | @@ -5131,9 +5179,10 @@ Page({ |
| 5131 | 5179 | if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { |
| 5132 | 5180 | if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { |
| 5133 | 5181 | wx.showToast({ |
| 5134 | - title: '超出商品限购', | |
| 5135 | - icon: 'none', | |
| 5182 | + title: '超出商品限购', | |
| 5183 | + icon: 'none', | |
| 5136 | 5184 | }); |
| 5185 | + | |
| 5137 | 5186 | // s.my_warnning('超出商品限购', 0, th); |
| 5138 | 5187 | var num = th.data.prom_buy_limit - th.data.prom_buy_num; |
| 5139 | 5188 | if (num < 0) num = 0; |
| ... | ... | @@ -5212,9 +5261,10 @@ Page({ |
| 5212 | 5261 | // return s.my_warnning("商品数量不能为0", 0, th); |
| 5213 | 5262 | }; |
| 5214 | 5263 | if (th.data.goodsInputNum > o.store_count) { |
| 5215 | - th.setData({ | |
| 5216 | - goodsInputNum: o.store_count | |
| 5217 | - }) | |
| 5264 | + | |
| 5265 | + // th.setData({ | |
| 5266 | + // goodsInputNum: o.store_count | |
| 5267 | + // }) | |
| 5218 | 5268 | wx.showToast({ |
| 5219 | 5269 | title: '超出商品库存', |
| 5220 | 5270 | icon: 'none', |
| ... | ... | @@ -7561,6 +7611,9 @@ Page({ |
| 7561 | 7611 | this.data.is_act=1; |
| 7562 | 7612 | } |
| 7563 | 7613 | |
| 7614 | + console.log("11111111-gd"); | |
| 7615 | + console.log(th.data.sele_g); | |
| 7616 | + | |
| 7564 | 7617 | //-- 更新默认购买的数量 --- |
| 7565 | 7618 | var mo_num=getApp().get_limit_qty(th.data.sele_g,this.data.is_act); |
| 7566 | 7619 | this.setData({goodsInputNum:mo_num}) | ... | ... |
pages/goods/goodsInfo/goodsInfo.wxml
| ... | ... | @@ -1410,7 +1410,7 @@ |
| 1410 | 1410 | <!-- 如果是线下库存购买的时候,且是普通商品购买的时候 --> |
| 1411 | 1411 | <block wx:if="{{sales_rules>=2 && prom_type==0 && !sele_g.whsle_id}}"> |
| 1412 | 1412 | |
| 1413 | - <block wx:if="{{!def_pick_store.CanOutQty || def_pick_store.CanOutQty<mo_num }}"> | |
| 1413 | + <block wx:if="{{!def_pick_store.CanOutQty || def_pick_store.CanOutQty<1 }}"> | |
| 1414 | 1414 | <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999"> |
| 1415 | 1415 | 库存不足 |
| 1416 | 1416 | </view> |
| ... | ... | @@ -1426,7 +1426,7 @@ |
| 1426 | 1426 | </block> |
| 1427 | 1427 | <!-- 线上销售 --> |
| 1428 | 1428 | <block wx:else> |
| 1429 | - <block wx:if="{{ sele_g.store_count<(mo_num?mo_num:1) && is_no_new}}"> | |
| 1429 | + <block wx:if="{{ sele_g.store_count<1 && is_no_new}}"> | |
| 1430 | 1430 | <view class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999"> |
| 1431 | 1431 | 库存不足 |
| 1432 | 1432 | </view> | ... | ... |