Files
MBTI_wang/miniprogram/custom-tab-bar/index.js
Ghost 6584417ed8 fix: 审核模式 runtime 同步、邀请码与小端 tabBar/个人中心及管理端用户页
- api: AppConfig runtime 返回 reviewMode;Invite/Settings/AppUser 等调整
- 微信小程序与抖音:app 与 tabBar、enterprise/camera/index/upload/profile 对齐审核与邀请逻辑
- 管理端:Dashboard、Settings、Users、UserDetailDialog 等更新

Made-with: Cursor
2026-03-28 17:46:36 +08:00

73 lines
2.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 自定义 tabBar不使用微信内置灰线 + 三栏,中间为浮起圆钮
Component({
data: {
selected: 0,
/** 审核模式:为 true 时隐藏中间「拍摄」入口(与 globalData.reviewMode / maintenanceMode 一致) */
reviewMode: false,
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
const gd = getApp().globalData || {}
const reviewMode = !!(gd.reviewMode || gd.maintenanceMode)
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, reviewMode })
} catch (error) {
console.error('updateSelected error:', error)
this.setData({ selected: 0, reviewMode: false })
}
},
switchTab(e) {
const index = parseInt(e.currentTarget.dataset.index, 10)
let url = e.currentTarget.dataset.path
const gd = getApp().globalData || {}
if (index === 1 && !!(gd.reviewMode || gd.maintenanceMode)) {
return
}
if (index === 0) {
try {
const app = getApp()
const scope = (app && app.globalData && app.globalData.appScope) || 'personal'
if (scope === 'enterprise') {
wx.navigateTo({ url: '/pages/enterprise/index' })
this.setData({ selected: index })
return
}
} catch (e) {}
}
wx.switchTab({ url })
this.setData({ selected: index })
}
}
})