替换商品为作品
This commit is contained in:
@@ -6,11 +6,11 @@
|
||||
<a-button class="back-btn" type="text" @click="handleBackClick">
|
||||
<LeftOutlined :style="{ fontSize: '20px' }" />
|
||||
</a-button>
|
||||
<h1 v-if="!showSearch">商品列表</h1>
|
||||
<h1 v-if="!showSearch">作品列表</h1>
|
||||
<div v-else class="search-input-container">
|
||||
<a-input-search
|
||||
v-model:value="searchKeyword"
|
||||
placeholder="搜索商品"
|
||||
placeholder="搜索作品"
|
||||
class="search-input"
|
||||
@search="handleSearch"
|
||||
enter-button
|
||||
@@ -36,9 +36,9 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧商品区域 -->
|
||||
<!-- 右侧作品区域 -->
|
||||
<div class="product-section">
|
||||
<!-- 商品网格 -->
|
||||
<!-- 作品网格 -->
|
||||
<div class="product-grid">
|
||||
<a-card
|
||||
v-for="item in products"
|
||||
@@ -48,7 +48,7 @@
|
||||
hoverable
|
||||
@click="handleProductClick(item)"
|
||||
>
|
||||
<!-- 商品图片 -->
|
||||
<!-- 作品图片 -->
|
||||
<div class="product-img">
|
||||
<img
|
||||
v-if="getProductImages(item) && getProductImages(item).length > 0"
|
||||
@@ -66,7 +66,7 @@
|
||||
class="product-tag"
|
||||
/>
|
||||
</div>
|
||||
<!-- 商品信息 -->
|
||||
<!-- 作品信息 -->
|
||||
<div class="product-info">
|
||||
<p class="name">{{ item.title || item.name }}</p>
|
||||
<div class="product-meta">
|
||||
@@ -139,7 +139,7 @@
|
||||
|
||||
<!-- 空状态 -->
|
||||
<div v-if="products.length === 0 && !loading" class="empty-state">
|
||||
<a-typography-text type="secondary">商家暂未上架更多商品</a-typography-text>
|
||||
<a-typography-text type="secondary">商家暂未上架更多作品</a-typography-text>
|
||||
</div>
|
||||
|
||||
<!-- 加载更多 -->
|
||||
@@ -147,7 +147,7 @@
|
||||
<a-button v-if="hasMore" type="link" @click="handleLoadMore">
|
||||
加载更多 <DownOutlined />
|
||||
</a-button>
|
||||
<a-typography-text v-else type="secondary">没有更多商品了</a-typography-text>
|
||||
<a-typography-text v-else type="secondary">没有更多作品了</a-typography-text>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -195,7 +195,7 @@ const selectedCategory = ref('全部')
|
||||
// 分类列表(动态从标签获取)
|
||||
const categories = ref<string[]>(['全部'])
|
||||
|
||||
// 商品数据
|
||||
// 作品数据
|
||||
const products = ref<ProductVO[]>([])
|
||||
|
||||
// 是否还有更多数据
|
||||
@@ -225,7 +225,7 @@ const fetchTags = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 加载商品列表
|
||||
// 加载作品列表
|
||||
const loadImageUrls = async (productList: ProductVO[]) => {
|
||||
for (const product of productList) {
|
||||
if (product.imageFileIds) {
|
||||
@@ -258,7 +258,7 @@ const getProductImages = (product: ProductVO): string[] => {
|
||||
return imageUrls.value[product.id] || [DEFAULT_PRODUCT_IMAGE]
|
||||
}
|
||||
|
||||
// 从后端获取商品数据
|
||||
// 从后端获取作品数据
|
||||
const fetchProducts = async () => {
|
||||
if (loading.value) return
|
||||
|
||||
@@ -300,7 +300,7 @@ const handleCategoryClick = (category: string) => {
|
||||
fetchProducts()
|
||||
}
|
||||
|
||||
// 处理商品卡片点击
|
||||
// 处理作品卡片点击
|
||||
const handleProductClick = (item: any) => {
|
||||
router.push(`/product/${item.id}`)
|
||||
}
|
||||
@@ -309,7 +309,7 @@ const handleProductClick = (item: any) => {
|
||||
const handleAddToCart = async (item: any) => {
|
||||
try {
|
||||
await cartApi.addToCart({ productId: item.id, quantity: 1 })
|
||||
message.success(`已将 ${item.title || item.name || '商品'} 添加到购物车`)
|
||||
message.success(`已将 ${item.title || item.name || '作品'} 添加到购物车`)
|
||||
} catch (error) {
|
||||
message.error('添加到购物车失败,请重试')
|
||||
}
|
||||
@@ -327,7 +327,7 @@ const toggleSearch = () => {
|
||||
if (!showSearch.value) {
|
||||
searchKeyword.value = ''
|
||||
isSearching.value = false
|
||||
fetchProducts() // 重置为默认商品列表
|
||||
fetchProducts() // 重置为默认作品列表
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ const handleSearch = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 页面挂载时获取标签和商品数据
|
||||
// 页面挂载时获取标签和作品数据
|
||||
onMounted(async () => {
|
||||
await fetchTags()
|
||||
fetchProducts()
|
||||
@@ -445,7 +445,7 @@ onMounted(async () => {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* 右侧商品区域 */
|
||||
/* 右侧作品区域 */
|
||||
.product-section {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
|
||||
Reference in New Issue
Block a user