nav.js 1.69 KB
// components/nav/nav.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    backgroundColor:{
      type:String,
        value:'#ffffff'
    },
      color:{
          type:String,
          value:'#000000'
      },
      hasHome:{
        type:Boolean,
          value:false
      }
  },

  /**
   * 组件的初始数据
   */
  data: {
    disHome:false,
      disBack:false,
  },

    attached(){
        this.init();
    },
  /**
   * 组件的方法列表
   */
  methods: {
    back(){
      this.triggerEvent('NavEvent');
      wx.navigateBack();
    },
      home(){
        if(!this.data.disHome) return;
        wx.reLaunch({
            url:'/pages/customer/index'
        })
      },
      init(){
          let wxBarHeight=68;
          let disBack = false;
          let disHome = false;
          let pages = getCurrentPages();
          console.log('pages.length',pages[0]);
          if (pages.length > 1) {
              disBack = true;
          } else {
              //if (getApp().shareTicket && this.data.hasHome) {
              if (this.data.hasHome && pages[0].route!="pages/customer/list") {
                  disHome = true;
              }
          }
          let statusBarHeight=40;
          if(getApp().system.system){
              statusBarHeight=getApp().system.statusBarHeight
                  *(getApp().system.system.toLowerCase().indexOf('ios')>-1?2:getApp().system.pixelRatio);
          }
          this.setData({
              statusBarHeight: statusBarHeight,
              disHome: disHome,
              disBack: disBack,
              statusBarHeightFull:wxBarHeight + statusBarHeight,
          })
          console.log('this.setData',this.data);
      },
  }
})