12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- Component({
- data: {
- active: 0,
- list: [],
- initList: [
- {
- icon: 'home-o',
- text: '首页',
- url: '/pages/index/index'
- },
- {
- icon: 'bar-chart-o',
- text: '数据中心',
- url: '/pages/data/index'
- },
- {
- icon: 'user-o',
- text: '个人中心',
- url: '/pages/account/index'
- }
- ],
- role: ''
- },
- lifetimes: {
- attached: function() {
-
- },
- },
- methods: {
- onChange(event) {
- this.setData({ active: event.detail });
- wx.switchTab({
- url: this.data.list[event.detail].url
- });
- },
- init() {
- const page = getCurrentPages().pop();
- var userInfo = getApp().globalData.userInfo
- var role = userInfo ? userInfo.topRole : ''
- var list = this.data.initList
- if(role && role.key == 'leader') {
- list = this.data.initList.slice(1)
- }
- this.setData({
- list: list
- })
- this.setData({
- active: this.data.list.findIndex(item => item.url === `/${page.route}`)
- });
- if(role) {
- this.setData({role})
- }
- }
- }
- });
|