navigationBar.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. const app = getApp()
  2. Component({
  3. options: {
  4. styleIsolation: 'apply-shared'
  5. },
  6. /**
  7. * 组件的属性列表
  8. */
  9. properties: {
  10. navBarConfig: {
  11. type: Object,
  12. value: {
  13. booFixed: false,
  14. backgroundColor: 'transparent',
  15. icon: 'back',
  16. iconPath: '',
  17. title: '',
  18. label: ''
  19. },
  20. observer: function (newVal, oldVal) {
  21. }
  22. }
  23. },
  24. /**
  25. * 组件的初始数据
  26. */
  27. data: {
  28. navBarHeight: app.globalData.navBarHeight,
  29. menuRight: app.globalData.menuRight,
  30. menuBottom: app.globalData.menuBottom,
  31. menuHeight: app.globalData.menuHeight,
  32. historyLength: 1
  33. },
  34. /**
  35. * 组件的方法列表
  36. */
  37. methods: {
  38. navBarEvent() {
  39. if (this.data.historyLength <= 1 && this.data.navBarConfig.icon === 'back') {
  40. wx.switchTab({
  41. url: '/pages/home/home'
  42. })
  43. return
  44. }
  45. this.triggerEvent('navBarEvent', { name: 'ppp' })
  46. }
  47. },
  48. pageLifetimes: {
  49. show: function () {
  50. this.setData({
  51. historyLength: getCurrentPages().length
  52. })
  53. }
  54. }
  55. })