重写活动商品的购物车页面 修改数据展示逻辑

This commit is contained in:
赵毅 2025-09-27 17:19:59 +08:00
parent b3a65335db
commit 8e62a47125
5 changed files with 1045 additions and 6 deletions

View File

@ -116,6 +116,9 @@
color: #ffffff; color: #ffffff;
background-color: #fc5d15; background-color: #fc5d15;
border-radius: 15rpx 0 0 15rpx; border-radius: 15rpx 0 0 15rpx;
display: flex;
align-items: center;
justify-content: center;
} }
.group-price2{ .group-price2{

View File

@ -137,11 +137,11 @@ export default {
}); });
}, },
toDetail(itemObj) { toDetail(itemObj) {
// const item = { const item = {
// ...itemObj, ...itemObj,
// groupById: itemObj.group_buy_activity_info ? itemObj.group_buy_activity_info.id : '' groupById: itemObj.group_buy_activity_info ? itemObj.group_buy_activity_info.id : ''
// }; };
// NavgateTo(`/packages/shop/groupPurchaseDetail/index?item=${JSON.stringify(item)}`) NavgateTo(`/packages/advertising/goodsDetail/index?item=${JSON.stringify(item)}`)
}, },
// //
increaseQuantity(index) { increaseQuantity(index) {
@ -222,7 +222,7 @@ export default {
const item = { const item = {
is_adver: 1, is_adver: 1,
} }
NavgateTo("/packages/shop/shopCar/index?item=" + JSON.stringify(item)); NavgateTo("/packages/advertising/shopCar/index?item=" + JSON.stringify(item));
}, },
// //
getEndTheCountdown(endTime) { getEndTheCountdown(endTime) {

View File

@ -0,0 +1,258 @@
.main {
height: 77vh;
overflow-y: auto;
}
.searchBox {
display: flex;
align-items: center;
z-index: 2;
padding-bottom: 30rpx;
}
.searchBox_mid {
font-size: 40rpx;
color: #222222;
flex: 1;
text-align: center;
}
.searchBox_left {
box-sizing: border-box;
padding-left: 20rpx;
flex: 1;
}
.searchBox_right {
opacity: 0;
flex: 1;
}
.isDay {
position: absolute;
}
.tag {
background-color: #ff7d00;
color: white;
font-size: 22rpx;
padding: 5rpx 10rpx;
border-radius: 20rpx 0 20rpx 20rpx;
}
.tag-img {
position: absolute;
/* top: 1; */
bottom: 1;
left: 10;
z-index: 1;
}
.is_day {
margin-left: 20rpx;
}
.empty {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
margin-top: 160rpx;
}
.empty image {
width: 500rpx;
height: 500rpx;
}
.empty div {
font-size: 26rpx;
color: #999999;
margin-top: -40rpx;
text-align: center;
}
.deleteIcon {
margin: 0 40rpx;
box-sizing: border-box;
margin-top: 36rpx;
display: flex;
justify-content: flex-end;
}
.goodsItem_supplier {
display: flex;
align-items: center;
margin: 20rpx;
}
.goodsItem_tit {
font-size: 35rpx;
font-weight: bold;
}
.goodsItem {
display: flex;
align-items: center;
margin: 0 20rpx;
padding: 30rpx 0;
box-sizing: border-box;
border-bottom: 1rpx solid #EBEBEB;
}
.goodsItem_left {
width: 32rpx;
height: 32rpx;
margin-right: 32rpx;
}
.goodsItem_right {
flex: 1;
}
.goodsItem_msg {
display: flex;
align-items: center;
}
.goodsItem_msg_right {
flex: 1;
}
.goodsItem_msg_img {
width: 140rpx;
height: 140rpx;
border-radius: 20rpx 20rpx 20rpx 20rpx;
margin-right: 20rpx;
}
.goodsItem_msg_right {
flex: 1;
}
.goodsItem_msg_right_msg_left {
display: flex;
align-items: center;
font-size: 34rpx;
color: #FF370B;
margin-top: 26rpx;
}
.goodsItem_msg_right_tit {
font-size: 30rpx;
color: #000000;
font-weight: 700;
}
.goodsItem_msg_right_subTit {
font-size: 26rpx;
color: #999999;
margin-top: 10rpx;
}
.goodsItem_msg_right_msg {
display: flex;
align-items: center;
justify-content: space-between;
}
.goodsItem_msg_right_msg_left span {
font-size: 28rpx;
}
.goodsItem_msg_right_msg_right {
display: flex;
align-items: center;
}
.minus {
width: 22px;
height: 22px;
border-width: 1px;
border-color: #E6E6E6;
border-style: solid;
border-top-left-radius: 100px;
border-top-right-radius: 100px;
border-bottom-left-radius: 100px;
border-bottom-right-radius: 100px;
display: flex;
justify-content: center;
align-items: center;
}
.input {
padding: 0 10px;
}
.plus {
width: 22px;
height: 22px;
background-color: #FF0000;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
}
.footer {
width: 750rpx;
background: #FFFFFF;
box-shadow: 3rpx -3rpx 15rpx 0rpx rgba(255, 27, 27, 0.05);
display: flex;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
padding: 40rpx 20rpx;
position: fixed;
left: 0;
right: 0;
bottom: 0;
justify-content: space-between;
}
.footer_left {
display: flex;
align-items: center;
}
.footer_all {
font-size: 28rpx;
color: #000000;
display: flex;
align-items: center;
}
.footer_all image {
width: 28rpx;
height: 28rpx;
margin-right: 16rpx;
}
.footer_total {
font-weight: bold;
font-size: 40rpx;
color: #FF370B;
margin-left: 90rpx;
}
.footer_total span {
font-size: 32rpx;
color: #222222;
font-weight: 400;
}
.footer_right {
font-size: 36rpx;
color: #FFFFFF;
font-weight: 700;
width: 230rpx;
height: 70rpx;
background: linear-gradient(91deg, #FF7658 0%, #FF370B 100%);
border-radius: 100rpx 100rpx 100rpx 100rpx;
display: flex;
align-items: center;
justify-content: center;
}

View File

@ -0,0 +1,757 @@
<template>
<view>
<view class="header">
<view class="searchBox" :style="{ height: localHeight + 'px', paddingTop: top + 'px' }">
<view class="searchBox_left" @click="back">
<u-icon name="arrow-left" size="20px" color="#000"></u-icon>
</view>
<view class="searchBox_mid">购物车({{ shopCarTotal }})</view>
<view class="searchBox_right">
<u-icon name="arrow-left" size="20px" color="#000"></u-icon>
</view>
</view>
</view>
<view class="empty" v-if="shopCarTotal == 0">
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/shopCar_no.png"></image>
</view>
<view class="main" v-else>
<view class="deleteIcon" @click="deleteItem">
<u-icon name="trash" size="50rpx"></u-icon>
</view>
<view class="is_day " v-if="isDayshow">
<view class="footer_all" @click="is_day_checked"
style="color: orange; font-size: 35rpx; font-weight: bolder;">
<image v-if="!isDaychecked"
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check1.png">
</image>
<image v-if="isDaychecked"
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check2.png">
</image>
当日达
</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)">
<image v-if="!item.checked"
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check1.png">
</image>
<image v-if="item.checked"
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check2.png">
</image>
</view>
<view class="goodsItem_right">
<view class="goodsItem_msg">
<view class="goodsItem_msg_img">
<view class="tag tag-img">当日达</view>
<image :src="picUrl + item.commodity_goods_info.commodity_pic">
</image>
</view>
<view class="goodsItem_msg_right">
<view class="goodsItem_msg_right_tit">
{{ item.commodity_goods_info.goods_name }}
</view>
<view class="goodsItem_msg_right_subTit">
{{ item.commodity_goods_info.goods_intro }}
</view>
<view class="goodsItem_msg_right_msg">
<view class="goodsItem_msg_right_msg_left">
<span></span>{{ getPrice(item) }}
<!-- {{ item.commodity_goods_info.group_buy_price ?
item.commodity_goods_info.group_buy_price :
item.commodity_goods_info.sales_price }} -->
<span>/{{ item.commodity_goods_info.goods_unit }}</span>
</view>
<view class="goodsItem_msg_right_msg_right">
<u-number-box v-model="item.count" :asyncChange="true" min="0">
<view slot="minus" class="minus"
@click="minus(carItem, index, carItem.commodity_cart_and_goods_model)">
<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" @click="add(carItem, index)">
<u-icon name="plus" color="#FFFFFF" size="32" bold></u-icon>
</view>
</u-number-box>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
<view class="is_day" v-if="parcelPostshow" style="margin-top: 20rpx;">
<view class="footer_all" @click="parcel_post_checked"
style="color: orange; font-size: 35rpx; font-weight: bolder;">
<image v-if="!isParcelPostchecked"
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check1.png">
</image>
<image v-if="isParcelPostchecked"
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check2.png">
</image>
包邮
</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)">
<image v-if="!item.checked"
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check1.png">
</image>
<image v-if="item.checked"
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check2.png">
</image>
</view>
<view class="goodsItem_right">
<view class="goodsItem_msg">
<view class="goodsItem_msg_img">
<image :src="picUrl + item.commodity_goods_info.commodity_pic">
</image>
</view>
<view class="goodsItem_msg_right">
<view class="goodsItem_msg_right_tit">
{{ item.commodity_goods_info.goods_name }}
</view>
<view class="goodsItem_msg_right_subTit">
{{ item.commodity_goods_info.goods_intro }}
</view>
<view class="goodsItem_msg_right_msg">
<view class="goodsItem_msg_right_msg_left">
<span></span>{{ getPrice(item) }}
<!-- {{ item.commodity_goods_info.group_buy_price ?
item.commodity_goods_info.group_buy_price :
item.commodity_goods_info.sales_price }} -->
<span>/{{ item.commodity_goods_info.goods_unit }}</span>
</view>
<view class="goodsItem_msg_right_msg_right">
<u-number-box v-model="item.count" :asyncChange="true" min="0">
<view slot="minus" class="minus"
@click="minus(item, index, carItem.commodity_cart_and_goods_model)">
<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" @click="add(item, index)">
<u-icon name="plus" color="#FFFFFF" size="32" bold></u-icon>
</view>
</u-number-box>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
<view class="footer">
<view class="footer_left">
<view class="footer_all" @click="allChecked">
<image v-if="!isAllchecked"
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check1.png">
</image>
<image v-if="isAllchecked"
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check2.png">
</image>
全选
</view>
<view class="footer_total">
<span>合计</span>
{{ shopMoney }}
</view>
</view>
<view class="footer_right" @click="submitOrder">结算</view>
</view>
</view>
</view>
</template>
<script>
import {
apiArr
} from "../../../api/shop";
import {
picUrl,
menuButtonInfo,
request,
NavgateTo
} from "../../../utils";
export default {
data() {
return {
picUrl,
top: "",
localHeight: "",
value: 3,
type: "error",
shopCarList: [],
isDayCarList: [],
shopCarTotal: 0,
shopMoney: 0,
isAllchecked: false, //
isDaychecked: false, //
isDayshow: false,
isParcelPostchecked: false,
parcelPostshow: false,
is_group_buy: '',
is_adver: ''
};
},
// watch: {
// // console.log(this.isDaychecked);
// isDaychecked(e) {
// console.log('', e);
// },
// isParcelPostchecked(e) {
// console.log('', e);
// }
// isAllchecked(e) {
// console.log('', e);
// }
// },
methods: {
back() {
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 = [];
//
this.shopCarList.forEach((item) => {
item.commodity_cart_and_goods_model.forEach((ite) => {
if (ite.checked) {
ite.supplier_name = item.supplier_name;
arr.push(ite);
}
})
});
//
this.isDayCarList.forEach((item) => {
item.commodity_cart_and_goods_model.forEach((ite) => {
if (ite.checked) {
ite.supplier_name = item.supplier_name;
arr.push(ite);
}
})
});
if (arr.length == 0) {
this.$u.toast("请选择商品");
return;
}
// isAdver=true
const updatedArr = arr.map(item => ({
...item,
isAdver: item.adver_id ? true : ''
}));
// NavgateTo(`../submitOrder/index?shopCarList=${JSON.stringify(arr)}`);
NavgateTo(`../goodsSubmit/index?shopCarList=${JSON.stringify(updatedArr)}`);
},
//
getShopCar() {
const params = {
is_group_buy: this.is_group_buy,
is_adver: this.is_adver
}
request(apiArr.getCar, "POST", params).then((res) => {
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;
this.shopCarList = []
}
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;
this.isDayCarList = []
}
// res.normal_cart_list.forEach((item) => {
// if (item.is_support_same_day == false) {
// this.isDayshow = false;
// this.parcelPostshow = true;
// this.shopCarList = item.commodity_cart_and_goods_model;
// item.checked = false;
// } else {
// this.isDayshow = true;
// this.parcelPostshow = false;
// this.isDayCarList = item.commodity_cart_and_goods_model;
// item.checked = false;
// }
// });
this.shopCarTotal = res.total;
});
},
//
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)
);
//
this.isParcelPostchecked = this.shopCarList.every(carItem =>
carItem.commodity_cart_and_goods_model.every(goods => goods.checked)
);
//
this.isAllchecked = this.isDaychecked && this.isParcelPostchecked;
},
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)
);
//
this.isParcelPostchecked = this.shopCarList.every(carItem =>
carItem.commodity_cart_and_goods_model.every(goods => goods.checked)
);
//
this.isAllchecked = this.isDaychecked && this.isParcelPostchecked;
},
//
allChecked() {
this.isAllchecked = !this.isAllchecked;
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;
});
});
this.calcTotal();
},
//
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;
});
});
//
this.isAllchecked = this.isDaychecked && this.isParcelPostchecked;
this.calcTotal();
},
//
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;
});
});
//
this.isAllchecked = this.isDaychecked && this.isParcelPostchecked;
this.calcTotal();
},
//
calcTotal() {
let total = 0;
const currentTime = new Date().getTime();
//
this.isDayCarList.forEach(carItem => {
carItem.commodity_cart_and_goods_model.forEach(goods => {
if (goods.checked) {
//
const startTime = new Date(goods.commodity_goods_info.group_buy_activity_info?.start_time).getTime();
const endTime = new Date(goods.commodity_goods_info.group_buy_activity_info?.end_time).getTime();
if (currentTime >= startTime && currentTime <= endTime) {
total += goods.commodity_goods_info.group_buy_price * goods.count;
} else {
total += goods.commodity_goods_info.sales_price * goods.count;
}
}
});
});
//
this.shopCarList.forEach(carItem => {
carItem.commodity_cart_and_goods_model.forEach(goods => {
if (goods.checked) {
//
const startTime = new Date(goods.commodity_goods_info.group_buy_activity_info?.start_time).getTime();
const endTime = new Date(goods.commodity_goods_info.group_buy_activity_info?.end_time).getTime();
if (currentTime >= startTime && currentTime <= endTime) {
total += goods.commodity_goods_info.group_buy_price * goods.count;
} else {
total += goods.commodity_goods_info.sales_price * goods.count;
}
}
});
});
this.shopMoney = total.toFixed(2);
},
//
//
deleteCarItem(carItem, goodsIndex, item) {
const that = this;
request(apiArr.deleteCar, "POST", {
ids: [carItem.id],
}).then((res) => {
//
item.splice(goodsIndex, 1);
//
if (item.length === 0) {
//
const dayCarIndex = that.isDayCarList.findIndex(dayItem =>
dayItem.commodity_cart_and_goods_model === item
);
const normalCarIndex = that.shopCarList.findIndex(normalItem =>
normalItem.commodity_cart_and_goods_model === item
);
if (dayCarIndex !== -1) {
that.isDayCarList.splice(dayCarIndex, 1);
//
if (that.isDayCarList.length === 0) {
that.isDayshow = false;
}
}
if (normalCarIndex !== -1) {
that.shopCarList.splice(normalCarIndex, 1);
//
if (that.shopCarList.length === 0) {
that.parcelPostshow = false;
}
}
}
that.calcTotal();
}).catch(error => {
console.error('删除商品失败:', error);
uni.showToast({
title: '删除失败,请重试',
icon: 'none'
});
});
},
//
minus(carItem, goodsIndex, item) {
const that = this;
const currentTime = new Date().getTime();
//
const isGroupBuyActive = carItem.commodity_goods_info.group_buy_activity_info &&
currentTime >= new Date(carItem.commodity_goods_info.group_buy_activity_info?.start_time).getTime() &&
currentTime <= new Date(carItem.commodity_goods_info.group_buy_activity_info?.end_time).getTime();
if (carItem.count > 0) {
if (isGroupBuyActive && carItem.count === carItem.commodity_goods_info.min_order_quantity) {
//
uni.showToast({
title: '最少购买' + carItem.commodity_goods_info.min_order_quantity + '件',
icon: 'none'
});
//
that.shopCarTotal = Math.max(0, that.shopCarTotal - carItem.commodity_goods_info.min_order_quantity);
//
that.deleteCarItem(carItem, goodsIndex, item);
} else {
//
this.shopCarTotal = Math.max(0, this.shopCarTotal - 1);
carItem.count = carItem.count - 1;
this.handleQuantityChange(carItem.count, carItem);
// 0
if (carItem.count === 0) {
that.deleteCarItem(carItem, goodsIndex, item);
} else {
// 0
this.calcTotal();
}
}
}
},
//
add(carItem, goodsIndex) {
const currentTime = new Date().getTime();
const isGroupBuyActive = carItem.commodity_goods_info.group_buy_activity_info &&
currentTime >= new Date(carItem.commodity_goods_info.group_buy_activity_info?.start_time).getTime() &&
currentTime <= new Date(carItem.commodity_goods_info.group_buy_activity_info?.end_time).getTime();
if (isGroupBuyActive) {
if (carItem.count == 0) {
carItem.count = carItem.commodity_goods_info.min_order_quantity
this.shopCarTotal += carItem.commodity_goods_info.min_order_quantity;
} else {
if (carItem.count == carItem.commodity_goods_info.total_stock) {
uni.showToast({
title: '库存不足',
icon: 'none'
});
return
}
if (carItem.count == carItem.commodity_goods_info.max_limit_quantity) {
uni.showToast({
title: '一次最多购买' + carItem.commodity_goods_info.max_limit_quantity + '件',
icon: 'none'
});
return
}
carItem.count++;
this.shopCarTotal++;
}
} else {
if (carItem.count >= carItem.commodity_goods_info.stock_quantity) {
uni.showToast({
title: '库存不足',
icon: 'none'
});
return
}
carItem.count++;
this.shopCarTotal++;
}
const item = carItem.commodity_cart_and_goods_model;
this.handleQuantityChange(carItem.count, carItem);
this.calcTotal();
},
//
deleteItem() {
let that = this;
uni.showModal({
title: "提示",
content: "确定删除所选商品吗",
success: function (res) {
if (res.confirm) {
let ids = [];
// ID
that.isDayCarList.forEach(carItem => {
carItem.commodity_cart_and_goods_model.forEach(goods => {
if (goods.checked) {
ids.push(goods.id);
goods.checked = false;
}
});
});
// ID
that.shopCarList.forEach(carItem => {
carItem.commodity_cart_and_goods_model.forEach(goods => {
if (goods.checked) {
ids.push(goods.id);
goods.checked = false;
}
});
});
if (ids.length === 0) {
uni.showToast({
title: "请选择要删除的商品",
icon: "none",
duration: 2000,
});
return;
}
request(apiArr.deleteCar, "POST", {
ids,
})
.then((res) => {
uni.showToast({
title: "删除成功",
duration: 2000,
});
that.getShopCar();
that.calcTotal();
})
.catch((err) => {
console.log(err);
});
} else if (res.cancel) {
console.log("用户点击取消");
}
},
});
},
//
handleQuantityChange(val, item) {
const params = {
user_id: uni.getStorageSync("userId"),
goods_id_and_count: [{
goods_id: item.goods_id,
count: val,
},],
};
request(apiArr.updateCar, "POST", params).then((res) => {
console.log(res);
uni.showToast({
title: "操作成功!",
success() { },
});
return Promise.resolve();
});
},
// -
getPrice(item) {
const currentTime = new Date().getTime();
const startTime = new Date(item.commodity_goods_info.group_buy_activity_info?.start_time).getTime();
const endTime = new Date(item.commodity_goods_info.group_buy_activity_info?.end_time).getTime();
if (currentTime >= startTime && currentTime <= endTime) {
return item.commodity_goods_info.group_buy_price;
} else {
return item.commodity_goods_info.sales_price;
}
},
},
onLoad(options) {
const meun = menuButtonInfo();
this.top = meun.top;
this.localHeight = meun.height;
this.is_group_buy = options.item ? JSON.parse(options.item).is_group_buy : ''
this.is_adver = options.item ? JSON.parse(options.item).is_adver : ''
this.getShopCar();
},
onShow() {
this.getShopCar();
//
this.isAllchecked = false;
this.isDaychecked = false;
this.isParcelPostchecked = false;
this.shopMoney = 0.00;
},
onReachBottom() { },
};
</script>
<style>
@import url("./index.css");
</style>

View File

@ -1012,6 +1012,27 @@
"navigationBarTitleText": "推荐商品", "navigationBarTitleText": "推荐商品",
"navigationBarBackgroundColor": "#ffffff" "navigationBarBackgroundColor": "#ffffff"
} }
},
{
"path": "shopCar/index",
"style": {
"navigationBarBackgroundColor": "#fff",
"navigationStyle": "custom"
}
},
{
"path": "goodsSubmit/index",
"style": {
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "提交团单"
}
},
{
"path": "goodsDetail/index",
"style": {
"navigationBarBackgroundColor": "#fff",
"navigationStyle": "custom"
}
} }
] ]
} }