var app = getApp();
var that;
Page({
  data: {
    num:0,
    str:'企业信息同步中...',
  },
  onLoad() {
   that = this;
   that.loginAll();
  },
  loginAll(){
      // dd.showLoading();
      app.login(app.globalData.corpId, function (is) {
        if(is){
          // dd.hideLoading();
          dd.reLaunch({
            url: '../workbench/index/index'
          })
        } else {
          dd.reLaunch({
            url: '../workbench/noJurisdiction/noJurisdiction'
          })
        }
      },function(data){
        console.log(data,that.data.num)
        if(data.code==2001&&data.msg!='企业授权已过期'){
          if(that.data.num==3){ return false}
          setTimeout(function(){ 
            let num=that.data.num;
            that.setData({ num:num+1 })
            that.loginAll();
          }, 3000);
        }else{
             that.setData({
              num:0,
              str:data.msg
            })
        }
      })
  },
});
