index.ts 987 B

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