修复:对齐用户端店铺页面

This commit is contained in:
xiaowang
2026-05-30 18:31:35 +08:00
parent 31cd06b5c9
commit 22347ff076
10 changed files with 165 additions and 108 deletions
+49 -16
View File
@@ -6,10 +6,12 @@
<LeftOutlined />
</button>
<div class="header-title">
<span>{{ isBuyNowMode ? '确认订单' : '购物车' }}</span>
<strong>YumiNail</strong>
<strong>{{ isBuyNowMode ? '确认订单' : '购物车' }}</strong>
</div>
<div class="header-count" aria-label="购物车数量">
<ShoppingOutlined />
<span v-if="cartItems.length">{{ cartItems.length }}</span>
</div>
<div class="header-count" aria-label="购物车数量">{{ cartItems.length }}</div>
</header>
<a-empty v-if="!cartItems.length" class="empty-cart" description="购物车还是空的">
@@ -58,9 +60,9 @@
<div class="checkout-layout">
<section class="cart-group-card" aria-label="购物车商品">
<div class="group-head">
<div class="shop-mark">Y</div>
<div class="shop-mark">指</div>
<div class="group-copy">
<span>YumiNail Studio</span>
<span>{{ checkoutShopName }}</span>
<strong>{{ cartItems.length }} 项作品</strong>
</div>
<em>{{ selectedCount }} 项已选</em>
@@ -287,7 +289,7 @@
*/
import { computed, inject, onMounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { DeleteOutlined, LeftOutlined, RightOutlined } from '@ant-design/icons-vue'
import { DeleteOutlined, LeftOutlined, RightOutlined, ShoppingOutlined } from '@ant-design/icons-vue'
import { message, Modal } from 'ant-design-vue'
import type { ButtonProps } from 'ant-design-vue/es/button/buttonTypes'
import { cartApi } from '../api/cart'
@@ -352,6 +354,7 @@ interface CartItem {
id: IdType
productId: IdType
shopId?: IdType
shopName?: string
productTitle: string
productImage: string
originalProductImage?: string
@@ -439,6 +442,26 @@ const isBuyNowMode = computed(() => Boolean(buyNowProductId.value))
/** selectedItems is a reactive state variable used by the template and event handlers. */
const selectedItems = computed(() => cartItems.value.filter(item => item.selected))
const checkoutShopName = computed(() => {
const itemWithShopName = selectedItems.value.find(item => item.shopName) || cartItems.value.find(item => item.shopName)
if (itemWithShopName?.shopName) {
return itemWithShopName.shopName
}
if (typeof window !== 'undefined') {
try {
const raw = localStorage.getItem('userInfo')
const storedUser = raw ? JSON.parse(raw) as { shopName?: string } : null
if (storedUser?.shopName) {
return storedUser.shopName
}
} catch {
// Ignore malformed cached user data and fall back to the neutral shop label.
}
}
return '当前门店'
})
/** selectedCount is a reactive state variable used by the template and event handlers. */
const selectedCount = computed(() => selectedItems.value.length)
/** totalQuantity is a reactive state variable used by the template and event handlers. */
@@ -1033,6 +1056,7 @@ onMounted(async () => {
--cart-radius-lg: 24px;
--cart-radius-md: 18px;
--cart-bottom-offset: 60px;
--cart-shell-width: var(--frontend-page-max-width);
min-height: 100vh;
color: var(--text-primary);
background:
@@ -1041,7 +1065,7 @@ onMounted(async () => {
}
.content {
width: min(100%, 430px);
width: min(100%, var(--cart-shell-width));
margin: 0 auto;
padding: 0 16px calc(168px + env(safe-area-inset-bottom));
}
@@ -1079,6 +1103,7 @@ onMounted(async () => {
}
.header-count {
position: relative;
justify-self: end;
color: var(--theme-secondary);
font-size: 13px;
@@ -1090,26 +1115,34 @@ onMounted(async () => {
text-align: center;
}
.header-title span,
.header-title strong {
display: block;
}
.header-title span {
color: var(--text-secondary);
font-size: 11px;
font-weight: 700;
}
.header-title strong {
overflow: hidden;
color: var(--text-primary);
font-size: 15px;
font-size: 16px;
line-height: 1.25;
text-overflow: ellipsis;
white-space: nowrap;
}
.header-count span {
position: absolute;
top: 4px;
right: 3px;
min-width: 14px;
height: 14px;
padding: 0 4px;
border: 1px solid var(--theme-card-bg);
border-radius: 999px;
background: var(--theme-primary);
color: var(--theme-accent);
font-size: 9px;
line-height: 12px;
}
.empty-cart {
margin-top: 64px;
padding: 44px 18px;
@@ -1745,7 +1778,7 @@ onMounted(async () => {
left: 50%;
bottom: var(--cart-bottom-offset);
z-index: 20;
width: min(100%, 430px);
width: min(100%, var(--cart-shell-width));
display: flex;
align-items: center;
gap: 12px;