功能:更新 YumiNail 用户端流程
This commit is contained in:
@@ -1,16 +1,11 @@
|
||||
<template>
|
||||
<div class="mobile-container product-list-page">
|
||||
<header class="gallery-header">
|
||||
<a-button class="icon-btn" type="text" aria-label="返回首页" @click="handleBackClick">
|
||||
<MenuOutlined />
|
||||
</a-button>
|
||||
<div class="brand-lockup" aria-label="指尖设计师">
|
||||
<h1>指尖设计师</h1>
|
||||
<span class="header-spacer" aria-hidden="true"></span>
|
||||
<div class="brand-lockup" :aria-label="currentShopName">
|
||||
<h1>{{ currentShopName }}</h1>
|
||||
</div>
|
||||
<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>
|
||||
</a-button>
|
||||
<span class="header-spacer" aria-hidden="true"></span>
|
||||
</header>
|
||||
|
||||
<main class="gallery-content">
|
||||
@@ -105,7 +100,7 @@
|
||||
@click.stop="handleAddToCart(item)"
|
||||
>
|
||||
<CheckOutlined v-if="item.inCart" />
|
||||
<PlusOutlined v-else />
|
||||
<ShoppingCartOutlined v-else />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -151,6 +146,16 @@
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<button
|
||||
v-show="showBackTop"
|
||||
class="back-to-top-button"
|
||||
type="button"
|
||||
aria-label="返回顶部"
|
||||
@click="scrollToTop"
|
||||
>
|
||||
<UpOutlined />
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -159,17 +164,16 @@
|
||||
* 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.
|
||||
*/
|
||||
import { onMounted, ref, watch, inject, computed } from 'vue'
|
||||
import { computed, inject, onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
import { useRouter, useRoute } from 'vue-router'
|
||||
import {
|
||||
CheckOutlined,
|
||||
ClockCircleOutlined,
|
||||
HeartOutlined,
|
||||
MenuOutlined,
|
||||
PlusOutlined,
|
||||
SearchOutlined,
|
||||
ShoppingOutlined,
|
||||
StarOutlined
|
||||
ShoppingCartOutlined,
|
||||
StarOutlined,
|
||||
UpOutlined
|
||||
} from '@ant-design/icons-vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
/**
|
||||
@@ -219,6 +223,8 @@ const allTags = computed(() => filterGroups.value.flatMap(group => group.tags ||
|
||||
const selectedCategory = ref('全部')
|
||||
/** selectedTagId tracks the grouped filter id sent to the backend. */
|
||||
const selectedTagId = ref('')
|
||||
const selectedShopId = ref('')
|
||||
const bookableOnly = ref(false)
|
||||
/**
|
||||
* 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.
|
||||
@@ -226,6 +232,8 @@ const selectedTagId = ref('')
|
||||
const products = ref<ProductListItem[]>([])
|
||||
/** loading is a reactive state variable used by the template and event handlers. */
|
||||
const loading = ref(false)
|
||||
/** showBackTop toggles the floating shortcut after the gallery scrolls down. */
|
||||
const showBackTop = ref(false)
|
||||
/** showSearch is a reactive state variable used by the template and event handlers. */
|
||||
const showSearch = ref(false)
|
||||
/** searchKeyword is a reactive state variable used by the template and event handlers. */
|
||||
@@ -245,17 +253,57 @@ let useGlobalLoadingForNextRouteSync = false
|
||||
|
||||
/** 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 routeShopName = typeof route.query.shopName === 'string' ? route.query.shopName.trim() : ''
|
||||
if (routeShopName) {
|
||||
return routeShopName
|
||||
}
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
try {
|
||||
const raw = localStorage.getItem('userInfo')
|
||||
const storedUser = raw ? JSON.parse(raw) as { shopName?: string; shopNames?: string[] } : null
|
||||
return storedUser?.shopName || storedUser?.shopNames?.find(Boolean) || '当前门店'
|
||||
} catch {
|
||||
return '当前门店'
|
||||
}
|
||||
}
|
||||
|
||||
return '当前门店'
|
||||
})
|
||||
/** activeBannerText is a reactive state variable used by the template and event handlers. */
|
||||
const activeBannerText = computed(() => {
|
||||
if (searchKeyword.value.trim()) {
|
||||
return `当前显示“${searchKeyword.value.trim()}”的匹配结果`
|
||||
}
|
||||
if (selectedShopId.value && bookableOnly.value) {
|
||||
return `当前显示“${currentShopName.value}”的可预约作品`
|
||||
}
|
||||
if (selectedShopId.value) {
|
||||
return `当前显示“${currentShopName.value}”的作品`
|
||||
}
|
||||
if (selectedCategory.value !== '全部') {
|
||||
return `当前按场景“${selectedCategory.value}”筛选`
|
||||
}
|
||||
return ''
|
||||
})
|
||||
|
||||
const getScopedRouteQuery = (includeBookable = true) => {
|
||||
const query: Record<string, string> = {}
|
||||
const routeShopName = typeof route.query.shopName === 'string' ? route.query.shopName.trim() : ''
|
||||
if (selectedShopId.value) {
|
||||
query.shopId = selectedShopId.value
|
||||
}
|
||||
if (routeShopName) {
|
||||
query.shopName = routeShopName
|
||||
}
|
||||
if (includeBookable && bookableOnly.value) {
|
||||
query.bookable = '1'
|
||||
}
|
||||
return query
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -341,7 +389,15 @@ const fetchProducts = async () => {
|
||||
response = pageResult.list || []
|
||||
}
|
||||
|
||||
products.value = markProductsInCart(Array.isArray(response) ? response : [])
|
||||
let filteredProducts = Array.isArray(response) ? response : []
|
||||
if (selectedShopId.value) {
|
||||
filteredProducts = filteredProducts.filter(item => String(item.shopId || '') === selectedShopId.value)
|
||||
}
|
||||
if (bookableOnly.value) {
|
||||
filteredProducts = filteredProducts.filter(item => item.availableBookableArtistCount === undefined || Number(item.availableBookableArtistCount) > 0)
|
||||
}
|
||||
|
||||
products.value = markProductsInCart(filteredProducts)
|
||||
await loadImageUrls(products.value)
|
||||
} catch (error: any) {
|
||||
console.error('获取作品列表失败:', error)
|
||||
@@ -358,12 +414,16 @@ const syncRouteFilters = async () => {
|
||||
const keyword = typeof route.query.keyword === 'string' ? route.query.keyword.trim() : ''
|
||||
const tag = typeof route.query.tag === 'string' ? route.query.tag.trim() : ''
|
||||
const tagId = typeof route.query.tagId === 'string' ? route.query.tagId.trim() : ''
|
||||
const shopId = typeof route.query.shopId === 'string' ? route.query.shopId.trim() : ''
|
||||
const bookable = route.query.bookable === '1'
|
||||
const matchedTag = tagId
|
||||
? allTags.value.find(item => String(item.id) === tagId)
|
||||
: allTags.value.find(item => item.tagName === tag || item.displayName === tag)
|
||||
|
||||
searchKeyword.value = keyword
|
||||
showSearch.value = Boolean(keyword)
|
||||
selectedShopId.value = shopId
|
||||
bookableOnly.value = bookable
|
||||
selectedTagId.value = matchedTag ? String(matchedTag.id) : ''
|
||||
selectedCategory.value = matchedTag ? (matchedTag.displayName || matchedTag.tagName) : '全部'
|
||||
if (useGlobalLoadingForNextRouteSync) {
|
||||
@@ -374,11 +434,6 @@ const syncRouteFilters = async () => {
|
||||
await fetchProducts()
|
||||
}
|
||||
|
||||
/** handleBackClick is a local helper used by this page script. */
|
||||
const handleBackClick = () => {
|
||||
router.push('/home')
|
||||
}
|
||||
|
||||
/** handleCategoryClick is a local helper used by this page script. */
|
||||
const handleCategoryClick = (category: string) => {
|
||||
selectedCategory.value = category
|
||||
@@ -386,7 +441,7 @@ const handleCategoryClick = (category: string) => {
|
||||
searchKeyword.value = ''
|
||||
showSearch.value = false
|
||||
useGlobalLoadingForNextRouteSync = true
|
||||
router.replace({ path: '/products', query: {} })
|
||||
router.replace({ path: '/products', query: getScopedRouteQuery() })
|
||||
}
|
||||
|
||||
/** handleTagClick is a local helper used by grouped scene-filter chips. */
|
||||
@@ -398,7 +453,7 @@ const handleTagClick = (tag: TagVO) => {
|
||||
useGlobalLoadingForNextRouteSync = true
|
||||
router.replace({
|
||||
path: '/products',
|
||||
query: { tag: tag.displayName || tag.tagName, tagId: String(tag.id) }
|
||||
query: { ...getScopedRouteQuery(), tag: tag.displayName || tag.tagName, tagId: String(tag.id) }
|
||||
})
|
||||
}
|
||||
|
||||
@@ -434,7 +489,7 @@ const handleSearch = () => {
|
||||
useGlobalLoadingForNextRouteSync = true
|
||||
router.replace({
|
||||
path: '/products',
|
||||
query: keyword ? { keyword } : {}
|
||||
query: keyword ? { ...getScopedRouteQuery(), keyword } : getScopedRouteQuery()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -444,8 +499,19 @@ const resetFilters = () => {
|
||||
selectedTagId.value = ''
|
||||
searchKeyword.value = ''
|
||||
showSearch.value = false
|
||||
bookableOnly.value = false
|
||||
useGlobalLoadingForNextRouteSync = true
|
||||
router.replace('/products')
|
||||
router.replace({ path: '/products', query: getScopedRouteQuery(false) })
|
||||
}
|
||||
|
||||
/** handleWindowScroll keeps the return-to-top shortcut in sync with page position. */
|
||||
const handleWindowScroll = () => {
|
||||
showBackTop.value = (document.documentElement.scrollTop || document.body.scrollTop) > 360
|
||||
}
|
||||
|
||||
/** scrollToTop returns the product gallery to the top of the page. */
|
||||
const scrollToTop = () => {
|
||||
window.scrollTo({ top: 0, behavior: 'smooth' })
|
||||
}
|
||||
|
||||
watch(
|
||||
@@ -459,6 +525,12 @@ watch(
|
||||
onMounted(async () => {
|
||||
await fetchTags()
|
||||
await syncRouteFilters()
|
||||
handleWindowScroll()
|
||||
window.addEventListener('scroll', handleWindowScroll, { passive: true })
|
||||
})
|
||||
|
||||
onUnmounted(() => {
|
||||
window.removeEventListener('scroll', handleWindowScroll)
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -484,19 +556,25 @@ onMounted(async () => {
|
||||
.gallery-header {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
left: 50%;
|
||||
z-index: 100;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
width: min(100%, var(--app-mobile-max-width, 480px));
|
||||
height: var(--gallery-header-height);
|
||||
padding: 0 var(--gallery-gutter);
|
||||
border-bottom: 1px solid var(--gallery-border);
|
||||
background: color-mix(in srgb, var(--theme-tertiary) 86%, transparent);
|
||||
box-shadow: 0 12px 36px color-mix(in srgb, var(--theme-neutral) 8%, transparent);
|
||||
backdrop-filter: blur(20px);
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
.header-spacer {
|
||||
flex: 0 0 36px;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
}
|
||||
|
||||
.brand-lockup {
|
||||
@@ -508,45 +586,14 @@ onMounted(async () => {
|
||||
|
||||
.brand-lockup h1 {
|
||||
margin: 0;
|
||||
overflow: hidden;
|
||||
color: var(--text-primary);
|
||||
font-size: 16px;
|
||||
font-weight: 800;
|
||||
line-height: 1;
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
.icon-btn {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 999px;
|
||||
color: var(--theme-primary-action);
|
||||
background: color-mix(in srgb, var(--theme-card-bg) 72%, transparent);
|
||||
box-shadow: 0 10px 24px color-mix(in srgb, var(--theme-primary) 12%, transparent);
|
||||
}
|
||||
|
||||
.icon-btn:hover,
|
||||
.icon-btn:focus {
|
||||
color: var(--theme-accent);
|
||||
background: var(--theme-primary-soft);
|
||||
}
|
||||
|
||||
.icon-btn :deep(.anticon) {
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.bag-dot {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 9px;
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
border: 1px solid var(--theme-card-bg);
|
||||
border-radius: 999px;
|
||||
background: var(--theme-secondary);
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.gallery-content {
|
||||
@@ -555,17 +602,17 @@ onMounted(async () => {
|
||||
|
||||
.search-panel {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
margin-bottom: 16px;
|
||||
gap: 10px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.search-field {
|
||||
display: grid;
|
||||
grid-template-columns: 22px minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
min-height: 56px;
|
||||
padding: 8px 8px 8px 17px;
|
||||
gap: 8px;
|
||||
min-height: 46px;
|
||||
padding: 6px 7px 6px 15px;
|
||||
border: 1px solid var(--gallery-border);
|
||||
border-radius: 999px;
|
||||
background: var(--gallery-surface-strong);
|
||||
@@ -582,7 +629,7 @@ onMounted(async () => {
|
||||
|
||||
.search-field__icon {
|
||||
color: var(--theme-primary-action);
|
||||
font-size: 19px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.search-field__input {
|
||||
@@ -600,9 +647,9 @@ onMounted(async () => {
|
||||
}
|
||||
|
||||
.search-field__action {
|
||||
min-width: 58px;
|
||||
height: 38px;
|
||||
padding: 0 14px;
|
||||
min-width: 52px;
|
||||
height: 32px;
|
||||
padding: 0 12px;
|
||||
border: 1px solid color-mix(in srgb, var(--theme-primary) 54%, var(--theme-card-bg));
|
||||
border-radius: 999px;
|
||||
color: var(--theme-primary-action);
|
||||
@@ -625,10 +672,10 @@ onMounted(async () => {
|
||||
|
||||
.category-rail {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
gap: 8px;
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
padding: 1px 0 7px;
|
||||
padding: 0 0 5px;
|
||||
scroll-snap-type: x proximity;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
@@ -639,8 +686,8 @@ onMounted(async () => {
|
||||
|
||||
.category-item {
|
||||
flex: 0 0 auto;
|
||||
min-height: 36px;
|
||||
padding: 0 18px;
|
||||
min-height: 30px;
|
||||
padding: 0 14px;
|
||||
border: 1px solid var(--gallery-border);
|
||||
border-radius: 999px;
|
||||
color: var(--text-secondary);
|
||||
@@ -922,6 +969,34 @@ onMounted(async () => {
|
||||
box-shadow: var(--theme-button-shadow);
|
||||
}
|
||||
|
||||
.back-to-top-button {
|
||||
position: fixed;
|
||||
right: max(18px, calc((100vw - var(--app-mobile-max-width, 480px)) / 2 + 18px));
|
||||
bottom: calc(92px + env(safe-area-inset-bottom, 0px));
|
||||
z-index: 120;
|
||||
display: inline-grid;
|
||||
width: 42px;
|
||||
height: 42px;
|
||||
place-items: center;
|
||||
border: 1px solid color-mix(in srgb, var(--theme-primary) 36%, var(--theme-border));
|
||||
border-radius: 999px;
|
||||
color: var(--theme-card-bg);
|
||||
background: var(--theme-primary-action);
|
||||
box-shadow: 0 14px 34px color-mix(in srgb, var(--theme-primary) 26%, transparent);
|
||||
cursor: pointer;
|
||||
transition: transform 0.18s ease, opacity 0.18s ease;
|
||||
}
|
||||
|
||||
.back-to-top-button:hover,
|
||||
.back-to-top-button:focus {
|
||||
transform: translateY(-2px);
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
.back-to-top-button:active {
|
||||
transform: scale(0.94);
|
||||
}
|
||||
|
||||
@media (max-width: 360px) {
|
||||
.product-list-page {
|
||||
--gallery-gutter: 14px;
|
||||
|
||||
Reference in New Issue
Block a user