index.ts 1.4 KB

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