Commit 8536745351d1111843d55ab1ee7623fb706faf5b
1 parent
ceabe523
购物车页当购买数量超出限购数量时出现toast提示,并修改商品数量为当前可购买数量
Showing
2 changed files
with
15 additions
and
7 deletions
pages/cart/cart/cart.js
@@ -1013,7 +1013,7 @@ Page({ | @@ -1013,7 +1013,7 @@ Page({ | ||
1013 | console.log('add+'); | 1013 | console.log('add+'); |
1014 | if (a.goods_num < a.store_count) { | 1014 | if (a.goods_num < a.store_count) { |
1015 | var e = { | 1015 | var e = { |
1016 | - goods_num: a.goods_num + 1, | 1016 | + goods_num: a.goods_num + 1, |
1017 | id: a.id, | 1017 | id: a.id, |
1018 | goods_id: a.goods_id, | 1018 | goods_id: a.goods_id, |
1019 | store_id: oo.stoid | 1019 | store_id: oo.stoid |
@@ -1744,16 +1744,24 @@ Page({ | @@ -1744,16 +1744,24 @@ Page({ | ||
1744 | 1744 | ||
1745 | }) | 1745 | }) |
1746 | 1746 | ||
1747 | - | ||
1748 | - var buyed_mum2 = t.goods_num + goodsbuynum; | ||
1749 | - if (buyed_mum2 > limit && limit > 0) { | 1747 | + //--> by ty |
1748 | + // var buyed_mum2 = t.goods_num + goodsbuynum; | ||
1749 | + var buyed_mum2 = t.goods_num; | ||
1750 | + //<-- | ||
1751 | + | ||
1752 | + // 判断当前预购买的数量是否超过可购买的数量 | ||
1753 | + if (buyed_mum2 > (limit - goodsbuynum) && limit > 0) { | ||
1750 | wx.showToast({ | 1754 | wx.showToast({ |
1751 | title: '购买数量超出商品限购', | 1755 | title: '购买数量超出商品限购', |
1752 | icon: 'none', | 1756 | icon: 'none', |
1753 | - // content: '购买数量超出商品限购' | ||
1754 | }); | 1757 | }); |
1755 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; | 1758 | var txt = "requestData[" + pitem + "].goods[" + item + "].goods_num"; |
1756 | - var cbuy = limit - buyed_mum2; | 1759 | + |
1760 | + //--> by ty | ||
1761 | + var cbuy = limit - goodsbuynum; | ||
1762 | + // var cbuy = limit - buyed_mum2 + 1; | ||
1763 | + //<-- | ||
1764 | + | ||
1757 | e.setData({ | 1765 | e.setData({ |
1758 | // [txt]: cbuy > 0 ? cbuy : 0, | 1766 | // [txt]: cbuy > 0 ? cbuy : 0, |
1759 | [txt]: cbuy > 0 ? cbuy : limit, | 1767 | [txt]: cbuy > 0 ? cbuy : limit, |
pages/cart/cart/cart.wxss
@@ -131,7 +131,7 @@ radio { | @@ -131,7 +131,7 @@ radio { | ||
131 | 131 | ||
132 | .sub, .add, .count>input { | 132 | .sub, .add, .count>input { |
133 | /* border-right: 1px solid #000; */ | 133 | /* border-right: 1px solid #000; */ |
134 | - background-color: #f8f8f8; | 134 | + background-color: #f0f0f0; |
135 | border-radius: 8rpx; | 135 | border-radius: 8rpx; |
136 | } | 136 | } |
137 | .sub.active { | 137 | .sub.active { |