feat: 调整了跳转的交互
This commit is contained in:
@@ -20,6 +20,11 @@
|
||||
|
||||
<script setup>
|
||||
import { onMounted, ref } from "vue";
|
||||
import { SEND_MESSAGE_CONTENT_TEXT, SEND_MESSAGE_COMMAND_TYPE, SWITCH_TO_COMPANION_TAB } from "@/constant/constant";
|
||||
import { navigateTo } from "@/router";
|
||||
import { getAccessToken } from "@/constant/token";
|
||||
import { checkToken } from "@/hooks/useGoLogin";
|
||||
|
||||
import FindTabs from "./components/FindTabs/index.vue";
|
||||
import CardSwiper from "./components/CardSwiper/index.vue";
|
||||
import QuickQuestions from "./components/QuickQuestions/index.vue";
|
||||
@@ -27,6 +32,7 @@ import discoveryCover from "@/components/ImageSwiper/images/2025-07-12_180248.jp
|
||||
|
||||
import { homeTabsData, homeTabContentData, homeQuickQuestionData } from "../../request/api/MainPageDataApi";
|
||||
import { useAppStore } from "@/store";
|
||||
import { JumpType } from "../../model/ChatModel";
|
||||
const appStore = useAppStore();
|
||||
/// 从个渠道获取如二维码
|
||||
const sceneId = appStore.sceneId || "";
|
||||
@@ -101,20 +107,50 @@ const configDataList = (data) => {
|
||||
tabContentId: item.tabContent.id,
|
||||
jumpContent: item.tabContent.jumpContent,
|
||||
jumpDesc: item.tabContent.jumpDesc,
|
||||
jumpType: item.tabContent.jumpType,
|
||||
jumpType: item.tabContent.jumpType,/// 跳转类型: 0商品 1提示词 2链接 3组件指令
|
||||
}));
|
||||
}
|
||||
|
||||
/// 卡片点击事件
|
||||
const handleCardClick = (item) => {
|
||||
console.log(JSON.stringify(item));
|
||||
handleClick(item);
|
||||
};
|
||||
|
||||
/// 快速问题点击事件
|
||||
const handleQuickQuestionClick = (item) => {
|
||||
console.log(JSON.stringify(item));
|
||||
handleClick(item);
|
||||
};
|
||||
|
||||
const handleClick = async (item) => {
|
||||
await checkToken();
|
||||
|
||||
console.log(`执行点击事件: ${item.jumpType},参数:${JSON.stringify(item.jumpContent)}`);
|
||||
/// 商品
|
||||
if (item.jumpType === JumpType.commodity) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/goods/index?commodityId=${item.jumpContent}`,
|
||||
});
|
||||
}
|
||||
/// 提示词
|
||||
else if (item.jumpType === JumpType.prompt) {
|
||||
uni.$emit(SWITCH_TO_COMPANION_TAB); /// 切换到伴游tab
|
||||
uni.$emit(SEND_MESSAGE_CONTENT_TEXT, item.jumpContent);
|
||||
}
|
||||
/// 链接
|
||||
else if (item.jumpType === JumpType.link) {
|
||||
if (item.jumpContent) {
|
||||
const token = getAccessToken();
|
||||
navigateTo(item.jumpContent, { token: token });
|
||||
}
|
||||
}
|
||||
/// 组件指令
|
||||
else if (item.jumpType === JumpType.command) {
|
||||
uni.$emit(SWITCH_TO_COMPANION_TAB); /// 切换到伴游tab
|
||||
uni.$emit(SEND_MESSAGE_COMMAND_TYPE, { type: item.jumpContent, title: item.jumpDesc });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// 组件挂载后请求数据
|
||||
onMounted(() => {
|
||||
queryTabsList();
|
||||
|
||||
Reference in New Issue
Block a user