替换商品为作品
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
<div class="back-btn" @click="handleBackClick">
|
||||
<el-icon><ArrowLeft /></el-icon>
|
||||
</div>
|
||||
<h1>{{ product.name || '商品详情' }}</h1>
|
||||
<h1>{{ product.name || '作品详情' }}</h1>
|
||||
<div class="actions">
|
||||
<el-icon @click="handleFavoriteClick" :style="{ fontSize: '20px' }" :class="{ active: isFavorite }"><Star /></el-icon>
|
||||
</div>
|
||||
@@ -152,7 +152,7 @@ const productImages = ref<string[]>([])
|
||||
const imageIdCache = ref<Record<string, string>>({})
|
||||
const DEFAULT_PRODUCT_IMAGE = 'data:image/svg+xml;base64,PHN2ZyB3aW0dPSJodHRwOi8vd3d3Lm9yZy8yMDAwL3N2ZyI+Pjwvc3ZnPg=='
|
||||
|
||||
// 从后端获取商品详情
|
||||
// 从后端获取作品详情
|
||||
const fetchProductDetail = async () => {
|
||||
const productId = route.params.id
|
||||
|
||||
@@ -168,7 +168,7 @@ const fetchProductDetail = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 检查商品是否在收藏列表中
|
||||
// 检查作品是否在收藏列表中
|
||||
const checkWishlistStatus = async () => {
|
||||
if (product.value.id) {
|
||||
const token = localStorage.getItem('accessToken') || sessionStorage.getItem('accessToken')
|
||||
@@ -187,7 +187,7 @@ const checkWishlistStatus = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 检查用户是否已点赞商品
|
||||
// 检查用户是否已点赞作品
|
||||
const checkLikeStatus = async () => {
|
||||
if (product.value.id) {
|
||||
const token = localStorage.getItem('accessToken') || sessionStorage.getItem('accessToken')
|
||||
@@ -206,7 +206,7 @@ const checkLikeStatus = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 加载商品图片
|
||||
// 加载作品图片
|
||||
const loadProductImages = async () => {
|
||||
if (product.value.imageFileIds) {
|
||||
const ids = product.value.imageFileIds.split(',')
|
||||
@@ -309,7 +309,7 @@ const handleAddToCart = async () => {
|
||||
try {
|
||||
await cartApi.addToCart({ productId: product.value.id, quantity: 1 })
|
||||
await updateCartCount()
|
||||
ElMessage.success(`已将 ${product.value.title || product.value.name || '商品'} 添加到购物车`)
|
||||
ElMessage.success(`已将 ${product.value.title || product.value.name || '作品'} 添加到购物车`)
|
||||
} catch (error) {
|
||||
console.error('添加到购物车失败:', error)
|
||||
ElMessage.error('添加到购物车失败,请重试')
|
||||
@@ -327,7 +327,7 @@ const handleBuyNow = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 页面挂载时获取商品详情
|
||||
// 页面挂载时获取作品详情
|
||||
onMounted(() => {
|
||||
fetchProductDetail()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user