feat : 合并代码
This commit is contained in:
commit
1d6831a76e
@ -6,4 +6,5 @@ export const apiArr = {
|
||||
getCarCount:"/api/v2/wechat/commodity/cart/all_count",//购物车数量
|
||||
addCar:"/api/v2/wechat/commodity/cart/add",//添加购物车
|
||||
deleteCar:"/api/v2/wechat/commodity/cart/delete",//删除购物车
|
||||
updateCar:"/api/v2/wechat/commodity/cart/update",
|
||||
}
|
||||
@ -27,6 +27,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 规格 -->
|
||||
<!-- @click="changeGG2(item, index)" :class="index == currentGGIndex ? 'active' : ''"> -->
|
||||
<div class="GGBox">
|
||||
<div class="GG_left">
|
||||
<div class="GG_Item" v-for="(item, index) in info.commodity_goods_info_list" :key="item.id"
|
||||
@ -63,6 +64,8 @@
|
||||
<image v-for="item in currentGG.goods_detail_pic" :src="picUrl + item" mode="widthFix"></image>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- 底部购物车 -->
|
||||
<div class="Car">
|
||||
<div class="car_left">
|
||||
@ -80,18 +83,21 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="car_right" v-if="!info[currentGGIndex].cart_count || info[currentGGIndex].cart_count.count == 0"
|
||||
<div class="car_right"
|
||||
v-if="!info.commodity_goods_info_list[currentGGIndex].cart_count || info.commodity_goods_info_list[currentGGIndex].cart_count.count == 0"
|
||||
@click="addCar">
|
||||
加入购物车
|
||||
</div>
|
||||
|
||||
<div class="car_right" v-if="info[currentGGIndex].cart_count.count > 0">
|
||||
<u-number-box v-model="info[currentGGIndex].cart_count.count" @change="changeCar">
|
||||
<div class="car_right" v-if="info.commodity_goods_info_list[currentGGIndex].cart_count.count > 0">
|
||||
|
||||
<u-number-box v-model="info.commodity_goods_info_list[currentGGIndex].cart_count.count"
|
||||
@change="changeCar" min="0">
|
||||
<view slot="minus" class="minus">
|
||||
<u-icon name="minus" size="36" bold></u-icon>
|
||||
</view>
|
||||
<text slot="input" style="width: 200rpx;text-align: center;" class="input">{{
|
||||
info[currentGGIndex].cart_count.count }}</text>
|
||||
<text slot="input" style="width: 200rpx;text-align: center;" class="input">
|
||||
{{ info.commodity_goods_info_list[currentGGIndex].cart_count.count }}</text>
|
||||
<view slot="plus" class="plus">
|
||||
<u-icon name="plus" color="#FFFFFF" size="36" bold></u-icon>
|
||||
</view>
|
||||
@ -143,7 +149,6 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { info } from 'sass';
|
||||
import {
|
||||
apiArr
|
||||
} from '../../../api/shop';
|
||||
@ -171,6 +176,8 @@ export default {
|
||||
|
||||
currentGG: "", //当前选中规格
|
||||
currentGGIndex: "", //当前规格index
|
||||
|
||||
carOrderList: [],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -266,6 +273,7 @@ export default {
|
||||
item.commodity_pic = item.commodity_pic.split(',')
|
||||
});
|
||||
this.currentGG = res.commodity_goods_info_list[0]
|
||||
this.currentGGIndex = 0
|
||||
})
|
||||
},
|
||||
|
||||
@ -282,10 +290,22 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
// changeGG2(item, index) {
|
||||
|
||||
// request(apiArr.addCar,"POST",{
|
||||
// goods_id:item.id,
|
||||
// count:1
|
||||
// })
|
||||
// },
|
||||
|
||||
changeGG(item, index) {
|
||||
this.currentGG = item
|
||||
this.currentGGIndex = index
|
||||
if (this.currentGG.cart_count) {
|
||||
this.currentNum = this.currentGG.cart_count.count
|
||||
} else {
|
||||
this.currentGG.cart_count = { count: 0 }
|
||||
}
|
||||
},
|
||||
car() {
|
||||
NavgateTo('../shopCar/index')
|
||||
@ -299,14 +319,37 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
//离开页面的时候 判断添加了多少 删除了多少商品
|
||||
getShopCarList() {
|
||||
request(apiArr.getCar, 'POST', {}).then(res => {
|
||||
this.carOrderList = res.commodity_cart_list
|
||||
})
|
||||
},
|
||||
|
||||
addCar() {
|
||||
this.info.commodity_goods_info_list[this.currentGGIndex].cart_count.count = 1
|
||||
console.log(this.info);
|
||||
|
||||
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
|
||||
},
|
||||
|
||||
changeCar(newValue) {
|
||||
this.info.commodity_goods_info_list[this.currentGGIndex].cart_count.count = newValue.value
|
||||
let carNum = 0
|
||||
this.info.commodity_goods_info_list.forEach(item => {
|
||||
if (item.cart_count) {
|
||||
carNum += item.cart_count.count
|
||||
}
|
||||
})
|
||||
this.carNum = carNum
|
||||
},
|
||||
|
||||
|
||||
},
|
||||
onLoad(options) {
|
||||
const meun = menuButtonInfo();
|
||||
@ -316,30 +359,27 @@ export default {
|
||||
this.id = options.id
|
||||
this.getGoodsInfo()
|
||||
this.getShopCar()
|
||||
this.getShopCarList()
|
||||
},
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
onHide() {
|
||||
|
||||
let goods_id_and_count = []
|
||||
this.info.commodity_goods_info_list.forEach(item => {
|
||||
goods_id_and_count.push({
|
||||
goods_id: item.id,
|
||||
count: item.cart_count.count
|
||||
})
|
||||
})
|
||||
|
||||
request(apiArr.updateCar, "POST", {
|
||||
goods_id_and_count
|
||||
})
|
||||
return
|
||||
},
|
||||
// watch() {
|
||||
// return {
|
||||
// 'info.commodity_goods_info_list': {
|
||||
// handler(newList) {
|
||||
// // 计算购物车总数
|
||||
// this.carNum = newList.reduce((total, item) => {
|
||||
// if (item.cart_count && item.cart_count.count) {
|
||||
// return total + item.cart_count.count;
|
||||
// }
|
||||
// return total;
|
||||
// }, 0);
|
||||
// },
|
||||
// deep: true,
|
||||
// immediate: true
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -538,7 +538,7 @@ page {
|
||||
height: 140rpx;
|
||||
position: fixed;
|
||||
right: 33rpx;
|
||||
bottom: 380rpx;
|
||||
bottom: 180rpx;
|
||||
z-index: 10;
|
||||
}
|
||||
.shop_car image{
|
||||
|
||||
@ -191,7 +191,7 @@
|
||||
<nav-footer :current="2" />
|
||||
|
||||
<div class="shop_car" @click="shopCar">
|
||||
<u-badge numberType="limit" type="error" max="99" :value="value"></u-badge>
|
||||
<u-badge numberType="limit" type="error" max="99" :value="carNum"></u-badge>
|
||||
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/shop_car_num.png"></image>
|
||||
<!-- <image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/shop_car_empty.png"></image> -->
|
||||
</div>
|
||||
@ -277,7 +277,8 @@ export default {
|
||||
rightCateList:[], //底部右侧分类
|
||||
currentThirdId:"",
|
||||
|
||||
tagList:[]
|
||||
tagList:[],
|
||||
carNum:"",
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -336,6 +337,13 @@ export default {
|
||||
})
|
||||
},
|
||||
|
||||
getShopCarList(){
|
||||
request(apiArr.getCar,"POST",).then(res=>{
|
||||
console.log(res);
|
||||
this.carNum = res.total
|
||||
})
|
||||
},
|
||||
|
||||
changeLeftCate(e){
|
||||
this.secondId = e
|
||||
this.getGoodsList()
|
||||
@ -347,6 +355,7 @@ export default {
|
||||
this.top = meun.top;
|
||||
this.localHeight = meun.height;
|
||||
this.getCateList()
|
||||
this.getShopCarList()
|
||||
},
|
||||
onReachBottom() {
|
||||
if (this.flag) {
|
||||
|
||||
@ -13,28 +13,28 @@
|
||||
</div>
|
||||
|
||||
<div class="main">
|
||||
<div class="deleteIcon">
|
||||
<div class="deleteIcon" @click="deleteItem">
|
||||
<u-icon name="trash" size="50rpx"></u-icon>
|
||||
</div>
|
||||
|
||||
<div class="goodsList">
|
||||
<div class="goodsItem" v-for="item, index in shopCarList" :key="item.id">
|
||||
<div class="goodsItem_left" @click="changeChecked(item,index)">
|
||||
<div class="goodsItem_left" @click="changeChecked(item, index)">
|
||||
<image v-if="!item.checked" src="http://192.168.0.172:5500/7.15/shop_checked1.png"></image>
|
||||
<image v-if="item.checked" src="http://192.168.0.172:5500/7.15/shop_checked2.png"></image>
|
||||
</div>
|
||||
<div class="goodsItem_right">
|
||||
<div class="goodsItem_msg">
|
||||
<div class="goodsItem_msg_img">
|
||||
<image :src="picUrl + item.commodity_pic">
|
||||
<image :src="picUrl + item.commodity_goods_info.commodity_pic">
|
||||
</image>
|
||||
</div>
|
||||
<div class="goodsItem_msg_right">
|
||||
<div class="goodsItem_msg_right_tit">{{ item.goods_name }}</div>
|
||||
<div class="goodsItem_msg_right_subTit">{{ item.goods_intro }}</div>
|
||||
<div class="goodsItem_msg_right_tit">{{ item.commodity_goods_info.goods_name }}</div>
|
||||
<div class="goodsItem_msg_right_subTit">{{ item.commodity_goods_info.goods_intro }}</div>
|
||||
<div class="goodsItem_msg_right_msg">
|
||||
<div class="goodsItem_msg_right_msg_left">
|
||||
<span>¥</span>{{ item.sales_price }} <span>/{{ item.goods_unit }}</span>
|
||||
<span>¥</span>{{ item.commodity_goods_info.sales_price }} <span>/{{ item.commodity_goods_info.goods_unit }}</span>
|
||||
</div>
|
||||
<div class="goodsItem_msg_right_msg_right">
|
||||
<u-number-box v-model="item.count">
|
||||
@ -114,6 +114,9 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
back() {
|
||||
NavgateTo("1")
|
||||
},
|
||||
submitOrder() {
|
||||
NavgateTo("../submitOrder/index")
|
||||
},
|
||||
@ -156,11 +159,40 @@ export default {
|
||||
let total = 0
|
||||
this.shopCarList.forEach(item => {
|
||||
if (item.checked) {
|
||||
total += item.sales_price * item.count
|
||||
total += item.commodity_goods_info.sales_price * item.count
|
||||
}
|
||||
});
|
||||
this.shopMoney = total
|
||||
},
|
||||
|
||||
deleteItem() {
|
||||
let that = this
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定删除所选商品吗',
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
let ids = []
|
||||
that.shopCarList.forEach(item => {
|
||||
if(item.checked){
|
||||
ids.push(item.id)
|
||||
}
|
||||
})
|
||||
request(apiArr.deleteCar, "POST", {
|
||||
ids
|
||||
}).then(res=>{
|
||||
uni.showToast({
|
||||
title: '删除成功',
|
||||
duration: 2000
|
||||
});
|
||||
that.getShopCar()
|
||||
})
|
||||
} else if (res.cancel) {
|
||||
console.log('用户点击取消');
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
onLoad(options) {
|
||||
const meun = menuButtonInfo();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user