2026-02-13 17:34:32 +08:00
< template >
2026-05-29 13:30:56 +08:00
< div class = "mobile-container product-list-page" >
< header class = "gallery-header" >
< a-button class = "icon-btn" type = "text" aria -label =" 返回首页 " @click ="handleBackClick" >
< MenuOutlined />
2026-02-13 17:34:32 +08:00
</ a-button >
2026-05-29 13:30:56 +08:00
< div class = "brand-lockup" aria -label =" YumiNail 作品列表 " >
< span class = "brand-kicker" > Nail Gallery </ span >
< h1 > YumiNail </ h1 >
2026-03-05 16:02:34 +08:00
</ div >
2026-05-29 13:30:56 +08:00
< a-button class = "icon-btn icon-btn--bag" type = "text" aria -label =" 前往购物车 " @click ="router.push('/cart')" >
< ShoppingOutlined />
< span class = "bag-dot" aria -hidden =" true " ></ span >
2026-02-13 17:34:32 +08:00
</ a-button >
</ header >
2026-05-29 13:30:56 +08:00
< main class = "gallery-content" >
< section class = "search-panel" aria -label =" 作品搜索与筛选 " >
< div class = "search-field" >
< SearchOutlined class = "search-field__icon" />
< input
v-model = "searchKeyword"
class = "search-field__input"
type = "search"
placeholder = "搜索美甲款式..."
@keydown.enter ="handleSearch"
/>
2026-05-23 21:56:18 +08:00
< button
2026-05-29 13:30:56 +08:00
type = "button"
class = "search-field__action"
@click ="handleSearch"
>
搜索
</ button >
</ div >
< div class = "category-rail" aria -label =" 作品分类 " >
< button
class = "category-item"
: class = "{ active: selectedCategory === '全部' }"
type = "button"
@click ="handleCategoryClick('全部')"
>
全部风格
</ button >
< button
v-for = "tag in allTags"
2026-05-23 21:56:18 +08:00
:key = "tag.id"
class = "category-item"
: class = "{ active: selectedTagId === String(tag.id) }"
type = "button"
@click ="handleTagClick(tag)"
>
{{ tag . displayName || tag . tagName }}
</ button >
2026-02-13 17:34:32 +08:00
</ div >
2026-05-29 13:30:56 +08:00
</ section >
< div v-if = "activeBannerText" class="page-banner" role="status" >
{{ activeBannerText }}
2026-02-13 17:34:32 +08:00
</ div >
2026-05-29 13:30:56 +08:00
< section class = "product-section" aria -label =" 作品列表 " >
2026-02-13 17:34:32 +08:00
< div class = "product-grid" >
2026-05-29 13:30:56 +08:00
< article
2026-02-13 17:34:32 +08:00
v-for = "item in products"
:key = "item.id"
class = "product-card"
2026-05-29 13:30:56 +08:00
role = "button"
tabindex = "0"
2026-02-13 17:34:32 +08:00
@click ="handleProductClick(item)"
2026-05-29 13:30:56 +08:00
@keydown.enter ="handleProductClick(item)"
@keydown.space.prevent ="handleProductClick(item)"
2026-02-13 17:34:32 +08:00
>
2026-05-29 13:30:56 +08:00
< div class = "product-media" >
< div class = "product-img" >
< img
v-if = "getProductImages(item).length > 0"
:src = "getProductImages(item)[0]"
: alt = "item.title || item.name"
class = "product-image"
loading = "lazy"
decoding = "async"
/>
< div v-else class = "product-img-placeholder" >
< span >{{ ( item . title || item . name ) ? .[ 0 ] || '作' }}</ span >
</ div >
2026-02-24 09:59:22 +08:00
</ div >
</ div >
2026-03-26 10:28:28 +08:00
2026-02-24 09:59:22 +08:00
< div class = "product-info" >
2026-05-29 13:30:56 +08:00
< div class = "product-head" >
< div class = "product-title-block" >
< h2 class = "name" >{{ item . title || item . name }}</ h2 >
< p v-if = "item.shopName" class="shop-name" >{{ item.shopName }}</ p >
< div class = "duration" >
< ClockCircleOutlined />
< span >{{ item . approximateDuration || '时长待定' }}</ span >
</ div >
2026-02-24 09:59:22 +08:00
</ div >
2026-05-29 13:30:56 +08:00
< button
class = "cart-btn"
: class = "{ 'cart-btn-in-cart': item.inCart }"
type = "button"
: aria -label =" item.inCart ? ' 购物车已有 ' : ` 加入购物车 : ${ item.title || item.name || ' 作品 ' } `"
@click.stop ="handleAddToCart(item)"
>
< CheckOutlined v-if = "item.inCart" />
< PlusOutlined v-else />
</ button >
2026-02-24 09:59:22 +08:00
</ div >
2026-03-26 10:28:28 +08:00
2026-02-24 09:59:22 +08:00
< div class = "product-tags" >
2026-03-26 10:28:28 +08:00
< template v-if = "item.tagInfos?.length" >
< a-tag
2026-03-03 17:50:10 +08:00
v-for = "tag in item.tagInfos"
:key = "tag.id"
size = "small"
: style = "{
2026-03-26 10:28:28 +08:00
marginRight: '4px',
2026-03-03 17:50:10 +08:00
marginBottom: '4px',
2026-05-29 13:30:56 +08:00
color: tag.textColor || 'var(--text-primary)',
backgroundColor: tag.bgColor || 'var(--theme-primary-soft)',
borderColor: tag.borderColor || 'var(--theme-border)'
2026-03-03 17:50:10 +08:00
}"
>
{{ tag . tagName }}
</ a-tag >
</ template >
2026-05-29 13:30:56 +08:00
< a-tag v-else size = "small" color = "default" > 精选款式 </ a-tag >
2026-02-24 09:59:22 +08:00
</ div >
2026-03-26 10:28:28 +08:00
2026-05-29 13:30:56 +08:00
< div class = "card-foot" >
2026-03-26 10:28:28 +08:00
< p class = "price" > ¥ {{ Number ( item . price || 0 ). toFixed ( 2 ) }}</ p >
2026-05-29 13:30:56 +08:00
< div class = "stats" >
< span >< HeartOutlined />{{ item . likeCount || 0 }}</ span >
< span >< StarOutlined />{{ item . collectCount || 0 }}</ span >
2026-05-13 12:43:01 +08:00
</ div >
2026-02-24 09:59:22 +08:00
</ div >
</ div >
2026-05-29 13:30:56 +08:00
</ article >
2026-02-13 17:34:32 +08:00
</ div >
2026-02-24 09:59:22 +08:00
< div v-if = "products.length === 0 && !loading" class="empty-state" >
2026-03-26 10:28:28 +08:00
< a-empty description = "暂时没有匹配的作品" >
< a-button type = "primary" @click ="resetFilters" > 查看全部作品 </ a -button >
</ a-empty >
2026-02-24 09:59:22 +08:00
</ div >
2026-03-26 10:28:28 +08:00
< div v-if = "loading" class="loading-state" >
< a-spin />
2026-02-24 09:59:22 +08:00
</ div >
2026-05-29 13:30:56 +08:00
</ section >
</ main >
2026-02-13 17:34:32 +08:00
</ div >
</ template >
< script setup lang = "ts" >
2026-05-18 09:46:11 +08:00
/**
* ProductListView page script.
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
*/
2026-03-26 10:28:28 +08:00
import { onMounted , ref , watch , inject , computed } from 'vue'
import { useRouter , useRoute } from 'vue-router'
2026-05-29 13:30:56 +08:00
import {
CheckOutlined ,
ClockCircleOutlined ,
HeartOutlined ,
MenuOutlined ,
PlusOutlined ,
SearchOutlined ,
ShoppingOutlined ,
StarOutlined
} from '@ant-design/icons-vue'
2026-02-13 17:34:32 +08:00
import { message } from 'ant-design-vue'
2026-05-23 18:44:57 +08:00
/**
* Purpose: ProductVO supports ProductListView.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.
*/
2026-02-24 09:59:22 +08:00
import { productApi , type ProductVO } from '@/api/product'
2026-05-23 18:44:57 +08:00
/**
* Purpose: TagVO supports ProductListView.vue by holding or executing the tag 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.
*/
2026-05-23 21:56:18 +08:00
import { tagApi , type TagFilterGroupVO , type TagVO } from '@/api/tag'
2026-02-27 15:57:22 +08:00
import { cartApi } from '@/api/cart'
2026-05-13 12:43:01 +08:00
import { runWithGlobalLoading } from '@/utils/action-loading'
import { fetchCartProductIdSet , hasCartProduct , withAddedCartProduct } from '@/utils/cart-state'
2026-05-29 13:30:56 +08:00
import { getCachedSignedImageUrls , getCachedSignedImageUrlsSync , parseImageFileIds } from '@/utils/signed-image-cache'
2026-05-13 12:43:01 +08:00
2026-05-23 18:44:57 +08:00
/**
* Purpose: ProductListItem supports ProductListView.vue by holding or executing the product list item 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.
*/
2026-05-13 12:43:01 +08:00
type ProductListItem = ProductVO & {
inCart ?: boolean
}
2026-02-13 17:34:32 +08:00
2026-05-23 18:44:57 +08:00
/**
* Purpose: router supports ProductListView.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.
*/
2026-03-26 10:28:28 +08:00
const router = useRouter ()
2026-05-23 18:44:57 +08:00
/**
* Purpose: route supports ProductListView.vue by holding or executing the route 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.
*/
2026-03-26 10:28:28 +08:00
const route = useRoute ()
2026-05-23 18:44:57 +08:00
/**
* Purpose: updateCartCount supports ProductListView.vue by holding or executing the update cart count 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.
*/
2026-03-19 20:51:07 +08:00
const updateCartCount = inject < () => Promise < void > > ( 'updateCartCount' , async () => {})
2026-03-05 16:28:05 +08:00
2026-05-23 21:56:18 +08:00
/** filterGroups stores scene-based tag filters shown above the product grid. */
const filterGroups = ref < TagFilterGroupVO [] >([])
/** allTags flattens filter groups for route/query lookup. */
const allTags = computed (() => filterGroups . value . flatMap ( group => group . tags || []))
2026-05-18 09:46:11 +08:00
/** selectedCategory is a reactive state variable used by the template and event handlers. */
2026-03-26 10:28:28 +08:00
const selectedCategory = ref ( '全部' )
2026-05-23 21:56:18 +08:00
/** selectedTagId tracks the grouped filter id sent to the backend. */
const selectedTagId = ref ( '' )
2026-05-23 18:44:57 +08:00
/**
* Purpose: products supports ProductListView.vue by holding or executing the products 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.
*/
2026-05-13 12:43:01 +08:00
const products = ref < ProductListItem [] >([])
2026-05-18 09:46:11 +08:00
/** loading is a reactive state variable used by the template and event handlers. */
2026-02-24 09:59:22 +08:00
const loading = ref ( false )
2026-05-18 09:46:11 +08:00
/** showSearch is a reactive state variable used by the template and event handlers. */
2026-03-05 16:02:34 +08:00
const showSearch = ref ( false )
2026-05-18 09:46:11 +08:00
/** searchKeyword is a reactive state variable used by the template and event handlers. */
2026-03-05 16:02:34 +08:00
const searchKeyword = ref ( '' )
2026-05-23 18:44:57 +08:00
/**
* Purpose: imageUrls supports ProductListView.vue by holding or executing the image urls 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.
*/
2026-03-27 14:55:41 +08:00
const imageUrls = ref < Record < string , string [] > > ({})
2026-05-18 09:46:11 +08:00
/** cartProductIdSet is a reactive state variable used by the template and event handlers. */
2026-05-13 12:43:01 +08:00
const cartProductIdSet = ref ( new Set < string >())
2026-05-23 18:44:57 +08:00
/**
* Purpose: useGlobalLoadingForNextRouteSync supports ProductListView.vue by holding or executing the use global loading for next route sync page or API role.
* Usage: import, call, read, or update this let from the owning page/module while preserving the surrounding loading and permission flow.
*/
2026-05-13 12:43:01 +08:00
let useGlobalLoadingForNextRouteSync = false
2026-02-26 11:16:24 +08:00
2026-05-18 09:46:11 +08:00
/** isLoggedIn is a reactive state variable used by the template and event handlers. */
2026-03-26 10:28:28 +08:00
const isLoggedIn = computed (() => Boolean ( localStorage . getItem ( 'accessToken' ) || sessionStorage . getItem ( 'accessToken' )))
2026-05-18 09:46:11 +08:00
/** activeBannerText is a reactive state variable used by the template and event handlers. */
2026-03-26 10:28:28 +08:00
const activeBannerText = computed (() => {
if ( searchKeyword . value . trim ()) {
2026-05-13 12:43:01 +08:00
return `当前显示“ ${ searchKeyword . value . trim () } ”的匹配结果`
2026-03-26 10:28:28 +08:00
}
if ( selectedCategory . value !== '全部' ) {
2026-05-23 21:56:18 +08:00
return `当前按场景“ ${ selectedCategory . value } ”筛选`
2026-03-26 10:28:28 +08:00
}
return ''
})
2026-05-23 18:44:57 +08:00
/**
* Purpose: DEFAULT_PRODUCT_IMAGE supports ProductListView.vue by holding or executing the default product image 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.
*/
2026-03-26 10:28:28 +08:00
const DEFAULT_PRODUCT_IMAGE = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCBmaWxsPSIjZjVmNWY1IiB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIvPjx0ZXh0IHg9IjUwJSIgeT0iNTAlIiBmaWxsPSIjYmZiZmJmIiBmb250LXNpemU9IjI0IiB0ZXh0LWFuY2hvcj0ibWlkZGxlIiBkeT0iLjNlbSI+YWFhPC90ZXh0Pjwvc3ZnPg=='
2026-05-18 09:46:11 +08:00
/** ensureLoginForAction is a local helper used by this page script. */
2026-03-26 10:28:28 +08:00
const ensureLoginForAction = ( actionText : string ) => {
if ( isLoggedIn . value ) {
return true
}
message . info ( ` ${ actionText } 前请先登录账号` )
router . push ( '/' )
return false
}
2026-05-18 09:46:11 +08:00
/** loadImageUrls is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-03-26 10:28:28 +08:00
const loadImageUrls = async ( productList : ProductVO []) => {
for ( const product of productList ) {
if ( ! product . imageFileIds ) {
2026-03-27 14:55:41 +08:00
imageUrls . value [ String ( product . id )] = [ DEFAULT_PRODUCT_IMAGE ]
2026-03-26 10:28:28 +08:00
continue
}
2026-05-29 13:30:56 +08:00
const ids = parseImageFileIds ( product . imageFileIds )
const cachedUrls = getCachedSignedImageUrlsSync ( ids )
if ( cachedUrls . length ) {
imageUrls . value [ String ( product . id )] = cachedUrls
2026-03-26 10:28:28 +08:00
}
2026-05-29 13:30:56 +08:00
const urls = await getCachedSignedImageUrls ( ids , DEFAULT_PRODUCT_IMAGE )
2026-03-27 14:55:41 +08:00
imageUrls . value [ String ( product . id )] = urls . length ? urls : [ DEFAULT_PRODUCT_IMAGE ]
2026-03-26 10:28:28 +08:00
}
}
2026-05-18 09:46:11 +08:00
/** getProductImages is a local helper used by this page script. */
2026-03-27 14:55:41 +08:00
const getProductImages = ( product : ProductVO ) : string [] => imageUrls . value [ String ( product . id )] || [ DEFAULT_PRODUCT_IMAGE ]
2026-03-26 10:28:28 +08:00
2026-05-18 09:46:11 +08:00
/** markProductsInCart is a local helper used by this page script. */
2026-05-13 12:43:01 +08:00
const markProductsInCart = ( productList : ProductVO []) => {
return ( Array . isArray ( productList ) ? productList : []). map ( item => ({
... item ,
inCart : hasCartProduct ( cartProductIdSet . value , item . id )
}))
}
2026-05-18 09:46:11 +08:00
/** syncCartProductState is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-05-13 12:43:01 +08:00
const syncCartProductState = async () => {
if ( ! isLoggedIn . value ) {
cartProductIdSet . value = new Set ()
return
}
cartProductIdSet . value = await fetchCartProductIdSet ()
}
2026-05-18 09:46:11 +08:00
/** fetchTags is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-02-24 09:59:22 +08:00
const fetchTags = async () => {
try {
2026-05-23 21:56:18 +08:00
const response = await tagApi . getFilterOptions () as unknown as TagFilterGroupVO []
filterGroups . value = Array . isArray ( response ) ? response : []
2026-05-13 12:43:01 +08:00
} catch ( error : any ) {
2026-02-24 09:59:22 +08:00
console . error ( '获取标签失败:' , error )
2026-05-23 21:56:18 +08:00
filterGroups . value = []
2026-02-24 09:59:22 +08:00
}
}
2026-05-18 09:46:11 +08:00
/** fetchProducts is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-02-24 09:59:22 +08:00
const fetchProducts = async () => {
loading . value = true
try {
2026-03-26 10:28:28 +08:00
let response : ProductVO [] = []
const keyword = searchKeyword . value . trim ()
if ( keyword ) {
response = await productApi . searchProducts ( keyword )
2026-05-23 21:56:18 +08:00
} else if ( ! selectedTagId . value ) {
2026-03-26 10:28:28 +08:00
response = await productApi . getAllProducts ()
2026-02-24 09:59:22 +08:00
} else {
2026-05-23 21:56:18 +08:00
const pageResult = await productApi . getProductPage ({
page : 1 ,
size : 200 ,
tagIds : selectedTagId . value
})
response = pageResult . list || []
2026-02-24 09:59:22 +08:00
}
2026-03-26 10:28:28 +08:00
2026-05-13 12:43:01 +08:00
products . value = markProductsInCart ( Array . isArray ( response ) ? response : [])
2026-03-03 17:50:10 +08:00
await loadImageUrls ( products . value )
2026-05-13 12:43:01 +08:00
} catch ( error : any ) {
2026-03-26 10:28:28 +08:00
console . error ( '获取作品列表失败:' , error )
2026-05-13 12:43:01 +08:00
message . error ( error ? . message || '加载作品列表失败,请稍后重试' )
2026-03-26 10:28:28 +08:00
products . value = []
2026-02-24 09:59:22 +08:00
} finally {
loading . value = false
}
2026-02-26 11:16:24 +08:00
}
2026-05-18 09:46:11 +08:00
/** syncRouteFilters is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-03-26 10:28:28 +08:00
const syncRouteFilters = async () => {
2026-05-13 12:43:01 +08:00
await syncCartProductState ()
2026-03-26 10:28:28 +08:00
const keyword = typeof route . query . keyword === 'string' ? route . query . keyword . trim () : ''
const tag = typeof route . query . tag === 'string' ? route . query . tag . trim () : ''
2026-05-23 21:56:18 +08:00
const tagId = typeof route . query . tagId === 'string' ? route . query . tagId . trim () : ''
const matchedTag = tagId
? allTags . value . find ( item => String ( item . id ) === tagId )
: allTags . value . find ( item => item . tagName === tag || item . displayName === tag )
2026-02-26 11:16:24 +08:00
2026-03-26 10:28:28 +08:00
searchKeyword . value = keyword
showSearch . value = Boolean ( keyword )
2026-05-23 21:56:18 +08:00
selectedTagId . value = matchedTag ? String ( matchedTag . id ) : ''
selectedCategory . value = matchedTag ? ( matchedTag . displayName || matchedTag . tagName ) : '全部'
2026-05-13 12:43:01 +08:00
if ( useGlobalLoadingForNextRouteSync ) {
useGlobalLoadingForNextRouteSync = false
await runWithGlobalLoading (() => fetchProducts ())
return
}
2026-03-26 10:28:28 +08:00
await fetchProducts ()
}
2026-02-24 09:59:22 +08:00
2026-05-18 09:46:11 +08:00
/** handleBackClick is a local helper used by this page script. */
2026-02-13 17:34:32 +08:00
const handleBackClick = () => {
2026-03-26 10:28:28 +08:00
router . push ( '/home' )
2026-02-13 17:34:32 +08:00
}
2026-05-18 09:46:11 +08:00
/** handleCategoryClick is a local helper used by this page script. */
2026-02-13 17:34:32 +08:00
const handleCategoryClick = ( category : string ) => {
selectedCategory . value = category
2026-05-23 21:56:18 +08:00
selectedTagId . value = ''
searchKeyword . value = ''
showSearch . value = false
useGlobalLoadingForNextRouteSync = true
router . replace ({ path : '/products' , query : {} })
}
/** handleTagClick is a local helper used by grouped scene-filter chips. */
const handleTagClick = ( tag : TagVO ) => {
selectedCategory . value = tag . displayName || tag . tagName
selectedTagId . value = String ( tag . id )
2026-03-05 16:02:34 +08:00
searchKeyword . value = ''
2026-03-26 10:28:28 +08:00
showSearch . value = false
2026-05-13 12:43:01 +08:00
useGlobalLoadingForNextRouteSync = true
2026-03-26 10:28:28 +08:00
router . replace ({
path : '/products' ,
2026-05-23 21:56:18 +08:00
query : { tag : tag . displayName || tag . tagName , tagId : String ( tag . id ) }
2026-03-26 10:28:28 +08:00
})
2026-02-13 17:34:32 +08:00
}
2026-05-18 09:46:11 +08:00
/** handleProductClick is a local helper used by this page script. */
2026-03-26 10:28:28 +08:00
const handleProductClick = ( item : ProductVO ) => {
2026-02-13 17:34:32 +08:00
router . push ( `/product/ ${ item . id } ` )
}
2026-05-18 09:46:11 +08:00
/** handleAddToCart is an async page action. Trigger it from the template or lifecycle hook, then await the result. */
2026-05-13 12:43:01 +08:00
const handleAddToCart = async ( item : ProductListItem ) => {
2026-03-26 10:28:28 +08:00
if ( ! ensureLoginForAction ( '加入购物车' )) {
return
}
2026-05-13 12:43:01 +08:00
if ( hasCartProduct ( cartProductIdSet . value , item . id )) {
message . info ( '购物车已有' )
return
}
2026-02-27 15:57:22 +08:00
try {
2026-05-13 12:43:01 +08:00
await runWithGlobalLoading (() => cartApi . addToCart ({ productId : item . id , quantity : 1 }))
cartProductIdSet . value = withAddedCartProduct ( cartProductIdSet . value , item . id )
products . value = markProductsInCart ( products . value )
2026-03-19 20:51:07 +08:00
await updateCartCount ()
2026-03-26 10:28:28 +08:00
message . success ( `已将 ${ item . title || item . name || '作品' } 加入购物车` )
2026-05-13 12:43:01 +08:00
} catch ( error : any ) {
2026-03-26 10:28:28 +08:00
console . error ( '加入购物车失败:' , error )
2026-05-13 12:43:01 +08:00
message . error ( error ? . message || '加入购物车失败,请稍后重试' )
2026-02-27 15:57:22 +08:00
}
2026-02-13 17:34:32 +08:00
}
2026-05-18 09:46:11 +08:00
/** handleSearch is a local helper used by this page script. */
2026-03-26 10:28:28 +08:00
const handleSearch = () => {
const keyword = searchKeyword . value . trim ()
2026-05-13 12:43:01 +08:00
useGlobalLoadingForNextRouteSync = true
2026-03-26 10:28:28 +08:00
router . replace ({
path : '/products' ,
query : keyword ? { keyword } : {}
})
2026-02-13 17:34:32 +08:00
}
2026-02-24 09:59:22 +08:00
2026-05-18 09:46:11 +08:00
/** resetFilters is a local helper used by this page script. */
2026-03-26 10:28:28 +08:00
const resetFilters = () => {
selectedCategory . value = '全部'
2026-05-23 21:56:18 +08:00
selectedTagId . value = ''
2026-03-26 10:28:28 +08:00
searchKeyword . value = ''
showSearch . value = false
2026-05-13 12:43:01 +08:00
useGlobalLoadingForNextRouteSync = true
2026-03-26 10:28:28 +08:00
router . replace ( '/products' )
2026-03-05 16:02:34 +08:00
}
2026-03-26 10:28:28 +08:00
watch (
() => route . query ,
async () => {
await syncRouteFilters ()
},
{ deep : true }
)
2026-02-24 11:34:25 +08:00
onMounted ( async () => {
await fetchTags ()
2026-03-26 10:28:28 +08:00
await syncRouteFilters ()
2026-02-24 09:59:22 +08:00
})
2026-02-13 17:34:32 +08:00
</ script >
< style scoped >
2026-05-29 13:30:56 +08:00
. product - list - page {
-- gallery - header - height : 64 px ;
-- gallery - gutter : 20 px ;
-- gallery - surface : color - mix ( in srgb , var ( -- theme - card - bg ) 76 % , transparent );
-- gallery - surface - strong : color - mix ( in srgb , var ( -- theme - card - bg ) 90 % , transparent );
-- gallery - border : color - mix ( in srgb , var ( -- theme - border ) 72 % , var ( -- theme - card - bg ));
-- gallery - muted : color - mix ( in srgb , var ( -- text - secondary ) 78 % , var ( -- theme - card - bg ));
-- gallery - shadow : 0 18 px 44 px color - mix ( in srgb , var ( -- theme - neutral ) 11 % , transparent );
-- gallery - soft - shadow : 0 10 px 30 px color - mix ( in srgb , var ( -- theme - primary ) 14 % , transparent );
2026-02-13 17:34:32 +08:00
min - height : 100 vh ;
2026-05-29 13:30:56 +08:00
padding : var ( -- gallery - header - height ) 0 calc ( 104 px + env ( safe - area - inset - bottom , 0 px ));
2026-05-21 18:43:59 +08:00
color : var ( -- text - primary );
background :
2026-05-29 13:30:56 +08:00
radial - gradient ( circle at 18 % 5 % , color - mix ( in srgb , var ( -- theme - secondary ) 22 % , transparent ) 0 , transparent 30 % ),
radial - gradient ( circle at 86 % 10 % , color - mix ( in srgb , var ( -- theme - primary ) 26 % , transparent ) 0 , transparent 34 % ),
linear - gradient ( 180 deg , color - mix ( in srgb , var ( -- theme - tertiary ) 96 % , var ( -- theme - card - bg )) 0 % , var ( -- theme - page - bg ) 62 % , var ( -- theme - primary - soft ) 100 % );
2026-02-13 17:34:32 +08:00
}
2026-05-29 13:30:56 +08:00
. gallery - header {
2026-02-13 17:34:32 +08:00
position : fixed ;
top : 0 ;
left : 0 ;
right : 0 ;
z - index : 100 ;
display : flex ;
align - items : center ;
2026-05-29 13:30:56 +08:00
justify - content : space - between ;
width : 100 % ;
height : var ( -- gallery - header - height );
padding : 0 var ( -- gallery - gutter );
border - bottom : 1 px solid var ( -- gallery - border );
background : color - mix ( in srgb , var ( -- theme - tertiary ) 86 % , transparent );
box - shadow : 0 12 px 36 px color - mix ( in srgb , var ( -- theme - neutral ) 8 % , transparent );
backdrop - filter : blur ( 20 px );
2026-02-13 17:34:32 +08:00
}
2026-05-29 13:30:56 +08:00
. brand - lockup {
display : grid ;
place - items : center ;
min - width : 0 ;
}
. brand - kicker {
color : var ( -- theme - primary - action );
font - size : 10 px ;
2026-03-26 10:28:28 +08:00
font - weight : 700 ;
2026-05-29 13:30:56 +08:00
line - height : 1 ;
letter - spacing : 0 ;
text - transform : uppercase ;
}
. brand - lockup h1 {
margin : 3 px 0 0 ;
color : var ( -- theme - primary - action );
font - family : "Playfair Display" , "Times New Roman" , serif ;
font - size : 28 px ;
font - weight : 700 ;
line - height : 1 ;
2026-05-21 18:43:59 +08:00
letter - spacing : 0 ;
2026-02-13 17:34:32 +08:00
}
2026-05-29 13:30:56 +08:00
. icon - btn {
position : relative ;
display : inline - flex ;
2026-02-13 17:34:32 +08:00
align - items : center ;
justify - content : center ;
2026-05-29 13:30:56 +08:00
width : 40 px ;
height : 40 px ;
2026-05-21 18:43:59 +08:00
border - radius : 999 px ;
2026-05-29 13:30:56 +08:00
color : var ( -- theme - primary - action );
background : color - mix ( in srgb , var ( -- theme - card - bg ) 72 % , transparent );
box - shadow : 0 10 px 24 px color - mix ( in srgb , var ( -- theme - primary ) 12 % , transparent );
2026-05-21 18:43:59 +08:00
}
2026-05-29 13:30:56 +08:00
. icon - btn : hover ,
. icon - btn : focus {
2026-05-21 18:43:59 +08:00
color : var ( -- theme - accent );
background : var ( -- theme - primary - soft );
2026-02-13 17:34:32 +08:00
}
2026-05-29 13:30:56 +08:00
. icon - btn : deep (. anticon ) {
font - size : 20 px ;
2026-05-21 18:43:59 +08:00
}
2026-05-29 13:30:56 +08:00
. bag - dot {
position : absolute ;
top : 10 px ;
right : 9 px ;
width : 7 px ;
height : 7 px ;
border : 1 px solid var ( -- theme - card - bg );
border - radius : 999 px ;
background : var ( -- theme - secondary );
2026-05-21 18:43:59 +08:00
}
2026-05-29 13:30:56 +08:00
. gallery - content {
padding : 0 var ( -- gallery - gutter );
}
. search - panel {
display : grid ;
gap : 16 px ;
margin - bottom : 16 px ;
}
. search - field {
display : grid ;
grid - template - columns : 22 px minmax ( 0 , 1 fr ) auto ;
align - items : center ;
gap : 10 px ;
min - height : 56 px ;
padding : 8 px 8 px 8 px 17 px ;
border : 1 px solid var ( -- gallery - border );
border - radius : 999 px ;
background : var ( -- gallery - surface - strong );
box - shadow : var ( -- gallery - soft - shadow );
backdrop - filter : blur ( 16 px );
transition : border - color 0.2 s ease , box - shadow 0.2 s ease , transform 0.2 s ease ;
}
. search - field : focus - within {
border - color : var ( -- theme - primary );
box - shadow : var ( -- theme - focus - shadow ), var ( -- gallery - soft - shadow );
transform : translateY ( - 1 px );
}
. search - field__icon {
color : var ( -- theme - primary - action );
font - size : 19 px ;
}
. search - field__input {
min - width : 0 ;
border : 0 ;
outline : 0 ;
2026-05-21 18:43:59 +08:00
color : var ( -- text - primary );
2026-05-29 13:30:56 +08:00
background : transparent ;
font - size : 15 px ;
line - height : 1.4 ;
2026-05-21 18:43:59 +08:00
}
2026-05-29 13:30:56 +08:00
. search - field__input :: placeholder {
color : var ( -- gallery - muted );
2026-05-21 18:43:59 +08:00
}
2026-05-29 13:30:56 +08:00
. search - field__action {
min - width : 58 px ;
height : 38 px ;
padding : 0 14 px ;
border : 1 px solid color - mix ( in srgb , var ( -- theme - primary ) 54 % , var ( -- theme - card - bg ));
border - radius : 999 px ;
color : var ( -- theme - primary - action );
background : color - mix ( in srgb , var ( -- theme - primary ) 18 % , var ( -- theme - card - bg ));
font - size : 13 px ;
font - weight : 700 ;
cursor : pointer ;
transition : transform 0.18 s ease , background 0.18 s ease , color 0.18 s ease ;
2026-03-05 16:02:34 +08:00
}
2026-05-29 13:30:56 +08:00
. search - field__action : hover ,
. search - field__action : focus {
color : var ( -- theme - card - bg );
background : var ( -- theme - primary - action );
}
. search - field__action : active {
transform : scale ( 0.96 );
}
. category - rail {
2026-02-13 17:34:32 +08:00
display : flex ;
2026-05-29 13:30:56 +08:00
gap : 10 px ;
2026-05-21 18:43:59 +08:00
overflow - x : auto ;
overflow - y : hidden ;
2026-05-29 13:30:56 +08:00
padding : 1 px 0 7 px ;
scroll - snap - type : x proximity ;
2026-05-21 18:43:59 +08:00
scrollbar - width : none ;
}
2026-05-29 13:30:56 +08:00
. category - rail ::- webkit - scrollbar {
2026-05-21 18:43:59 +08:00
display : none ;
2026-02-13 17:34:32 +08:00
}
. category - item {
2026-05-21 18:43:59 +08:00
flex : 0 0 auto ;
2026-05-29 13:30:56 +08:00
min - height : 36 px ;
padding : 0 18 px ;
border : 1 px solid var ( -- gallery - border );
2026-05-21 18:43:59 +08:00
border - radius : 999 px ;
2026-05-23 21:56:18 +08:00
color : var ( -- text - secondary );
2026-05-29 13:30:56 +08:00
background : var ( -- gallery - surface - strong );
font - size : 13 px ;
2026-05-23 21:56:18 +08:00
font - weight : 700 ;
2026-05-29 13:30:56 +08:00
letter - spacing : 0 ;
cursor : pointer ;
scroll - snap - align : start ;
transition : transform 0.18 s ease , color 0.18 s ease , background 0.18 s ease , border - color 0.18 s ease , box - shadow 0.18 s ease ;
2026-05-23 21:56:18 +08:00
}
2026-05-29 13:30:56 +08:00
. category - item : hover ,
. category - item : focus {
color : var ( -- theme - primary - action );
2026-05-21 18:43:59 +08:00
border - color : var ( -- theme - primary );
transform : translateY ( - 1 px );
2026-02-13 17:34:32 +08:00
}
. category - item . active {
2026-05-29 13:30:56 +08:00
color : var ( -- theme - card - bg );
2026-05-21 18:43:59 +08:00
border - color : transparent ;
2026-05-29 13:30:56 +08:00
background : var ( -- theme - primary - action );
2026-05-21 18:43:59 +08:00
box - shadow : var ( -- theme - button - shadow );
2026-02-13 17:34:32 +08:00
}
2026-05-29 13:30:56 +08:00
. page - banner {
display : inline - flex ;
align - items : center ;
max - width : 100 % ;
min - height : 34 px ;
margin - bottom : 14 px ;
padding : 0 14 px ;
border : 1 px solid color - mix ( in srgb , var ( -- theme - secondary ) 36 % , var ( -- theme - border ));
border - radius : 999 px ;
color : var ( -- theme - primary - action );
background : color - mix ( in srgb , var ( -- theme - secondary ) 16 % , var ( -- theme - card - bg ));
font - size : 12 px ;
font - weight : 700 ;
line - height : 1.35 ;
2026-03-26 10:28:28 +08:00
}
2026-05-29 13:30:56 +08:00
. product - section {
min - height : 50 vh ;
2026-02-13 17:34:32 +08:00
}
. product - grid {
2026-05-29 13:30:56 +08:00
column - count : 2 ;
column - gap : 10 px ;
2026-02-13 17:34:32 +08:00
}
. product - card {
2026-05-29 13:30:56 +08:00
display : inline - block ;
width : 100 % ;
margin : 0 0 10 px ;
overflow : hidden ;
border : 1 px solid color - mix ( in srgb , var ( -- theme - card - bg ) 70 % , var ( -- theme - border ));
border - radius : 24 px ;
color : inherit ;
background : var ( -- gallery - surface );
box - shadow : var ( -- gallery - shadow );
backdrop - filter : blur ( 16 px );
cursor : pointer ;
break - inside : avoid ;
transition : transform 0.22 s ease , box - shadow 0.22 s ease , border - color 0.22 s ease ;
}
. product - card : hover ,
. product - card : focus {
border - color : color - mix ( in srgb , var ( -- theme - primary ) 58 % , var ( -- theme - border ));
box - shadow : 0 22 px 52 px color - mix ( in srgb , var ( -- theme - primary ) 18 % , transparent );
transform : translateY ( - 2 px );
outline : 0 ;
}
. product - media {
padding : 8 px 8 px 0 ;
2026-02-13 17:34:32 +08:00
}
. product - img {
width : 100 % ;
2026-05-29 13:30:56 +08:00
aspect - ratio : 3 / 4 ;
2026-02-24 09:59:22 +08:00
overflow : hidden ;
2026-05-29 13:30:56 +08:00
border - radius : 20 px ;
background :
linear - gradient ( 145 deg , var ( -- theme - primary - soft ), color - mix ( in srgb , var ( -- theme - secondary ) 18 % , var ( -- theme - card - bg )));
}
. product - card : nth - child ( 4 n + 2 ) . product - img {
aspect - ratio : 4 / 5 ;
}
. product - card : nth - child ( 4 n + 3 ) . product - img {
aspect - ratio : 1 / 1 ;
}
. product - card : nth - child ( 4 n ) . product - img {
aspect - ratio : 3 / 5 ;
2026-02-24 09:59:22 +08:00
}
. product - image {
width : 100 % ;
height : 100 % ;
object - fit : cover ;
2026-05-29 13:30:56 +08:00
transition : transform 0.55 s ease ;
}
. product - card : hover . product - image ,
. product - card : focus . product - image {
transform : scale ( 1.045 );
2026-02-24 09:59:22 +08:00
}
. product - img - placeholder {
2026-05-29 13:30:56 +08:00
display : grid ;
2026-02-24 09:59:22 +08:00
width : 100 % ;
height : 100 % ;
2026-05-29 13:30:56 +08:00
place - items : center ;
color : color - mix ( in srgb , var ( -- theme - primary - action ) 30 % , transparent );
font - family : "Playfair Display" , "Times New Roman" , serif ;
font - size : 42 px ;
2026-03-26 10:28:28 +08:00
font - weight : 700 ;
2026-05-29 13:30:56 +08:00
}
. product - info {
display : grid ;
gap : 10 px ;
padding : 12 px 12 px 14 px ;
}
. product - head {
display : grid ;
grid - template - columns : minmax ( 0 , 1 fr ) 32 px ;
align - items : start ;
gap : 8 px ;
}
. product - title - block {
min - width : 0 ;
2026-02-13 17:34:32 +08:00
}
. name {
2026-05-29 13:30:56 +08:00
display : - webkit - box ;
min - width : 0 ;
margin : 0 ;
2026-02-13 17:34:32 +08:00
overflow : hidden ;
2026-05-29 13:30:56 +08:00
color : var ( -- text - primary );
font - size : 15 px ;
font - weight : 800 ;
line - height : 1.28 ;
letter - spacing : 0 ;
- webkit - box - orient : vertical ;
- webkit - line - clamp : 2 ;
2026-05-21 18:43:59 +08:00
}
2026-05-18 09:46:11 +08:00
. shop - name {
2026-05-29 13:30:56 +08:00
margin : 5 px 0 0 ;
2026-05-18 09:46:11 +08:00
overflow : hidden ;
2026-05-29 13:30:56 +08:00
color : var ( -- gallery - muted );
font - size : 11 px ;
line - height : 1.3 ;
2026-05-18 09:46:11 +08:00
text - overflow : ellipsis ;
2026-05-29 13:30:56 +08:00
white - space : nowrap ;
2026-02-24 09:59:22 +08:00
}
. duration {
2026-03-26 10:28:28 +08:00
display : inline - flex ;
align - items : center ;
2026-05-29 13:30:56 +08:00
max - width : 100 % ;
margin - top : 7 px ;
color : var ( -- gallery - muted );
font - size : 11 px ;
line - height : 1.2 ;
white - space : nowrap ;
2026-02-24 09:59:22 +08:00
}
2026-05-29 13:30:56 +08:00
. duration : deep (. anticon ) {
flex : 0 0 auto ;
margin - right : 5 px ;
color : var ( -- theme - secondary );
font - size : 13 px ;
}
. cart - btn {
display : inline - grid ;
width : 32 px ;
height : 32 px ;
place - items : center ;
border : 0 ;
border - radius : 999 px ;
color : var ( -- theme - primary - action );
background : color - mix ( in srgb , var ( -- theme - primary ) 28 % , var ( -- theme - card - bg ));
box - shadow : 0 8 px 18 px color - mix ( in srgb , var ( -- theme - primary ) 22 % , transparent );
cursor : pointer ;
transition : transform 0.18 s ease , background 0.18 s ease , color 0.18 s ease ;
}
. cart - btn : hover ,
. cart - btn : focus {
color : var ( -- theme - card - bg );
background : var ( -- theme - primary - action );
outline : 0 ;
}
. cart - btn : active {
transform : scale ( 0.92 );
}
. cart - btn - in - cart {
color : var ( -- theme - primary - action );
background : color - mix ( in srgb , var ( -- theme - secondary ) 28 % , var ( -- theme - card - bg ));
box - shadow : 0 8 px 18 px color - mix ( in srgb , var ( -- theme - secondary ) 22 % , transparent );
2026-02-24 09:59:22 +08:00
}
2026-03-26 10:28:28 +08:00
. product - tags {
2026-05-29 13:30:56 +08:00
min - height : 24 px ;
max - height : 54 px ;
overflow : hidden ;
2026-02-24 09:59:22 +08:00
}
2026-05-29 13:30:56 +08:00
. product - tags : deep (. ant - tag ) {
max - width : 100 % ;
border - radius : 999 px ;
font - size : 11 px ;
line - height : 20 px ;
}
. card - foot {
2026-02-13 17:34:32 +08:00
display : flex ;
2026-05-29 13:30:56 +08:00
align - items : flex - end ;
2026-02-13 17:34:32 +08:00
justify - content : space - between ;
2026-05-29 13:30:56 +08:00
gap : 8 px ;
2026-02-13 17:34:32 +08:00
}
. price {
margin : 0 ;
2026-05-29 13:30:56 +08:00
color : var ( -- theme - primary - action );
font - size : 15 px ;
font - weight : 800 ;
line - height : 1 ;
2026-05-13 12:43:01 +08:00
white - space : nowrap ;
}
2026-05-29 13:30:56 +08:00
. stats {
display : flex ;
flex - wrap : wrap ;
justify - content : flex - end ;
gap : 6 px ;
min - width : 0 ;
color : var ( -- gallery - muted );
font - size : 11 px ;
line - height : 1 ;
2026-05-13 12:43:01 +08:00
}
2026-05-29 13:30:56 +08:00
. stats span {
display : inline - flex ;
align - items : center ;
gap : 3 px ;
white - space : nowrap ;
}
. stats : deep (. anticon ) {
color : var ( -- theme - secondary );
font - size : 12 px ;
2026-05-13 12:43:01 +08:00
}
2026-03-26 10:28:28 +08:00
. empty - state ,
. loading - state {
2026-05-29 13:30:56 +08:00
padding : 58 px 0 ;
text - align : center ;
2026-02-24 09:59:22 +08:00
}
2026-03-24 09:50:55 +08:00
2026-05-29 13:30:56 +08:00
. empty - state : deep (. ant - empty - description ) {
color : var ( -- text - secondary );
}
. empty - state : deep (. ant - btn - primary ) {
border - color : transparent ;
background : var ( -- theme - primary - action );
box - shadow : var ( -- theme - button - shadow );
}
@ media ( max - width : 360 px ) {
. product - list - page {
-- gallery - gutter : 14 px ;
2026-03-24 09:59:52 +08:00
}
2026-05-29 13:30:56 +08:00
. search - field {
grid - template - columns : 20 px minmax ( 0 , 1 fr ) auto ;
gap : 7 px ;
padding - left : 14 px ;
2026-03-24 09:59:52 +08:00
}
2026-05-29 13:30:56 +08:00
. search - field__action {
min - width : 50 px ;
padding : 0 11 px ;
2026-03-24 09:59:52 +08:00
}
. product - grid {
2026-05-29 13:30:56 +08:00
column - gap : 8 px ;
}
. product - info {
padding - right : 10 px ;
padding - left : 10 px ;
}
}
@ media ( min - width : 768 px ) {
. gallery - header {
top : 0 ;
left : 50 % ;
width : min ( 100 % , var ( -- frontend - page - max - width ), calc ( 100 vw - 48 px ));
border - top - left - radius : 32 px ;
border - top - right - radius : 32 px ;
transform : translateX ( - 50 % );
2026-03-24 09:50:55 +08:00
}
}
2026-03-19 20:51:07 +08:00
</ style >