1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- const app = getApp();
- import { system } from '../../utils/dict';
- Component({
- /**
- * 组件的属性列表
- */
- options: { multipleSlots: true },
- properties: {
- // tabSelectid: { type: 'string', value: '' }
- },
- // 生命周期函数,可以为函数,或一个在methods段中定义的方法名
- attached: function () { }, // 此处attached的声明会被lifetimes字段中的声明覆盖
- ready: function () { },
- pageLifetimes: {
- // 组件所在页面的生命周期函数
- show: function () { this.search() },
- hide: function () { },
- resize: function () { },
- },
- /**
- * 组件的初始数据
- */
- data: {
- // 菜单列表
- menuList: [],
- active: 0,
- },
- /**
- * 组件的方法列表
- */
- methods: {
- // 跳转
- tabPath(e) {
- const that = this;
- this.setData({ active: e.detail })
- let route = that.data.menuList[e.detail];
- if (route) this.triggerEvent('tabPath', route);
- },
- search() {
- const that = this;
- wx.getStorage({
- key: 'token',
- success: res => {
- let pages = getCurrentPages();
- let currentPage = pages[pages.length - 1];
- let menu = system.filter((i) => i.type.includes(res.data.type))
- if (menu) {
- that.setData({ menuList: menu })
- // 默认显示的值
- let index = menu.findIndex((i) => i.route == currentPage.route);
- that.setData({ active: index })
- }
- },
- fail: res => {
- wx.redirectTo({ url: '/pages/index/index', })
- }
- })
- }
- }
- })
|