Files
JayuCloud/FD-Frontend/src/views/HomeView.vue
T

1602 lines
43 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="mobile-container home-page">
<header class="home-topbar">
<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">
<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>
</div>
</div>
<button class="avatar-button" type="button" @click="handleUserClick">
<a-avatar :size="42" :src="userInfo?.avatar || DEFAULT_AVATAR" />
</button>
</section>
<form class="search-card" @submit.prevent="handleSearch">
<SearchOutlined class="search-card__icon" />
<input v-model="searchQuery" type="search" placeholder="搜索服务或美甲款式..." />
<button type="submit">搜索</button>
</form>
<div v-if="announcements.length" class="announcement-bar">
<div class="announcement-track">
<button
v-for="item in announcementLoop"
:key="`${item.id}-${item.loopKey}`"
class="announcement-item"
type="button"
@click="openAnnouncementDetail(item)"
>
<b>{{ item.publisherName || '平台' }}</b>:{{ getAnnouncementPreview(item) }}
</button>
</div>
</div>
<a-modal
v-model:open="announcementDetailOpen"
title="公告详情"
:footer="null"
centered
>
<div v-if="selectedAnnouncement" class="announcement-detail">
<div class="announcement-detail__meta">
<span>{{ selectedAnnouncement.publisherName || '平台' }}</span>
<span>{{ formatAnnouncementTime(selectedAnnouncement.publishTime) }}</span>
</div>
<div class="announcement-rich-content" v-html="selectedAnnouncementContentHtml"></div>
</div>
</a-modal>
<section class="feature-banner" aria-label="新品作品">
<a-carousel
v-if="newArrivalItems.length"
class="new-arrival-carousel"
:dots="newArrivalItems.length > 1"
autoplay
:autoplay-speed="3600"
>
<div v-for="(item, index) in newArrivalItems" :key="item.id" class="new-arrival-slide">
<button class="new-arrival-card" type="button" @click="handleProductClick(item)">
<img
:src="item.coverUrl || DEFAULT_PRODUCT_IMAGE"
:alt="item.name"
class="feature-banner__image"
:loading="index === 0 ? 'eager' : 'lazy'"
decoding="async"
@error="handleProductCardImageError(item)"
/>
<div class="feature-banner__shade"></div>
<div class="feature-banner__copy">
<span>新品上市</span>
<h2>{{ item.name }}</h2>
<p>{{ item.shopName || item.meta }} · ¥{{ item.price }}</p>
</div>
</button>
</div>
</a-carousel>
<button v-else class="new-arrival-card" type="button" @click="router.push('/products')">
<img :src="DEFAULT_PRODUCT_IMAGE" alt="春日繁花系列" class="feature-banner__image" loading="eager" decoding="async" />
<div class="feature-banner__shade"></div>
<div class="feature-banner__copy">
<span>新品上市</span>
<h2>春日繁花系列</h2>
<p>轻盈裸粉、微闪珠光与日常通勤都刚好。</p>
</div>
</button>
</section>
<nav class="quick-actions" aria-label="快捷入口">
<button type="button" @click="router.push('/products')">
<span><CalendarOutlined /></span>
<b>在线预约</b>
</button>
<button type="button" @click="router.push('/products')">
<span><AppstoreOutlined /></span>
<b>作品集</b>
</button>
<button type="button" @click="router.push('/vip-center')">
<span><CreditCardOutlined /></span>
<b>会员中心</b>
</button>
<button type="button" @click="router.push('/coupons')">
<span><TagsOutlined /></span>
<b>优惠活动</b>
</button>
</nav>
<section class="section">
<div class="section-header">
<div>
<span class="section-kicker">Curated</span>
<h3>精选作品</h3>
</div>
<button class="see-all" type="button" @click="handleSeeAll('featured')">
查看全部 <RightOutlined />
</button>
</div>
<div class="product-grid">
<article
v-for="item in featuredPreview"
:key="item.id"
class="product-card"
@click="handleProductClick(item)"
>
<div class="product-img">
<img v-if="item.coverUrl" :src="item.coverUrl" :alt="item.name" class="product-cover" loading="lazy" decoding="async" @error="handleProductCardImageError(item)" />
<span v-else>{{ item.name[0] }}</span>
</div>
<div class="product-info">
<p class="name">{{ item.name }}</p>
<p class="meta">{{ item.shopName || item.meta }}</p>
<div class="product-foot">
<p class="price">¥{{ item.price }}</p>
<span>{{ item.meta }}</span>
</div>
</div>
</article>
</div>
</section>
<section class="section popular-section">
<div class="section-header">
<div>
<span class="section-kicker">Trending</span>
<h3>热门作品</h3>
</div>
<button class="see-all" type="button" @click="handleSeeAll('popular')">
查看全部 <RightOutlined />
</button>
</div>
<div class="product-grid">
<article
v-for="item in popularPreview"
:key="item.id"
class="product-card grid-item"
@click="handleProductClick(item)"
>
<div class="product-img">
<img v-if="item.coverUrl" :src="item.coverUrl" :alt="item.name" class="product-cover" loading="lazy" decoding="async" @error="handleProductCardImageError(item)" />
<span v-else>{{ item.name[0] }}</span>
</div>
<div class="product-info">
<p class="name">{{ item.name }}</p>
<p class="meta">{{ item.shopName || item.meta }}</p>
<div class="product-foot">
<p class="price">¥{{ item.price }}</p>
<span>{{ item.meta }}</span>
</div>
</div>
</article>
</div>
<div v-if="loading" class="loading-more">
<a-spin size="small" />
<span>加载中...</span>
</div>
<div v-else-if="!hasMore && popularItems.length > 0" class="no-more">
没有更多热门推荐了
</div>
<div v-else-if="popularItems.length === 0 && !loading" class="no-products">
暂无热门作品
</div>
</section>
<section v-if="shopPreview.length" class="section shop-section">
<div class="section-header">
<div>
<span class="section-kicker">Stores</span>
<h3>门店环境</h3>
</div>
<button class="see-all" type="button" @click="router.push('/products')">
参观门店 <RightOutlined />
</button>
</div>
<div class="shop-strip">
<button
v-for="shop in shopPreview"
:key="shop.id"
class="shop-card"
type="button"
@click="openShopById(shop.shopId)"
>
<img :src="shop.url" :alt="shop.shopName" loading="lazy" decoding="async" @error="handleBannerImageError(shop)" />
<span>{{ shop.shopName }}</span>
</button>
</div>
</section>
</div>
</template>
<script setup lang="ts">
/**
* HomeView page script.
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
*/
import { computed, onMounted, onUnmounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import { message } from 'ant-design-vue'
import {
AppstoreOutlined,
CalendarOutlined,
CreditCardOutlined,
RightOutlined,
SearchOutlined,
TagsOutlined,
} from '@ant-design/icons-vue'
/**
* Purpose: AnnouncementVO supports HomeView.vue by holding or executing the announcement vo page or API role.
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
*/
import { userApi, type AnnouncementVO, type UserVO } from '../api/user'
/**
* Purpose: ProductVO supports HomeView.vue by holding or executing the product vo page or API role.
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
*/
import { productApi, type ProductVO } from '../api/product'
/**
* Purpose: ShopVO supports HomeView.vue by holding or executing the shop vo page or API role.
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
*/
import { shopApi, type ShopVO } from '../api/shop'
import { DEFAULT_AVATAR, DEFAULT_PRODUCT_IMAGE } from '@/constants'
import type { IdType } from '@/utils/id'
import { extractRichText, renderRichContent } from '@/utils/rich-content'
import {
getPublicImageFileIds,
refreshPublicImageUrl,
resolvePublicImageUrl,
resolvePublicImageUrlsSync
} from '@/utils/public-image-assets'
/**
* Purpose: BannerImage supports HomeView.vue by holding or executing the banner image page or API role.
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
*/
interface BannerImage {
id: string
shopId: IdType
shopName: string
businessHours?: string
url: string
imageFileId?: string
}
/**
* Purpose: ProductCardItem supports HomeView.vue by holding or executing the product card item page or API role.
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
*/
interface ProductCardItem {
id: IdType
name: string
price: string
meta: string
shopName?: string
coverUrl: string
imageFileId?: string
bgColor: string
}
/**
* Purpose: router supports HomeView.vue by holding or executing the router page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const router = useRouter()
/**
* Purpose: userInfo supports HomeView.vue by holding or executing the user info page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const userInfo = ref<UserVO | null>(null)
/**
* Purpose: publicShops supports HomeView.vue by holding or executing the public shops page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const publicShops = ref<ShopVO[]>([])
/**
* Purpose: bannerImages supports HomeView.vue by holding or executing the banner images page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const bannerImages = ref<BannerImage[]>([])
/** newArrivalItems supports the home new-arrival carousel. */
const newArrivalItems = ref<ProductCardItem[]>([])
/**
* Purpose: featuredItems supports HomeView.vue by holding or executing the featured items page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const featuredItems = ref<ProductCardItem[]>([])
/**
* Purpose: popularSource supports HomeView.vue by holding or executing the popular source page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const popularSource = ref<ProductCardItem[]>([])
/**
* Purpose: popularItems supports HomeView.vue by holding or executing the popular items page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const popularItems = ref<ProductCardItem[]>([])
/**
* Purpose: announcements supports HomeView.vue by holding or executing the announcements page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const announcements = ref<AnnouncementVO[]>([])
/**
* Purpose: selectedAnnouncement supports HomeView.vue by holding or executing the selected announcement page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const selectedAnnouncement = ref<AnnouncementVO | null>(null)
/**
* Purpose: announcementDetailOpen supports HomeView.vue by holding or executing the announcement detail open page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const announcementDetailOpen = ref(false)
/** searchQuery is a reactive state variable used by the template and event handlers. */
const searchQuery = ref('')
/** loading is a reactive state variable used by the template and event handlers. */
const loading = ref(false)
/** hasMore is a reactive state variable used by the template and event handlers. */
const hasMore = ref(true)
/** page is a reactive state variable used by the template and event handlers. */
const page = ref(1)
/**
* Purpose: pageSize supports HomeView.vue by holding or executing the page size page or API role.
* 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: number | 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 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 ? '普通会员' : '游客')}`)
/** announcementLoop is a reactive state variable used by the template and event handlers. */
const announcementLoop = computed(() => [...announcements.value, ...announcements.value].map((item, index) => ({ ...item, loopKey: index })))
const selectedAnnouncementContentHtml = computed(() => renderRichContent(selectedAnnouncement.value?.content || '暂无公告内容'))
const featuredPreview = computed(() => featuredItems.value.slice(0, 4))
const popularPreview = computed(() => popularItems.value.slice(0, 4))
const shopPreview = computed(() => bannerImages.value.slice(0, 3))
/**
* Purpose: openAnnouncementDetail supports HomeView.vue by holding or executing the open announcement detail page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const openAnnouncementDetail = (item: AnnouncementVO) => {
selectedAnnouncement.value = item
announcementDetailOpen.value = true
}
/**
* Purpose: formatAnnouncementTime supports HomeView.vue by holding or executing the format announcement time page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const formatAnnouncementTime = (value?: string) => {
if (!value) return ''
return value.replace('T', ' ').slice(0, 16)
}
const getAnnouncementPreview = (item: AnnouncementVO) => extractRichText(item.content) || item.title || '公告'
/** getRandomColor is a local helper used by this page script. */
const getRandomColor = (): string => {
const colors = ['var(--theme-primary-soft)', 'var(--secondary-bg-color)', 'var(--theme-page-bg)']
return colors[Math.floor(Math.random() * colors.length)] ?? 'var(--theme-primary-soft)'
}
/** getProductCoverUrl is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const getProductCoverUrl = async (product: ProductVO): Promise<string> => {
const cachedUrls = resolvePublicImageUrlsSync(product, '')
if (cachedUrls.length) return cachedUrls[0] || DEFAULT_PRODUCT_IMAGE
return resolvePublicImageUrl(product, DEFAULT_PRODUCT_IMAGE)
}
/** formatProductCards is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const formatProductCards = async (products: ProductVO[]): Promise<ProductCardItem[]> =>
Promise.all(products.map(async item => ({
id: item.id,
name: item.title || item.name || '未命名作品',
price: Number(item.price || 0).toFixed(2),
meta: item.approximateDuration || item.shopName || '支持预约',
shopName: item.shopName,
coverUrl: await getProductCoverUrl(item),
imageFileId: getPublicImageFileIds(item)[0],
bgColor: getRandomColor()
})))
/** appendPopularItems is a local helper used by this page script. */
const appendPopularItems = (loadMore = false) => {
const nextItems = popularSource.value.slice(0, page.value * pageSize)
popularItems.value = nextItems
hasMore.value = nextItems.length < popularSource.value.length
if (!loadMore && nextItems.length === 0) {
hasMore.value = false
}
}
/** loadUserInfo is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const loadUserInfo = async () => {
if (!isLoggedIn.value) {
userInfo.value = null
return
}
try {
const response = await userApi.getUserInfo()
userInfo.value = response || null
} catch (error) {
console.error('获取用户信息失败:', error)
userInfo.value = null
}
}
/** loadPublicShops is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const loadPublicShops = async () => {
try {
const shops = await shopApi.getPublicShops()
publicShops.value = Array.isArray(shops) ? shops : []
await loadBannerImages()
} catch (error) {
console.error('获取门店列表失败:', error)
publicShops.value = []
bannerImages.value = []
}
}
/** loadBannerImages is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const loadBannerImages = async () => {
const banners: BannerImage[] = []
for (const shop of publicShops.value) {
const imageRecord = {
coverImageFileId: shop.coverImageFileId,
imageFileIds: shop.imageFileIds,
imageUrls: shop.imageUrls
}
const fileId = getPublicImageFileIds(imageRecord)[0]
const url = await resolvePublicImageUrl(imageRecord, '')
if (url) {
banners.push({
id: `${shop.id}-${fileId || url}`,
shopId: shop.id,
shopName: shop.shopName,
businessHours: shop.businessHours,
url,
imageFileId: fileId
})
}
}
bannerImages.value = banners.slice(0, 8)
}
const replaceProductCardImage = (items: ProductCardItem[], productId: IdType, imageUrl: string): ProductCardItem[] =>
items.map(item => String(item.id) === String(productId) ? { ...item, coverUrl: imageUrl } : item)
const handleProductCardImageError = async (item: ProductCardItem) => {
const imageUrl = item.imageFileId ? await refreshPublicImageUrl(item.imageFileId, DEFAULT_PRODUCT_IMAGE) : DEFAULT_PRODUCT_IMAGE
newArrivalItems.value = replaceProductCardImage(newArrivalItems.value, item.id, imageUrl)
featuredItems.value = replaceProductCardImage(featuredItems.value, item.id, imageUrl)
popularSource.value = replaceProductCardImage(popularSource.value, item.id, imageUrl)
popularItems.value = replaceProductCardImage(popularItems.value, item.id, imageUrl)
}
const handleBannerImageError = async (shop: BannerImage) => {
const imageUrl = shop.imageFileId ? await refreshPublicImageUrl(shop.imageFileId, DEFAULT_PRODUCT_IMAGE) : DEFAULT_PRODUCT_IMAGE
bannerImages.value = bannerImages.value.map(item => item.id === shop.id ? { ...item, url: imageUrl } : item)
}
/** loadNewArrivalProducts fills the top carousel with products tagged as new arrivals. */
const loadNewArrivalProducts = async () => {
try {
const products = await productApi.getProductsByTag('新品')
newArrivalItems.value = await formatProductCards((Array.isArray(products) ? products : []).slice(0, 8))
} catch (error) {
console.error('获取新品作品失败:', error)
newArrivalItems.value = []
}
}
/** loadFeaturedProducts is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const loadFeaturedProducts = async () => {
try {
let products = await productApi.getProductsByTag('精选')
if (!Array.isArray(products) || products.length === 0) {
products = await productApi.getAllProducts()
}
featuredItems.value = await formatProductCards((products || []).slice(0, 6))
} catch (error) {
console.error('获取精选作品失败:', error)
featuredItems.value = []
}
}
/** loadPopularProducts is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const loadPopularProducts = async () => {
loading.value = true
try {
let products = await productApi.getProductsByTag('热门')
if (!Array.isArray(products) || products.length === 0) {
products = await productApi.getAllProducts()
}
popularSource.value = await formatProductCards(products || [])
page.value = 1
appendPopularItems()
} catch (error) {
console.error('获取热门作品失败:', error)
popularSource.value = []
popularItems.value = []
hasMore.value = false
} finally {
loading.value = false
}
}
/** loadAnnouncements is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
const loadAnnouncements = async () => {
if (!isLoggedIn.value) {
announcements.value = []
return
}
try {
announcements.value = (await userApi.listMyAnnouncements()) || []
} catch (error) {
console.error('加载公告失败:', error)
announcements.value = []
}
}
/** handleScroll is a local helper used by this page script. */
const handleScroll = () => {
if (loading.value || !hasMore.value) {
return
}
const scrollTop = document.documentElement.scrollTop || document.body.scrollTop
const scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight
const clientHeight = document.documentElement.clientHeight
if (scrollTop + clientHeight >= scrollHeight - 120) {
page.value += 1
appendPopularItems(true)
}
}
/** handleUserClick is a local helper used by this page script. */
const handleUserClick = () => {
if (isLoggedIn.value) {
router.push('/profile')
return
}
message.info('登录后可查看个人中心、收藏和订单')
router.push('/')
}
/** handleSearch is a local helper used by this page script. */
const handleSearch = () => {
const keyword = searchQuery.value.trim()
router.push(keyword ? { path: '/products', query: { keyword } } : '/products')
}
/** handleSeeAll is a local helper used by this page script. */
const handleSeeAll = (type: 'featured' | 'popular') => {
router.push({
path: '/products',
query: type === 'featured' ? { tag: '精选' } : { tag: '热门' }
})
}
/** handleProductClick is a local helper used by this page script. */
const handleProductClick = (item: ProductCardItem) => {
router.push(`/product/${item.id}`)
}
/** openShopById is a local helper used by this page script. */
const openShopById = (shopId: IdType) => {
router.push(`/shop/${shopId}`)
}
onMounted(async () => {
now.value = new Date()
greetingTimer = window.setInterval(() => {
now.value = new Date()
}, 60 * 1000)
const homeTasks = [
loadUserInfo(),
loadAnnouncements(),
loadNewArrivalProducts(),
loadFeaturedProducts(),
loadPopularProducts(),
loadPublicShops()
]
await Promise.all(homeTasks)
window.addEventListener('scroll', handleScroll)
})
onUnmounted(() => {
if (greetingTimer) {
window.clearInterval(greetingTimer)
}
window.removeEventListener('scroll', handleScroll)
})
</script>
<style scoped>
.mobile-container {
min-height: 100vh;
color: var(--text-primary);
background:
linear-gradient(color-mix(in srgb, var(--theme-card-bg) 68%, transparent), color-mix(in srgb, var(--theme-card-bg) 92%, transparent)),
var(--theme-background-image),
var(--theme-page-bg);
background-size: cover, cover, auto;
background-position: center top;
}
.header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 16px 20px 8px;
}
.user-info {
display: flex;
align-items: center;
gap: 12px;
cursor: pointer;
}
.greeting {
font-size: 12px;
color: var(--text-secondary);
margin: 0 0 2px;
}
.username {
font-size: 16px;
font-weight: 700;
margin: 0;
color: var(--text-primary);
}
.header-action {
border-radius: 999px;
}
.search-section {
padding: 8px 20px 0;
}
.announcement-bar {
margin: 12px 20px 0;
overflow: hidden;
border-radius: 8px;
background: var(--theme-primary-soft);
border: 1px solid var(--theme-border);
}
.announcement-track {
display: flex;
width: max-content;
gap: 32px;
padding: 9px 14px;
color: var(--theme-primary);
animation: announcement-scroll 22s linear infinite;
}
.announcement-item {
border: 0;
padding: 0;
background: transparent;
color: inherit;
cursor: pointer;
white-space: nowrap;
}
.announcement-item:hover {
color: var(--theme-accent);
}
.announcement-detail {
display: grid;
gap: 14px;
}
.announcement-detail__meta {
display: flex;
justify-content: space-between;
gap: 12px;
color: var(--text-secondary);
font-size: 13px;
}
.announcement-rich-content {
margin: 0;
color: var(--text-primary);
line-height: 1.8;
overflow-wrap: break-word;
}
.announcement-rich-content :deep(*) {
max-width: 100%;
}
.announcement-rich-content :deep(p),
.announcement-rich-content :deep(ul),
.announcement-rich-content :deep(ol),
.announcement-rich-content :deep(blockquote),
.announcement-rich-content :deep(pre),
.announcement-rich-content :deep(table) {
margin: 0 0 12px;
}
.announcement-rich-content :deep(p:last-child),
.announcement-rich-content :deep(ul:last-child),
.announcement-rich-content :deep(ol:last-child),
.announcement-rich-content :deep(blockquote:last-child),
.announcement-rich-content :deep(pre:last-child),
.announcement-rich-content :deep(table:last-child) {
margin-bottom: 0;
}
.announcement-rich-content :deep(ul),
.announcement-rich-content :deep(ol) {
padding-left: 1.25em;
}
.announcement-rich-content :deep(a) {
color: var(--theme-primary);
}
.announcement-rich-content :deep(img) {
display: block;
max-width: 100%;
border-radius: 8px;
}
.announcement-rich-content :deep(pre) {
overflow-x: auto;
padding: 10px 12px;
border-radius: 8px;
background: var(--theme-primary-soft);
}
@keyframes announcement-scroll {
from { transform: translateX(0); }
to { transform: translateX(-50%); }
}
.guest-alert {
margin: 16px 20px 0;
border-radius: 16px;
}
.banner-container {
padding: 0 20px;
}
.banner-carousel {
width: 100%;
border-radius: 18px;
overflow: hidden;
min-height: 220px;
box-shadow: 0 12px 30px color-mix(in srgb, var(--theme-neutral) 12%, transparent);
background: var(--theme-gradient-soft);
}
.banner-slide {
position: relative;
width: 100%;
aspect-ratio: 16 / 9;
cursor: pointer;
}
.banner-img {
width: 100%;
height: 100%;
object-fit: cover;
}
.banner-copy {
position: absolute;
left: 24px;
bottom: 24px;
padding: 16px 18px;
border-radius: 16px;
background: color-mix(in srgb, var(--theme-card-bg) 92%, transparent);
backdrop-filter: blur(6px);
box-shadow: 0 8px 20px color-mix(in srgb, var(--theme-neutral) 8%, transparent);
}
.banner-copy h3 {
margin: 10px 0 4px;
font-size: 19px;
color: var(--text-primary);
}
.banner-copy p {
margin: 0;
color: var(--text-secondary);
}
.banner-empty {
min-height: 220px;
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: center;
gap: 12px;
padding: 28px;
}
.banner-empty h3 {
margin: 0;
font-size: 21px;
color: var(--text-primary);
}
.banner-empty p {
margin: 0;
max-width: 360px;
color: var(--text-secondary);
line-height: 1.7;
}
.section {
padding: 24px 0 0;
}
.section-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 20px 14px;
}
.section-header h3 {
margin: 0;
font-size: 18px;
font-weight: 700;
}
.see-all {
color: var(--theme-primary);
font-size: 13px;
}
.horizontal-scroll {
display: flex;
gap: 14px;
overflow-x: auto;
padding: 0 20px;
scrollbar-width: none;
}
.horizontal-scroll::-webkit-scrollbar {
display: none;
}
.product-card {
border-radius: 18px;
}
.horizontal-scroll .product-card {
flex: 0 0 calc((100% - 14px) / 2);
width: calc((100% - 14px) / 2);
max-width: calc((100% - 14px) / 2);
}
.product-card :deep(.ant-card-body) {
padding: 12px 12px 16px;
}
.product-img {
width: 100%;
aspect-ratio: 1;
border-radius: 14px;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 10px;
font-size: 40px;
font-weight: 700;
color: color-mix(in srgb, var(--theme-neutral) 18%, transparent);
}
.product-cover {
width: 100%;
height: 100%;
object-fit: cover;
}
.name {
margin: 0 0 4px;
font-size: 14px;
font-weight: 600;
color: var(--text-primary);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.meta {
margin: 0 0 6px;
font-size: 12px;
color: var(--text-secondary);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.price {
margin: 0 0 2px;
font-size: 16px;
font-weight: 700;
line-height: 1.25;
color: var(--theme-primary-action);
}
.product-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 14px;
padding: 0 20px;
}
.grid-item {
width: 100%;
}
.loading-more,
.no-more,
.no-products {
display: flex;
justify-content: center;
align-items: center;
gap: 8px;
padding: 24px 0 36px;
color: var(--text-secondary);
}
@media (max-width: 420px) {
.header {
gap: 12px;
padding: 14px 16px 8px;
flex-wrap: wrap;
}
.user-info {
min-width: 0;
flex: 1 1 auto;
}
.welcome {
min-width: 0;
}
.greeting,
.username {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.header-action {
flex: 0 0 auto;
}
.search-section {
padding: 8px 16px 0;
}
.guest-alert {
margin: 14px 16px 0;
}
.banner-container,
.horizontal-scroll,
.product-grid {
padding-left: 16px;
padding-right: 16px;
}
.section-header {
padding: 0 16px 12px;
}
.banner-empty {
padding: 22px 18px;
}
.banner-empty h3 {
font-size: 20px;
line-height: 1.35;
}
.banner-empty p {
max-width: none;
font-size: 13px;
line-height: 1.6;
}
.banner-copy {
left: 16px;
right: 16px;
bottom: 16px;
padding: 12px 14px;
}
.banner-copy h3 {
font-size: 18px;
}
.banner-copy p {
font-size: 13px;
}
}
@media (min-width: 992px) {
.header,
.search-section,
.section,
.guest-alert {
max-width: var(--frontend-content-max-width);
margin-left: auto;
margin-right: auto;
}
.banner-container {
padding: 0 24px;
}
.banner-carousel {
max-width: var(--frontend-content-max-width);
}
.horizontal-scroll {
overflow: visible;
flex-wrap: wrap;
}
.horizontal-scroll .product-card {
flex: 0 0 calc(25% - 12px);
width: calc(25% - 12px);
max-width: calc(25% - 12px);
min-width: 180px;
}
.product-grid {
grid-template-columns: repeat(4, minmax(0, 1fr));
}
.product-grid .product-card {
width: 100%;
max-width: none;
min-width: 0;
}
}
.home-page {
min-height: 100vh;
padding: 0 0 calc(86px + env(safe-area-inset-bottom, 0px));
background:
radial-gradient(circle at 86% -4%, color-mix(in srgb, var(--theme-primary) 28%, transparent), transparent 30%),
linear-gradient(180deg, color-mix(in srgb, var(--theme-card-bg) 76%, transparent), var(--theme-page-bg) 42%, color-mix(in srgb, var(--theme-secondary) 10%, var(--theme-page-bg)));
}
.home-topbar {
position: sticky;
top: 0;
z-index: 40;
display: grid;
grid-template-columns: 42px minmax(0, 1fr) 42px;
align-items: center;
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 {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
padding: 6px 18px 0;
}
.hero-copy {
min-width: 0;
}
.hero-greeting {
display: flex;
min-width: 0;
align-items: baseline;
margin: 0;
color: var(--text-primary);
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;
gap: 8px;
margin: 7px 0 0;
}
.member-line span {
display: inline-block;
width: 7px;
height: 7px;
border-radius: 999px;
background: var(--theme-secondary);
}
.member-line p {
margin: 0;
color: var(--text-secondary);
font-size: 12px;
line-height: 1.5;
}
.avatar-button {
flex: 0 0 auto;
border: 2px solid var(--theme-card-bg);
border-radius: 999px;
background: transparent;
box-shadow: 0 12px 24px color-mix(in srgb, var(--theme-primary) 22%, transparent);
cursor: pointer;
}
.search-card {
display: flex;
align-items: center;
gap: 8px;
height: 42px;
margin: 16px 18px 0;
padding: 0 7px 0 13px;
border: 1px solid color-mix(in srgb, var(--theme-primary) 28%, var(--theme-border));
border-radius: 13px;
background: color-mix(in srgb, var(--theme-card-bg) 92%, transparent);
box-shadow: 0 14px 28px color-mix(in srgb, var(--theme-neutral) 6%, transparent);
}
.search-card__icon {
color: var(--text-secondary);
font-size: 15px;
}
.search-card input {
min-width: 0;
flex: 1;
border: 0;
outline: 0;
color: var(--text-primary);
background: transparent;
font-size: 13px;
}
.search-card input::placeholder {
color: color-mix(in srgb, var(--text-secondary) 70%, var(--theme-card-bg));
}
.search-card button {
height: 30px;
min-width: 58px;
border: 0;
border-radius: 10px;
color: var(--theme-card-bg);
background: linear-gradient(135deg, var(--theme-primary-action), var(--theme-secondary));
font-size: 13px;
font-weight: 800;
cursor: pointer;
}
.announcement-bar {
margin: 12px 18px 0;
border-color: color-mix(in srgb, var(--theme-secondary) 28%, var(--theme-border));
border-radius: 14px;
background: color-mix(in srgb, var(--theme-secondary) 14%, var(--theme-card-bg));
}
.announcement-track {
color: var(--theme-primary-action);
}
.feature-banner {
position: relative;
aspect-ratio: 4 / 3;
min-height: 132px;
margin: 16px 18px 0;
overflow: hidden;
border-radius: 22px;
background: var(--theme-gradient-soft);
box-shadow: 0 20px 42px color-mix(in srgb, var(--theme-neutral) 13%, transparent);
cursor: pointer;
}
.new-arrival-carousel,
.new-arrival-card,
.new-arrival-slide,
.new-arrival-carousel :deep(.slick-slider),
.new-arrival-carousel :deep(.slick-list),
.new-arrival-carousel :deep(.slick-track),
.new-arrival-carousel :deep(.slick-slide),
.new-arrival-carousel :deep(.slick-slide > div) {
height: 100% !important;
min-height: 100%;
}
.new-arrival-carousel,
.new-arrival-card {
position: absolute;
inset: 0;
}
.new-arrival-card {
display: block;
width: 100%;
height: 100%;
overflow: hidden;
border: 0;
background: transparent;
color: inherit;
cursor: pointer;
text-align: left;
}
.new-arrival-slide {
position: relative;
width: 100%;
}
.new-arrival-carousel :deep(.slick-dots) {
right: 16px;
bottom: 14px;
left: auto;
z-index: 2;
width: auto;
}
.new-arrival-carousel :deep(.slick-dots li button) {
width: 7px;
height: 7px;
border-radius: 999px;
background: color-mix(in srgb, var(--theme-card-bg) 78%, transparent);
opacity: 1;
}
.new-arrival-carousel :deep(.slick-dots li.slick-active button) {
width: 18px;
background: var(--theme-card-bg);
}
.feature-banner__image {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
object-fit: cover;
object-position: center;
}
.feature-banner__shade {
position: absolute;
inset: 0;
background:
linear-gradient(90deg, color-mix(in srgb, var(--theme-neutral) 58%, transparent), transparent 76%),
linear-gradient(180deg, transparent, color-mix(in srgb, var(--theme-neutral) 30%, transparent));
}
.feature-banner__copy {
position: relative;
z-index: 1;
display: flex;
height: 100%;
min-height: 0;
max-width: 72%;
flex-direction: column;
justify-content: flex-end;
padding: 18px;
color: var(--theme-card-bg);
}
.feature-banner__copy span {
width: fit-content;
margin-bottom: 8px;
padding: 4px 8px;
border-radius: 999px;
background: color-mix(in srgb, var(--theme-card-bg) 20%, transparent);
font-size: 11px;
font-weight: 800;
backdrop-filter: blur(10px);
}
.feature-banner__copy h2 {
margin: 0;
font-size: 21px;
font-weight: 850;
line-height: 1.08;
}
.feature-banner__copy p {
margin: 6px 0 0;
font-size: 12px;
line-height: 1.5;
opacity: 0.92;
}
.quick-actions {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 10px;
margin: 16px 18px 0;
}
.quick-actions button {
display: grid;
justify-items: center;
gap: 6px;
border: 0;
background: transparent;
color: var(--text-secondary);
cursor: pointer;
}
.quick-actions span {
display: inline-flex;
align-items: center;
justify-content: center;
width: 42px;
height: 42px;
border: 1px solid color-mix(in srgb, var(--theme-primary) 24%, var(--theme-border));
border-radius: 14px;
color: var(--theme-primary-action);
background: color-mix(in srgb, var(--theme-card-bg) 82%, var(--theme-primary-soft));
box-shadow: 0 12px 24px color-mix(in srgb, var(--theme-neutral) 6%, transparent);
}
.quick-actions b {
font-size: 11px;
font-weight: 700;
}
.home-page .section {
padding: 22px 0 0;
}
.home-page .section-header {
align-items: flex-end;
padding: 0 18px 13px;
}
.section-kicker {
display: block;
margin-bottom: 2px;
color: var(--theme-secondary);
font-family: Georgia, 'Times New Roman', serif;
font-size: 11px;
font-weight: 700;
}
.home-page .section-header h3 {
color: var(--text-primary);
font-size: 17px;
font-weight: 820;
}
.home-page .see-all {
display: inline-flex;
align-items: center;
gap: 4px;
border: 0;
background: transparent;
color: var(--theme-primary-action);
font-size: 12px;
font-weight: 700;
cursor: pointer;
}
.home-page .product-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 14px;
padding: 0 18px;
}
.home-page .product-card {
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;
border-radius: 18px;
background: var(--theme-primary-soft);
box-shadow: 0 16px 28px color-mix(in srgb, var(--theme-neutral) 8%, transparent);
}
.home-page .name {
margin-bottom: 4px;
font-size: 13px;
font-weight: 780;
}
.home-page .meta {
margin-bottom: 7px;
color: var(--text-secondary);
font-size: 11px;
}
.product-foot {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
min-height: 22px;
padding-bottom: 3px;
}
.home-page .price {
color: var(--theme-primary-action);
font-size: 14px;
font-weight: 820;
}
.product-foot span {
min-width: 0;
overflow: hidden;
color: var(--theme-secondary);
font-size: 11px;
font-weight: 700;
text-overflow: ellipsis;
white-space: nowrap;
}
.shop-strip {
display: flex;
gap: 12px;
overflow-x: auto;
padding: 0 18px 4px;
scrollbar-width: none;
}
.shop-strip::-webkit-scrollbar {
display: none;
}
.shop-card {
position: relative;
flex: 0 0 168px;
height: 108px;
overflow: hidden;
border: 0;
border-radius: 18px;
color: var(--theme-card-bg);
background: var(--theme-primary-soft);
box-shadow: 0 16px 30px color-mix(in srgb, var(--theme-neutral) 10%, transparent);
cursor: pointer;
}
.shop-card img {
width: 100%;
height: 100%;
object-fit: cover;
}
.shop-card::after {
content: '';
position: absolute;
inset: 0;
background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--theme-neutral) 46%, transparent));
}
.shop-card span {
position: absolute;
right: 12px;
bottom: 10px;
left: 12px;
z-index: 1;
overflow: hidden;
font-size: 13px;
font-weight: 800;
text-align: left;
text-overflow: ellipsis;
white-space: nowrap;
}
@media (max-width: 360px) {
.hero-greeting {
font-size: 20px;
}
.quick-actions {
gap: 6px;
}
.quick-actions span {
width: 38px;
height: 38px;
}
}
</style>