Component({ /** * 组件的属性列表 */ properties: {}, lifetimes: { attached() { // 在组件实例进入页面节点树时执行 }, ready: function () { if (this.data.count == 1) return; if (wx.getStorageSync('userauth') != 0) { //判断页面 以免一直触发 let pages = getCurrentPages(); let prevPage = pages[pages.length - 1]; if (prevPage.route == 'pages/login/selectSite' || prevPage.route.includes('pages/tabbar/')) { let auth = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['通用'], ['个人中心']); let auth2 = getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['营销工具'], ['营销物料']); let list = ['首页', '信息']; auth.forEach(v => { switch (v.systemmodulename) { case "个人中心": list.push('我的') break; } }) if (auth2.length == 1) list.push('营销物料'); this.setData({ Permission: list, auth }) } } }, }, /** * 组件的初始数据 */ /* { icon: 'icon-a-biaoqianlangongzuo', text: '工作', url: '/pages/tabbar/workbench/index' }, */ data: { active: 'home', Permission: ['首页'], auth: [], //个人信息和消息信息的权限 tabbarList: [{ icon: 'icon-a-biaoqianlanshouyexuanzhong', text: '首页', url: '/pages/tabbar/home/index', name: 'home' }, { icon: 'icon-a-biaoqianlanxiaoxi', text: '信息', url: '/pages/tabbar/message/index', name: 'message' }, { icon: 'icon-a-biaoqianlanzhiku', text: '营销物料', url: '/pages/tabbar/smartStore/index', name: 'smartStore' }, { icon: 'icon-a-biaoqianlanwode', text: '我的', url: '/pages/tabbar/mine/index', name: 'mine' } ], }, /** * 组件的方法列表 */ methods: { /* tabbar */ onChange(event) { let active = event.detail, obj = this.data.tabbarList.find(v => v.name == active); wx.switchTab({ url: obj.url }); this.setData({ active }); }, init() { const page = getCurrentPages().pop(); let obj = this.data.tabbarList.find(item => item.url === `/${page.route}`); this.setData({ active: obj.name }); }, }, })