index.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. Component({
  2. /**
  3. * 组件的属性列表
  4. */
  5. properties: {},
  6. /**
  7. * 组件的初始数据
  8. */
  9. data: {
  10. active: 'pages/home/home',
  11. list: [
  12. {
  13. 'pagePath': 'pages/home/home',
  14. 'text': '首页',
  15. 'iconPath': 'image/tabBar/home_0@2x.png',
  16. 'selectedIconPath': 'image/tabBar/home_1@2x.png'
  17. },
  18. {
  19. 'pagePath': 'pages/partner/partner',
  20. 'text': '优秀合作社',
  21. 'iconPath': 'image/tabBar/home_0@2x.png',
  22. 'selectedIconPath': 'image/tabBar/home_1@2x.png'
  23. },
  24. {
  25. 'pagePath': 'pages/news/news',
  26. 'text': '农事天地',
  27. 'iconPath': 'image/tabBar/home_0@2x.png',
  28. 'selectedIconPath': 'image/tabBar/home_1@2x.png'
  29. },
  30. {
  31. 'pagePath': 'pages/mine/mine',
  32. 'text': '我的',
  33. 'iconPath': 'image/tabBar/mine_0@2x.png',
  34. 'selectedIconPath': 'image/tabBar/mine_1@2x.png'
  35. }
  36. ]
  37. },
  38. /**
  39. * 组件的方法列表
  40. */
  41. methods: {
  42. onChange(e) {
  43. const detail = e.detail
  44. wx.switchTab({
  45. url: `/${detail}`
  46. })
  47. this.setData({
  48. active: detail
  49. })
  50. },
  51. init() {
  52. const page = getCurrentPages().pop()
  53. this.setData({
  54. active: `${page.route}`
  55. })
  56. }
  57. }
  58. })