商品标签筛选功能完善
This commit is contained in:
@@ -147,8 +147,8 @@ const allTags = ref<TagVO[]>([])
|
||||
// 当前选中的分类
|
||||
const selectedCategory = ref('全部')
|
||||
|
||||
// 分类列表
|
||||
const categories = ['全部', '美甲', '美睫', '手足护理', '纹绣']
|
||||
// 分类列表(动态从标签获取)
|
||||
const categories = ref<string[]>(['全部'])
|
||||
|
||||
// 商品数据
|
||||
const products = ref<ProductVO[]>([])
|
||||
@@ -164,6 +164,8 @@ const fetchTags = async () => {
|
||||
try {
|
||||
const tags = await tagApi.getAllTags()
|
||||
allTags.value = tags as unknown as TagVO[]
|
||||
// 动态生成分类列表
|
||||
categories.value = ['全部', ...allTags.value.map(tag => tag.tagName)]
|
||||
} catch (error) {
|
||||
console.error('获取标签失败:', error)
|
||||
}
|
||||
@@ -240,9 +242,9 @@ const handleLoadMore = () => {
|
||||
hasMore.value = false
|
||||
}
|
||||
|
||||
// 页面挂载时获取商品数据
|
||||
onMounted(() => {
|
||||
fetchTags()
|
||||
// 页面挂载时获取标签和商品数据
|
||||
onMounted(async () => {
|
||||
await fetchTags()
|
||||
fetchProducts()
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user