From bfe83211241f578a31f771a5c6a0efe4b03b840f Mon Sep 17 00:00:00 2001 From: dzq Date: Sat, 13 Dec 2025 11:07:56 +0800 Subject: [PATCH] =?UTF-8?q?feat(rental):=20=E4=BF=AE=E5=A4=8D=E9=80=80?= =?UTF-8?q?=E6=AC=BE=E9=A1=B5=E9=9D=A2=E5=8F=82=E6=95=B0=E9=A1=BA=E5=BA=8F?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=B9=B6=E5=AE=8C=E5=96=84=E7=A7=9F=E7=94=A8?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复退款页面跳转时参数顺序错误的问题 添加租用模式相关功能,包括租用柜机展示、购物车逻辑和结算流程 优化租用柜机容器样式和交互体验 --- .../components/renting-cabinet-container.vue | 72 ++++++++----------- src/pages/index/index.vue | 35 ++++++++- src/pages/rental/index.vue | 2 +- 3 files changed, 62 insertions(+), 47 deletions(-) diff --git a/src/pages/index/components/renting-cabinet-container.vue b/src/pages/index/components/renting-cabinet-container.vue index f0f3e9a..2a86d26 100644 --- a/src/pages/index/components/renting-cabinet-container.vue +++ b/src/pages/index/components/renting-cabinet-container.vue @@ -16,7 +16,7 @@ const emit = defineEmits<{ // 状态管理 const rentingCabinetStore = useRentingCabinetStore(); -const { rentingCabinets, rentingCartItems, rentingCartTotalQuantity } = storeToRefs(rentingCabinetStore); +const { rentingCabinets, rentingCartItems, rentingCartTotalQuantity, rentingCartTotalPrice } = storeToRefs(rentingCabinetStore); // 从props接收的数据 const activeCategory = ref(0); // 这里的分类可以根据 cabinetName 来划分,也可以简化为所有可租用格口 @@ -57,14 +57,22 @@ function getRentingCartItemCount(cellId: number) { // 过滤格口列表,搜索框功能 const filteredRentingCells = computed(() => { let cells: any[] = []; - // 如果有分类,则按分类过滤 + + // 根据当前选中的分类获取对应的柜机格口 if (rentingCabinets.value.length > 0) { - // Flattern all cells from all cabinets - cells = rentingCabinets.value.flatMap(cabinet => cabinet.cells); + if (activeCategory.value >= 0 && activeCategory.value < rentingCabinets.value.length) { + // 只显示当前选中柜机的格口 + cells = rentingCabinets.value[activeCategory.value].cells || []; + } else { + // 显示所有柜机的格口 + cells = rentingCabinets.value.flatMap(cabinet => cabinet.cells || []); + } } - // 过滤掉已租用 (isRented = 1) 和已占用 (usageStatus = 2) 的格口 - const availableCells = cells.filter(cell => cell.isRented === 0 && cell.usageStatus === 1); + // 过滤掉已租用 (isRented = 1)、已占用 (usageStatus = 2) 或不可用 (availableStatus = 2) 的格口 + const availableCells = cells.filter(cell => + cell.isRented === 0 && cell.usageStatus === 1 && cell.availableStatus === 1 + ); // 搜索过滤 if (!searchQuery.value) { @@ -155,17 +163,16 @@ function showCartDetail() { - - 🛒 - {{ rentingCartTotalQuantity }} - - - 已选格口数:{{ rentingCartTotalQuantity }} - + + + + + 合计{{ rentingCartTotalQuantity }}格 ¥{{ rentingCartTotalPrice.toFixed(2) }} + - + @@ -173,7 +180,7 @@ function showCartDetail() { diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 94281c6..56145d2 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -1,11 +1,13 @@