feat(rental): 修复退款页面参数顺序错误并完善租用模式功能

修复退款页面跳转时参数顺序错误的问题
添加租用模式相关功能,包括租用柜机展示、购物车逻辑和结算流程
优化租用柜机容器样式和交互体验
This commit is contained in:
dzq 2025-12-13 11:07:56 +08:00
parent c6a76fecc0
commit bfe8321124
3 changed files with 62 additions and 47 deletions

View File

@ -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() {
<!-- 底部购物车栏 -->
<view v-if="rentingCartItems.length" class="shopping-cart-bar" @click="showCartDetail">
<view class="cart-info">
<view class="badge-wrapper">
<text class="cart-icon">🛒</text>
<view class="badge">{{ rentingCartTotalQuantity }}</view>
</view>
<view class="total-price">
已选格口数{{ rentingCartTotalQuantity }}
</view>
<wd-badge :model-value="rentingCartTotalQuantity" right="0" top="0">
<wd-icon name="cart" size="24px"></wd-icon>
</wd-badge>
<text class="total-price">
合计{{ rentingCartTotalQuantity }} ¥{{ rentingCartTotalPrice.toFixed(2) }}
</text>
</view>
<button type="primary" size="default" @click.stop="handleCheckout" class="checkout-btn">
<view class="checkout-btn" @click.stop="handleCheckout">
去结算
</button>
</view>
</view>
</view>
</template>
@ -173,7 +180,7 @@ function showCartDetail() {
<style scoped lang="scss">
.product-container {
display: flex;
height: 100vh;
height: calc(100vh - 150px);
background: #f7f8fa;
position: relative;
overflow: hidden;
@ -222,6 +229,7 @@ function showCartDetail() {
display: flex;
flex-direction: column;
background: #ffffff;
position: relative;
}
.search-wrapper {
@ -243,6 +251,7 @@ function showCartDetail() {
flex: 1;
overflow-y: auto;
padding: 10px;
padding-bottom: 55px;
}
.product-item {
@ -372,7 +381,6 @@ function showCartDetail() {
opacity: 0.6;
}
/* 修改购物车栏样式 */
.shopping-cart-bar {
position: absolute;
bottom: 0;
@ -394,28 +402,6 @@ function showCartDetail() {
gap: 12px;
}
.badge-wrapper {
position: relative;
}
.cart-icon {
font-size: 24px;
}
.badge {
position: absolute;
top: -6px;
right: -8px;
background: #e95d5d;
color: #fff;
border-radius: 10px;
padding: 0 6px;
font-size: 10px;
line-height: 18px;
min-width: 18px;
text-align: center;
}
.total-price {
font-size: 14px;
color: #333;
@ -423,13 +409,13 @@ function showCartDetail() {
}
.checkout-btn {
background-color: #e95d5d;
background-color: #F56C6C;
border: none;
border-radius: 16px;
padding: 0 24px;
height: 32px;
line-height: 32px;
font-size: 14px;
height: 36px;
line-height: 36px;
color: #fff;
font-size: 14px;
}
</style>

View File

@ -1,11 +1,13 @@
<script lang="ts" setup>
import { ref, onMounted } from 'vue'
import { ref, computed, onMounted } from 'vue'
import { useWxStore } from '@/pinia/stores/wx'
import { useProductStore } from '@/pinia/stores/product'
import { useCartStore } from '@/pinia/stores/cart'
import { useRentingCabinetStore } from '@/pinia/stores/rentingCabinet'
import { getShopListApi } from '@/api/shop'
import type { ShopEntity } from '@/api/shop/types'
import ProductContainer from './components/product-container.vue';
import RentingCabinetContainer from './components/renting-cabinet-container.vue';
import { generateDynamicCode, getWxUserByOpenid, mpCodeToOpenId } from '@/api/users'
import { toHttpsUrl, uniLogin } from '@/utils'
import { useAb98UserStore } from '@/pinia/stores/ab98-user'
@ -22,6 +24,7 @@ definePage({
const wxStore = useWxStore()
const productStore = useProductStore()
const cartStore = useCartStore()
const rentingCabinetStore = useRentingCabinetStore()
const ab98UserStore = useAb98UserStore()
//
@ -29,6 +32,16 @@ const showShopList = ref<boolean>(true)
const shopList = ref<ShopEntity[]>([])
const shopId = ref<number>(0)
//
const selectedShopMode = computed(() => {
if (!shopId.value) return 0
const shop = shopList.value.find(s => s.shopId === shopId.value)
return shop?.mode || 0
})
//
const isRentingMode = computed(() => selectedShopMode.value === 3)
//
@ -44,11 +57,12 @@ function handleShopSelect(selectedShopId: number) {
productStore.setSelectedShop(selectedShop)
if (selectedShop.mode == 3) {
//
// rentingCabinetStore.fetchRentingCabinetDetail(selectedShopId)
rentingCabinetStore.fetchRentingCabinetDetail(selectedShopId)
} else {
productStore.getGoods(selectedShopId)
}
cartStore.clearCart()
rentingCabinetStore.clearRentingCart()
}
}
@ -58,6 +72,7 @@ function backToShopList() {
shopId.value = 0
productStore.categories = []
cartStore.clearCart()
rentingCabinetStore.clearRentingCart()
}
//
@ -67,6 +82,13 @@ function handleCheckout() {
})
}
//
function handleCheckoutRenting() {
uni.navigateTo({
url: '/pages/index/checkout'
})
}
onLoad(async (query) => {
const wxParamsStore = useWxParamsStore();
const { wxUserDTO } = storeToRefs(wxStore);
@ -171,9 +193,16 @@ onShow(async () => {
</view>
</view>
<!-- 租用格口列表 -->
<RentingCabinetContainer
v-if="!showShopList && isRentingMode"
:shop-id="shopId"
@backToShopList="backToShopList"
@checkoutRenting="handleCheckoutRenting"
/>
<!-- 商品列表 -->
<ProductContainer
v-if="!showShopList"
v-else-if="!showShopList && !isRentingMode"
@backToShopList="backToShopList"
@checkout="handleCheckout"
/>

View File

@ -219,7 +219,7 @@ const handleOpenLocker = async (locker: LockerItem) => {
*/
const handleRefund = (orderId: number, orderGoodsId: number) => {
uni.navigateTo({
url: `/pages/approval/submit?orderGoodsId=${orderId}&orderId=${orderGoodsId}`,
url: `/pages/approval/submit?orderGoodsId=${orderGoodsId}&orderId=${orderId}`,
fail: (err) => {
console.error('页面跳转失败:', err)
uni.showToast({