const app = getApp();
Component({
  /**
   * 组件的一些选项
   */
  options: {
    addGlobalClass: true,
    multipleSlots: true
  },
  /**
   * 组件的对外属性
   */
  properties: {
    bgColor: {
      type: String,
      default: ''
    }, 
    isCustom: {
      type: [Boolean, String],
      default: false
    },
    isBack: {
      type: [Boolean, String],
      default: false
    },
    canGoHome: {
      type: [Boolean, String],
      default: false
    },
    is5G: {
      type: [Boolean, String],
      default: false
    },
    bgImage: {
      type: String,
      default: ''
    },
    title:{
      type:String,
      default:''
    },
    isSystem:{
      type:[Boolean,String],
      default:false,
    },
    isQuery:{
      type:[Boolean,String],
      default:false,
    },
    isToScan:{
      type:[Boolean,String],
      default:false,
    }
  },
  /**
   * 组件的初始数据
   */
  data: {
    StatusBar: app.globalData.StatusBar,
    CustomBar: app.globalData.CustomBar,
    Custom: app.globalData.Custom,
    setName:'管理'
  },
  /**
   * 组件的方法列表
   */
  methods: {
    BackPage() {
      wx.navigateBack({
        delta: 1
      });
    },
    to5G() {
      wx.navigateTo({
        url: '/pages/device/device',
      })
    },
    toHome(){
      wx.switchTab({
        url: '/pages/index/index',
      })
    },
    toQuery(){
      wx.switchTab({
        url: '/pages/query/query',
      })
    },
    toScan(){
    //获取用户信息，判断userInfo是否过期
      let userInfo = wx.getStorageSync('userInfo');
      const {loginRole,ifOverFlow,status} = userInfo;
      app.globalData.tabarData = {loginRole, ifOverFlow, status, path:'find'};
      wx.switchTab({
        url: '/pages/workbench/workbench',
      })
    },
    systemBut(){
      var flag = this.data.flag;
      let token = wx.getStorageSync('token');
      if(!token){
        wx.navigateTo({
          url: '/pages/login/login',
        })
        return;
      }
      if(flag){
        this.setData({
          flag : false,
          setName:'管理'
        })
        this.triggerEvent('myevent',{flag:'N' })
      }else{
        this.setData({
          flag : true,
          setName:'保存'
        })
        this.triggerEvent('myevent',{flag:'Y'})
      }
    }
  }
})