diff --git a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js index bf8cbfe..26f0375 100644 --- a/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js +++ b/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js @@ -287,6 +287,8 @@ Page({ is_get_guide:0, keyword:'', //门店搜索 sec_i:-1,//选中分类门店 下标 + + adding:0 //避免重复点击 }, //------初始化加载---------- @@ -896,6 +898,9 @@ Page({ //---展示--- onShow: async function () { + //添加购物车的控制要清理0 + this.data.adding=0; + getApp().check_can_share(this); // console.log('onshow'); var goods_list = null, th = this, that = this; @@ -1435,7 +1440,6 @@ Page({ open_ind_store: ind }); - th.add_cart_func(t); }, @@ -4688,6 +4692,9 @@ Page({ return; } + if(this.data.adding) return false; + this.data.adding=1; + wx.showLoading({ mask:true }); @@ -4704,6 +4711,7 @@ Page({ if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { wx.hideLoading(); + th.data.adding=0; wx.showModal({ title: '提示', content: '超出商品限购' @@ -4725,7 +4733,9 @@ Page({ }); if (th.data.sto_sele_name == ""){ - wx.hideLoading();return s.my_warnning("请选择门店", 0, th); + wx.hideLoading(); + th.data.adding=0; + return s.my_warnning("请选择门店", 0, th); } //--------------此时操作的数据------------ @@ -4799,6 +4809,7 @@ Page({ if (CanOutQty) { if (CanOutQty < e.data.goodsInputNum) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '库存不足!', icon: 'none', @@ -4809,6 +4820,7 @@ Page({ th.by_next_func(newd); } else { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '库存不足!', icon: 'none', @@ -4820,6 +4832,7 @@ Page({ } else { if (o.store_count <= 0) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '库存已为空!', icon: 'none', @@ -4830,6 +4843,7 @@ Page({ if (o.store_count < e.data.goodsInputNum) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '库存不足!', icon: 'none', diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index 7ade854..f2f6e6b 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -274,6 +274,8 @@ Page({ showFold:true, new_share_imgurl:'', //普通商品分享图片 + adding:0 //加入购物车的避免重复 + }, //------初始化加载---------- @@ -919,6 +921,8 @@ Page({ //---展示--- onShow: function () { + //添加购物车的控制要清理0 + this.data.adding=0; getApp().check_can_share(this); @@ -1389,10 +1393,17 @@ Page({ return false; } + if(th.data.adding) return false; + th.data.adding=1; + wx.showLoading({ mask:true }) + + + + //如果是秒杀的话,要看redis够不够 if (this.data.prom_type == 1 || this.data.prom_type == 2) { @@ -1406,6 +1417,7 @@ Page({ this.getactLen(function (num) { if (num < th.data.goodsInputNum) { wx.hideLoading(); + th.data.adding=0; // getApp().my_warnning("活动库存不足!", 0, th); wx.showToast({ title: '活动库存不足!', @@ -1586,11 +1598,13 @@ Page({ var i = getApp().request; if (oo.user_id == null) { wx.hideLoading(); + th.data.adding=0; return s.my_warnning("还未登录!", 0, this); } if (!getApp().globalData.userInfo) { wx.hideLoading(); + th.data.adding=0; return s.my_warnning("还未登录!", 0, this); } @@ -1606,6 +1620,7 @@ Page({ if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '超出商品限购', icon: 'none', @@ -1618,6 +1633,7 @@ Page({ if ((th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) && !th.data.is_normal) { if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '超出商品活动限购', icon: 'none', @@ -1628,14 +1644,18 @@ Page({ } if (th.data.goodsInputNum <= 0){ - wx.hideLoading();return s.my_warnning("商品数量不能为0", 0, th); + wx.hideLoading(); + th.data.adding=0; + return s.my_warnning("商品数量不能为0", 0, th); } if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined) th.setData({ sto_sele_name: "" }); if (th.data.sto_sele_name == ""){ - wx.hideLoading();return s.my_warnning("请选择门店", 0, th); + wx.hideLoading(); + th.data.adding=0; + return s.my_warnning("请选择门店", 0, th); } //--------------此时操作的数据------------ @@ -1714,6 +1734,7 @@ Page({ if (CanOutQty) { if (CanOutQty < e.data.goodsInputNum) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '库存不足!', icon: 'none', @@ -1724,6 +1745,7 @@ Page({ th.add_cart_next(e, t, a, o, newd, CanOutQty); } else { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '库存不足!', icon: 'none', @@ -1736,6 +1758,7 @@ Page({ } else { if (o.store_count <= 0) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '库存已为空!', icon: 'none' @@ -1744,6 +1767,7 @@ Page({ } if (o.store_count < e.data.goodsInputNum) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '库存不足!', icon: 'none', @@ -1763,6 +1787,7 @@ Page({ if (o.store_count <= 0) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '库存已为空!', icon: 'none', @@ -1771,6 +1796,7 @@ Page({ } if (o.store_count < e.data.goodsInputNum) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '库存不足!', icon: 'none', @@ -1790,6 +1816,7 @@ Page({ newd.prom_type = 7; if (o.store_count <= 0) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '库存已为空!', icon: 'none', @@ -1798,6 +1825,7 @@ Page({ }; if (o.store_count < e.data.goodsInputNum) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '库存不足!', icon: 'none', @@ -1817,6 +1845,7 @@ Page({ if (CanOutQty < e.data.goodsInputNum) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '库存不足!', icon: 'none', @@ -1827,6 +1856,7 @@ Page({ th.add_cart_next(e, t, a, o, newd, CanOutQty); } else { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '库存不足!', icon: 'none', @@ -1838,6 +1868,7 @@ Page({ } else { if (o.store_count <= 0) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '库存已为空!', icon: 'none', @@ -1847,6 +1878,7 @@ Page({ }; if (o.store_count < e.data.goodsInputNum) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '库存不足!', icon: 'none', @@ -1874,6 +1906,7 @@ Page({ if (CanOutQty < e.data.goodsInputNum) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '库存不足!', icon: 'none', @@ -2014,6 +2047,7 @@ Page({ if (CanOutQty) { if (item.goods_num + th.data.goodsInputNum > CanOutQty) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '库存不足!', icon: 'none', @@ -2024,6 +2058,7 @@ Page({ } else { if (item.goods_num + th.data.goodsInputNum > o.store_count) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '库存不足!', icon: 'none', @@ -2035,6 +2070,7 @@ Page({ //秒杀有限购的时候,同时不是普通购买 if ( item.goods_num + th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit && th.data.prom_buy_limit>0 && !newd.is_pd_normal && (th.data.prom_type == 1 || th.data.prom_type == 2)) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '此商品已在购物车,去购物车结算!', icon: 'none', @@ -2076,6 +2112,7 @@ Page({ data: updata, success: function (t) { wx.hideLoading(); + th.data.adding=0; getApp().my_warnning('加入购物车成功', 1, th, 450); var c_num = th.data.cartGoodsNum + th.data.goodsInputNum; th.setData({ @@ -2089,6 +2126,7 @@ Page({ data: newd, success: function (t) { wx.hideLoading(); + th.data.adding=0; getApp().my_warnning('加入购物车成功', 1, th, 450); var c_num = th.data.cartGoodsNum + e.data.goodsInputNum; th.setData({ @@ -5270,6 +5308,8 @@ Page({ th = e, o = this.data.sele_g; + if(th.data.adding) return false; + th.data.adding=0; wx.showLoading({ mask:true @@ -5283,6 +5323,7 @@ Page({ if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '超出商品限购', icon: 'none', @@ -5301,6 +5342,7 @@ Page({ if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0 && th.data.is_normal != 1) { if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '超出商品活动限购', icon: 'none', @@ -5321,6 +5363,7 @@ Page({ if (o.store_count <= 0) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '库存已为空!', icon: 'none', @@ -5337,6 +5380,7 @@ Page({ if (th.data.goodsInputNum > redis_num) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '超出商品活动库存', icon: 'none', @@ -5351,6 +5395,7 @@ Page({ } else { if (o.store_count <= 0) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '库存已为空!', icon: 'none', @@ -5362,6 +5407,7 @@ Page({ if (th.data.goodsInputNum <= 0) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '商品数量不能为0', icon: 'none', @@ -5372,6 +5418,7 @@ Page({ if (th.data.goodsInputNum > o.store_count) { wx.hideLoading(); + th.data.adding=0; wx.showToast({ title: '超出商品库存', icon: 'none', @@ -5386,6 +5433,7 @@ Page({ }); if (th.data.sto_sele_name == ""){ wx.hideLoading(); + th.data.adding=0; return s.my_warnning("请选择门店", 0, th); } //--------------此时操作的数据------------