Commit f8f200f690000e6a3528b71e7066d2776906cc12
1 parent
fb803415
拼团的普通购买要判断一下线下库存
Showing
1 changed file
with
50 additions
and
2 deletions
pages/goods/goodsInfo/goodsInfo.js
| @@ -5318,6 +5318,21 @@ Page({ | @@ -5318,6 +5318,21 @@ Page({ | ||
| 5318 | }, | 5318 | }, |
| 5319 | 5319 | ||
| 5320 | //-----------------拼单生成方法--------------------- | 5320 | //-----------------拼单生成方法--------------------- |
| 5321 | + // addCart_pt: function () { | ||
| 5322 | + // var th = this; | ||
| 5323 | + // if (this.data.is_normal == 0) { | ||
| 5324 | + // //看一下有没有起购数,如果有起购数,要计算起购数 | ||
| 5325 | + // var qnum = parseFloat(th.data.prom_act.minbuynum); | ||
| 5326 | + // if (qnum > 0 && th.data.goodsInputNum < qnum) { | ||
| 5327 | + // getApp().confirmBox("拼团商品至少要买" + qnum + "件!"); | ||
| 5328 | + // return false; | ||
| 5329 | + // } | ||
| 5330 | + // } | ||
| 5331 | + // th.addcart_pt_func(); | ||
| 5332 | + // | ||
| 5333 | + // }, | ||
| 5334 | + | ||
| 5335 | + //-----------------拼单生成方法--------------------- | ||
| 5321 | addCart_pt: function () { | 5336 | addCart_pt: function () { |
| 5322 | var th = this; | 5337 | var th = this; |
| 5323 | if (this.data.is_normal == 0) { | 5338 | if (this.data.is_normal == 0) { |
| @@ -5327,12 +5342,45 @@ Page({ | @@ -5327,12 +5342,45 @@ Page({ | ||
| 5327 | getApp().confirmBox("拼团商品至少要买" + qnum + "件!"); | 5342 | getApp().confirmBox("拼团商品至少要买" + qnum + "件!"); |
| 5328 | return false; | 5343 | return false; |
| 5329 | } | 5344 | } |
| 5330 | - } | ||
| 5331 | 5345 | ||
| 5332 | - th.addcart_pt_func(); | 5346 | + th.addcart_pt_func(); |
| 5347 | + | ||
| 5348 | + } else { | ||
| 5349 | + | ||
| 5350 | + //如果是线下库存的时候 | ||
| 5351 | + if (th.data.sales_rules >= 2 && !th.data.sele_g.whsle_id) { | ||
| 5352 | + var pick = th.get_pick_from_list(th.data.sto_sele_id) | ||
| 5353 | + //---通过接口获取门店的线下库存信息-- | ||
| 5354 | + th.check_CanOutQty(th.data.sele_g, pick, function (CanOutQty) { | ||
| 5355 | + if (CanOutQty) { | ||
| 5356 | + if (CanOutQty < e.data.goodsInputNum) { | ||
| 5357 | + wx.hideLoading(); | ||
| 5358 | + th.data.adding = 0; | ||
| 5359 | + wx.showToast({ | ||
| 5360 | + title: '库存不足!', | ||
| 5361 | + icon: 'none', | ||
| 5362 | + }); | ||
| 5363 | + return false; | ||
| 5364 | + } | ||
| 5333 | 5365 | ||
| 5366 | + //-- 成功才来下一步 -- | ||
| 5367 | + th.addcart_pt_func(); | ||
| 5368 | + } else { | ||
| 5369 | + wx.hideLoading(); | ||
| 5370 | + wx.showToast({ | ||
| 5371 | + title: '库存不足!', | ||
| 5372 | + icon: 'none', | ||
| 5373 | + }); | ||
| 5374 | + return false; | ||
| 5375 | + } | ||
| 5376 | + }) | ||
| 5377 | + }else{ | ||
| 5378 | + th.addcart_pt_func(); | ||
| 5379 | + } | ||
| 5380 | + } | ||
| 5334 | }, | 5381 | }, |
| 5335 | 5382 | ||
| 5383 | + | ||
| 5336 | addcart_pt_func: function () { | 5384 | addcart_pt_func: function () { |
| 5337 | if (oo.user_id == null) { | 5385 | if (oo.user_id == null) { |
| 5338 | s.my_warnning("还未登录!", 0, this); | 5386 | s.my_warnning("还未登录!", 0, this); |