|
|
@@ -288,26 +288,25 @@
|
|
|
})
|
|
|
},
|
|
|
setGoodsNum() {
|
|
|
+
|
|
|
if (this.cartData.goods_list.length > 0) {
|
|
|
- let goodsIds = []
|
|
|
- this.cartData.goods_list.forEach(item => {
|
|
|
- this.categoryData.forEach(categoryItem => {
|
|
|
- if (categoryItem.type === item.category_id) {
|
|
|
- categoryItem.list.forEach(goodsItem => {
|
|
|
- console.log(item.goods_id, goodsItem.goods_id)
|
|
|
- if (item.goods_id === goodsItem.goods_id) {
|
|
|
- if (goodsIds.indexOf(item.goods_id) < 0) {
|
|
|
- goodsIds.push(item.goods_id)
|
|
|
- goodsItem.num = item.goods_number * 1
|
|
|
- } else {
|
|
|
- goodsItem.num += item.goods_number * 1
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
+ let goodsIds = []
|
|
|
+ this.categoryData.forEach(categoryItem => {
|
|
|
+ categoryItem.list.forEach(goodsItem => {
|
|
|
+ goodsItem.num =0
|
|
|
+ this.cartData.goods_list.forEach(item => {
|
|
|
+ if (item.goods_id === goodsItem.goods_id){
|
|
|
+ if (goodsIds.indexOf(item.goods_id) < 0) {
|
|
|
+ goodsIds.push(item.goods_id)
|
|
|
+ goodsItem.num = item.goods_number * 1
|
|
|
+ } else {
|
|
|
+ goodsItem.num += item.goods_number * 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
|
|
|
- })
|
|
|
- })
|
|
|
} else {
|
|
|
//购物车数据清除
|
|
|
this.categoryData.forEach(categoryItem => {
|