From f8f200f690000e6a3528b71e7066d2776906cc12 Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Mon, 16 Oct 2023 11:26:01 +0800 Subject: [PATCH] 拼团的普通购买要判断一下线下库存 --- pages/goods/goodsInfo/goodsInfo.js | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 2 deletions(-) diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index 7c90395..fe8e5a0 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -5318,6 +5318,21 @@ Page({ }, //-----------------拼单生成方法--------------------- + // addCart_pt: function () { + // var th = this; + // if (this.data.is_normal == 0) { + // //看一下有没有起购数,如果有起购数,要计算起购数 + // var qnum = parseFloat(th.data.prom_act.minbuynum); + // if (qnum > 0 && th.data.goodsInputNum < qnum) { + // getApp().confirmBox("拼团商品至少要买" + qnum + "件!"); + // return false; + // } + // } + // th.addcart_pt_func(); + // + // }, + + //-----------------拼单生成方法--------------------- addCart_pt: function () { var th = this; if (this.data.is_normal == 0) { @@ -5327,12 +5342,45 @@ Page({ getApp().confirmBox("拼团商品至少要买" + qnum + "件!"); return false; } - } - th.addcart_pt_func(); + th.addcart_pt_func(); + + } else { + + //如果是线下库存的时候 + if (th.data.sales_rules >= 2 && !th.data.sele_g.whsle_id) { + var pick = th.get_pick_from_list(th.data.sto_sele_id) + //---通过接口获取门店的线下库存信息-- + th.check_CanOutQty(th.data.sele_g, pick, function (CanOutQty) { + if (CanOutQty) { + if (CanOutQty < e.data.goodsInputNum) { + wx.hideLoading(); + th.data.adding = 0; + wx.showToast({ + title: '库存不足!', + icon: 'none', + }); + return false; + } + //-- 成功才来下一步 -- + th.addcart_pt_func(); + } else { + wx.hideLoading(); + wx.showToast({ + title: '库存不足!', + icon: 'none', + }); + return false; + } + }) + }else{ + th.addcart_pt_func(); + } + } }, + addcart_pt_func: function () { if (oo.user_id == null) { s.my_warnning("还未登录!", 0, this); -- libgit2 0.21.4