修改购物车页面 -- 添加根据供应商选择的逻辑

This commit is contained in:
赵毅 2025-08-25 11:45:36 +08:00
parent aaf8962505
commit 53d09262c2
2 changed files with 76 additions and 12 deletions

View File

@ -76,8 +76,13 @@
justify-content: flex-end;
}
.goodsItem_supplier{
display: flex;
align-items: center;
margin: 20rpx;
}
.goodsItem_tit{
margin: 20rpx 0 0 20rpx;
font-size: 35rpx;
font-weight: bold;
}

View File

@ -29,9 +29,15 @@
</view>
<view class="goodsList">
<view v-for="(carItem, carIndex) in isDayCarList" :key="carItem.id" :index="carIndex">
<view class="goodsItem_supplier">
<view class="goodsItem_left" @click="supplierCheck(carItem, true)">
<image v-if="!carItem.supplierChecked" src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check1.png"></image>
<image v-if="carItem.supplierChecked" src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check2.png"></image>
</view>
<view class="goodsItem_tit">
{{ carItem.supplier_name }}
</view>
</view>
<view class="goodsItem" v-for="(item, index) in carItem.commodity_cart_and_goods_model"
:key="item.id">
<view class="goodsItem_left" @click="DayChecked(item)">
@ -96,9 +102,15 @@
</view>
<view class="goodsList">
<view v-for="(carItem, carIndex) in shopCarList" :key="carItem.id" :index="carIndex">
<view class="goodsItem_supplier">
<view class="goodsItem_left" @click="supplierCheck(carItem, false)">
<image v-if="!carItem.supplierChecked" src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check1.png"></image>
<image v-if="carItem.supplierChecked" src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check2.png"></image>
</view>
<view class="goodsItem_tit">
{{ carItem.supplier_name }}
</view>
</view>
<view class="goodsItem" v-for="(item, index) in carItem.commodity_cart_and_goods_model"
:key="item.id">
<view class="goodsItem_left" @click="changeChecked(item)">
@ -231,6 +243,29 @@ export default {
NavgateTo("1");
},
// /
supplierCheck(carItem, isDay) {
carItem.supplierChecked = !carItem.supplierChecked;
carItem.commodity_cart_and_goods_model.forEach(goods => {
goods.checked = carItem.supplierChecked;
});
this.calcTotal();
//
if (isDay) {
this.isDaychecked = this.isDayCarList.every(item =>
item.commodity_cart_and_goods_model.every(goods => goods.checked)
);
} else {
this.isParcelPostchecked = this.shopCarList.every(item =>
item.commodity_cart_and_goods_model.every(goods => goods.checked)
);
}
//
this.isAllchecked = this.isDaychecked && this.isParcelPostchecked;
},
//
submitOrder() {
let arr = [];
@ -262,12 +297,14 @@ export default {
if (res.normal_cart_list.length > 0) {
res.normal_cart_list.forEach((item) => {
item.checked = false;
item.supplierChecked = false;
this.parcelPostshow = true;
})
this.shopCarList = res.normal_cart_list
} else {
res.normal_cart_list.forEach((item) => {
item.checked = false;
item.supplierChecked = false;
this.parcelPostshow = false;
})
}
@ -275,12 +312,14 @@ export default {
if (res.same_day_cart_list.length > 0) {
res.same_day_cart_list.forEach((item) => {
item.checked = false;
item.supplierChecked = false;
this.isDayshow = true;
})
this.isDayCarList = res.same_day_cart_list
} else {
res.normal_cart_list.forEach((item) => {
item.checked = false;
item.supplierChecked = false;
this.isDayshow = false;
})
}
@ -307,6 +346,14 @@ export default {
changeChecked(item) {
item.checked = !item.checked;
this.calcTotal();
//
this.shopCarList.forEach(carItem => {
if (carItem.commodity_cart_and_goods_model.includes(item)) {
carItem.supplierChecked = carItem.commodity_cart_and_goods_model.every(goods => goods.checked);
}
});
//
this.isDaychecked = this.isDayCarList.every(carItem =>
carItem.commodity_cart_and_goods_model.every(goods => goods.checked)
@ -321,6 +368,14 @@ export default {
DayChecked(item) {
item.checked = !item.checked;
this.calcTotal();
//
this.isDayCarList.forEach(carItem => {
if (carItem.commodity_cart_and_goods_model.includes(item)) {
carItem.supplierChecked = carItem.commodity_cart_and_goods_model.every(goods => goods.checked);
}
});
//
this.isDaychecked = this.isDayCarList.every(carItem =>
carItem.commodity_cart_and_goods_model.every(goods => goods.checked)
@ -338,15 +393,17 @@ export default {
this.isDaychecked = this.isAllchecked;
this.isParcelPostchecked = this.isAllchecked;
//
//
this.isDayCarList.forEach(carItem => {
carItem.supplierChecked = this.isAllchecked;
carItem.commodity_cart_and_goods_model.forEach(goods => {
goods.checked = this.isAllchecked;
});
});
//
//
this.shopCarList.forEach(carItem => {
carItem.supplierChecked = this.isAllchecked;
carItem.commodity_cart_and_goods_model.forEach(goods => {
goods.checked = this.isAllchecked;
});
@ -359,8 +416,9 @@ export default {
is_day_checked() {
this.isDaychecked = !this.isDaychecked;
//
//
this.isDayCarList.forEach(carItem => {
carItem.supplierChecked = this.isDaychecked;
carItem.commodity_cart_and_goods_model.forEach(goods => {
goods.checked = this.isDaychecked;
});
@ -376,8 +434,9 @@ export default {
parcel_post_checked() {
this.isParcelPostchecked = !this.isParcelPostchecked;
//
//
this.shopCarList.forEach(carItem => {
carItem.supplierChecked = this.isParcelPostchecked;
carItem.commodity_cart_and_goods_model.forEach(goods => {
goods.checked = this.isParcelPostchecked;
});