feat(square): add 4 HotCategoryBlock components
- Import HotCategoryBlock and getHotInspirationFlowBatchApi - Add hotCategories and hotCategoryRefs state - Add loadHotCategories function to fetch categories - Add handleHotCardClick handler for navigation - Add template with v-for loop for hot category blocks - Add CSS style for .hot-category-wrapper - Call loadHotCategories in onMounted after loadBannerActivities Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
d45a2fb479
commit
bcc422109c
@ -70,6 +70,20 @@
|
|||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<!-- 热门分类区块 -->
|
||||||
|
<view
|
||||||
|
v-for="category in hotCategories"
|
||||||
|
:key="category.type"
|
||||||
|
class="hot-category-wrapper"
|
||||||
|
>
|
||||||
|
<HotCategoryBlock
|
||||||
|
:ref="el => { if(el) hotCategoryRefs[category.type] = el }"
|
||||||
|
:categoryType="category.type"
|
||||||
|
:title="category.title"
|
||||||
|
@cardClick="handleHotCardClick"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
|
||||||
<!-- 区域三:创作网格列表 -->
|
<!-- 区域三:创作网格列表 -->
|
||||||
<CreationGrid
|
<CreationGrid
|
||||||
:screenWidth="screenWidth"
|
:screenWidth="screenWidth"
|
||||||
@ -94,7 +108,9 @@ import BottomNav from '../components/BottomNav.vue'
|
|||||||
import GuideOverlay from '@/components/GuideOverlay.vue'
|
import GuideOverlay from '@/components/GuideOverlay.vue'
|
||||||
import RankingModal from '../components/RankingModal.vue'
|
import RankingModal from '../components/RankingModal.vue'
|
||||||
import BannerCarousel from './components/BannerCarousel.vue'
|
import BannerCarousel from './components/BannerCarousel.vue'
|
||||||
|
import HotCategoryBlock from './components/HotCategoryBlock.vue'
|
||||||
import CreationGrid from './components/CreationGrid.vue'
|
import CreationGrid from './components/CreationGrid.vue'
|
||||||
|
import { getHotInspirationFlowBatchApi } from '@/utils/api.js'
|
||||||
import { clearSubStepProgress, shouldShowGuideStartModal } from '@/utils/guideConfig.js'
|
import { clearSubStepProgress, shouldShowGuideStartModal } from '@/utils/guideConfig.js'
|
||||||
import { useBanner } from './composables/useBanner.js'
|
import { useBanner } from './composables/useBanner.js'
|
||||||
import { doubleTapLike } from '@/utils/likeHelper.js'
|
import { doubleTapLike } from '@/utils/likeHelper.js'
|
||||||
@ -112,6 +128,8 @@ const showRankingModal = ref(false)
|
|||||||
const isActive = ref(true)
|
const isActive = ref(true)
|
||||||
const isFixed = ref(false)
|
const isFixed = ref(false)
|
||||||
const creationGridRef = ref(null)
|
const creationGridRef = ref(null)
|
||||||
|
const hotCategories = ref([])
|
||||||
|
const hotCategoryRefs = ref({})
|
||||||
const cardTapTimers = {}
|
const cardTapTimers = {}
|
||||||
const likingMap = ref({})
|
const likingMap = ref({})
|
||||||
|
|
||||||
@ -176,6 +194,23 @@ const handleCardClick = (card) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const loadHotCategories = async () => {
|
||||||
|
try {
|
||||||
|
const res = await getHotInspirationFlowBatchApi()
|
||||||
|
if (res.code === 200 && res.data?.categories) {
|
||||||
|
hotCategories.value = res.data.categories
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('[square] 加载热门分类失败', e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const handleHotCardClick = (item) => {
|
||||||
|
uni.navigateTo({
|
||||||
|
url: `/pages/asset-detail/asset-detail?asset_id=${item.asset_id}`
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const handleScrollToLower = () => {
|
const handleScrollToLower = () => {
|
||||||
if (creationGridRef.value) {
|
if (creationGridRef.value) {
|
||||||
creationGridRef.value.loadMore()
|
creationGridRef.value.loadMore()
|
||||||
@ -242,6 +277,7 @@ onMounted(() => {
|
|||||||
|
|
||||||
resetSquare()
|
resetSquare()
|
||||||
loadBannerActivities()
|
loadBannerActivities()
|
||||||
|
loadHotCategories()
|
||||||
})
|
})
|
||||||
|
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
@ -371,6 +407,11 @@ onUnmounted(() => {
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* 热门分类区块 */
|
||||||
|
.hot-category-wrapper {
|
||||||
|
margin-bottom: 16rpx;
|
||||||
|
}
|
||||||
|
|
||||||
/* 蒙层 */
|
/* 蒙层 */
|
||||||
.nav-mask {
|
.nav-mask {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user