Files
RenyiXCX/custom-tab-bar/index.js

55 lines
1.3 KiB
JavaScript
Raw Normal View History

2026-03-09 13:54:17 +08:00
Component({
data: {
selected: 0,
color: "#999999",
selectedColor: "#FF6B35",
2026-03-10 16:57:45 +08:00
"list": []
2026-03-09 13:54:17 +08:00
},
attached() {
2026-03-10 16:57:45 +08:00
const app = getApp();
const userId = wx.getStorageSync("userId");
const userInfodata = wx.getStorageSync("userInfo");
let ifsel = 0;
if (userId && userInfodata) {
const userInfo = JSON.parse(userInfodata);
ifsel = userInfo.bdshEnable;
}
// 从全局配置获取菜单列表
this.setData({
list: ifsel == 1 ? app.globalData.tabBarListBdsh : app.globalData.tabBarList
});
2026-03-09 13:54:17 +08:00
},
methods: {
switchTab(e) {
var data = e.currentTarget.dataset
var url = data.path
if(data.index==8){
var userId = wx.getStorageSync("userId")
var LoginId = wx.getStorageSync("LoginId")
var userInfodata = wx.getStorageSync("userInfo")
if(userId&&LoginId&&userInfodata){
wx.switchTab({
url: url,
});
this.setData({
selected: data.index
})
}else{
wx.navigateTo({
url: "../login/index"
})
}
}else{
wx.switchTab({
url: url,
});
this.setData({
selected: data.index
})
}
}
}
})