Parcourir la source

Merge branch 'master' of http://git.sjzkeji.com/panghu/school_webUser

# Conflicts:
#	pages-takeout/shop-mod/menu.vue
py il y a 2 ans
Parent
commit
4ef6cce5f6
1 fichiers modifiés avec 31 ajouts et 17 suppressions
  1. 31 17
      pages-takeout/shop-mod/menu.vue

+ 31 - 17
pages-takeout/shop-mod/menu.vue

@@ -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
@@ -385,13 +385,13 @@
 			},
 			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, item)
+				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)
+					this.setShopIngNumber(item.goods_id, item.category_id, type, '', 1,item)
 				}
 			},
-			setShopIngAdd(goodsId, categoryId, goodsSpecId, number, item) {
+			setShopIngAdd(goodsId, categoryId, goodsSpecId, number,item) {
 				setShopIngAdd({
 					'type': 1,
 					'goods_id': goodsId,
@@ -401,16 +401,20 @@
 					'number': number,
 				}).then(res => {
 					this.isAjax = false
-					if (item) {
-						++item.num;
-					}
-					this.getShopIngList()
-					this.$forceUpdate()
+          if(res.code===1){
+            if(item){
+              ++item.num;
+            }
+            this.getShopIngList()
+          }else {
+            tools.error(res.msg)
+          }
+
 				}).catch(() => {
 					this.isAjax = false
 				})
 			},
-			setShopIngNumber(goodsId, categoryId, operation, goodsSpecId, number) {
+			setShopIngNumber(goodsId, categoryId, operation, goodsSpecId, number,item) {
 				setShopIngNumber({
 					'type': 1,
 					'goods_id': goodsId,
@@ -420,12 +424,22 @@
 					'number': number,
 					'operation': operation === 2 ? 1 : 2,
 				}).then(res => {
-					if (item) {
-						--item.num;
-					}
-					this.isAjax = false
-					this.getShopIngList()
-					this.$forceUpdate()
+          this.isAjax = false
+          if(res.code===1){
+            if(item){
+              if(operation===2){
+                ++item.num;
+              }else {
+                --item.num;
+              }
+
+            }
+
+            this.getShopIngList()
+          }else {
+            tools.error(res.msg)
+          }
+
 				}).catch(() => {
 					this.isAjax = false
 				})