修改购物车页面 -- 添加根据供应商选择的逻辑
This commit is contained in:
parent
aaf8962505
commit
53d09262c2
@ -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;
|
||||
}
|
||||
|
||||
@ -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;
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user