新增手机号码注册,手机号码验证码登录

(cherry picked from commit 8e269ab2807642d77a109d6bead0ff12915f1dd7)
This commit is contained in:
Rust 2025-10-31 22:54:34 -07:00 committed by speakeloudest
parent 9ef53abad5
commit 3f838d224c
2 changed files with 104 additions and 2 deletions

View File

@ -75,6 +75,9 @@ class KRLoginController extends GetxController
///
var kr_loginStatus = KRLoginProgressStatus.kr_registerSendCode.obs;
/// 使true=false=
var kr_isPasswordLogin = true.obs;
///
var _countdown = 60; //
late Timer _timer;
@ -172,8 +175,8 @@ class KRLoginController extends GetxController
}
// entry kr_loginByPsd
}
//
_timer = Timer(Duration.zero, () {});

View File

@ -107,6 +107,39 @@ class KRAuthApi {
return right(baseResponse.model.kr_token.toString());
}
/// +++
Future<Either<HttpError, String>> kr_telephoneRegister(
String telephone,
String areaCode,
String password,
String code,
{String? inviteCode}) async {
final Map<String, dynamic> data = <String, dynamic>{};
data['telephone'] = telephone;
data['telephone_area_code'] = areaCode;
data['password'] = password;
data['code'] = code;
data["identifier"] = KRDeviceInfoService().deviceId ?? 'unknown';
//
if (inviteCode != null && inviteCode.isNotEmpty) {
data["invite"] = inviteCode;
}
// cf_token
data["cf_token"] = "";
BaseResponse<KRLoginData> baseResponse = await HttpUtil.getInstance()
.request<KRLoginData>('/v1/auth/register/telephone', data,
method: HttpMethod.POST, isShowLoading: true);
if (!baseResponse.isSuccess) {
return left(
HttpError(msg: baseResponse.retMsg, code: baseResponse.retCode));
}
return right(baseResponse.model.kr_token.toString());
}
///
Future<Either<HttpError, bool>> kr_checkVerificationCode(
String email, String code, int type) async {
@ -151,6 +184,52 @@ class KRAuthApi {
return right(baseResponse.model.kr_token.toString());
}
/// ++
Future<Either<HttpError, String>> kr_telephoneLogin(
String telephone, String areaCode, String password) async {
final Map<String, dynamic> data = <String, dynamic>{};
data['telephone'] = telephone;
data['telephone_area_code'] = areaCode;
data['password'] = password;
final deviceId = KRDeviceInfoService().deviceId ?? 'unknown';
KRLogUtil.kr_i('设备ID: $deviceId', tag: 'KRAuthApi');
data["identifier"] = deviceId;
BaseResponse<KRLoginData> baseResponse = await HttpUtil.getInstance()
.request<KRLoginData>('/v1/auth/login/telephone', data,
method: HttpMethod.POST, isShowLoading: true);
if (!baseResponse.isSuccess) {
return left(
HttpError(msg: baseResponse.retMsg, code: baseResponse.retCode));
}
return right(baseResponse.model.kr_token.toString());
}
/// ++
Future<Either<HttpError, String>> kr_telephoneCodeLogin(
String telephone, String areaCode, String code) async {
final Map<String, dynamic> data = <String, dynamic>{};
data['telephone'] = telephone;
data['telephone_area_code'] = areaCode;
data['telephone_code'] = code;
final deviceId = KRDeviceInfoService().deviceId ?? 'unknown';
KRLogUtil.kr_i('设备ID: $deviceId', tag: 'KRAuthApi');
data["identifier"] = deviceId;
BaseResponse<KRLoginData> baseResponse = await HttpUtil.getInstance()
.request<KRLoginData>('/v1/auth/login/telephone', data,
method: HttpMethod.POST, isShowLoading: true);
if (!baseResponse.isSuccess) {
return left(
HttpError(msg: baseResponse.retMsg, code: baseResponse.retCode));
}
return right(baseResponse.model.kr_token.toString());
}
///
/// type: 1=, 2=, 3=
Future<Either<HttpError, bool>> kr_sendCode(String email, int type) async {
@ -169,6 +248,26 @@ class KRAuthApi {
return right(true);
}
///
/// type: 1=, 2=
Future<Either<HttpError, bool>> kr_sendSmsCode(
String telephone, String areaCode, int type) async {
final Map<String, dynamic> data = <String, dynamic>{};
data['telephone'] = telephone;
data['telephone_area_code'] = areaCode;
data['type'] = type;
BaseResponse<dynamic> baseResponse = await HttpUtil.getInstance()
.request<dynamic>('/v1/common/send_sms_code', data,
method: HttpMethod.POST, isShowLoading: true);
if (!baseResponse.isSuccess) {
return left(
HttpError(msg: baseResponse.retMsg, code: baseResponse.retCode));
}
return right(true);
}
///
Future<Either<HttpError, String>> kr_deleteAccount(String email, String code) async {
final Map<String, dynamic> data = <String, dynamic>{};