index.ts 959 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. Component({
  2. /**
  3. * 组件的属性列表
  4. */
  5. properties: {
  6. },
  7. options: {
  8. styleIsolation: 'shared'
  9. },
  10. /**
  11. * 组件的初始数据
  12. */
  13. data: {
  14. active: 0,
  15. color: '#888888',
  16. activeColor: '#387BDC',
  17. list: [
  18. {
  19. icon: 'home-o',
  20. text: '首页',
  21. url: '/pages/home/index'
  22. },
  23. {
  24. icon: 'todo-list-o',
  25. text: '挂牌大厅',
  26. url: '/pages/trade/index'
  27. },
  28. {
  29. icon: 'gem-o',
  30. text: '钻石圈',
  31. url: '/pages/circle/index'
  32. },
  33. {
  34. icon: 'contact',
  35. text: '我的',
  36. url: '/pages/mine/index'
  37. }
  38. ]
  39. },
  40. /**
  41. * 组件的方法列表
  42. */
  43. methods: {
  44. onChange(e: any) {
  45. wx.switchTab({
  46. url: this.data.list[e.detail].url
  47. });
  48. this.setData({ active: e.detail });
  49. },
  50. init() {
  51. const page = getCurrentPages().pop();
  52. this.setData({
  53. active: this.data.list.findIndex(item => item.url === `/${page.route}`)
  54. });
  55. }
  56. }
  57. })