var app = getApp();
var that;
Page({
  data: {
    num: 0,
    str: '企业信息同步中...',
  },
  onLoad() {
    that = this;
    that.loginAll();
  },
  loginAll() {
    app.login(app.globalData.corpId, function (is) {
      if (is) {
        dd.reLaunch({
          url: '../../home/home/home'
        })
      } else {
        dd.reLaunch({
          url: '../noJurisdiction/noJurisdiction'
        })
      }
    }, function (data) {
      if (data.code == 3000) {
        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
        })
      }
    }, true)
  },
});
