diff --git a/uniapp/manifest.json b/uniapp/manifest.json index b56f978..58eb3ae 100644 --- a/uniapp/manifest.json +++ b/uniapp/manifest.json @@ -1,6 +1,6 @@ { "name" : "学业邑规划", - "appid" : "__UNI__1BAACAB", + "appid" : "__UNI__A612028", "description" : "", "versionName" : "1.0.0", "versionCode" : "100", diff --git a/uniapp/pages/index/index.vue b/uniapp/pages/index/index.vue index 4e6b907..b54be78 100644 --- a/uniapp/pages/index/index.vue +++ b/uniapp/pages/index/index.vue @@ -218,18 +218,42 @@ async function initPageData() { } } +/** + * 内部页面跳转(兼容 TabBar 页面带参数) + * switchTab 不支持 query 参数,通过 globalData 传递 + */ +function navigateToInternal(url) { + if (!url) return + // 解析路径和参数 + const [path, queryStr] = url.split('?') + const query = {} + if (queryStr) { + queryStr.split('&').forEach(pair => { + const [key, val] = pair.split('=') + if (key) query[key] = decodeURIComponent(val || '') + }) + } + + uni.navigateTo({ + url, + fail: () => { + // TabBar 页面:通过 globalData 传递参数 + if (Object.keys(query).length > 0) { + getApp().globalData = getApp().globalData || {} + getApp().globalData.tabPageParams = query + } + uni.switchTab({ url: path }) + } + }) +} + /** * 处理Banner点击 */ function handleBannerClick(item) { if (!item.linkUrl) return if (item.linkType === 1) { - uni.navigateTo({ - url: item.linkUrl, - fail: () => { - uni.switchTab({ url: item.linkUrl }) - } - }) + navigateToInternal(item.linkUrl) } else if (item.linkType === 2) { uni.navigateTo({ url: `/pages/webview/index?url=${encodeURIComponent(item.linkUrl)}` @@ -251,12 +275,7 @@ function handleCardClick(item) { } // actionType === 1: 跳转页面 if (!item.linkUrl) return - uni.navigateTo({ - url: item.linkUrl, - fail: () => { - uni.switchTab({ url: item.linkUrl }) - } - }) + navigateToInternal(item.linkUrl) } /** diff --git a/uniapp/pages/team/index.vue b/uniapp/pages/team/index.vue index 07b8d3e..1835d1f 100644 --- a/uniapp/pages/team/index.vue +++ b/uniapp/pages/team/index.vue @@ -72,7 +72,7 @@ * tab 超出屏幕时可横向滚动 */ import { ref, computed, onMounted } from 'vue' -import { onLoad } from '@dcloudio/uni-app' +import { onLoad, onShow } from '@dcloudio/uni-app' import { getTeamInfo } from '@/api/team.js' import Loading from '@/components/Loading/index.vue' import Navbar from '@/components/Navbar/index.vue' @@ -90,6 +90,19 @@ onLoad((query) => { } }) +// switchTab 不支持 query 参数,通过 globalData 传递 +onShow(() => { + const app = getApp() + if (app.globalData && app.globalData.tabPageParams) { + const params = app.globalData.tabPageParams + if (params.tab !== undefined) { + activeIndex.value = Number(params.tab) || 0 + } + // 读取后清除,避免重复触发 + delete app.globalData.tabPageParams + } +}) + // 当前选中项 const currentItem = computed(() => { return items.value[activeIndex.value] || {}