设置不同角色 显示
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* TabBar Mixin
|
||||
* 用于在页面中自动显示/隐藏自定义 tabbar
|
||||
*/
|
||||
import { getVisibleTabBar, getCurrentTabIndex } from '@/common/tabbar.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
showTabBar: false,
|
||||
tabBarCurrent: 0
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.checkShowTabBar()
|
||||
},
|
||||
onShow() {
|
||||
this.checkShowTabBar()
|
||||
this.updateTabBarCurrent()
|
||||
},
|
||||
methods: {
|
||||
checkShowTabBar() {
|
||||
// 获取当前页面路径
|
||||
const pages = getCurrentPages()
|
||||
const currentPage = pages[pages.length - 1]
|
||||
const currentPath = currentPage.route || currentPage.$route?.path || ''
|
||||
|
||||
// 获取可见的 tabbar 列表
|
||||
const visibleTabs = getVisibleTabBar()
|
||||
|
||||
// 检查当前页面是否在 tabbar 列表中
|
||||
const path = currentPath.startsWith('/') ? currentPath.slice(1) : currentPath
|
||||
const isTabBarPage = visibleTabs.some(item => {
|
||||
const itemPath = item.pagePath.startsWith('/') ? item.pagePath.slice(1) : item.pagePath
|
||||
return itemPath === path
|
||||
})
|
||||
|
||||
this.showTabBar = isTabBarPage
|
||||
},
|
||||
updateTabBarCurrent() {
|
||||
if (this.showTabBar) {
|
||||
const pages = getCurrentPages()
|
||||
const currentPage = pages[pages.length - 1]
|
||||
const currentPath = currentPage.route || currentPage.$route?.path || ''
|
||||
this.tabBarCurrent = getCurrentTabIndex(currentPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user