From-wh 3 лет назад
Родитель
Сommit
9ba5b5332f
1 измененных файлов с 5 добавлено и 4 удалено
  1. 5 4
      template/uni-app/pages/order_addcart/order_addcart.vue

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