chore: 首次提交 - 关联 GitHub fnvtk/MBTI_wang

Made-with: Cursor
This commit is contained in:
卡若
2026-03-17 12:39:38 +08:00
commit eb510304c0
259 changed files with 60464 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
// 自定义 tabBar不使用微信内置灰线 + 三栏,中间为浮起圆钮
Component({
data: {
selected: 0,
list: [
{ pagePath: '/pages/index/index', text: '首页', textKey: 'home', icon: 'home' },
{ pagePath: '/pages/index/camera', text: '查看报告', textKey: 'camera', icon: 'camera' },
{ pagePath: '/pages/profile/index', text: '我的', textKey: 'profile', icon: 'user' }
]
},
lifetimes: {
attached() {
this.updateSelected()
}
},
pageLifetimes: {
show() {
this.updateSelected()
}
},
methods: {
updateSelected() {
try {
const pages = getCurrentPages()
if (!pages || pages.length === 0) {
return
}
const currentPage = pages[pages.length - 1]
if (!currentPage || !currentPage.route) {
return
}
const url = currentPage.route
let selected = 0
if (url === 'pages/index/index' || url === 'pages/enterprise/index') {
selected = 0
} else if (url === 'pages/index/camera') {
selected = 1
} else if (url === 'pages/profile/index') {
selected = 2
}
this.setData({ selected })
} catch (error) {
console.error('updateSelected error:', error)
// 默认选中第一个
this.setData({ selected: 0 })
}
},
switchTab(e) {
const index = parseInt(e.currentTarget.dataset.index, 10)
let url = e.currentTarget.dataset.path
// 点击"首页"index=0根据当前 scope 跳到企业版或个人版首页
if (index === 0) {
try {
const app = getApp()
const scope = (app && app.globalData && app.globalData.appScope) || 'personal'
if (scope === 'enterprise') {
// 企业版navigateTo不是 tabBar 页面,不能用 switchTab
wx.navigateTo({ url: '/pages/enterprise/index' })
this.setData({ selected: index })
return
}
} catch (e) {}
}
wx.switchTab({ url })
this.setData({ selected: index })
}
}
})