This commit is contained in:
2025-03-19 15:05:33 +08:00
parent a2bf3311f9
commit d1b9024fb1
9 changed files with 1721 additions and 1109 deletions

View File

@@ -5,20 +5,43 @@
<scroll-view scroll-y="true">
<view class="cartItem" v-for="(item,index) in cartList" :key="index">
<view class="select">
<checkbox :checked="item.checked" @click="checkboxGroupChange(index,item)"
<checkbox style="transform:scale(0.8)" :checked="item.checked" @click="checkboxGroupChange(index,item)"
class="round checkedItem" />
</view>
<view class="cartContent">
<view class="cartContent" style="position: relative;">
<span v-if="item.isVipPrice==1&&item.vipPrice!=0&&item.vipPrice!=null"
style="position: absolute;z-index: 10;top: 4px;left: 0px;margin-right: 10px;text-align: center;font-size: 18rpx;background-color: #f94f04;color: #fff;font-weight: bold;border-radius:4px;width: 80rpx; padding:2px 4px;box-sizing: border-box;">VIP优惠</span>
<image :src="item.image" mode="" @click="goDetail(item.productId)"></image>
<view class="itemCenter">
<view class="cartTitle" @click="goDetail(item.productId)">
<view class="cartTitle" @click="goDetail(item.productId)" style="display: flex;align-items: center;">
<text>{{item.productName}}</text>
</view>
<view class="itemPrice">
<text v-if="item.activityPrice && item.activityPrice > 0">{{item.activityPrice*item.productAmount}}</text>
<text v-else>{{item.price*item.productAmount}}</text>
<u-number-box v-model="item.productAmount" @change="valChange($event,item)" :input-width="50"
:input-height="20" :min="1" :max="item.productStock" integer @overlimit='overlimit'></u-number-box>
<text v-if="item.isVipPrice==1&&item.vipPrice!=0&&item.vipPrice!=null">
<text style="color: #e97512;font-size: 16px;font-weight: bold;">{{(item.vipPrice).toFixed(2)}}</text>
<!-- <text style="color: #fa2d12;font-size: 10px;margin-left: 4px;">VIP到手价</text> -->
<text style="color: #8a8a8a;font-size: 14px;margin-left: 4px;font-weight: bold;text-decoration: line-through;">{{(item.price).toFixed(2)}}</text>
</text>
<text
v-else-if="item.activityPrice && item.activityPrice > 0">
<text style="color: #e97512;font-size: 16px;font-weight: bold;">{{(item.activityPrice).toFixed(2)}}</text>
<!-- <text style="color: #613804;font-size: 10px;margin-left: 4px;">活动价</text> -->
<text style="color: #8a8a8a;font-size: 14px;margin-left: 4px;font-weight: bold;text-decoration: line-through;">{{(item.price).toFixed(2)}}</text>
</text>
<text v-else style="color: #e97512;font-size: 16px;font-weight: bold;">{{item.price}}</text>
<u-number-box button-size="20" v-model="item.productAmount" @change="valChange($event,item)"
:input-width="25" :input-height="10" :min="1" :max="item.productStock" integer
@overlimit='overlimit'></u-number-box>
</view>
</view>
</view>
@@ -29,13 +52,20 @@
<!-- 底部操作区 -->
<view class="shopCarFooter">
<view class="selectAll">
<checkbox :checked="all" @click="isSelectAll()" class="round checkedItem" />
<checkbox :checked="all" style="transform:scale(0.8)" @click="isSelectAll()" class="round checkedItem" />
<text class="cartCho">全选</text>
<!-- <text class="cartDel" >删除</text> -->
<button class="mini-btn" style="border-radius: 40rpx; font-size: 30rpx; height: 56rpx; line-height: 56rpx; margin-left: 6rpx;" v-if="isCartDelShow" @click="delCart()" type="warn" size="mini">删除</button>
<button class="mini-btn"
style="border-radius: 40rpx; font-size: 30rpx; height: 56rpx; line-height: 56rpx; margin-left: 6rpx;"
v-if="isCartDelShow" @click="delCart()" type="warn" size="mini">删除</button>
</view>
<view class="exhibition">
<text class="total">合计: <b>{{totalPrice}}</b></text>
<view class="total">合计: <b>{{totalPrice}}</b>
<!-- <text style="display: inline-block;width: 80%;color: #8a8a8a;font-size: 10px;">
不包含运费
</text> -->
</view>
<view class="settlement" @click="setTment()">
结算
</view>
@@ -59,7 +89,7 @@
export default {
data() {
return {
playData:{},
playData: {},
totalPrice: 0, // 总价
all: false, // 是否全选
isCartDelShow: false, // 是否展示删除按钮
@@ -84,8 +114,8 @@
computed: {
...mapState(['userInfo']),
},
components:{
musicPlay
components: {
musicPlay
},
//方法
methods: {
@@ -135,36 +165,40 @@
this.cartList.forEach((item, index) => {
let price = 0;
if (item.checked) {
if(item.activityPrice && item.activityPrice > 0){
price = item.productAmount * item.activityPrice;
}else{
price = item.productAmount * item.price;
if (item.isVipPrice == 1 && item.vipPrice != 0) {
price = (item.productAmount * item.vipPrice).toFixed(2);
} else {
if (item.activityPrice && item.activityPrice > 0) {
price = (item.productAmount * item.activityPrice).toFixed(2);
} else {
price = (item.productAmount * item.price).toFixed(2);
}
}
allprice += price
}
allprice += Number(price)
})
this.totalPrice = allprice
},
this.totalPrice = allprice.toFixed(2)
},
// 超出阈值时
overlimit(){
overlimit() {
uni.showToast({
title:'超出商品数量',
title: '超出商品数量',
icon: 'error',
duration: 1000
})
},
valChange(e, item) {
console.log(e)
let productItem = {}
productItem = item
let productItem = {}
productItem = item
productItem.productAmount = e.value
this.updateCart(productItem)
setTimeout(() => {
this.total()
}, 300)
this.updateCart(productItem)
setTimeout(() => {
this.total()
}, 300)
},
// 更新购物车
updateCart(shagnpin){
updateCart(shagnpin) {
// 已在购物车中添加
$http.request({
url: "book/ordercart/update",
@@ -211,7 +245,7 @@
}).then(res => {
this.isCartDelShow = false
this.totalPrice = 0
this.getCartList()
this.getCartList()
uni.hideLoading()
})
} else {
@@ -223,27 +257,27 @@
// 跳转结算页面
setTment() {
let shangList=[]
let shangList = []
this.cartList.forEach((item, index) => {
if (item.checked) {
shangList.push(index)
shangList.push({productId:item.productId,num:item.productAmount})
}
})
// 如果没有勾选
if(shangList.length == 0){
if (shangList.length == 0) {
uni.showToast({
title: "请先勾选商品",
icon: 'error',
duration: 1000,
})
}else{
uni.navigateTo({
url: '../bookShop/settlement?type=1&list='+JSON.stringify(shangList)
});
} else {
uni.navigateTo({
url: '../bookShop/settlement?type=1&list=' + JSON.stringify(shangList)
});
}
},
// 商品内容跳转
goDetail(id) {
uni.navigateTo({
@@ -264,7 +298,7 @@
padding-top: 20rpx;
.cartItem {
padding: 10rpx 10rpx 10rpx 20rpx;
padding: 10rpx 10rpx 10rpx 10rpx;
margin-bottom: 20rpx;
display: flex;
align-items: center;
@@ -276,8 +310,8 @@
display: flex;
image {
width: 150rpx;
height: 180rpx;
width: 130rpx;
height: 150rpx;
border-radius: 10rpx;
padding: 10rpx;
margin-right: 15rpx;
@@ -359,4 +393,4 @@
}
}
}
</style>
</style>