USER-20230908AJ\Administrator před 2 roky
rodič
revize
37738f2d20
1 změnil soubory, kde provedl 24 přidání a 8 odebrání
  1. 24 8
      pages-takeout/shop-mod/menu.vue

+ 24 - 8
pages-takeout/shop-mod/menu.vue

@@ -385,7 +385,7 @@
 			},
 			setSub(item, type) {
 				let cartKey = this.cartData.goods_list.findIndex(row => row.goods_id === item.goods_id)
-				if (type === 2 ) {
+				if (type === 2  && cartKey<0) {
 					this.setShopIngAdd(item.goods_id, item.category_id, '', 1,item)
 				} else {
 					this.setShopIngNumber(item.goods_id, item.category_id, type, '', 1,item)
@@ -401,10 +401,15 @@
 					'number': number,
 				}).then(res => {
 					this.isAjax = false
-          if(item){
-            ++item.num;
+          if(res.code===1){
+            if(item){
+              ++item.num;
+            }
+            this.getShopIngList()
+          }else {
+            tools.error(res.msg)
           }
-					this.getShopIngList()
+
 				}).catch(() => {
 					this.isAjax = false
 				})
@@ -419,11 +424,22 @@
 					'number': number,
 					'operation': operation === 2 ? 1 : 2,
 				}).then(res => {
-          if(item){
-            --item.num;
+          this.isAjax = false
+          if(res.code===1){
+            if(item){
+              if(operation===2){
+                ++item.num;
+              }else {
+                --item.num;
+              }
+
+            }
+
+            this.getShopIngList()
+          }else {
+            tools.error(res.msg)
           }
-					this.isAjax = false
-					this.getShopIngList()
+
 				}).catch(() => {
 					this.isAjax = false
 				})