feat: 调整展示逻辑

This commit is contained in:
2026-07-30 13:40:23 +08:00
parent 9e048a1174
commit f17c6e5e3f

View File

@@ -16,10 +16,10 @@
</view> </view>
<scroll-view class="h-0 min-h-0 w-full flex-1 overflow-hidden" scroll-y @scroll="handleContentScroll"> <scroll-view class="h-0 min-h-0 w-full flex-1 overflow-hidden" scroll-y @scroll="handleContentScroll">
<view v-if="isMainPanoramaGuide" class="flex w-full flex-col gap-[12px]"> <view v-show="isMainPanoramaGuide" class="flex w-full flex-col gap-[12px]">
<PanoramicHome @select="handlePanoramicHomeSelect" /> <PanoramicHome @select="handlePanoramicHomeSelect" />
</view> </view>
<view v-else class="flex w-full flex-col gap-[12px]"> <view v-if="!isMainPanoramaGuide" class="flex w-full flex-col gap-[12px]">
<CardSwiper v-if="discoveryCards.length > 0" :list="discoveryCards" @didSelectItem="handleCardClick" /> <CardSwiper v-if="discoveryCards.length > 0" :list="discoveryCards" @didSelectItem="handleCardClick" />
<ExploreCards v-if="exploreCards.length > 0" :list="exploreCards" @didSelectItem="handleCardClick" /> <ExploreCards v-if="exploreCards.length > 0" :list="exploreCards" @didSelectItem="handleCardClick" />
@@ -68,6 +68,7 @@ const emit = defineEmits(["content-scroll"]);
/// 是否是主景区引导页 默认是 true点击主景区后为 false /// 是否是主景区引导页 默认是 true点击主景区后为 false
const isMainPanoramaGuide = ref(true); const isMainPanoramaGuide = ref(true);
/// 监听页面滚动事件
const handleContentScroll = (e) => { const handleContentScroll = (e) => {
emit("content-scroll", { emit("content-scroll", {
scrollTop: Number(e.detail?.scrollTop || 0), scrollTop: Number(e.detail?.scrollTop || 0),
@@ -92,23 +93,29 @@ const handleTabChange = ({ tab, idx }) => {
/// 请求发现页tab数据 /// 请求发现页tab数据
const queryTabsList = async (homePageId) => { const queryTabsList = async (homePageId) => {
const res = await homeTabsData({ homePageId }); const res = await homeTabsData({ homePageId });
if (res.code === 0) { if (res.code === 0 && Array.isArray(res.data)) {
/// 处理tab数据
const tabList = res.data; const tabList = res.data;
/// 设置tab数据 if (tabList.length === 0) {
uni.showToast({
title: "暂无发现内容",
icon: "none"
});
return;
};
isMainPanoramaGuide.value = false;
discoveryTabs.value.push(...tabList); discoveryTabs.value.push(...tabList);
/// 根据sceneId查询对应tab数据 /// 根据sceneId查询对应tab数据
findTabByIdWithActiveTabIndex(sceneId); findTabByIdWithActiveTabIndex(sceneId);
/// 如果没有sceneId则获取位置信息获取附近标签数据
getLocation();
} }
} }
/// 点击主景区后选择景区后查询对应tab数据
const handlePanoramicHomeSelect = (item) => { const handlePanoramicHomeSelect = (item) => {
const homePageId = item?.homePageId; const homePageId = item?.homePageId;
if (!homePageId) return; if (!homePageId) return;
isMainPanoramaGuide.value = false;
queryTabsList(homePageId); queryTabsList(homePageId);
getLocation();
}; };
/// 根据id查询tab并设置activeIndex /// 根据id查询tab并设置activeIndex