feat: 首页接口资源接口对接
This commit is contained in:
@@ -50,8 +50,7 @@ import DiscoveryAudioToolCard from "./components/DiscoveryAudioToolCard/index.vu
|
||||
import DiscoveryGuideMapToolCard from "./components/DiscoveryGuideMapToolCard/index.vue";
|
||||
import DiscoveryGoodsCard from "./components/DiscoveryGoodsCard/index.vue";
|
||||
import PanoramicHome from "./components/PanoramicHome/index.vue";
|
||||
|
||||
import { homeTabsData, getNearbyTags, homeTabContentData, homeQuickQuestionData } from "../../request/api/MainPageDataApi";
|
||||
import { homeTabsData, getNearbyTags, homeTabContentData, homeQuickQuestionData, resourceCenterData } from "../../request/api/MainPageDataApi";
|
||||
import { useAppStore, useLocationStore } from "@/store";
|
||||
import { JumpType } from "../../model/ChatModel";
|
||||
|
||||
@@ -65,6 +64,7 @@ const discoveryTabs = ref([]);
|
||||
const discoveryCards = ref([]);
|
||||
const exploreCards = ref([]);
|
||||
const discoveryQuickQuestions = ref([]);
|
||||
const discoveryResourceCenterItems = ref([]);
|
||||
const emit = defineEmits(["content-scroll"]);
|
||||
|
||||
/// 是否是主景区引导页 默认是 true,点击主景区后为 false
|
||||
@@ -84,13 +84,14 @@ const handleMainPanoramaClick = () => {
|
||||
discoveryCards.value = [];
|
||||
exploreCards.value = [];
|
||||
discoveryQuickQuestions.value = [];
|
||||
discoveryResourceCenterItems.value = [];
|
||||
};
|
||||
|
||||
|
||||
/// tabs 切换事件
|
||||
const handleTabChange = ({ tab, idx }) => {
|
||||
activeIndex.value = idx;
|
||||
queryDiscoveryData(tab.id);
|
||||
queryDiscoveryData(tab);
|
||||
}
|
||||
|
||||
/// 请求发现页tab数据
|
||||
@@ -123,24 +124,31 @@ const handlePanoramicHomeSelect = (item) => {
|
||||
|
||||
/// 根据id查询tab并设置activeIndex
|
||||
const findTabByIdWithActiveTabIndex = (tabsId) => {
|
||||
/// 查询是否有id参数
|
||||
const activeTabIndex = discoveryTabs.value.findIndex((tab) => tab.id === tabsId);
|
||||
/// 如果有则优先展示对应tab数据,没有则展示第一个tab数据
|
||||
if (activeTabIndex > -1) {
|
||||
activeIndex.value = activeTabIndex;
|
||||
queryDiscoveryData(tabsId);
|
||||
} else {
|
||||
if (discoveryTabs.value.length > 0) {
|
||||
activeIndex.value = 0;
|
||||
queryDiscoveryData(discoveryTabs.value[0].id);
|
||||
}
|
||||
}
|
||||
const resolvedTab = resolveDiscoveryTab(discoveryTabs.value, tabsId);
|
||||
if (!resolvedTab.tab) return;
|
||||
|
||||
activeIndex.value = resolvedTab.activeIndex;
|
||||
queryDiscoveryData(resolvedTab.tab);
|
||||
}
|
||||
|
||||
/// 找到对应的tab后,查询发现页数据
|
||||
const resolveDiscoveryTab = (tabs, tabId) => {
|
||||
if (!Array.isArray(tabs) || tabs.length === 0) {
|
||||
return { activeIndex: -1, tab: null };
|
||||
}
|
||||
|
||||
const matchedIndex = tabs.findIndex((tab) => tab.id === tabId);
|
||||
const activeIndex = matchedIndex > -1 ? matchedIndex : 0;
|
||||
return { activeIndex, tab: tabs[activeIndex] };
|
||||
};
|
||||
|
||||
/// 统一请求发现页数据
|
||||
const queryDiscoveryData = async (tabId) => {
|
||||
queryDiscoveryCards(tabId);
|
||||
queryQuickQuestionData(tabId);
|
||||
const queryDiscoveryData = async (tab) => {
|
||||
if (!tab?.id) return;
|
||||
|
||||
queryDiscoveryCards(tab.id);
|
||||
queryQuickQuestionData(tab.id);
|
||||
loadResourceCenterDataList(tab.resourceSetCode);
|
||||
};
|
||||
|
||||
/// 请求发现页卡片数据
|
||||
@@ -173,6 +181,15 @@ const queryQuickQuestionData = async (tabId) => {
|
||||
}
|
||||
}
|
||||
|
||||
/// 按资源集编码读取当前生效快照
|
||||
const loadResourceCenterDataList = async (resourceSetCode) => {
|
||||
if (!resourceSetCode) return;
|
||||
const res = await resourceCenterData({ resourceSetCode });
|
||||
if (res.code === 0) {
|
||||
discoveryResourceCenterItems.value = res.data;
|
||||
}
|
||||
}
|
||||
|
||||
/// 统一处理接口返回数据结构
|
||||
const configDataList = (data) => {
|
||||
return data.map((item) => ({
|
||||
|
||||
@@ -15,6 +15,11 @@ function homeTabContentData(args) {
|
||||
return request.post("/hotelBiz/mainScene/queryContentListWithCache", args);
|
||||
}
|
||||
|
||||
/// 按资源集编码读取当前生效快照
|
||||
function resourceCenterData(args) {
|
||||
return request.post("/hotelBiz/resourceCenter/client/sets", args);
|
||||
}
|
||||
|
||||
/// 获取距离用户最近的标签
|
||||
function getNearbyTags(args) {
|
||||
return request.get("/hotelBiz/mainScene/nearestTag", args);
|
||||
@@ -55,6 +60,7 @@ export {
|
||||
homeAllScenicData,
|
||||
homeTabsData,
|
||||
homeTabContentData,
|
||||
resourceCenterData,
|
||||
getNearbyTags,
|
||||
getLocalWeather,
|
||||
getTimeNoticeList,
|
||||
|
||||
Reference in New Issue
Block a user