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(); });