Files
ks-app-employment-service/utils/tabbarManager.js
2025-10-23 17:16:16 +08:00

46 lines
1.1 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管理器
export const tabbarManager = {
// 显示tabbar
showTabBar() {
if (typeof getTabBar === 'function' && getTabBar()) {
getTabBar().setData({
selected: 0
});
}
},
// 更新tabbar选中状态
updateSelected(index) {
if (typeof getTabBar === 'function' && getTabBar()) {
getTabBar().setData({
selected: index
});
}
},
// 根据用户类型更新tabbar
updateTabBarByUserType() {
if (typeof getTabBar === 'function' && getTabBar()) {
const userInfo = uni.getStorageSync('userInfo') || {};
const userType = userInfo.isCompanyUser !== undefined ? userInfo.isCompanyUser : 1;
getTabBar().generateTabbarList(userType);
}
},
// 初始化tabbar
initTabBar() {
// 延迟初始化自定义tabbar
setTimeout(() => {
this.updateTabBarByUserType();
}, 200);
},
// 强制刷新tabbar登录后调用
refreshTabBar() {
// 延迟刷新,确保用户信息已更新
setTimeout(() => {
this.updateTabBarByUserType();
}, 100);
}
};