foot.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // commpents/mobile-frame/mobile-main.js
  2. const app = getApp()
  3. Component({
  4. /**
  5. * 组件的属性列表
  6. */
  7. options: { multipleSlots: true },
  8. properties: {
  9. tabSelectid: { type: 'string', value: '' }
  10. },
  11. // 生命周期函数,可以为函数,或一个在methods段中定义的方法名
  12. attached: function () { }, // 此处attached的声明会被lifetimes字段中的声明覆盖
  13. ready: function () { },
  14. pageLifetimes: {
  15. // 组件所在页面的生命周期函数
  16. show: function () { this.search() },
  17. hide: function () { },
  18. resize: function () { },
  19. },
  20. /**
  21. * 组件的初始数据
  22. */
  23. data: {
  24. active: 0,
  25. one: {
  26. normal: '/image/shouye.png',
  27. active: '/image/shouye-01.png',
  28. },
  29. two: {
  30. normal: '/image/saishi.png',
  31. active: '/image/saishi-01.png',
  32. },
  33. three: {
  34. normal: '/image/miaobiao.png',
  35. active: '/image/miaobiao-01.png',
  36. },
  37. four: {
  38. normal: '/image/duiwu.png',
  39. active: '/image/duiwu-01.png',
  40. },
  41. five: {
  42. normal: '/image/wodexiao.png',
  43. active: '/image/wodexiao-01.png',
  44. },
  45. },
  46. /**
  47. * 组件的方法列表
  48. */
  49. methods: {
  50. // 跳转
  51. tabPath(e) {
  52. this.setData({ active: e.detail })
  53. let route = e.detail == 0 ? 'home' : e.detail == 1 ? 'search' : e.detail == '2' ? 'administration' : e.detail == '3' ? 'team' : e.detail == '4' ? 'me' : '';
  54. this.triggerEvent('tabPath', route)
  55. },
  56. search() {
  57. let pages = getCurrentPages();
  58. let currentPage = pages[pages.length - 1];
  59. if (currentPage.route == 'pages/home/index') {
  60. this.setData({ active: 0 })
  61. } else if (currentPage.route == 'pages/search/index') {
  62. this.setData({ active: 1 })
  63. } else if (currentPage.route == 'pages/administration/index') {
  64. this.setData({ active: 2 })
  65. } else if (currentPage.route == 'pages/team/index') {
  66. this.setData({ active: 3 })
  67. } else if (currentPage.route == 'pages/me/index') {
  68. this.setData({ active: 4 })
  69. }
  70. }
  71. }
  72. })