功能:更新 YumiNail 用户端流程

This commit is contained in:
xiaowang
2026-05-31 18:36:52 +08:00
parent 22347ff076
commit 73483e7b0c
49 changed files with 6053 additions and 1306 deletions
+92 -30
View File
@@ -1,19 +1,17 @@
<template>
<div class="mobile-container home-page">
<header class="home-topbar">
<button class="yumi-icon-button" type="button" aria-label="打开菜单" @click="router.push('/profile')">
<MenuOutlined />
</button>
<strong class="home-brand">首页</strong>
<button class="yumi-icon-button" type="button" aria-label="查看购物车" @click="router.push('/cart')">
<ShoppingOutlined />
</button>
<span class="home-topbar-spacer" aria-hidden="true"></span>
<strong class="home-brand">{{ currentShopName }}</strong>
<span class="home-topbar-spacer" aria-hidden="true"></span>
</header>
<section class="hero">
<div class="hero-copy" @click="handleUserClick">
<p class="hero-kicker">{{ greeting }}</p>
<h1>{{ displayName }}</h1>
<h1 class="hero-greeting">
<span>{{ greeting }}</span>
<span class="hero-greeting__name">{{ displayName }}</span>
</h1>
<div class="member-line" aria-label="会员等级">
<span></span>
<p>{{ memberLevelText }}</p>
@@ -230,10 +228,8 @@ import {
AppstoreOutlined,
CalendarOutlined,
CreditCardOutlined,
MenuOutlined,
RightOutlined,
SearchOutlined,
ShoppingOutlined,
TagsOutlined,
} from '@ant-design/icons-vue'
/**
@@ -348,11 +344,45 @@ const page = ref(1)
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const pageSize = 8
const now = ref(new Date())
let greetingTimer: ReturnType<typeof window.setInterval> | undefined
/** isLoggedIn is a reactive state variable used by the template and event handlers. */
const isLoggedIn = computed(() => Boolean(localStorage.getItem('accessToken') || sessionStorage.getItem('accessToken')))
/** currentShopName renders the active shop name in the page navigation bar. */
const currentShopName = computed(() => {
const userShopName = userInfo.value?.shopName || userInfo.value?.shopNames?.find(Boolean)
if (userShopName) {
return userShopName
}
if (typeof window !== 'undefined') {
try {
const raw = localStorage.getItem('userInfo')
const storedUser = raw ? JSON.parse(raw) as { shopName?: string; shopNames?: string[] } : null
const cachedShopName = storedUser?.shopName || storedUser?.shopNames?.find(Boolean)
if (cachedShopName) {
return cachedShopName
}
} catch {
// Ignore malformed cached user data and keep resolving from public shops.
}
}
return publicShops.value.find(shop => shop.shopName)?.shopName || '当前门店'
})
/** greeting is a reactive state variable used by the template and event handlers. */
const greeting = computed(() => '早上好,')
const greeting = computed(() => {
const hour = now.value.getHours()
if (hour >= 5 && hour < 9) return '早上好,'
if (hour >= 9 && hour < 11) return '上午好,'
if (hour >= 11 && hour < 13) return '中午好,'
if (hour >= 13 && hour < 17) return '下午好,'
if (hour >= 17 && hour < 19) return '傍晚好,'
if (hour >= 19 && hour < 23) return '晚上好,'
if (hour >= 23 || hour < 1) return '深夜好,'
return '凌晨好,'
})
/** displayName is a reactive state variable used by the template and event handlers. */
const displayName = computed(() => userInfo.value?.nickname || (isLoggedIn.value ? '用户' : '朋友'))
const memberLevelText = computed(() => `会员等级:${userInfo.value?.level || (isLoggedIn.value ? '普通会员' : '游客')}`)
@@ -587,6 +617,11 @@ const openShopById = (shopId: IdType) => {
}
onMounted(async () => {
now.value = new Date()
greetingTimer = window.setInterval(() => {
now.value = new Date()
}, 60 * 1000)
const homeTasks = [
loadUserInfo(),
loadAnnouncements(),
@@ -601,6 +636,9 @@ onMounted(async () => {
})
onUnmounted(() => {
if (greetingTimer) {
window.clearInterval(greetingTimer)
}
window.removeEventListener('scroll', handleScroll)
})
</script>
@@ -795,7 +833,7 @@ onUnmounted(() => {
.banner-copy h3 {
margin: 10px 0 4px;
font-size: 22px;
font-size: 19px;
color: var(--text-primary);
}
@@ -816,7 +854,7 @@ onUnmounted(() => {
.banner-empty h3 {
margin: 0;
font-size: 26px;
font-size: 21px;
color: var(--text-primary);
}
@@ -872,7 +910,7 @@ onUnmounted(() => {
}
.product-card :deep(.ant-card-body) {
padding: 12px;
padding: 12px 12px 16px;
}
.product-img {
@@ -915,9 +953,10 @@ onUnmounted(() => {
}
.price {
margin: 0;
margin: 0 0 2px;
font-size: 16px;
font-weight: 700;
line-height: 1.25;
color: var(--theme-primary-action);
}
@@ -994,7 +1033,7 @@ onUnmounted(() => {
}
.banner-empty h3 {
font-size: 22px;
font-size: 20px;
line-height: 1.35;
}
@@ -1073,20 +1112,30 @@ onUnmounted(() => {
position: sticky;
top: 0;
z-index: 40;
display: flex;
display: grid;
grid-template-columns: 42px minmax(0, 1fr) 42px;
align-items: center;
justify-content: space-between;
padding: 12px 18px 9px;
border-bottom: 1px solid color-mix(in srgb, var(--theme-border) 78%, transparent);
background: color-mix(in srgb, var(--theme-card-bg) 88%, transparent);
backdrop-filter: blur(18px);
}
.home-topbar-spacer {
width: 42px;
height: 32px;
}
.home-brand {
overflow: hidden;
color: var(--text-primary);
font-size: 16px;
font-weight: 800;
letter-spacing: 0;
line-height: 1.25;
text-align: center;
text-overflow: ellipsis;
white-space: nowrap;
}
.hero {
@@ -1101,21 +1150,29 @@ onUnmounted(() => {
min-width: 0;
}
.hero-kicker {
margin: 0 0 4px;
color: var(--text-secondary);
font-size: 12px;
line-height: 1.2;
}
.hero h1 {
.hero-greeting {
display: flex;
min-width: 0;
align-items: baseline;
margin: 0;
color: var(--text-primary);
font-size: 23px;
font-size: 18px;
font-weight: 800;
line-height: 1.12;
}
.hero-greeting span {
flex: 0 0 auto;
}
.hero-greeting__name {
flex: 1 1 auto;
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.member-line {
display: flex;
align-items: center;
@@ -1403,13 +1460,16 @@ onUnmounted(() => {
}
.home-page .product-card {
overflow: hidden;
border-radius: 20px;
background: transparent;
box-shadow: none;
cursor: pointer;
}
.home-page .product-info {
padding: 0 2px 8px;
}
.home-page .product-img {
aspect-ratio: 1 / 1.08;
margin: 0 0 9px;
@@ -1435,6 +1495,8 @@ onUnmounted(() => {
align-items: center;
justify-content: space-between;
gap: 8px;
min-height: 22px;
padding-bottom: 3px;
}
.home-page .price {
@@ -1506,7 +1568,7 @@ onUnmounted(() => {
}
@media (max-width: 360px) {
.hero h1 {
.hero-greeting {
font-size: 20px;
}