feat : 合并代码

This commit is contained in:
赵毅 2025-07-18 10:48:02 +08:00
commit 15d42c2df1
5 changed files with 192 additions and 43 deletions

View File

@ -6,5 +6,6 @@ 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",//更新购物车
updateCar:"/api/v2/wechat/commodity/cart/update",//更新购物车信息
getUserDefAddress:"/api/v2/wechat/commodity/receiving_address/get_default",//获取用户默认地址
}

View File

@ -327,25 +327,67 @@ export default {
},
addCar() {
console.log(this.info);
this.info.commodity_goods_info_list[this.currentGGIndex].cart_count = {count:1}
let carNum = 0
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 => {
carNum += item.cart_count.count
console.log(item);
goods_id_and_count.push({
goods_id: item.id,
count: item.cart_count.count
})
})
this.carNum = carNum
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
let carNum = 0
this.info.commodity_goods_info_list.forEach(item => {
if (item.cart_count) {
carNum += item.cart_count.count
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
},
@ -357,12 +399,15 @@ export default {
this.localHeight = meun.height;
this.id = options.id
this.getGoodsInfo()
this.getShopCar()
this.getShopCarList()
},
onReachBottom() {
},
onShow() {
this.getGoodsInfo()
this.getShopCar()
this.getShopCarList()
},
onHide() {

View File

@ -31,19 +31,21 @@
</div>
<div class="goodsItem_msg_right">
<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_subTit">{{ item.commodity_goods_info.goods_intro }}
</div>
<div class="goodsItem_msg_right_msg">
<div class="goodsItem_msg_right_msg_left">
<span></span>{{ item.commodity_goods_info.sales_price }} <span>/{{ item.commodity_goods_info.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">
<view slot="minus" class="minus">
<u-number-box v-model="item.count" :asyncChange="true" min="0">
<view slot="minus" class="minus" @click="minus(item, index)">
<u-icon name="minus" size="32" bold></u-icon>
</view>
<text slot="input" style="width: 80rpx;text-align: center;" class="input">{{
item.count }}</text>
<view slot="plus" class="plus">
<view slot="plus" class="plus" @click="add(item, index)">
<u-icon name="plus" color="#FFFFFF" size="32" bold></u-icon>
</view>
</u-number-box>
@ -118,7 +120,15 @@ export default {
NavgateTo("1")
},
submitOrder() {
NavgateTo("../submitOrder/index")
let arr = []
this.shopCarList.forEach(item => {
if (item.checked) {
arr.push(item)
}
})
NavgateTo(`../submitOrder/index?shopCarList=${JSON.stringify(arr)}`)
},
getShopCar() {
@ -126,7 +136,6 @@ export default {
res.commodity_cart_list.forEach(item => {
item.checked = false
});
console.log(res.commodity_cart_list);
this.shopCarTotal = res.total
this.shopCarList = res.commodity_cart_list
})
@ -156,8 +165,11 @@ export default {
},
//
calcTotal() {
let total = 0
this.shopCarList.forEach(item => {
console.log(item);
if (item.checked) {
total += item.commodity_goods_info.sales_price * item.count
}
@ -165,6 +177,25 @@ export default {
this.shopMoney = total
},
minus(item, index) {
let that = this
if (item.count === 1) {
request(apiArr.deleteCar, "POST", {
ids: [item.id]
}).then(res => {
that.shopCarList.splice(index, 1)
that.calcTotal()
})
}
this.shopCarList[index].count = this.shopCarList[index].count - 1
this.calcTotal()
},
add(item, index) {
this.shopCarList[index].count = this.shopCarList[index].count + 1
this.calcTotal()
},
deleteItem() {
let that = this
uni.showModal({
@ -174,18 +205,22 @@ export default {
if (res.confirm) {
let ids = []
that.shopCarList.forEach(item => {
if(item.checked){
if (item.checked) {
ids.push(item.id)
item.checked = false
}
})
request(apiArr.deleteCar, "POST", {
ids
}).then(res=>{
}).then(res => {
uni.showToast({
title: '删除成功',
duration: 2000
});
that.getShopCar()
that.calcTotal()
}).catch(err => {
console.log(err);
})
} else if (res.cancel) {
console.log('用户点击取消');

View File

@ -177,3 +177,23 @@
align-items: center;
justify-content: center;
}
.address_Info_btn {
background: linear-gradient(91deg, #FF7658 0%, #FF370B 100%);
border-radius: 100rpx 100rpx 100rpx 100rpx;
height: 90rpx;
width: 600rpx;
font-size: 36rpx;
color: #FFFFFF;
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto;
}
.noneDef{
display: flex;
align-items: center;
justify-content: center;
width: 100%;
}

View File

@ -4,42 +4,49 @@
<div class="border">
<image src="http://192.168.0.172:5500/7.15/shop_border.png" mode="widthFix"></image>
</div>
<div class="address_Info" @click="choseAddress">
<div class="address_Info" @click="choseAddress" v-if="defAddress">
<div class="address_Info_left">
<div class="address_Info_left_tit">收货地址</div>
<div class="address_Info_left_name">李佳 15901518415</div>
<div class="address_Info_left_addr">北京北京市朝阳区珠江绿洲文化广场</div>
</div>
<div class="address_Info_right">
<u-icon name="arrow-right" size="40rpx"></u-icon>
</div>
</div>
<div class="address_Info" @click="choseAddress" v-if="!defAddress">
<div class="address_Info_left noneDef">
<div class="address_Info_btn">添加收货地址</div>
</div>
</div>
<div class="border">
<image src="http://192.168.0.172:5500/7.15/shop_border.png" mode="widthFix"></image>
</div>
</div>
<div class="goodsCate" v-for="items, indexs in 2" :key="indexs">
<div class="goodsItem" v-for="item, index in 3" :key="index">
<div class="goodsCate" v-for="items, indexs in carList" :key="indexs">
<div class="goodsItem">
<div class="goodsItem_msg_img">
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_MsgImg1.png">
<image :src="picUrl + items.commodity_goods_info.commodity_pic">
</image>
</div>
<div class="goodsItem_msg_right">
<div class="goodsItem_msg_right_tit">泰国金枕榴莲</div>
<div class="goodsItem_msg_right_subTit">商品介绍商品介绍</div>
<div class="goodsItem_msg_right_tit">{{ items.commodity_goods_info.goods_name }}</div>
<div class="goodsItem_msg_right_subTit">{{ items.commodity_goods_info.goods_intro }}</div>
<div class="goodsItem_msg_right_msg">
<div class="goodsItem_msg_right_msg_left">
<span></span>125.9 <span>/</span>
<span></span>{{ items.commodity_goods_info.sales_price }}
<span>/{{ items.commodity_goods_info.goods_unit }}</span>
</div>
<div class="goodsItem_msg_right_msg_right">
<u-number-box v-model="value">
<view slot="minus" class="minus">
<view slot="minus" class="minus" @click="minus(items, indexs)">
<u-icon name="minus" size="32" bold></u-icon>
</view>
<text slot="input" style="width: 80rpx;text-align: center;" class="input">{{
value }}</text>
<view slot="plus" class="plus">
<text slot="input" style="width: 80rpx;text-align: center;" class="input">
{{ items.count }}
</text>
<view slot="plus" class="plus" @click="add(items, indexs)">
<u-icon name="plus" color="#FFFFFF" size="32" bold></u-icon>
</view>
</u-number-box>
@ -55,7 +62,7 @@
<div class="footer">
<div class="btn">立即支付4500.00</div>
<div class="btn">立即支付{{ totalMony }}</div>
</div>
</view>
@ -64,7 +71,7 @@
<script>
import {
apiArr
} from '../../../api/doorToDoor';
} from '../../../api/shop';
import {
picUrl,
menuButtonInfo,
@ -74,22 +81,63 @@ import {
export default {
data() {
return {
picUrl,
top: "",
localHeight: "",
value: 3,
type: "error",
carList: [],
totalMony: 0,
defAddress:{},
}
},
methods: {
choseAddress(){
choseAddress() {
NavgateTo('../address/index')
},
calcTotal() {
let total = 0
this.carList.forEach(item => {
total += item.commodity_goods_info.sales_price * item.count
})
this.totalMony = total
},
minus(item, index) {
let that = this
if (item.count === 1) {
request(apiArr.deleteCar, "POST", {
ids: [item.id]
}).then(res => {
that.carList.splice(index, 1)
that.calcTotal()
})
}
this.carList[index].count = this.carList[index].count - 1
this.calcTotal()
},
add(item, index) {
this.carList[index].count = this.carList[index].count + 1
this.calcTotal()
},
//
getUserAddress() {
request(apiArr.getUserDefAddress, "POST", {}).then(res => {
this.defAddress = res.default_address
})
},
},
onShow() {
this.getUserAddress()
},
onLoad(options) {
const meun = menuButtonInfo();
this.top = meun.top;
this.localHeight = meun.height;
this.carList = JSON.parse(options.shopCarList)
this.calcTotal()
},
onReachBottom() {