Răsfoiți Sursa

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

py 2 ani în urmă
părinte
comite
5047d732c2
1 a modificat fișierele cu 19 adăugiri și 18 ștergeri
  1. 19 18
      pages-takeout/shop-mod/menu.vue

+ 19 - 18
pages-takeout/shop-mod/menu.vue

@@ -168,7 +168,6 @@
 		},
 		methods: {
 			setSpecNum(type) {
-				console.log(this.popData.goods_spec_id)
 				if (!this.popData.goods_spec_id) {
 					tools.error('请选择规格')
 					return;
@@ -183,22 +182,12 @@
 						--this.popData.num;
 					} else {
 						this.isAjax = false
-						return
 					}
 				} else {
 					// 加
 					++this.popData.num;
 				}
-				let cartKey = this.cartData.goods_list.findIndex(row => this.popData.goods_spec_id === row.goods_spec_id)
-				console.log(cartKey)
-				console.log(type === 2 && cartKey < 0)
-				if (type === 2 && cartKey < 0) {
-					this.setShopIngAdd(this.popData.goods_id, this.popData.goodsItem.category_id, this.popData
-						.goods_spec_id)
-				} else {
-					this.setShopIngNumber(this.popData.goods_id, this.popData.goodsItem.category_id, type, this.popData
-						.goods_spec_id)
-				}
+
 			},
 			getShopGoodsSpec(item) {
 				shopGoodsSpec({
@@ -211,10 +200,10 @@
 						this.popData.price = '0.00'
 						this.popData.line_price = ''
 						this.popData.spec_key = ''
-						this.popData.num = 0
+						this.popData.num = 1
 						this.popData.spec_ids = []
 					}else {
-            this.popData.num =0;
+            this.popData.num =1;
             if(this.cartData.goods_list.length>0){
               this.cartData.goods_list.forEach(item=>{
                 if(item.spec_sku_id===this.popData.spec_key){
@@ -364,23 +353,34 @@
 				} else {
 					this.$refs.popupGG.close();
 					this.isAjax = false
+          let cartKey = this.cartData.goods_list.findIndex(row => this.popData.goods_spec_id === row.goods_spec_id)
+          console.log(cartKey)
+          let addType=this.popData.num>0?1:2
+          if (addType === 2 && cartKey < 0) {
+            this.setShopIngAdd(this.popData.goods_id, this.popData.goodsItem.category_id, this.popData
+                .goods_spec_id,this.popData.num)
+          } else {
+            this.setShopIngNumber(this.popData.goods_id, this.popData.goodsItem.category_id, type, this.popData
+                .goods_spec_id,this.popData.num)
+          }
 				}
 			},
 			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, '')
+					this.setShopIngAdd(item.goods_id, item.category_id, '',1)
 				} else {
-					this.setShopIngNumber(item.goods_id, item.category_id, type, '')
+					this.setShopIngNumber(item.goods_id, item.category_id, type, '',1)
 				}
 			},
-			setShopIngAdd(goodsId, categoryId, goodsSpecId) {
+			setShopIngAdd(goodsId, categoryId, goodsSpecId,number) {
 				setShopIngAdd({
 					'type': 1,
 					'goods_id': goodsId,
 					'shop_id': this.shop_id,
 					'category_id': categoryId,
 					'goods_spec_id': goodsSpecId,
+					'number': number,
 				}).then(res => {
 					this.isAjax = false
 					this.getShopIngList()
@@ -388,13 +388,14 @@
 					this.isAjax = false
 				})
 			},
-			setShopIngNumber(goodsId, categoryId, operation, goodsSpecId) {
+			setShopIngNumber(goodsId, categoryId, operation, goodsSpecId,number) {
 				setShopIngNumber({
 					'type': 1,
 					'goods_id': goodsId,
 					'shop_id': this.shop_id,
 					'category_id': categoryId,
 					'goods_spec_id': goodsSpecId,
+					'number': number,
 					'operation': operation === 2 ? 1 : 2,
 				}).then(res => {
 					this.isAjax = false