跳转
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
18631081161 2026-04-02 19:07:01 +08:00
parent 7e368dc111
commit ff61ee72b1
3 changed files with 46 additions and 14 deletions

View File

@ -1,6 +1,6 @@
{
"name" : "学业邑规划",
"appid" : "__UNI__1BAACAB",
"appid" : "__UNI__A612028",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "100",

View File

@ -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)
}
/**

View File

@ -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] || {}