Merge branch 'qjl'
# Conflicts: # unpackage/dist/dev/mp-weixin/project.private.config.json
This commit is contained in:
commit
0a71636436
@ -267,6 +267,7 @@ export default {
|
||||
}).then(res => {
|
||||
console.log(res);
|
||||
this.info = res
|
||||
// 分割图片
|
||||
res.commodity_goods_info_list.forEach(item => {
|
||||
item.goods_detail_pic = item.goods_detail_pic.split(',')
|
||||
item.goods_carousel = item.goods_carousel.split(',')
|
||||
@ -290,14 +291,8 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
// changeGG2(item, index) {
|
||||
|
||||
// request(apiArr.addCar,"POST",{
|
||||
// goods_id:item.id,
|
||||
// count:1
|
||||
// })
|
||||
// },
|
||||
|
||||
// 切换规格
|
||||
changeGG(item, index) {
|
||||
this.currentGG = item
|
||||
this.currentGGIndex = index
|
||||
@ -319,7 +314,7 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
//离开页面的时候 判断添加了多少 删除了多少商品
|
||||
//离开页面的时候直接更新购物车数量(目前接口是 传入商品id 数量。如果有当前商品就更新数量。如果没有就增加商品)
|
||||
getShopCarList() {
|
||||
request(apiArr.getCar, 'POST', {}).then(res => {
|
||||
this.carOrderList = res.commodity_cart_list
|
||||
@ -327,67 +322,41 @@ export default {
|
||||
},
|
||||
|
||||
addCar() {
|
||||
|
||||
let that = this
|
||||
//如果没有当前商品 直接添加一个
|
||||
let goods_id_and_count = []
|
||||
this.info.commodity_goods_info_list[this.currentGGIndex].cart_count = { count: 1 }
|
||||
this.info.commodity_goods_info_list.forEach(item => {
|
||||
console.log(item);
|
||||
|
||||
goods_id_and_count.push({
|
||||
goods_id: item.id,
|
||||
count: item.cart_count.count
|
||||
count: 1
|
||||
})
|
||||
})
|
||||
|
||||
//因为是当前商品没有 调用update就是增加商品。增加商品之后再获取购物车数量
|
||||
request(apiArr.updateCar, "POST", {
|
||||
goods_id_and_count
|
||||
}).then(res => {
|
||||
that.getShopCar()
|
||||
that.getShopCarList()
|
||||
})
|
||||
// let flag = false
|
||||
// this.carOrderList.forEach(item => {
|
||||
// if (item.goods_id == this.info.commodity_goods_info_list[this.currentGGIndex].id) {
|
||||
// flag = true
|
||||
// }
|
||||
// })
|
||||
// console.log(flag);
|
||||
|
||||
// if (flag) {
|
||||
|
||||
// this.info.commodity_goods_info_list[this.currentGGIndex].cart_count = { count: 1 }
|
||||
// let carNum = 0
|
||||
// this.info.commodity_goods_info_list.forEach(item => {
|
||||
// carNum += item.cart_count.count
|
||||
// })
|
||||
// this.carNum = carNum
|
||||
// } else {
|
||||
|
||||
// }
|
||||
|
||||
},
|
||||
|
||||
// 购物车更改
|
||||
changeCar(newValue) {
|
||||
// 修改当前商品在购物车中的数量
|
||||
this.info.commodity_goods_info_list[this.currentGGIndex].cart_count.count = newValue.value
|
||||
|
||||
// 修改购物车列表中的数量
|
||||
this.carOrderList.forEach(item=>{
|
||||
if(item.commodity_goods_info.id == this.info.commodity_goods_info_list[this.currentGGIndex].id){
|
||||
console.log(item,'item');
|
||||
item.count = newValue.value
|
||||
}
|
||||
})
|
||||
// 计算购物车数量
|
||||
let carNum = 0
|
||||
this.carOrderList.forEach(item=>{
|
||||
carNum += item.count
|
||||
})
|
||||
// let carNum = 0
|
||||
// this.info.commodity_goods_info_list.forEach(item => {
|
||||
// if (item.cart_count) {
|
||||
// carNum += item.cart_count.count
|
||||
// }
|
||||
// })
|
||||
this.carNum = carNum
|
||||
},
|
||||
|
||||
|
||||
@ -8,15 +8,15 @@
|
||||
"miniprogram": {
|
||||
"list": [
|
||||
{
|
||||
"name": "packages/shop/address/index",
|
||||
"pathName": "packages/shop/address/index",
|
||||
"query": "",
|
||||
"name": "packages/shop/goods/index",
|
||||
"pathName": "packages/shop/goods/index",
|
||||
"query": "id=30",
|
||||
"scene": null,
|
||||
"launchMode": "default"
|
||||
},
|
||||
{
|
||||
"name": "packages/shop/addAddress/index",
|
||||
"pathName": "packages/shop/addAddress/index",
|
||||
"name": "packages/shop/shopCar/index",
|
||||
"pathName": "packages/shop/shopCar/index",
|
||||
"query": "",
|
||||
"launchMode": "default",
|
||||
"scene": null
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user