diff --git a/pages/cart/cart/cart.js b/pages/cart/cart/cart.js index 0826feb..de8c16b 100644 --- a/pages/cart/cart/cart.js +++ b/pages/cart/cart/cart.js @@ -2611,7 +2611,7 @@ Page({ } for (let j = 0; j < this.data.requestData.length;j++){ if(j!=pitem){ - var goods=this.data.requestData[j]; + var goods=this.data.requestData[j].goods; for (let k = 0; k store_count && !is_showing) { + if (t.goods_num+other_gd_num > store_count && !is_showing) { wx.showToast({ title: '购买数量超出商品库存', icon: 'none', @@ -2742,7 +2742,7 @@ Page({ is_showing=1; } //一直都要给一个最小值,和库存比较 - if(cbuy>store_count) cbuy=store_count; + if(cbuy>store_count-other_gd_num) cbuy=store_count-other_gd_num; var false_data = res_d.data.data; //--判断库存-- @@ -2789,7 +2789,7 @@ Page({ e.update_cart(t, pitem, item); } else { - e.normal_check(t, item, pitem,store_count,limit,goodsinfo, wareIds); //普通商品的调用和计算 + e.normal_check(t, item, pitem,store_count,limit,other_gd_num,goodsinfo, wareIds); //普通商品的调用和计算 } break; case 2: @@ -2799,7 +2799,7 @@ Page({ if (res.data.code == 0 && res.data.data) { var cbuy=limit; - if (t.goods_num > store_count && !is_showing) { + if (t.goods_num > store_count-other_gd_num && !is_showing) { wx.showToast({ title: '购买数量超出商品库存', icon: 'none', @@ -2807,7 +2807,7 @@ Page({ is_showing=1; } //一直都要给一个最小值,和库存比较 - if(cbuy>store_count) cbuy=store_count; + if(cbuy>store_count) cbuy=store_count-other_gd_num; var gr_data = res.data.data; //--判断库存-- @@ -2853,11 +2853,11 @@ Page({ e.update_cart(t, pitem, item); } else { - e.normal_check(t, item, pitem,store_count,limit,goodsinfo, wareIds); //普通商品的调用和计算 + e.normal_check(t, item, pitem,store_count,limit,other_gd_num,goodsinfo, wareIds); //普通商品的调用和计算 } break; default: - e.normal_check(t, item, pitem,store_count,limit, goodsinfo, wareIds); //普通商品的调用和计算 + e.normal_check(t, item, pitem,store_count,limit,other_gd_num,goodsinfo, wareIds); //普通商品的调用和计算 break } } @@ -2865,7 +2865,7 @@ Page({ }, //-- 这个函数在计算的时候,要包含限购的那一部分 -- - async normal_check(t, item, pitem,store_count,limit,goodsinfo, wareIds){ + async normal_check(t, item, pitem,store_count,limit,other_gd_num,goodsinfo, wareIds){ var cx_arr=await getApp().get_has_cx_act(goodsinfo.goods_id); @@ -2873,6 +2873,8 @@ Page({ // getApp().my_warnning('购买数量超出商品库存', 0, th); var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; + + var cQty=store_count; //--- 看一下是不是线下库存 --- if (th.data.sales_rules >= 2 && !goodsinfo.whsle_id) { @@ -2881,63 +2883,63 @@ Page({ await th.check_down_line_next(t, pitem, item, erpwareid, function (res) { ob = res; }); + cQty=ob.CanOutQty; + } - } else { + var is_showing=0; + var cbuy=limit; + if (t.goods_num > limit) { + wx.showToast({ + title: '购买数量超出商品限购', + icon: 'none', + }); + is_showing=1; + } - var is_showing=0; - var cbuy=limit; - if (t.goods_num > limit) { - wx.showToast({ - title: '购买数量超出商品限购', - icon: 'none', - }); - is_showing=1; + if (t.goods_num > cQty-other_gd_num) { + if(!is_showing){ + wx.showToast({ + title: '购买数量超出商品库存', + icon: 'none', + }); + is_showing=1; } + } + if(cbuy>cQty-other_gd_num) cbuy=cQty-other_gd_num; - if (t.goods_num > store_count) { - if(!is_showing){ - wx.showToast({ - title: '购买数量超出商品库存', - icon: 'none', - }); - is_showing=1; - } - } - if(cbuy>store_count) cbuy=store_count; + if(t.goods_num>cbuy) t.goods_num=cbuy; - if(t.goods_num>cbuy) t.goods_num=cbuy; + if([0,3,5,7,10].indexOf(goodsinfo.prom_type)>-1){ + var mo_num=getApp().get_limit_qty(goodsinfo,cx_arr.length); + var steep=getApp().get_limit_qty(goodsinfo,cx_arr.length,1); - if([0,3,5,7,10].indexOf(goodsinfo.prom_type)>-1){ - var mo_num=getApp().get_limit_qty(goodsinfo,cx_arr.length); - var steep=getApp().get_limit_qty(goodsinfo,cx_arr.length,1); + if(mo_num>1 && t.goods_num1 && t.goods_num1 && t.goods_num>mo_num && (t.goods_num-mo_num)%steep!=0){ if(!is_showing) { - wx.showToast({ - title: '购买数量小于商品的起订量', - icon: 'none', - }); + wx.showToast({ + title: '购买数量必须是起订量的倍数', + icon: 'none', + }); } - t.goods_num=mo_num; - } + if(t.goods_num1 && t.goods_num>mo_num && (t.goods_num-mo_num)%steep!=0){ - if(!is_showing) { - wx.showToast({ - title: '购买数量必须是起订量的倍数', - icon: 'none', - }); - } - if(t.goods_num