Sfoglia il codice sorgente

优化库存为空商品购买

wenjie 2 mesi fa
parent
commit
ee77552548
1 ha cambiato i file con 3 aggiunte e 1 eliminazioni
  1. 3 1
      pages/prod/prod.js

+ 3 - 1
pages/prod/prod.js

@@ -357,7 +357,7 @@ Page({
         // 获取优惠券
         this.getCouponList();
         // 组装sku
-        this.groupSkuProp(res.skuList);
+        res.skuList&&this.groupSkuProp(res.skuList);
 
         this.getShopInfo();
 
@@ -856,6 +856,7 @@ Page({
    * 加入购物车
    */
   addToCart: function (event) {
+    if(this.data.totalStocks == 0) return
     let skuList = this.data.skuList[0]
     console.log(333333,skuList);
     if (skuList.weight > 20000) {
@@ -924,6 +925,7 @@ Page({
    * 立即购买
    */
   buyNow: function () {
+    if(this.data.totalStocks == 0) return
     let skuList = this.data.skuList[0]
     if (skuList.weight > 20000) {
       wx.showToast({