nav.js 1.41 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(){
        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 wxBarHeight=68;
        let statusBarHeight=getApp().system.statusBarHeight*getApp().system.pixelRatio;
        this.setData({
            statusBarHeight: statusBarHeight,
            disHome: disHome,
            disBack: disBack,
            statusBarHeightFull:wxBarHeight + statusBarHeight,
        })
        console.log('this.setData',this.data);
    },
  /**
   * 组件的方法列表
   */
  methods: {
    back(){
      wx.navigateBack()
    },
      home(){
        if(!this.data.disHome) return;
        wx.reLaunch({
            url:'/pages/customer/index'
        })
      }
  }
})