Commit f81edf77d1c0413804d13539b9907c869148077f
1 parent
6cb6ed0a
避免重复点击的优化
Showing
2 changed files
with
66 additions
and
4 deletions
packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js
... | ... | @@ -287,6 +287,8 @@ Page({ |
287 | 287 | is_get_guide:0, |
288 | 288 | keyword:'', //门店搜索 |
289 | 289 | sec_i:-1,//选中分类门店 下标 |
290 | + | |
291 | + adding:0 //避免重复点击 | |
290 | 292 | }, |
291 | 293 | |
292 | 294 | //------初始化加载---------- |
... | ... | @@ -896,6 +898,9 @@ Page({ |
896 | 898 | //---展示--- |
897 | 899 | onShow: async function () { |
898 | 900 | |
901 | + //添加购物车的控制要清理0 | |
902 | + this.data.adding=0; | |
903 | + | |
899 | 904 | getApp().check_can_share(this); |
900 | 905 | // console.log('onshow'); |
901 | 906 | var goods_list = null, th = this, that = this; |
... | ... | @@ -1435,7 +1440,6 @@ Page({ |
1435 | 1440 | open_ind_store: ind |
1436 | 1441 | }); |
1437 | 1442 | |
1438 | - | |
1439 | 1443 | th.add_cart_func(t); |
1440 | 1444 | }, |
1441 | 1445 | |
... | ... | @@ -4688,6 +4692,9 @@ Page({ |
4688 | 4692 | return; |
4689 | 4693 | } |
4690 | 4694 | |
4695 | + if(this.data.adding) return false; | |
4696 | + this.data.adding=1; | |
4697 | + | |
4691 | 4698 | wx.showLoading({ |
4692 | 4699 | mask:true |
4693 | 4700 | }); |
... | ... | @@ -4704,6 +4711,7 @@ Page({ |
4704 | 4711 | if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { |
4705 | 4712 | if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { |
4706 | 4713 | wx.hideLoading(); |
4714 | + th.data.adding=0; | |
4707 | 4715 | wx.showModal({ |
4708 | 4716 | title: '提示', |
4709 | 4717 | content: '超出商品限购' |
... | ... | @@ -4725,7 +4733,9 @@ Page({ |
4725 | 4733 | }); |
4726 | 4734 | |
4727 | 4735 | if (th.data.sto_sele_name == ""){ |
4728 | - wx.hideLoading();return s.my_warnning("请选择门店", 0, th); | |
4736 | + wx.hideLoading(); | |
4737 | + th.data.adding=0; | |
4738 | + return s.my_warnning("请选择门店", 0, th); | |
4729 | 4739 | } |
4730 | 4740 | |
4731 | 4741 | //--------------此时操作的数据------------ |
... | ... | @@ -4799,6 +4809,7 @@ Page({ |
4799 | 4809 | if (CanOutQty) { |
4800 | 4810 | if (CanOutQty < e.data.goodsInputNum) { |
4801 | 4811 | wx.hideLoading(); |
4812 | + th.data.adding=0; | |
4802 | 4813 | wx.showToast({ |
4803 | 4814 | title: '库存不足!', |
4804 | 4815 | icon: 'none', |
... | ... | @@ -4809,6 +4820,7 @@ Page({ |
4809 | 4820 | th.by_next_func(newd); |
4810 | 4821 | } else { |
4811 | 4822 | wx.hideLoading(); |
4823 | + th.data.adding=0; | |
4812 | 4824 | wx.showToast({ |
4813 | 4825 | title: '库存不足!', |
4814 | 4826 | icon: 'none', |
... | ... | @@ -4820,6 +4832,7 @@ Page({ |
4820 | 4832 | } else { |
4821 | 4833 | if (o.store_count <= 0) { |
4822 | 4834 | wx.hideLoading(); |
4835 | + th.data.adding=0; | |
4823 | 4836 | wx.showToast({ |
4824 | 4837 | title: '库存已为空!', |
4825 | 4838 | icon: 'none', |
... | ... | @@ -4830,6 +4843,7 @@ Page({ |
4830 | 4843 | |
4831 | 4844 | if (o.store_count < e.data.goodsInputNum) { |
4832 | 4845 | wx.hideLoading(); |
4846 | + th.data.adding=0; | |
4833 | 4847 | wx.showToast({ |
4834 | 4848 | title: '库存不足!', |
4835 | 4849 | icon: 'none', | ... | ... |
pages/goods/goodsInfo/goodsInfo.js
... | ... | @@ -274,6 +274,8 @@ Page({ |
274 | 274 | showFold:true, |
275 | 275 | new_share_imgurl:'', //普通商品分享图片 |
276 | 276 | |
277 | + adding:0 //加入购物车的避免重复 | |
278 | + | |
277 | 279 | }, |
278 | 280 | |
279 | 281 | //------初始化加载---------- |
... | ... | @@ -919,6 +921,8 @@ Page({ |
919 | 921 | |
920 | 922 | //---展示--- |
921 | 923 | onShow: function () { |
924 | + //添加购物车的控制要清理0 | |
925 | + this.data.adding=0; | |
922 | 926 | |
923 | 927 | getApp().check_can_share(this); |
924 | 928 | |
... | ... | @@ -1389,10 +1393,17 @@ Page({ |
1389 | 1393 | return false; |
1390 | 1394 | } |
1391 | 1395 | |
1396 | + if(th.data.adding) return false; | |
1397 | + th.data.adding=1; | |
1398 | + | |
1392 | 1399 | wx.showLoading({ |
1393 | 1400 | mask:true |
1394 | 1401 | }) |
1395 | 1402 | |
1403 | + | |
1404 | + | |
1405 | + | |
1406 | + | |
1396 | 1407 | //如果是秒杀的话,要看redis够不够 |
1397 | 1408 | if (this.data.prom_type == 1 || this.data.prom_type == 2) { |
1398 | 1409 | |
... | ... | @@ -1406,6 +1417,7 @@ Page({ |
1406 | 1417 | this.getactLen(function (num) { |
1407 | 1418 | if (num < th.data.goodsInputNum) { |
1408 | 1419 | wx.hideLoading(); |
1420 | + th.data.adding=0; | |
1409 | 1421 | // getApp().my_warnning("活动库存不足!", 0, th); |
1410 | 1422 | wx.showToast({ |
1411 | 1423 | title: '活动库存不足!', |
... | ... | @@ -1586,11 +1598,13 @@ Page({ |
1586 | 1598 | var i = getApp().request; |
1587 | 1599 | if (oo.user_id == null) { |
1588 | 1600 | wx.hideLoading(); |
1601 | + th.data.adding=0; | |
1589 | 1602 | return s.my_warnning("还未登录!", 0, this); |
1590 | 1603 | } |
1591 | 1604 | |
1592 | 1605 | if (!getApp().globalData.userInfo) { |
1593 | 1606 | wx.hideLoading(); |
1607 | + th.data.adding=0; | |
1594 | 1608 | return s.my_warnning("还未登录!", 0, this); |
1595 | 1609 | } |
1596 | 1610 | |
... | ... | @@ -1606,6 +1620,7 @@ Page({ |
1606 | 1620 | if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { |
1607 | 1621 | if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { |
1608 | 1622 | wx.hideLoading(); |
1623 | + th.data.adding=0; | |
1609 | 1624 | wx.showToast({ |
1610 | 1625 | title: '超出商品限购', |
1611 | 1626 | icon: 'none', |
... | ... | @@ -1618,6 +1633,7 @@ Page({ |
1618 | 1633 | if ((th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) && !th.data.is_normal) { |
1619 | 1634 | if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) { |
1620 | 1635 | wx.hideLoading(); |
1636 | + th.data.adding=0; | |
1621 | 1637 | wx.showToast({ |
1622 | 1638 | title: '超出商品活动限购', |
1623 | 1639 | icon: 'none', |
... | ... | @@ -1628,14 +1644,18 @@ Page({ |
1628 | 1644 | } |
1629 | 1645 | |
1630 | 1646 | if (th.data.goodsInputNum <= 0){ |
1631 | - wx.hideLoading();return s.my_warnning("商品数量不能为0", 0, th); | |
1647 | + wx.hideLoading(); | |
1648 | + th.data.adding=0; | |
1649 | + return s.my_warnning("商品数量不能为0", 0, th); | |
1632 | 1650 | } |
1633 | 1651 | if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined) |
1634 | 1652 | th.setData({ |
1635 | 1653 | sto_sele_name: "" |
1636 | 1654 | }); |
1637 | 1655 | if (th.data.sto_sele_name == ""){ |
1638 | - wx.hideLoading();return s.my_warnning("请选择门店", 0, th); | |
1656 | + wx.hideLoading(); | |
1657 | + th.data.adding=0; | |
1658 | + return s.my_warnning("请选择门店", 0, th); | |
1639 | 1659 | } |
1640 | 1660 | |
1641 | 1661 | //--------------此时操作的数据------------ |
... | ... | @@ -1714,6 +1734,7 @@ Page({ |
1714 | 1734 | if (CanOutQty) { |
1715 | 1735 | if (CanOutQty < e.data.goodsInputNum) { |
1716 | 1736 | wx.hideLoading(); |
1737 | + th.data.adding=0; | |
1717 | 1738 | wx.showToast({ |
1718 | 1739 | title: '库存不足!', |
1719 | 1740 | icon: 'none', |
... | ... | @@ -1724,6 +1745,7 @@ Page({ |
1724 | 1745 | th.add_cart_next(e, t, a, o, newd, CanOutQty); |
1725 | 1746 | } else { |
1726 | 1747 | wx.hideLoading(); |
1748 | + th.data.adding=0; | |
1727 | 1749 | wx.showToast({ |
1728 | 1750 | title: '库存不足!', |
1729 | 1751 | icon: 'none', |
... | ... | @@ -1736,6 +1758,7 @@ Page({ |
1736 | 1758 | } else { |
1737 | 1759 | if (o.store_count <= 0) { |
1738 | 1760 | wx.hideLoading(); |
1761 | + th.data.adding=0; | |
1739 | 1762 | wx.showToast({ |
1740 | 1763 | title: '库存已为空!', |
1741 | 1764 | icon: 'none' |
... | ... | @@ -1744,6 +1767,7 @@ Page({ |
1744 | 1767 | } |
1745 | 1768 | if (o.store_count < e.data.goodsInputNum) { |
1746 | 1769 | wx.hideLoading(); |
1770 | + th.data.adding=0; | |
1747 | 1771 | wx.showToast({ |
1748 | 1772 | title: '库存不足!', |
1749 | 1773 | icon: 'none', |
... | ... | @@ -1763,6 +1787,7 @@ Page({ |
1763 | 1787 | |
1764 | 1788 | if (o.store_count <= 0) { |
1765 | 1789 | wx.hideLoading(); |
1790 | + th.data.adding=0; | |
1766 | 1791 | wx.showToast({ |
1767 | 1792 | title: '库存已为空!', |
1768 | 1793 | icon: 'none', |
... | ... | @@ -1771,6 +1796,7 @@ Page({ |
1771 | 1796 | } |
1772 | 1797 | if (o.store_count < e.data.goodsInputNum) { |
1773 | 1798 | wx.hideLoading(); |
1799 | + th.data.adding=0; | |
1774 | 1800 | wx.showToast({ |
1775 | 1801 | title: '库存不足!', |
1776 | 1802 | icon: 'none', |
... | ... | @@ -1790,6 +1816,7 @@ Page({ |
1790 | 1816 | newd.prom_type = 7; |
1791 | 1817 | if (o.store_count <= 0) { |
1792 | 1818 | wx.hideLoading(); |
1819 | + th.data.adding=0; | |
1793 | 1820 | wx.showToast({ |
1794 | 1821 | title: '库存已为空!', |
1795 | 1822 | icon: 'none', |
... | ... | @@ -1798,6 +1825,7 @@ Page({ |
1798 | 1825 | }; |
1799 | 1826 | if (o.store_count < e.data.goodsInputNum) { |
1800 | 1827 | wx.hideLoading(); |
1828 | + th.data.adding=0; | |
1801 | 1829 | wx.showToast({ |
1802 | 1830 | title: '库存不足!', |
1803 | 1831 | icon: 'none', |
... | ... | @@ -1817,6 +1845,7 @@ Page({ |
1817 | 1845 | |
1818 | 1846 | if (CanOutQty < e.data.goodsInputNum) { |
1819 | 1847 | wx.hideLoading(); |
1848 | + th.data.adding=0; | |
1820 | 1849 | wx.showToast({ |
1821 | 1850 | title: '库存不足!', |
1822 | 1851 | icon: 'none', |
... | ... | @@ -1827,6 +1856,7 @@ Page({ |
1827 | 1856 | th.add_cart_next(e, t, a, o, newd, CanOutQty); |
1828 | 1857 | } else { |
1829 | 1858 | wx.hideLoading(); |
1859 | + th.data.adding=0; | |
1830 | 1860 | wx.showToast({ |
1831 | 1861 | title: '库存不足!', |
1832 | 1862 | icon: 'none', |
... | ... | @@ -1838,6 +1868,7 @@ Page({ |
1838 | 1868 | } else { |
1839 | 1869 | if (o.store_count <= 0) { |
1840 | 1870 | wx.hideLoading(); |
1871 | + th.data.adding=0; | |
1841 | 1872 | wx.showToast({ |
1842 | 1873 | title: '库存已为空!', |
1843 | 1874 | icon: 'none', |
... | ... | @@ -1847,6 +1878,7 @@ Page({ |
1847 | 1878 | }; |
1848 | 1879 | if (o.store_count < e.data.goodsInputNum) { |
1849 | 1880 | wx.hideLoading(); |
1881 | + th.data.adding=0; | |
1850 | 1882 | wx.showToast({ |
1851 | 1883 | title: '库存不足!', |
1852 | 1884 | icon: 'none', |
... | ... | @@ -1874,6 +1906,7 @@ Page({ |
1874 | 1906 | |
1875 | 1907 | if (CanOutQty < e.data.goodsInputNum) { |
1876 | 1908 | wx.hideLoading(); |
1909 | + th.data.adding=0; | |
1877 | 1910 | wx.showToast({ |
1878 | 1911 | title: '库存不足!', |
1879 | 1912 | icon: 'none', |
... | ... | @@ -2014,6 +2047,7 @@ Page({ |
2014 | 2047 | if (CanOutQty) { |
2015 | 2048 | if (item.goods_num + th.data.goodsInputNum > CanOutQty) { |
2016 | 2049 | wx.hideLoading(); |
2050 | + th.data.adding=0; | |
2017 | 2051 | wx.showToast({ |
2018 | 2052 | title: '库存不足!', |
2019 | 2053 | icon: 'none', |
... | ... | @@ -2024,6 +2058,7 @@ Page({ |
2024 | 2058 | } else { |
2025 | 2059 | if (item.goods_num + th.data.goodsInputNum > o.store_count) { |
2026 | 2060 | wx.hideLoading(); |
2061 | + th.data.adding=0; | |
2027 | 2062 | wx.showToast({ |
2028 | 2063 | title: '库存不足!', |
2029 | 2064 | icon: 'none', |
... | ... | @@ -2035,6 +2070,7 @@ Page({ |
2035 | 2070 | //秒杀有限购的时候,同时不是普通购买 |
2036 | 2071 | 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)) { |
2037 | 2072 | wx.hideLoading(); |
2073 | + th.data.adding=0; | |
2038 | 2074 | wx.showToast({ |
2039 | 2075 | title: '此商品已在购物车,去购物车结算!', |
2040 | 2076 | icon: 'none', |
... | ... | @@ -2076,6 +2112,7 @@ Page({ |
2076 | 2112 | data: updata, |
2077 | 2113 | success: function (t) { |
2078 | 2114 | wx.hideLoading(); |
2115 | + th.data.adding=0; | |
2079 | 2116 | getApp().my_warnning('加入购物车成功', 1, th, 450); |
2080 | 2117 | var c_num = th.data.cartGoodsNum + th.data.goodsInputNum; |
2081 | 2118 | th.setData({ |
... | ... | @@ -2089,6 +2126,7 @@ Page({ |
2089 | 2126 | data: newd, |
2090 | 2127 | success: function (t) { |
2091 | 2128 | wx.hideLoading(); |
2129 | + th.data.adding=0; | |
2092 | 2130 | getApp().my_warnning('加入购物车成功', 1, th, 450); |
2093 | 2131 | var c_num = th.data.cartGoodsNum + e.data.goodsInputNum; |
2094 | 2132 | th.setData({ |
... | ... | @@ -5270,6 +5308,8 @@ Page({ |
5270 | 5308 | th = e, |
5271 | 5309 | o = this.data.sele_g; |
5272 | 5310 | |
5311 | + if(th.data.adding) return false; | |
5312 | + th.data.adding=0; | |
5273 | 5313 | |
5274 | 5314 | wx.showLoading({ |
5275 | 5315 | mask:true |
... | ... | @@ -5283,6 +5323,7 @@ Page({ |
5283 | 5323 | if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) { |
5284 | 5324 | |
5285 | 5325 | wx.hideLoading(); |
5326 | + th.data.adding=0; | |
5286 | 5327 | wx.showToast({ |
5287 | 5328 | title: '超出商品限购', |
5288 | 5329 | icon: 'none', |
... | ... | @@ -5301,6 +5342,7 @@ Page({ |
5301 | 5342 | if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0 && th.data.is_normal != 1) { |
5302 | 5343 | if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) { |
5303 | 5344 | wx.hideLoading(); |
5345 | + th.data.adding=0; | |
5304 | 5346 | wx.showToast({ |
5305 | 5347 | title: '超出商品活动限购', |
5306 | 5348 | icon: 'none', |
... | ... | @@ -5321,6 +5363,7 @@ Page({ |
5321 | 5363 | |
5322 | 5364 | if (o.store_count <= 0) { |
5323 | 5365 | wx.hideLoading(); |
5366 | + th.data.adding=0; | |
5324 | 5367 | wx.showToast({ |
5325 | 5368 | title: '库存已为空!', |
5326 | 5369 | icon: 'none', |
... | ... | @@ -5337,6 +5380,7 @@ Page({ |
5337 | 5380 | |
5338 | 5381 | if (th.data.goodsInputNum > redis_num) { |
5339 | 5382 | wx.hideLoading(); |
5383 | + th.data.adding=0; | |
5340 | 5384 | wx.showToast({ |
5341 | 5385 | title: '超出商品活动库存', |
5342 | 5386 | icon: 'none', |
... | ... | @@ -5351,6 +5395,7 @@ Page({ |
5351 | 5395 | } else { |
5352 | 5396 | if (o.store_count <= 0) { |
5353 | 5397 | wx.hideLoading(); |
5398 | + th.data.adding=0; | |
5354 | 5399 | wx.showToast({ |
5355 | 5400 | title: '库存已为空!', |
5356 | 5401 | icon: 'none', |
... | ... | @@ -5362,6 +5407,7 @@ Page({ |
5362 | 5407 | |
5363 | 5408 | if (th.data.goodsInputNum <= 0) { |
5364 | 5409 | wx.hideLoading(); |
5410 | + th.data.adding=0; | |
5365 | 5411 | wx.showToast({ |
5366 | 5412 | title: '商品数量不能为0', |
5367 | 5413 | icon: 'none', |
... | ... | @@ -5372,6 +5418,7 @@ Page({ |
5372 | 5418 | if (th.data.goodsInputNum > o.store_count) { |
5373 | 5419 | |
5374 | 5420 | wx.hideLoading(); |
5421 | + th.data.adding=0; | |
5375 | 5422 | wx.showToast({ |
5376 | 5423 | title: '超出商品库存', |
5377 | 5424 | icon: 'none', |
... | ... | @@ -5386,6 +5433,7 @@ Page({ |
5386 | 5433 | }); |
5387 | 5434 | if (th.data.sto_sele_name == ""){ |
5388 | 5435 | wx.hideLoading(); |
5436 | + th.data.adding=0; | |
5389 | 5437 | return s.my_warnning("请选择门店", 0, th); |
5390 | 5438 | } |
5391 | 5439 | //--------------此时操作的数据------------ | ... | ... |