59 lines
1.5 KiB
TypeScript
Raw Normal View History

2025-07-09 00:34:00 +08:00
import { Merchant, Investor, Agent } from './updateMenu'
2025-07-08 16:49:39 +08:00
export function setTabBar(res: { id?: number; name?: string; type?: string }) {
2025-07-09 00:34:00 +08:00
const App: any = getApp()
App.globalData.selectedOrg = res
if (res?.type === 'boss') {
2025-07-08 16:49:39 +08:00
//商户-首页
2025-07-09 00:34:00 +08:00
uni.switchTab({ url: '/pages/MERCHANT/index/index' })
2025-07-08 16:49:39 +08:00
}
2025-07-09 00:34:00 +08:00
if (res?.type === 'investor') {
2025-07-08 16:49:39 +08:00
//投资方-首页
2025-07-09 00:34:00 +08:00
uni.switchTab({ url: '/pages/INVESTOR/index/index' })
2025-07-08 16:49:39 +08:00
}
2025-07-09 00:34:00 +08:00
if (res?.type === 'agent') {
2025-07-08 16:49:39 +08:00
//代理商-首页
2025-07-09 00:34:00 +08:00
uni.switchTab({ url: '/pages/AGENT/index/index' })
2025-07-08 16:49:39 +08:00
}
2025-07-09 00:34:00 +08:00
console.log('App.globalData.selectedOrg', App.globalData.selectedOrg)
2025-07-08 16:49:39 +08:00
}
export function setTabBarData(idx: number, type?: string) {
2025-07-09 00:34:00 +08:00
const pages = getCurrentPages()
const currentPage: any = pages[pages.length - 1]
2025-07-08 16:49:39 +08:00
// 检查是否有TabBar并设置选中的菜单
if (currentPage) {
2025-07-09 00:34:00 +08:00
const tabBar = currentPage.getTabBar ? currentPage.getTabBar() : null
2025-07-08 16:49:39 +08:00
if (tabBar) {
if (idx === 3) {
2025-07-09 00:34:00 +08:00
if (type === 'boss') {
2025-07-08 16:49:39 +08:00
//商户菜单
tabBar.setData({
selected: 3,
2025-07-09 00:34:00 +08:00
list: Merchant
})
2025-07-08 16:49:39 +08:00
}
2025-07-09 00:34:00 +08:00
if (type === 'investor') {
2025-07-08 16:49:39 +08:00
//投资方菜单
tabBar.setData({
selected: 3,
2025-07-09 00:34:00 +08:00
list: Investor
})
2025-07-08 16:49:39 +08:00
}
2025-07-09 00:34:00 +08:00
if (type === 'agent') {
2025-07-08 16:49:39 +08:00
//代理商
tabBar.setData({
selected: 3,
2025-07-09 00:34:00 +08:00
list: Agent
})
2025-07-08 16:49:39 +08:00
}
2025-07-09 00:34:00 +08:00
return
2025-07-08 16:49:39 +08:00
}
tabBar.setData({
2025-07-09 00:34:00 +08:00
selected: idx
})
2025-07-08 16:49:39 +08:00
} else {
2025-07-09 00:34:00 +08:00
console.error('当前页面没有TabBar')
2025-07-08 16:49:39 +08:00
}
}
}