const app = getApp()
Component({
  options: {
    styleIsolation: 'apply-shared'
  },
  /**
   * 组件的属性列表
   */
  properties: {
    navBarConfig: {
      type: Object,
      value: {
        booFixed: false,
        backgroundColor: 'transparent',
        icon: 'back',
        iconPath: '',
        title: '',
        label: ''
      },
      observer: function (newVal, oldVal) {
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    navBarHeight: app.globalData.navBarHeight,
    menuRight: app.globalData.menuRight,
    menuBottom: app.globalData.menuBottom,
    menuHeight: app.globalData.menuHeight,
    historyLength: 1
  },

  /**
   * 组件的方法列表
   */
  methods: {
    navBarEvent() {
      if (this.data.historyLength <= 1 && this.data.navBarConfig.icon === 'back') {
        wx.switchTab({
          url: '/pages/home/home'
        })
        return
      }
      this.triggerEvent('navBarEvent', { name: 'ppp' })
    }
  },
  pageLifetimes: {
    show: function () {
      this.setData({
        historyLength: getCurrentPages().length
      })
    }
  }
})