Commit 6cb6ed0a77f381b6f20f6d39fa7b22aa2f6284c0

Authored by yvan.ni
1 parent a1a3f464

商品普通购买的时候,要防止重复点击

packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo.js
... ... @@ -4687,6 +4687,11 @@ Page({
4687 4687 s.my_warnning("还未登录!", 0, this);
4688 4688 return;
4689 4689 }
  4690 +
  4691 + wx.showLoading({
  4692 + mask:true
  4693 + });
  4694 +
4690 4695 var e = this,
4691 4696 th = e,
4692 4697 o = this.data.sele_g;
... ... @@ -4698,6 +4703,7 @@ Page({
4698 4703 //---判断商品是否超出限购---
4699 4704 if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) {
4700 4705 if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) {
  4706 + wx.hideLoading();
4701 4707 wx.showModal({
4702 4708 title: '提示',
4703 4709 content: '超出商品限购'
... ... @@ -4718,7 +4724,9 @@ Page({
4718 4724 sto_sele_name: ""
4719 4725 });
4720 4726  
4721   - if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th);
  4727 + if (th.data.sto_sele_name == ""){
  4728 + wx.hideLoading();return s.my_warnning("请选择门店", 0, th);
  4729 + }
4722 4730  
4723 4731 //--------------此时操作的数据------------
4724 4732 var newd = {
... ... @@ -4789,8 +4797,8 @@ Page({
4789 4797  
4790 4798 th.check_CanOutQty(th.data.sele_g, pick, function (CanOutQty) {
4791 4799 if (CanOutQty) {
4792   -
4793 4800 if (CanOutQty < e.data.goodsInputNum) {
  4801 + wx.hideLoading();
4794 4802 wx.showToast({
4795 4803 title: '库存不足!',
4796 4804 icon: 'none',
... ... @@ -4800,6 +4808,7 @@ Page({
4800 4808  
4801 4809 th.by_next_func(newd);
4802 4810 } else {
  4811 + wx.hideLoading();
4803 4812 wx.showToast({
4804 4813 title: '库存不足!',
4805 4814 icon: 'none',
... ... @@ -4810,6 +4819,7 @@ Page({
4810 4819  
4811 4820 } else {
4812 4821 if (o.store_count <= 0) {
  4822 + wx.hideLoading();
4813 4823 wx.showToast({
4814 4824 title: '库存已为空!',
4815 4825 icon: 'none',
... ... @@ -4819,6 +4829,7 @@ Page({
4819 4829 }
4820 4830  
4821 4831 if (o.store_count < e.data.goodsInputNum) {
  4832 + wx.hideLoading();
4822 4833 wx.showToast({
4823 4834 title: '库存不足!',
4824 4835 icon: 'none',
... ...
pages/goods/goodsInfo/goodsInfo.js
... ... @@ -1389,7 +1389,9 @@ Page({
1389 1389 return false;
1390 1390 }
1391 1391  
1392   -
  1392 + wx.showLoading({
  1393 + mask:true
  1394 + })
1393 1395  
1394 1396 //如果是秒杀的话,要看redis够不够
1395 1397 if (this.data.prom_type == 1 || this.data.prom_type == 2) {
... ... @@ -1403,7 +1405,7 @@ Page({
1403 1405  
1404 1406 this.getactLen(function (num) {
1405 1407 if (num < th.data.goodsInputNum) {
1406   -
  1408 + wx.hideLoading();
1407 1409 // getApp().my_warnning("活动库存不足!", 0, th);
1408 1410 wx.showToast({
1409 1411 title: '活动库存不足!',
... ... @@ -1583,10 +1585,12 @@ Page({
1583 1585 add_cart_func: function (t) {
1584 1586 var i = getApp().request;
1585 1587 if (oo.user_id == null) {
  1588 + wx.hideLoading();
1586 1589 return s.my_warnning("还未登录!", 0, this);
1587 1590 }
1588 1591  
1589 1592 if (!getApp().globalData.userInfo) {
  1593 + wx.hideLoading();
1590 1594 return s.my_warnning("还未登录!", 0, this);
1591 1595 }
1592 1596  
... ... @@ -1601,6 +1605,7 @@ Page({
1601 1605 //---判断商品是否超出限购---
1602 1606 if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) {
1603 1607 if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) {
  1608 + wx.hideLoading();
1604 1609 wx.showToast({
1605 1610 title: '超出商品限购',
1606 1611 icon: 'none',
... ... @@ -1612,6 +1617,7 @@ Page({
1612 1617 //---判断商品是否超出活动限购---
1613 1618 if ((th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) && !th.data.is_normal) {
1614 1619 if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) {
  1620 + wx.hideLoading();
1615 1621 wx.showToast({
1616 1622 title: '超出商品活动限购',
1617 1623 icon: 'none',
... ... @@ -1621,12 +1627,16 @@ Page({
1621 1627 }
1622 1628 }
1623 1629  
1624   - if (th.data.goodsInputNum <= 0) return s.my_warnning("商品数量不能为0", 0, th);
  1630 + if (th.data.goodsInputNum <= 0){
  1631 + wx.hideLoading();return s.my_warnning("商品数量不能为0", 0, th);
  1632 + }
1625 1633 if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined)
1626 1634 th.setData({
1627 1635 sto_sele_name: ""
1628 1636 });
1629   - if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th);
  1637 + if (th.data.sto_sele_name == ""){
  1638 + wx.hideLoading();return s.my_warnning("请选择门店", 0, th);
  1639 + }
1630 1640  
1631 1641 //--------------此时操作的数据------------
1632 1642 var newd = {
... ... @@ -1703,6 +1713,7 @@ Page({
1703 1713 th.check_CanOutQty(th.data.sele_g, pick, function (CanOutQty) {
1704 1714 if (CanOutQty) {
1705 1715 if (CanOutQty < e.data.goodsInputNum) {
  1716 + wx.hideLoading();
1706 1717 wx.showToast({
1707 1718 title: '库存不足!',
1708 1719 icon: 'none',
... ... @@ -1712,6 +1723,7 @@ Page({
1712 1723  
1713 1724 th.add_cart_next(e, t, a, o, newd, CanOutQty);
1714 1725 } else {
  1726 + wx.hideLoading();
1715 1727 wx.showToast({
1716 1728 title: '库存不足!',
1717 1729 icon: 'none',
... ... @@ -1723,47 +1735,48 @@ Page({
1723 1735  
1724 1736 } else {
1725 1737 if (o.store_count <= 0) {
  1738 + wx.hideLoading();
1726 1739 wx.showToast({
1727 1740 title: '库存已为空!',
1728 1741 icon: 'none'
1729 1742 });
1730 1743 return false;
1731   - };
  1744 + }
1732 1745 if (o.store_count < e.data.goodsInputNum) {
  1746 + wx.hideLoading();
1733 1747 wx.showToast({
1734 1748 title: '库存不足!',
1735 1749 icon: 'none',
1736 1750 });
1737 1751 return false;
1738 1752 // return s.my_warnning("库存不足!", 0, th);
1739   - };
  1753 + }
1740 1754 th.add_cart_next(e, t, a, o, newd); //加入购物车下一步
1741 1755 };
1742   -
1743 1756 return false;
1744 1757 }
1745 1758  
1746 1759 newd.goods_price = th.data.prom_price;
1747 1760 newd.member_goods_price = th.data.prom_price,
1748   - newd.prom_type = th.data.prom_type;
  1761 + newd.prom_type = th.data.prom_type;
1749 1762 newd.prom_id = th.data.prom_id;
1750 1763  
1751 1764 if (o.store_count <= 0) {
  1765 + wx.hideLoading();
1752 1766 wx.showToast({
1753 1767 title: '库存已为空!',
1754 1768 icon: 'none',
1755 1769 });
1756 1770 return false;
1757   - //return s.my_warnning("库存已为空!", 0, th);
1758   - };
  1771 + }
1759 1772 if (o.store_count < e.data.goodsInputNum) {
  1773 + wx.hideLoading();
1760 1774 wx.showToast({
1761 1775 title: '库存不足!',
1762 1776 icon: 'none',
1763 1777 });
1764 1778 return false;
1765   - };
1766   -
  1779 + }
1767 1780 th.add_cart_next(e, t, a, o, newd); //加入购物车下一步
1768 1781  
1769 1782 } else if (o.prom_type == 7) {
... ... @@ -1776,6 +1789,7 @@ Page({
1776 1789 newd.prom_id = th.data.sele_g.act.id;
1777 1790 newd.prom_type = 7;
1778 1791 if (o.store_count <= 0) {
  1792 + wx.hideLoading();
1779 1793 wx.showToast({
1780 1794 title: '库存已为空!',
1781 1795 icon: 'none',
... ... @@ -1783,6 +1797,7 @@ Page({
1783 1797 return false;
1784 1798 };
1785 1799 if (o.store_count < e.data.goodsInputNum) {
  1800 + wx.hideLoading();
1786 1801 wx.showToast({
1787 1802 title: '库存不足!',
1788 1803 icon: 'none',
... ... @@ -1801,6 +1816,7 @@ Page({
1801 1816 if (CanOutQty) {
1802 1817  
1803 1818 if (CanOutQty < e.data.goodsInputNum) {
  1819 + wx.hideLoading();
1804 1820 wx.showToast({
1805 1821 title: '库存不足!',
1806 1822 icon: 'none',
... ... @@ -1810,6 +1826,7 @@ Page({
1810 1826  
1811 1827 th.add_cart_next(e, t, a, o, newd, CanOutQty);
1812 1828 } else {
  1829 + wx.hideLoading();
1813 1830 wx.showToast({
1814 1831 title: '库存不足!',
1815 1832 icon: 'none',
... ... @@ -1820,6 +1837,7 @@ Page({
1820 1837  
1821 1838 } else {
1822 1839 if (o.store_count <= 0) {
  1840 + wx.hideLoading();
1823 1841 wx.showToast({
1824 1842 title: '库存已为空!',
1825 1843 icon: 'none',
... ... @@ -1828,6 +1846,7 @@ Page({
1828 1846 //return s.my_warnning("库存已为空!", 0, th);
1829 1847 };
1830 1848 if (o.store_count < e.data.goodsInputNum) {
  1849 + wx.hideLoading();
1831 1850 wx.showToast({
1832 1851 title: '库存不足!',
1833 1852 icon: 'none',
... ... @@ -1854,6 +1873,7 @@ Page({
1854 1873 if (CanOutQty) {
1855 1874  
1856 1875 if (CanOutQty < e.data.goodsInputNum) {
  1876 + wx.hideLoading();
1857 1877 wx.showToast({
1858 1878 title: '库存不足!',
1859 1879 icon: 'none',
... ... @@ -1863,6 +1883,7 @@ Page({
1863 1883  
1864 1884 th.add_cart_next(e, t, a, o, newd, CanOutQty);
1865 1885 } else {
  1886 + wx.hideLoading();
1866 1887 wx.showToast({
1867 1888 title: '库存不足!',
1868 1889 icon: 'none',
... ... @@ -1873,6 +1894,7 @@ Page({
1873 1894  
1874 1895 } else {
1875 1896 if (o.store_count <= 0) {
  1897 + wx.hideLoading();
1876 1898 wx.showToast({
1877 1899 title: '库存已为空!',
1878 1900 icon: 'none',
... ... @@ -1881,13 +1903,14 @@ Page({
1881 1903 //return s.my_warnning("库存已为空!", 0, th);
1882 1904 };
1883 1905 if (o.store_count < e.data.goodsInputNum) {
  1906 + wx.hideLoading();
1884 1907 wx.showToast({
1885 1908 title: '库存不足!',
1886 1909 icon: 'none',
1887 1910 });
1888 1911 return false;
1889 1912 //return s.my_warnning("库存不足!", 0, th);
1890   - };
  1913 + }
1891 1914 th.add_cart_next(e, t, a, o, newd); //加入购物车下一步
1892 1915 }
1893 1916 }
... ... @@ -1899,6 +1922,8 @@ Page({
1899 1922  
1900 1923 //---加入购物车的最后一步---
1901 1924 add_cart_next(e, t, a, o, newd, CanOutQty) {
  1925 +
  1926 +
1902 1927 if (getApp().globalData.groupchat_id) {
1903 1928 newd.groupchat_id = getApp().globalData.groupchat_id
1904 1929 }
... ... @@ -1988,6 +2013,7 @@ Page({
1988 2013 //判断数量,要看下购物车中有没有该商品
1989 2014 if (CanOutQty) {
1990 2015 if (item.goods_num + th.data.goodsInputNum > CanOutQty) {
  2016 + wx.hideLoading();
1991 2017 wx.showToast({
1992 2018 title: '库存不足!',
1993 2019 icon: 'none',
... ... @@ -1997,6 +2023,7 @@ Page({
1997 2023 }
1998 2024 } else {
1999 2025 if (item.goods_num + th.data.goodsInputNum > o.store_count) {
  2026 + wx.hideLoading();
2000 2027 wx.showToast({
2001 2028 title: '库存不足!',
2002 2029 icon: 'none',
... ... @@ -2007,6 +2034,7 @@ Page({
2007 2034  
2008 2035 //秒杀有限购的时候,同时不是普通购买
2009 2036 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 + wx.hideLoading();
2010 2038 wx.showToast({
2011 2039 title: '此商品已在购物车,去购物车结算!',
2012 2040 icon: 'none',
... ... @@ -2047,6 +2075,7 @@ Page({
2047 2075 getApp().request.put("/api/weshop/cart/update", {
2048 2076 data: updata,
2049 2077 success: function (t) {
  2078 + wx.hideLoading();
2050 2079 getApp().my_warnning('加入购物车成功', 1, th, 450);
2051 2080 var c_num = th.data.cartGoodsNum + th.data.goodsInputNum;
2052 2081 th.setData({
... ... @@ -2059,6 +2088,7 @@ Page({
2059 2088 getApp().request.post("/api/weshop/cart/save", {
2060 2089 data: newd,
2061 2090 success: function (t) {
  2091 + wx.hideLoading();
2062 2092 getApp().my_warnning('加入购物车成功', 1, th, 450);
2063 2093 var c_num = th.data.cartGoodsNum + e.data.goodsInputNum;
2064 2094 th.setData({
... ... @@ -5241,12 +5271,18 @@ Page({
5241 5271 o = this.data.sele_g;
5242 5272  
5243 5273  
  5274 + wx.showLoading({
  5275 + mask:true
  5276 + })
  5277 +
5244 5278 //----------添加到购物车时,要判断限购数量,--------
5245 5279 e.get_buy_num(o, async function (ee) {
5246 5280  
5247 5281 //---判断商品是否超出限购---
5248 5282 if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) {
5249 5283 if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.sele_g.goods_id) > th.data.sele_g.viplimited) {
  5284 +
  5285 + wx.hideLoading();
5250 5286 wx.showToast({
5251 5287 title: '超出商品限购',
5252 5288 icon: 'none',
... ... @@ -5264,6 +5300,7 @@ Page({
5264 5300 //---判断商品是否超出活动限购,拼团的普通购买不计算活动的限购---
5265 5301 if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0 && th.data.is_normal != 1) {
5266 5302 if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) {
  5303 + wx.hideLoading();
5267 5304 wx.showToast({
5268 5305 title: '超出商品活动限购',
5269 5306 icon: 'none',
... ... @@ -5283,6 +5320,7 @@ Page({
5283 5320 if (th.data.is_normal != 1) {
5284 5321  
5285 5322 if (o.store_count <= 0) {
  5323 + wx.hideLoading();
5286 5324 wx.showToast({
5287 5325 title: '库存已为空!',
5288 5326 icon: 'none',
... ... @@ -5298,6 +5336,7 @@ Page({
5298 5336 })
5299 5337  
5300 5338 if (th.data.goodsInputNum > redis_num) {
  5339 + wx.hideLoading();
5301 5340 wx.showToast({
5302 5341 title: '超出商品活动库存',
5303 5342 icon: 'none',
... ... @@ -5311,6 +5350,7 @@ Page({
5311 5350 }
5312 5351 } else {
5313 5352 if (o.store_count <= 0) {
  5353 + wx.hideLoading();
5314 5354 wx.showToast({
5315 5355 title: '库存已为空!',
5316 5356 icon: 'none',
... ... @@ -5321,6 +5361,7 @@ Page({
5321 5361 }
5322 5362  
5323 5363 if (th.data.goodsInputNum <= 0) {
  5364 + wx.hideLoading();
5324 5365 wx.showToast({
5325 5366 title: '商品数量不能为0',
5326 5367 icon: 'none',
... ... @@ -5330,9 +5371,7 @@ Page({
5330 5371 };
5331 5372 if (th.data.goodsInputNum > o.store_count) {
5332 5373  
5333   - // th.setData({
5334   - // goodsInputNum: o.store_count
5335   - // })
  5374 + wx.hideLoading();
5336 5375 wx.showToast({
5337 5376 title: '超出商品库存',
5338 5377 icon: 'none',
... ... @@ -5345,7 +5384,10 @@ Page({
5345 5384 th.setData({
5346 5385 sto_sele_name: ""
5347 5386 });
5348   - if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th);
  5387 + if (th.data.sto_sele_name == ""){
  5388 + wx.hideLoading();
  5389 + return s.my_warnning("请选择门店", 0, th);
  5390 + }
5349 5391 //--------------此时操作的数据------------
5350 5392 var newd = {
5351 5393 goods_id: o.goods_id,
... ...