import {getStaffbasicinfo} from "../../utils/api"; const app = getApp() import {getOwnedRolesOfStaffId} from '../../utils/statisticsApi.js' Component({ data: { selected: 0, color: "#999", selectedColor: "#3A80E7", "list": [ { "pagePath": "/pages/index/index", "text": "消息", "iconPath": "/images/home/message.png", "selectedIconPath": "/images/home/messageSelected.png", show: true }, { "pagePath": "/pages/work/work", "text": "工作", "iconPath": "/images/home/work.png", "selectedIconPath": "/images/home/workSelected.png", show: true }, , { "pagePath": "/pages/work2/work2", "text": "工作", "iconPath": "/images/home/work.png", "selectedIconPath": "/images/home/workSelected.png", show: true }, { "pagePath": "/pages/statistics/statistics", "text": "数据", "iconPath": "/images/home/information.png", "selectedIconPath": "/images/home/informationSelected.png", show: false }, { "pagePath": "/pages/mine/mine", "text": "我的", "iconPath": "/images/home/mine.png", "selectedIconPath": "/images/home/mineSelected.png", show: true } ], }, attached() { }, ready: function () { this.setData({ selected: app.globalData.selected }) // secretary 书记 admin 管理员 console.log( app.globalData.roleList.filter(item => item.roleKey === 'secretary')) if(app.globalData.roleList.length <= 0) { getStaffbasicinfo().then(res=>{ getOwnedRolesOfStaffId(res.data.id).then(res2 => { app.globalData.user = res.data this.setData({ "list[2].show": res2.data.filter(item => item.roleKey === 'secretary' || item.roleKey === 'admin').length > 0 }) }) }) } else { this.setData({ "list[2].show": app.globalData.roleList.filter(item => item.roleKey === 'secretary' || item.roleKey === 'admin').length > 0 }) } console.log(app.globalData.roleList, 'userss') }, methods: { switchTab(e) { console.log(e); const data = e.currentTarget.dataset; const url = data.path; app.globalData.selected = data.index; wx.switchTab({url}) } } })