修改页面

This commit is contained in:
2025-08-11 14:06:42 +08:00
parent 462073058e
commit 9c0be00fbd
31 changed files with 1180 additions and 309 deletions

View File

@ -125,6 +125,10 @@
</view>
</view>
</view>
<view class="settle-btn">
<u-button @tap="goSettle" shape="circle" :hair-line="false" hover-class="none" :customStyle="{backgroundColor: themeColor, color: '#fff', border: 'none', padding: '36rpx'}">去结算</u-button>
</view>
</scroll-view>
</view>
<view class="u-text-center" style="height: 700rpx;line-height: 700rpx;" v-else>
@ -171,6 +175,7 @@
page:1,
status: loadingType.LOADING,
selectIndex: 0,
categoryId: 0,
cateList: [],
goodsList: [],
goods_spec: [],
@ -251,6 +256,21 @@
// 添加到购物车(默认商品数量+1,可以让后端连表查询商品数量字段)
async addCartFun(item) {
console.log("🚀 ~ addCartFun ~ item:", item)
// 限购逻辑
if (item.first_category_id === 1 || item.first_category_id === 2) {
// 统计购物车中同类商品的总数量
const totalNum = this.cartLists
.filter(i => i.first_category_id === item.first_category_id)
.reduce((sum, i) => sum + (i.goods_num || 0), 0);
if (totalNum >= 2) {
this.$toast({ title: '该类商品每人限购2件' });
return;
}
}
const {
code,
data,
@ -285,6 +305,7 @@
// 获取购物车列表数据
getCartListFun() {
// 获取商品的分类ID
getCartList().then((res) => {
if (res.code == 1) {
@ -307,7 +328,7 @@
// // this.cartType = cartType;
this.totalPrice = total_amount
// // this.isShow = true;
// this.getCartNum();
this.getCartNum();
}
});
},
@ -325,6 +346,8 @@
// 去结算
goSettle() {
console.log(this.cartLists)
this.showCart = false
const goods = this.cartLists.map(item => {
return {
item_id: item.item_id,
@ -334,12 +357,12 @@
uni.navigateTo({
url: "/pages/order_now/order_now?data=" +
encodeURIComponent(
JSON.stringify({
goods,
type: "cart",
})
),
encodeURIComponent(
JSON.stringify({
goods,
type: "cart",
})
),
});
},
@ -457,4 +480,7 @@
border-radius: 100%;
}
.settle-btn {
padding: 20rpx;
}
</style>