foot.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. const app = getApp();
  2. import { system } from '../../utils/dict';
  3. Component({
  4. /**
  5. * 组件的属性列表
  6. */
  7. options: { multipleSlots: true },
  8. properties: {
  9. // tabSelectid: { type: 'string', value: '' }
  10. },
  11. // 生命周期函数,可以为函数,或一个在methods段中定义的方法名
  12. attached: function () { }, // 此处attached的声明会被lifetimes字段中的声明覆盖
  13. ready: function () { },
  14. pageLifetimes: {
  15. // 组件所在页面的生命周期函数
  16. show: function () { this.search() },
  17. hide: function () { },
  18. resize: function () { },
  19. },
  20. /**
  21. * 组件的初始数据
  22. */
  23. data: {
  24. // 菜单列表
  25. menuList: [],
  26. active: 0,
  27. },
  28. /**
  29. * 组件的方法列表
  30. */
  31. methods: {
  32. // 跳转
  33. tabPath(e) {
  34. const that = this;
  35. this.setData({ active: e.detail })
  36. let route = that.data.menuList[e.detail];
  37. if (route) this.triggerEvent('tabPath', route);
  38. },
  39. search() {
  40. const that = this;
  41. wx.getStorage({
  42. key: 'token',
  43. success: res => {
  44. let pages = getCurrentPages();
  45. let currentPage = pages[pages.length - 1];
  46. let menu = system.filter((i) => i.type.includes(res.data.type))
  47. if (menu) {
  48. that.setData({ menuList: menu })
  49. // 默认显示的值
  50. let index = menu.findIndex((i) => i.route == currentPage.route);
  51. that.setData({ active: index })
  52. }
  53. },
  54. fail: res => {
  55. wx.redirectTo({ url: '/pages/index/index', })
  56. }
  57. })
  58. }
  59. }
  60. })