reg static method

Future<DataResult> reg(
  1. String id, [
  2. bool three = false
])

Implementation

static Future<DataResult> reg(String id, [bool three = false]) async {
  var userId = SpUtil.getString(AppConfig.userNowId);
  var the = SpUtil.getBool(AppConfig.userIsThree);
  if (userId?.isEmpty == false && the == three) {
    nowUserId = int.parse(userId ?? '0');
    return DataResult(true, true);
  } else {
    SpUtil.putBool(AppConfig.userIsThree, three);
    Map other = {
      'email': id,
      'pwd': id,
    };
    var res =
        await BaseDao.fromBaseJson(other, NowAddress.reg(), token: false);
    if (res.result) {
      var entity = NowUserEntity.fromJson(res.data);
      SpUtil.putString(AppConfig.userNowId, entity.userId!);
      nowUserId = int.parse(entity.userId ?? '0');
      return DataResult(true, true);
    } else if (res.data.code == '-100') {
      var res2 =
          await BaseDao.fromBaseJson(other, NowAddress.login(), token: false);
      if (res2.result) {
        var entity = NowUserEntity.fromJson(res2.data);
        SpUtil.putString(AppConfig.userNowId, entity.id.toString());
        nowUserId = entity.id ?? 0;
        return DataResult(true, true);
      } else {
        return res2;
      }
    }
    return res;
  }
}