2026-02-13 17:34:32 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="mobile-container">
|
|
|
|
|
<header class="header">
|
2026-03-26 10:28:28 +08:00
|
|
|
<a-button type="text" @click="handleBackClick">
|
|
|
|
|
<LeftOutlined :style="{ fontSize: '20px' }" />
|
|
|
|
|
</a-button>
|
|
|
|
|
<h1>{{ product.title || product.name || '作品详情' }}</h1>
|
|
|
|
|
<a-button type="text" @click="handleFavoriteClick">
|
|
|
|
|
<component :is="isFavorite ? StarFilled : StarOutlined" :class="['header-star', { active: isFavorite }]" />
|
|
|
|
|
</a-button>
|
2026-02-13 17:34:32 +08:00
|
|
|
</header>
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
<main class="content">
|
|
|
|
|
<a-result
|
|
|
|
|
v-if="loadError"
|
|
|
|
|
status="warning"
|
|
|
|
|
title="暂时无法查看作品详情"
|
|
|
|
|
:sub-title="loadError"
|
|
|
|
|
>
|
|
|
|
|
<template #extra>
|
|
|
|
|
<a-button type="primary" @click="handleBackClick">返回上一页</a-button>
|
|
|
|
|
</template>
|
|
|
|
|
</a-result>
|
2026-02-13 17:34:32 +08:00
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
<template v-else>
|
|
|
|
|
<section class="hero-card">
|
|
|
|
|
<a-carousel v-if="productImages.length > 1" autoplay dots>
|
|
|
|
|
<div v-for="(image, index) in productImages" :key="index" class="carousel-slide">
|
|
|
|
|
<img :src="image" :alt="product.title || product.name" class="product-image" />
|
|
|
|
|
</div>
|
|
|
|
|
</a-carousel>
|
|
|
|
|
<div v-else class="single-image">
|
|
|
|
|
<img :src="productImages[0] || DEFAULT_PRODUCT_IMAGE" :alt="product.title || product.name" class="product-image" />
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
2026-02-13 17:34:32 +08:00
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
<section class="info-card">
|
|
|
|
|
<div class="info-header">
|
|
|
|
|
<div>
|
|
|
|
|
<h2 class="product-name">{{ product.title || product.name }}</h2>
|
|
|
|
|
<p class="product-price">¥{{ Number(product.price || 0).toFixed(2) }}</p>
|
|
|
|
|
</div>
|
|
|
|
|
<a-tag color="blue">{{ product.approximateDuration || '时长待确认' }}</a-tag>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="metric-row">
|
|
|
|
|
<button class="metric-card" type="button" @click="openShopDetail" :disabled="!shopInfo?.id">
|
|
|
|
|
<ShopOutlined />
|
|
|
|
|
<div>
|
|
|
|
|
<span class="metric-label">所属门店</span>
|
|
|
|
|
<strong>{{ shopInfo?.shopName || '暂未绑定门店' }}</strong>
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
|
|
|
|
<div class="metric-card">
|
|
|
|
|
<TeamOutlined />
|
|
|
|
|
<div>
|
|
|
|
|
<span class="metric-label">可约美甲师</span>
|
|
|
|
|
<strong>{{ artistCountText }}</strong>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="metric-card">
|
|
|
|
|
<CalendarOutlined />
|
|
|
|
|
<div>
|
|
|
|
|
<span class="metric-label">最早可约</span>
|
|
|
|
|
<strong>{{ earliestBookableText }}</strong>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div v-if="shopInfo" class="shop-summary" @click="openShopDetail">
|
|
|
|
|
<div class="shop-summary-title">{{ shopInfo.shopName }}</div>
|
|
|
|
|
<div class="shop-summary-text">{{ shopInfo.address || '门店地址待完善' }}</div>
|
|
|
|
|
<div class="shop-summary-text">{{ shopInfo.businessHours || '营业时间待完善' }}</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="stats-row">
|
|
|
|
|
<button type="button" class="stat-btn" @click="handleLikeClick">
|
|
|
|
|
<component :is="isLiked ? HeartFilled : HeartOutlined" :class="{ active: isLiked }" />
|
|
|
|
|
<span>{{ product.likeCount || 0 }} 点赞</span>
|
|
|
|
|
</button>
|
|
|
|
|
<button type="button" class="stat-btn" @click="handleFavoriteClick">
|
|
|
|
|
<component :is="isFavorite ? StarFilled : StarOutlined" :class="{ active: isFavorite }" />
|
|
|
|
|
<span>{{ product.collectCount || 0 }} 收藏</span>
|
|
|
|
|
</button>
|
|
|
|
|
<div class="stat-btn static">
|
|
|
|
|
<ClockCircleOutlined />
|
|
|
|
|
<span>{{ product.approximateDuration || '时长待定' }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="tags">
|
|
|
|
|
<a-tag
|
|
|
|
|
v-for="tag in product.tagInfos || []"
|
|
|
|
|
:key="tag.id"
|
|
|
|
|
:style="{
|
|
|
|
|
color: tag.textColor || '#333',
|
|
|
|
|
backgroundColor: tag.bgColor || '#f0f0f0',
|
|
|
|
|
borderColor: tag.borderColor || '#f0f0f0'
|
|
|
|
|
}"
|
|
|
|
|
>
|
|
|
|
|
{{ tag.tagName }}
|
|
|
|
|
</a-tag>
|
|
|
|
|
<a-tag v-if="!product.tagInfos?.length" color="default">暂无标签</a-tag>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="description-block">
|
|
|
|
|
<h3>作品介绍</h3>
|
|
|
|
|
<p>{{ product.description || '店家还没补充作品说明。' }}</p>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|
|
|
|
|
</template>
|
|
|
|
|
</main>
|
|
|
|
|
|
|
|
|
|
<footer v-if="!loadError" class="action-buttons">
|
|
|
|
|
<a-button class="add-cart-btn" size="large" @click="handleAddToCart">
|
|
|
|
|
<ShoppingCartOutlined />
|
|
|
|
|
加入购物车
|
|
|
|
|
</a-button>
|
|
|
|
|
<a-button class="buy-now-btn" type="primary" size="large" @click="handleBuyNow">
|
|
|
|
|
<ThunderboltOutlined />
|
|
|
|
|
立即预约
|
|
|
|
|
</a-button>
|
|
|
|
|
</footer>
|
2026-02-13 17:34:32 +08:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2026-03-26 10:28:28 +08:00
|
|
|
import { computed, inject, onMounted, ref } from 'vue'
|
|
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
|
|
import {
|
|
|
|
|
CalendarOutlined,
|
|
|
|
|
ClockCircleOutlined,
|
|
|
|
|
HeartFilled,
|
|
|
|
|
HeartOutlined,
|
|
|
|
|
LeftOutlined,
|
|
|
|
|
ShoppingCartOutlined,
|
|
|
|
|
ShopOutlined,
|
|
|
|
|
StarFilled,
|
|
|
|
|
StarOutlined,
|
|
|
|
|
TeamOutlined,
|
|
|
|
|
ThunderboltOutlined
|
|
|
|
|
} from '@ant-design/icons-vue'
|
|
|
|
|
import { message } from 'ant-design-vue'
|
2026-02-27 15:57:14 +08:00
|
|
|
import { cartApi } from '@/api/cart'
|
2026-03-03 17:50:10 +08:00
|
|
|
import { fileApi } from '@/api/file'
|
2026-03-26 10:28:28 +08:00
|
|
|
import { productApi, type ProductVO } from '@/api/product'
|
|
|
|
|
import { productLikeApi } from '@/api/productLike'
|
|
|
|
|
import { shopApi, type ShopVO } from '@/api/shop'
|
|
|
|
|
import { wishlistApi } from '@/api/wishlist'
|
|
|
|
|
import { DEFAULT_PRODUCT_IMAGE } from '@/constants'
|
2026-03-27 14:55:41 +08:00
|
|
|
import type { IdType } from '@/utils/id'
|
|
|
|
|
import { toOptionalIdString } from '@/utils/id'
|
2026-02-13 17:34:32 +08:00
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
const route = useRoute()
|
|
|
|
|
const router = useRouter()
|
2026-02-28 17:09:45 +08:00
|
|
|
const updateCartCount = inject<() => Promise<void>>('updateCartCount', async () => {})
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
const product = ref<ProductVO>({} as ProductVO)
|
|
|
|
|
const shopInfo = ref<ShopVO | null>(null)
|
2026-02-26 11:16:24 +08:00
|
|
|
const productImages = ref<string[]>([])
|
2026-03-03 17:50:10 +08:00
|
|
|
const imageIdCache = ref<Record<string, string>>({})
|
2026-03-26 10:28:28 +08:00
|
|
|
const isFavorite = ref(false)
|
|
|
|
|
const isLiked = ref(false)
|
|
|
|
|
const loadError = ref('')
|
2026-02-13 17:34:32 +08:00
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
const isLoggedIn = computed(() => Boolean(localStorage.getItem('accessToken') || sessionStorage.getItem('accessToken')))
|
|
|
|
|
const artistCount = computed(() => {
|
2026-03-27 11:51:43 +08:00
|
|
|
if (typeof product.value.availableBookableArtistCount === 'number') {
|
|
|
|
|
return product.value.availableBookableArtistCount
|
|
|
|
|
}
|
2026-03-26 10:28:28 +08:00
|
|
|
const rawValue = product.value.bookableArtists || ''
|
|
|
|
|
return rawValue
|
|
|
|
|
.split(',')
|
2026-03-27 14:55:41 +08:00
|
|
|
.map(id => id.trim())
|
|
|
|
|
.filter(Boolean).length
|
2026-03-26 10:28:28 +08:00
|
|
|
})
|
2026-03-27 11:51:43 +08:00
|
|
|
const artistCountText = computed(() => {
|
|
|
|
|
if (artistCount.value > 0) {
|
|
|
|
|
return `${artistCount.value} 位`
|
|
|
|
|
}
|
|
|
|
|
return product.value.bookableArtistRestricted ? '暂无' : '门店安排'
|
|
|
|
|
})
|
2026-03-26 10:28:28 +08:00
|
|
|
const earliestBookableText = computed(() => estimateEarliestBookable(shopInfo.value?.businessHours))
|
|
|
|
|
|
|
|
|
|
const parseTimeRange = (businessHours?: string): { start: string; end: string } | null => {
|
|
|
|
|
if (!businessHours) {
|
|
|
|
|
return null
|
2026-02-24 09:59:22 +08:00
|
|
|
}
|
2026-03-26 10:28:28 +08:00
|
|
|
const normalized = businessHours.replace(/\s+/g, '')
|
|
|
|
|
const matched = normalized.match(/(\d{1,2}:\d{2}).*?(\d{1,2}:\d{2})/)
|
|
|
|
|
if (!matched) {
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
const [, start, end] = matched
|
|
|
|
|
if (!start || !end) {
|
|
|
|
|
return null
|
|
|
|
|
}
|
|
|
|
|
return { start, end }
|
2026-02-24 09:59:22 +08:00
|
|
|
}
|
2026-02-13 17:34:32 +08:00
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
const formatDateTime = (date: Date) => {
|
|
|
|
|
const month = `${date.getMonth() + 1}`.padStart(2, '0')
|
|
|
|
|
const day = `${date.getDate()}`.padStart(2, '0')
|
|
|
|
|
const hour = `${date.getHours()}`.padStart(2, '0')
|
|
|
|
|
const minute = `${date.getMinutes()}`.padStart(2, '0')
|
|
|
|
|
return `${month}-${day} ${hour}:${minute}`
|
2026-03-03 17:50:10 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
const estimateEarliestBookable = (businessHours?: string) => {
|
|
|
|
|
const timeRange = parseTimeRange(businessHours)
|
|
|
|
|
if (!timeRange) {
|
|
|
|
|
return businessHours || '以门店安排为准'
|
2026-03-05 15:15:59 +08:00
|
|
|
}
|
2026-03-26 10:28:28 +08:00
|
|
|
|
|
|
|
|
const startParts = timeRange.start.split(':').map(Number)
|
|
|
|
|
const endParts = timeRange.end.split(':').map(Number)
|
|
|
|
|
const startHour = startParts[0]
|
|
|
|
|
const startMinute = startParts[1]
|
|
|
|
|
const endHour = endParts[0]
|
|
|
|
|
const endMinute = endParts[1]
|
|
|
|
|
if ([startHour, startMinute, endHour, endMinute].some(value => value === undefined || Number.isNaN(value))) {
|
|
|
|
|
return businessHours || '以门店安排为准'
|
|
|
|
|
}
|
|
|
|
|
const safeStartHour = startHour ?? 0
|
|
|
|
|
const safeStartMinute = startMinute ?? 0
|
|
|
|
|
const safeEndHour = endHour ?? 0
|
|
|
|
|
const safeEndMinute = endMinute ?? 0
|
|
|
|
|
const candidate = new Date(Date.now() + 30 * 60 * 1000)
|
|
|
|
|
|
|
|
|
|
const openTime = new Date(candidate)
|
|
|
|
|
openTime.setHours(safeStartHour, safeStartMinute, 0, 0)
|
|
|
|
|
|
|
|
|
|
const closeTime = new Date(candidate)
|
|
|
|
|
closeTime.setHours(safeEndHour, safeEndMinute, 0, 0)
|
|
|
|
|
|
|
|
|
|
if (candidate <= openTime) {
|
|
|
|
|
return `今天 ${timeRange.start}`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (candidate >= closeTime) {
|
|
|
|
|
const nextOpen = new Date(openTime)
|
|
|
|
|
nextOpen.setDate(nextOpen.getDate() + 1)
|
|
|
|
|
return `明天 ${timeRange.start}`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return formatDateTime(candidate)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const requireLogin = (actionText: string) => {
|
|
|
|
|
if (isLoggedIn.value) {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
message.info(`${actionText}前请先登录`)
|
|
|
|
|
router.push('/')
|
|
|
|
|
return false
|
2026-03-05 15:15:59 +08:00
|
|
|
}
|
|
|
|
|
|
2026-02-26 11:16:24 +08:00
|
|
|
const loadProductImages = async () => {
|
2026-03-26 10:28:28 +08:00
|
|
|
const fileIds = product.value.imageFileIds?.split(',').map(id => id.trim()).filter(Boolean) || []
|
|
|
|
|
if (!fileIds.length) {
|
2026-03-03 17:50:10 +08:00
|
|
|
productImages.value = [DEFAULT_PRODUCT_IMAGE]
|
2026-03-26 10:28:28 +08:00
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const urls: string[] = []
|
|
|
|
|
for (const id of fileIds) {
|
|
|
|
|
try {
|
|
|
|
|
if (!imageIdCache.value[id]) {
|
2026-03-27 14:55:41 +08:00
|
|
|
imageIdCache.value[id] = await fileApi.getSignedUrl(id) as unknown as string
|
2026-03-26 10:28:28 +08:00
|
|
|
}
|
|
|
|
|
if (imageIdCache.value[id]) {
|
|
|
|
|
urls.push(imageIdCache.value[id])
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('获取作品图片失败:', error)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
productImages.value = urls.length ? urls : [DEFAULT_PRODUCT_IMAGE]
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-27 14:55:41 +08:00
|
|
|
const loadShopInfo = async (shopId?: IdType | null) => {
|
2026-03-26 10:28:28 +08:00
|
|
|
if (!shopId) {
|
|
|
|
|
shopInfo.value = null
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
try {
|
2026-03-27 14:55:41 +08:00
|
|
|
const response = await shopApi.getShopById(shopId)
|
2026-03-26 10:28:28 +08:00
|
|
|
shopInfo.value = response || null
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('获取门店信息失败:', error)
|
|
|
|
|
shopInfo.value = null
|
2026-02-26 11:16:24 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
const checkWishlistStatus = async () => {
|
|
|
|
|
if (!isLoggedIn.value || !product.value.id) {
|
|
|
|
|
isFavorite.value = false
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
const status = await wishlistApi.checkWishlist(product.value.id)
|
|
|
|
|
isFavorite.value = Boolean(status)
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('获取收藏状态失败:', error)
|
|
|
|
|
isFavorite.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const checkLikeStatus = async () => {
|
|
|
|
|
if (!isLoggedIn.value || !product.value.id) {
|
|
|
|
|
isLiked.value = false
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
const status = await productLikeApi.checkLikeStatus(product.value.id)
|
|
|
|
|
isLiked.value = Boolean(status)
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('获取点赞状态失败:', error)
|
|
|
|
|
isLiked.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const resolveLoadError = (error: any) => {
|
|
|
|
|
const status = error?.response?.status
|
|
|
|
|
if (status === 404) {
|
|
|
|
|
return '这件作品可能已下架或不存在。'
|
|
|
|
|
}
|
|
|
|
|
if (status === 401) {
|
|
|
|
|
return '作品详情暂时无法加载,请稍后重试。'
|
|
|
|
|
}
|
|
|
|
|
return error?.message || '网络有点忙,请稍后再试。'
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const fetchProductDetail = async () => {
|
|
|
|
|
loadError.value = ''
|
|
|
|
|
try {
|
2026-03-27 14:55:41 +08:00
|
|
|
const productId = toOptionalIdString(route.params.id)
|
|
|
|
|
if (!productId) {
|
|
|
|
|
throw new Error('作品ID不存在')
|
|
|
|
|
}
|
2026-03-26 10:28:28 +08:00
|
|
|
const response = await productApi.getProductById(productId)
|
|
|
|
|
if (!response?.id) {
|
|
|
|
|
throw new Error('未找到对应作品')
|
|
|
|
|
}
|
|
|
|
|
product.value = response
|
|
|
|
|
await Promise.all([
|
|
|
|
|
loadProductImages(),
|
|
|
|
|
loadShopInfo(response.shopId),
|
|
|
|
|
checkWishlistStatus(),
|
|
|
|
|
checkLikeStatus()
|
|
|
|
|
])
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('获取作品详情失败:', error)
|
|
|
|
|
loadError.value = resolveLoadError(error)
|
|
|
|
|
}
|
2026-02-26 11:16:24 +08:00
|
|
|
}
|
|
|
|
|
|
2026-02-13 17:34:32 +08:00
|
|
|
const handleBackClick = () => {
|
|
|
|
|
router.back()
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
const openShopDetail = () => {
|
|
|
|
|
if (!shopInfo.value?.id) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
router.push(`/shop/${shopInfo.value.id}`)
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-03 17:50:10 +08:00
|
|
|
const handleFavoriteClick = async () => {
|
2026-03-26 10:28:28 +08:00
|
|
|
if (!product.value.id || !requireLogin('收藏作品')) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-03 17:50:10 +08:00
|
|
|
try {
|
|
|
|
|
if (isFavorite.value) {
|
|
|
|
|
await wishlistApi.removeFromWishlist(product.value.id)
|
2026-03-26 10:28:28 +08:00
|
|
|
product.value.collectCount = Math.max(0, Number(product.value.collectCount || 0) - 1)
|
|
|
|
|
message.success('已取消收藏')
|
2026-03-03 17:50:10 +08:00
|
|
|
} else {
|
|
|
|
|
await wishlistApi.addToWishlist(product.value.id)
|
2026-03-26 10:28:28 +08:00
|
|
|
product.value.collectCount = Number(product.value.collectCount || 0) + 1
|
|
|
|
|
message.success('已加入收藏')
|
2026-03-03 17:50:10 +08:00
|
|
|
}
|
|
|
|
|
isFavorite.value = !isFavorite.value
|
|
|
|
|
} catch (error) {
|
2026-03-26 10:28:28 +08:00
|
|
|
console.error('收藏操作失败:', error)
|
|
|
|
|
message.error('收藏操作失败,请稍后重试')
|
2026-03-03 17:50:10 +08:00
|
|
|
}
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-05 15:15:59 +08:00
|
|
|
const handleLikeClick = async () => {
|
2026-03-26 10:28:28 +08:00
|
|
|
if (!product.value.id || !requireLogin('点赞作品')) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-05 15:15:59 +08:00
|
|
|
try {
|
|
|
|
|
if (isLiked.value) {
|
|
|
|
|
await productLikeApi.unlikeProduct(product.value.id)
|
2026-03-26 10:28:28 +08:00
|
|
|
product.value.likeCount = Math.max(0, Number(product.value.likeCount || 0) - 1)
|
|
|
|
|
message.success('已取消点赞')
|
2026-03-05 15:15:59 +08:00
|
|
|
} else {
|
|
|
|
|
await productLikeApi.likeProduct(product.value.id)
|
2026-03-26 10:28:28 +08:00
|
|
|
product.value.likeCount = Number(product.value.likeCount || 0) + 1
|
|
|
|
|
message.success('已点赞')
|
2026-03-05 15:15:59 +08:00
|
|
|
}
|
|
|
|
|
isLiked.value = !isLiked.value
|
|
|
|
|
} catch (error) {
|
2026-03-26 10:28:28 +08:00
|
|
|
console.error('点赞操作失败:', error)
|
|
|
|
|
message.error('点赞操作失败,请稍后重试')
|
2026-03-05 15:15:59 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-27 15:57:14 +08:00
|
|
|
const handleAddToCart = async () => {
|
2026-03-26 10:28:28 +08:00
|
|
|
if (!product.value.id || !requireLogin('加入购物车')) {
|
|
|
|
|
return
|
|
|
|
|
}
|
2026-02-27 15:57:14 +08:00
|
|
|
try {
|
|
|
|
|
await cartApi.addToCart({ productId: product.value.id, quantity: 1 })
|
2026-02-28 17:09:45 +08:00
|
|
|
await updateCartCount()
|
2026-03-26 10:28:28 +08:00
|
|
|
message.success(`已将 ${product.value.title || product.value.name || '作品'} 加入购物车`)
|
2026-02-27 15:57:14 +08:00
|
|
|
} catch (error) {
|
2026-03-26 10:28:28 +08:00
|
|
|
console.error('加入购物车失败:', error)
|
|
|
|
|
message.error('加入购物车失败,请稍后重试')
|
2026-02-27 15:57:14 +08:00
|
|
|
}
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
|
|
|
|
|
2026-02-27 15:57:14 +08:00
|
|
|
const handleBuyNow = async () => {
|
2026-03-26 10:28:28 +08:00
|
|
|
if (!product.value.id || !requireLogin('预约下单')) {
|
|
|
|
|
return
|
|
|
|
|
}
|
2026-02-27 15:57:14 +08:00
|
|
|
try {
|
|
|
|
|
await cartApi.addToCart({ productId: product.value.id, quantity: 1 })
|
2026-02-28 17:09:45 +08:00
|
|
|
await updateCartCount()
|
2026-02-27 15:57:14 +08:00
|
|
|
router.push('/cart')
|
|
|
|
|
} catch (error) {
|
2026-03-26 10:28:28 +08:00
|
|
|
console.error('立即预约失败:', error)
|
|
|
|
|
message.error('操作失败,请稍后重试')
|
2026-02-27 15:57:14 +08:00
|
|
|
}
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
2026-02-24 09:59:22 +08:00
|
|
|
|
|
|
|
|
onMounted(() => {
|
2026-03-26 10:28:28 +08:00
|
|
|
void fetchProductDetail()
|
2026-02-24 09:59:22 +08:00
|
|
|
})
|
2026-02-13 17:34:32 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
2026-02-24 09:59:22 +08:00
|
|
|
.mobile-container {
|
|
|
|
|
min-height: 100vh;
|
|
|
|
|
background: #f5f5f5;
|
|
|
|
|
}
|
|
|
|
|
|
2026-02-13 17:34:32 +08:00
|
|
|
.header {
|
2026-02-24 09:59:22 +08:00
|
|
|
position: sticky;
|
|
|
|
|
top: 0;
|
|
|
|
|
z-index: 100;
|
2026-02-13 17:34:32 +08:00
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
2026-03-26 10:28:28 +08:00
|
|
|
justify-content: space-between;
|
|
|
|
|
gap: 12px;
|
|
|
|
|
padding: 10px 16px;
|
|
|
|
|
background: rgba(255, 255, 255, 0.96);
|
|
|
|
|
backdrop-filter: blur(10px);
|
|
|
|
|
border-bottom: 1px solid #f0f0f0;
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
2026-02-24 09:59:22 +08:00
|
|
|
|
2026-02-13 17:34:32 +08:00
|
|
|
.header h1 {
|
2026-03-05 15:15:59 +08:00
|
|
|
flex: 1;
|
2026-03-26 10:28:28 +08:00
|
|
|
margin: 0;
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
font-weight: 700;
|
2026-03-05 15:15:59 +08:00
|
|
|
text-align: center;
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
2026-02-24 09:59:22 +08:00
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
.header-star {
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
color: #8b8b9a;
|
2026-03-05 15:15:59 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
.header-star.active {
|
|
|
|
|
color: #f7b500;
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
.content {
|
|
|
|
|
padding: 16px 16px 108px;
|
2026-02-24 09:59:22 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
.hero-card,
|
|
|
|
|
.info-card {
|
|
|
|
|
max-width: 1040px;
|
|
|
|
|
margin: 0 auto 16px;
|
|
|
|
|
border-radius: 20px;
|
2026-03-05 15:15:59 +08:00
|
|
|
overflow: hidden;
|
2026-03-26 10:28:28 +08:00
|
|
|
background: white;
|
|
|
|
|
box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
|
2026-02-26 11:16:24 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
.carousel-slide,
|
|
|
|
|
.single-image {
|
|
|
|
|
aspect-ratio: 16 / 11;
|
|
|
|
|
overflow: hidden;
|
2026-02-24 09:59:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.product-image {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
object-fit: cover;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
.info-card {
|
|
|
|
|
padding: 24px;
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
2026-02-24 09:59:22 +08:00
|
|
|
|
2026-02-13 17:34:32 +08:00
|
|
|
.info-header {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
2026-02-24 09:59:22 +08:00
|
|
|
align-items: flex-start;
|
2026-03-26 10:28:28 +08:00
|
|
|
gap: 16px;
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
2026-02-24 09:59:22 +08:00
|
|
|
|
2026-02-13 17:34:32 +08:00
|
|
|
.product-name {
|
2026-03-26 10:28:28 +08:00
|
|
|
margin: 0 0 8px;
|
|
|
|
|
font-size: 26px;
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
color: #1f1f1f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.product-price {
|
2026-02-13 17:34:32 +08:00
|
|
|
margin: 0;
|
2026-03-26 10:28:28 +08:00
|
|
|
font-size: 28px;
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
color: #ff4d4f;
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
2026-02-24 09:59:22 +08:00
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
.metric-row {
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
|
|
|
gap: 12px;
|
|
|
|
|
margin-top: 20px;
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
2026-02-24 09:59:22 +08:00
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
.metric-card {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 10px;
|
|
|
|
|
width: 100%;
|
|
|
|
|
padding: 14px;
|
|
|
|
|
border: 1px solid #edf0f5;
|
|
|
|
|
border-radius: 16px;
|
|
|
|
|
background: #fafcff;
|
|
|
|
|
text-align: left;
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
2026-02-24 09:59:22 +08:00
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
.metric-card:disabled {
|
|
|
|
|
cursor: default;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.metric-card :deep(svg) {
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
color: #1677ff;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.metric-label {
|
|
|
|
|
display: block;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
color: #8b8b9a;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.metric-card strong {
|
2026-02-24 09:59:22 +08:00
|
|
|
font-size: 14px;
|
2026-03-26 10:28:28 +08:00
|
|
|
color: #1f1f1f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shop-summary {
|
|
|
|
|
margin-top: 18px;
|
|
|
|
|
padding: 16px 18px;
|
|
|
|
|
border-radius: 18px;
|
|
|
|
|
background: linear-gradient(135deg, #f8fbff 0%, #eef4ff 100%);
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shop-summary-title {
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
color: #1f1f1f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.shop-summary-text {
|
|
|
|
|
margin-top: 6px;
|
|
|
|
|
color: #666;
|
|
|
|
|
line-height: 1.6;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stats-row {
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 12px;
|
|
|
|
|
margin-top: 20px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.stat-btn {
|
|
|
|
|
display: inline-flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 8px;
|
|
|
|
|
padding: 10px 14px;
|
|
|
|
|
border: 1px solid #edf0f5;
|
|
|
|
|
border-radius: 999px;
|
|
|
|
|
background: white;
|
2026-02-24 09:59:22 +08:00
|
|
|
color: #666;
|
|
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
.stat-btn :deep(svg) {
|
|
|
|
|
font-size: 16px;
|
2026-02-24 09:59:22 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
.stat-btn :deep(.active),
|
|
|
|
|
.stat-btn :deep(svg.active) {
|
|
|
|
|
color: #ff4d4f;
|
2026-02-24 09:59:22 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
.stat-btn .active {
|
|
|
|
|
color: #ff4d4f;
|
2026-02-24 09:59:22 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
.stat-btn.static {
|
|
|
|
|
cursor: default;
|
2026-03-05 15:15:59 +08:00
|
|
|
}
|
|
|
|
|
|
2026-02-24 09:59:22 +08:00
|
|
|
.tags {
|
2026-03-26 10:28:28 +08:00
|
|
|
display: flex;
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
gap: 8px;
|
|
|
|
|
margin-top: 20px;
|
2026-02-24 09:59:22 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
.description-block {
|
|
|
|
|
margin-top: 24px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.description-block h3 {
|
|
|
|
|
margin: 0 0 12px;
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.description-block p {
|
2026-02-24 09:59:22 +08:00
|
|
|
margin: 0;
|
2026-03-26 10:28:28 +08:00
|
|
|
color: #666;
|
|
|
|
|
line-height: 1.8;
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.action-buttons {
|
2026-03-05 15:15:59 +08:00
|
|
|
position: fixed;
|
|
|
|
|
left: 0;
|
|
|
|
|
right: 0;
|
2026-03-26 10:28:28 +08:00
|
|
|
bottom: 0;
|
|
|
|
|
z-index: 120;
|
2026-03-05 15:15:59 +08:00
|
|
|
display: flex;
|
2026-03-26 10:28:28 +08:00
|
|
|
gap: 12px;
|
|
|
|
|
padding: 16px;
|
|
|
|
|
background: rgba(255, 255, 255, 0.96);
|
|
|
|
|
backdrop-filter: blur(10px);
|
2026-02-24 09:59:22 +08:00
|
|
|
border-top: 1px solid #f0f0f0;
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
2026-02-24 09:59:22 +08:00
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
.action-buttons :deep(.ant-btn) {
|
2026-03-05 15:15:59 +08:00
|
|
|
flex: 1;
|
2026-03-26 10:28:28 +08:00
|
|
|
height: 48px;
|
|
|
|
|
border-radius: 999px;
|
|
|
|
|
font-size: 15px;
|
|
|
|
|
font-weight: 700;
|
2026-02-13 17:34:32 +08:00
|
|
|
}
|
2026-02-24 09:59:22 +08:00
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
@media (max-width: 767px) {
|
|
|
|
|
.metric-row {
|
|
|
|
|
grid-template-columns: 1fr;
|
2026-03-24 09:59:52 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-26 10:28:28 +08:00
|
|
|
.stats-row {
|
|
|
|
|
flex-wrap: wrap;
|
2026-03-24 09:50:55 +08:00
|
|
|
}
|
|
|
|
|
}
|
2026-03-05 15:15:59 +08:00
|
|
|
</style>
|