index.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. Component({
  2. /**
  3. * 组件的属性列表
  4. */
  5. properties: {},
  6. lifetimes: {
  7. attached() {},
  8. ready: function () {
  9. // 在组件实例进入页面节点树时执行
  10. },
  11. },
  12. /**
  13. * 组件的初始数据
  14. */
  15. data: {
  16. active: 0,
  17. tabbarList: [{
  18. icon: 'icon-a-biaoqianlanshouyexuanzhong',
  19. text: '首页',
  20. url: '/pages/tabbar/home/index'
  21. },
  22. {
  23. icon: 'icon-a-biaoqianlanxiaoxi',
  24. text: '信息',
  25. url: '/pages/tabbar/message/index'
  26. },
  27. {
  28. icon: 'icon-a-biaoqianlangongzuo',
  29. text: '工作',
  30. url: '/pages/tabbar/workbench/index'
  31. },
  32. {
  33. icon: 'icon-a-biaoqianlanzhiku',
  34. text: '智库',
  35. url: '/pages/tabbar/smartStore/index',
  36. },
  37. {
  38. icon: 'icon-a-biaoqianlanwode',
  39. text: '我的',
  40. url: '/pages/tabbar/mine/index'
  41. }
  42. ],
  43. },
  44. /**
  45. * 组件的方法列表
  46. */
  47. methods: {
  48. /* tabbar */
  49. onChange(event) {
  50. this.setData({
  51. active: event.target.dataset.index
  52. });
  53. wx.switchTab({
  54. url: event.target.dataset.url
  55. });
  56. },
  57. init() {
  58. const page = getCurrentPages().pop();
  59. this.setData({
  60. active: this.data.tabbarList.findIndex(item => item.url === `/${page.route}`)
  61. });
  62. },
  63. },
  64. })