From 9ba5b5332f5fd9a123794857141b842163fafe71 Mon Sep 17 00:00:00 2001 From: From-wh Date: Mon, 20 Feb 2023 12:22:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B4=AD=E7=89=A9=E8=BD=A6=E5=88=A0?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/uni-app/pages/order_addcart/order_addcart.vue | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/template/uni-app/pages/order_addcart/order_addcart.vue b/template/uni-app/pages/order_addcart/order_addcart.vue index 046e54633..bcbd84a81 100644 --- a/template/uni-app/pages/order_addcart/order_addcart.vue +++ b/template/uni-app/pages/order_addcart/order_addcart.vue @@ -706,18 +706,19 @@ addCart: function(index) { let that = this; let item = that.cartList.valid[index]; - item.cart_num = Number(item.cart_num) + 1; + let lastnum = Number(item.cart_num) + 1 let productInfo = item.productInfo; - if (productInfo.hasOwnProperty('attrInfo') && item.cart_num >= item.productInfo.attrInfo.stock) { - item.cart_num = item.productInfo.attrInfo.stock; + if (productInfo.hasOwnProperty('attrInfo') && lastnum >= item.productInfo.attrInfo.stock) { + lastnum = item.productInfo.attrInfo.stock; item.numAdd = true; item.numSub = false; } else { item.numAdd = false; item.numSub = false; } - that.setCartNum(item.id, item.cart_num, function(data) { + that.setCartNum(item.id, lastnum, (data) => { that.cartList.valid[index] = item; + item.cart_num = Number(item.cart_num) + 1; that.getCartNum(); that.switchSelect(); });