index.ts 1.3 KB

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