瀏覽代碼

no message

USER-20230908AJ\Administrator 2 年之前
父節點
當前提交
c77a619411
共有 1 個文件被更改,包括 10 次插入 和 4 次删除
  1. 10 4
      pages-takeout/shop-mod/menu.vue

+ 10 - 4
pages-takeout/shop-mod/menu.vue

@@ -348,7 +348,7 @@
 				if (type === 1) {
 					// 减
 					if (item.num > 0) {
-						--item.num;
+						// --item.num;
 						this.setSub(item, type);
 					} else {
 						this.isAjax = false
@@ -356,7 +356,7 @@
 				} else if (type === 2) {
 					// 加
 					if (item.is_infinite === 1 || item.stock > item.num) {
-						++item.num;
+            // ++item.num;
 						this.setSub(item, type);
 					} else {
 						this.isAjax = false
@@ -386,12 +386,12 @@
 			setSub(item, type) {
 				let cartKey = this.cartData.goods_list.findIndex(row => row.goods_id === item.goods_id)
 				if (type === 2 && cartKey < 0) {
-					this.setShopIngAdd(item.goods_id, item.category_id, '', 1)
+					this.setShopIngAdd(item.goods_id, item.category_id, '', 1,item)
 				} else {
 					this.setShopIngNumber(item.goods_id, item.category_id, type, '', 1)
 				}
 			},
-			setShopIngAdd(goodsId, categoryId, goodsSpecId, number) {
+			setShopIngAdd(goodsId, categoryId, goodsSpecId, number,item) {
 				setShopIngAdd({
 					'type': 1,
 					'goods_id': goodsId,
@@ -401,6 +401,9 @@
 					'number': number,
 				}).then(res => {
 					this.isAjax = false
+          if(item){
+            ++item.num;
+          }
 					this.getShopIngList()
 				}).catch(() => {
 					this.isAjax = false
@@ -416,6 +419,9 @@
 					'number': number,
 					'operation': operation === 2 ? 1 : 2,
 				}).then(res => {
+          if(item){
+            --item.num;
+          }
 					this.isAjax = false
 					this.getShopIngList()
 				}).catch(() => {