nav.js 1.14 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.length);
        if (pages.length > 1) {
            disBack = true;
        } else {
            if (getApp().shareTicket && this.data.hasHome) {
                disHome = true;
            }
        }
        this.setData({
            statusBarHeight: getApp().system.statusBarHeight,
            disHome: disHome,
            disBack: disBack,
        })
        console.log('this.setData',this.data);
    },
  /**
   * 组件的方法列表
   */
  methods: {
    back(){
      wx.navigateBack()
    },
      home(){
        wx.reLaunch({
            url:'/pages/customer/index'
        })
      }
  }
})