|
@@ -242,7 +242,7 @@
|
|
|
|
|
|
|
|
},
|
|
},
|
|
|
getShopGoodsSpec(item) {
|
|
getShopGoodsSpec(item) {
|
|
|
- console.log(item, 'item');
|
|
|
|
|
|
|
+ console.log(item,this.cartData, 'item');
|
|
|
shopGoodsSpec({
|
|
shopGoodsSpec({
|
|
|
'goods_id': item.goods_id
|
|
'goods_id': item.goods_id
|
|
|
}).then(res => {
|
|
}).then(res => {
|
|
@@ -257,14 +257,19 @@
|
|
|
this.popData.spec_key = ''
|
|
this.popData.spec_key = ''
|
|
|
this.popData.num = 1
|
|
this.popData.num = 1
|
|
|
this.popData.spec_ids = []
|
|
this.popData.spec_ids = []
|
|
|
|
|
+ console.log(this.popData, '走if');
|
|
|
|
|
+ this.$forceUpdate()
|
|
|
} else {
|
|
} else {
|
|
|
- console.log('无');
|
|
|
|
|
|
|
+ console.log(this.popData,'无');
|
|
|
this.popData.num = 1;
|
|
this.popData.num = 1;
|
|
|
// this.popData.price = item.price
|
|
// this.popData.price = item.price
|
|
|
if (this.cartData.goods_list.length > 0) {
|
|
if (this.cartData.goods_list.length > 0) {
|
|
|
this.cartData.goods_list.forEach(item => {
|
|
this.cartData.goods_list.forEach(item => {
|
|
|
if (item.goods_spec_id === this.popData.spec_key) {
|
|
if (item.goods_spec_id === this.popData.spec_key) {
|
|
|
- this.popData.num = this.selectedSpecification.goods_number
|
|
|
|
|
|
|
+ // this.popData.num = this.selectedSpecification.goods_number
|
|
|
|
|
+ this.popData.num = this.popData.payNum
|
|
|
|
|
+ console.log(this.popData, '走else');
|
|
|
|
|
+ this.$forceUpdate()
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
@@ -465,14 +470,15 @@
|
|
|
this.isAjax = true
|
|
this.isAjax = true
|
|
|
if (type === 1) {
|
|
if (type === 1) {
|
|
|
// 减
|
|
// 减
|
|
|
- if (item.num > 0) {
|
|
|
|
|
- // --item.num;
|
|
|
|
|
- this.setSub(item, type);
|
|
|
|
|
|
|
+ --item.num;
|
|
|
|
|
+ if (item.num >= 0) {
|
|
|
|
|
+ this.addShoppingSave(item, item.num, type)
|
|
|
} else {
|
|
} else {
|
|
|
this.isAjax = false
|
|
this.isAjax = false
|
|
|
}
|
|
}
|
|
|
} else if (type === 2) {
|
|
} else if (type === 2) {
|
|
|
// 加
|
|
// 加
|
|
|
|
|
+ ++item.num;
|
|
|
if (item.is_infinite === 0 && item.num >= item.stock) {
|
|
if (item.is_infinite === 0 && item.num >= item.stock) {
|
|
|
tools.error('商品库存' + item.stock + '件')
|
|
tools.error('商品库存' + item.stock + '件')
|
|
|
this.isAjax = false
|
|
this.isAjax = false
|
|
@@ -480,7 +486,7 @@
|
|
|
tools.error('限购' + item.quota_num + '件')
|
|
tools.error('限购' + item.quota_num + '件')
|
|
|
this.isAjax = false
|
|
this.isAjax = false
|
|
|
} else {
|
|
} else {
|
|
|
- this.setSub(item, type);
|
|
|
|
|
|
|
+ this.addShoppingSave(item, item.num, type)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} else if (type === 3) {
|
|
} else if (type === 3) {
|
|
@@ -507,31 +513,32 @@
|
|
|
console.log('1', this.popData.goods_id, this.shop_id, this.popData.goodsItem.category_id, this.popData
|
|
console.log('1', this.popData.goods_id, this.shop_id, this.popData.goodsItem.category_id, this.popData
|
|
|
.spec_key, this.popData.num);
|
|
.spec_key, this.popData.num);
|
|
|
this.setShoppingSave()
|
|
this.setShoppingSave()
|
|
|
- // if (this.popData.goods_spec_id) {
|
|
|
|
|
- // if (this.popData.is_infinite === 0 && this.popData.payNum > this.popData.stock) {
|
|
|
|
|
- // tools.error('商品库存' + this.popData.stock + '件')
|
|
|
|
|
- // this.popData.num = this.popData.stock
|
|
|
|
|
- // } else if (this.popData.is_quota > 0 && this.popData.payNum > this.popData.quota_num) {
|
|
|
|
|
- // tools.error('限购' + this.popData.quota_num + '件')
|
|
|
|
|
- // this.popData.num = this.popData.quota_num
|
|
|
|
|
- // } else {
|
|
|
|
|
- // 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 ? 2 : 1
|
|
|
|
|
- // console.log('addType:' + addType)
|
|
|
|
|
- // 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)
|
|
|
|
|
- // }
|
|
|
|
|
- // }
|
|
|
|
|
- // } else {
|
|
|
|
|
- // console.log('无规格信息')
|
|
|
|
|
- // }
|
|
|
|
|
this.isAjax = false
|
|
this.isAjax = false
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
+ addShoppingSave(item, num, type) {
|
|
|
|
|
+ shoppingSave({
|
|
|
|
|
+ type: 1,
|
|
|
|
|
+ goods_id: item.goods_id,
|
|
|
|
|
+ shop_id: this.shop_id,
|
|
|
|
|
+ category_id: item.category_id,
|
|
|
|
|
+ goods_spec_id: '',
|
|
|
|
|
+ number: num
|
|
|
|
|
+ }).then((res) => {
|
|
|
|
|
+ if (res.code === 1) {
|
|
|
|
|
+ if (type === 1) {
|
|
|
|
|
+ tools.success('操作成功')
|
|
|
|
|
+ } else {
|
|
|
|
|
+ tools.success(res.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+ this.isAjax = false
|
|
|
|
|
+ this.getShopIngList()
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.isAjax = false
|
|
|
|
|
+ tools.error(res.msg)
|
|
|
|
|
+ }
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
gbPop() {
|
|
gbPop() {
|
|
|
this.$refs.popupGG.close();
|
|
this.$refs.popupGG.close();
|
|
|
},
|
|
},
|
|
@@ -652,7 +659,8 @@
|
|
|
if (oldKey >= 0) {
|
|
if (oldKey >= 0) {
|
|
|
this.popData.spec_ids.splice(oldKey, 1)
|
|
this.popData.spec_ids.splice(oldKey, 1)
|
|
|
this.popData.spec_name.splice(oldKey, 1)
|
|
this.popData.spec_name.splice(oldKey, 1)
|
|
|
- this.popData.price = Number(this.popData.price) - Number(this.popData.spec_attr[groupKey].spec_list[attrKey].spec_price)
|
|
|
|
|
|
|
+ this.popData.price = Number(this.popData.price) - Number(this.popData.spec_attr[groupKey]
|
|
|
|
|
+ .spec_list[attrKey].spec_price)
|
|
|
// if ( Number(info.spec_price) > 0 ) {
|
|
// if ( Number(info.spec_price) > 0 ) {
|
|
|
// this.popData.price = Number(this.popData.price) - Number(this.popData.spec_attr[groupKey].spec_list[attrKey].spec_price)
|
|
// this.popData.price = Number(this.popData.price) - Number(this.popData.spec_attr[groupKey].spec_list[attrKey].spec_price)
|
|
|
// }
|
|
// }
|