2,新增修改绑定手机号/邮箱 3,新增获取安全信息列表接口 4,新增获取已设置的安全信息接口 5,新增设置安全信息接口 6,新增获取解绑手机号Token 7,新增获取解绑邮箱Token
107 lines
3.0 KiB
Dart
107 lines
3.0 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:get/get.dart';
|
|
import 'package:star_lock/appRouters.dart';
|
|
import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart';
|
|
import 'package:star_lock/mine/minePersonInfo/minePersonInfoEmail/mineBindPhoneOrEmail_state.dart';
|
|
import 'package:star_lock/mine/minePersonInfo/minePersonInfoPage/minePersonInfo_page.dart';
|
|
import 'package:star_lock/network/api_repository.dart';
|
|
import 'package:star_lock/tools/baseGetXController.dart';
|
|
import 'package:star_lock/tools/toast.dart';
|
|
|
|
class MineBindPhoneOrEmailLogic extends BaseGetXController {
|
|
final MineBindPhoneOrEmailState state = MineBindPhoneOrEmailState();
|
|
|
|
late Timer _timer;
|
|
void _startTimer() {
|
|
_timer = Timer.periodic(1.seconds, (timer) {
|
|
if (state.currentSecond > 1) {
|
|
state.currentSecond--;
|
|
} else {
|
|
_cancelTimer();
|
|
state.currentSecond = state.totalSeconds;
|
|
}
|
|
state.resetResend();
|
|
});
|
|
}
|
|
|
|
void _cancelTimer() {
|
|
_timer.cancel();
|
|
}
|
|
|
|
//获取验证码请求
|
|
void sendValidationCode() async {
|
|
var entity = await ApiRepository.to.getValidationCodeAuth(
|
|
state.channel.value == '1' ? state.countryCode.value : '',
|
|
state.inputAccount.value,
|
|
state.channel.value,
|
|
state.codeType.value,
|
|
state.uniqueid.value,
|
|
state.xWidth.value.toString());
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
_startTimer();
|
|
}
|
|
}
|
|
|
|
//绑定邮箱请求
|
|
Future<void> bindEmailRequest() async {
|
|
PasswordKeyListEntity entity = await ApiRepository.to.bindEmail(
|
|
state.inputAccount.value,
|
|
state.verificationCode.value,
|
|
state.unbindToken.value);
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
Toast.show(msg: '邮箱绑定成功');
|
|
Get.until((route) => route.settings.name == Routers.minePersonInfoPage);
|
|
}
|
|
}
|
|
|
|
//绑定手机请求
|
|
Future<void> bindMobileRequest() async {
|
|
PasswordKeyListEntity entity = await ApiRepository.to.bindPhone(
|
|
state.countryCode.value,
|
|
state.inputAccount.value,
|
|
state.verificationCode.value,
|
|
state.unbindToken.value);
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
Toast.show(msg: '手机绑定成功');
|
|
Get.until((route) => route.settings.name == Routers.minePersonInfoPage);
|
|
}
|
|
}
|
|
|
|
void checkNext(TextEditingController controller) {
|
|
changeInput(controller);
|
|
}
|
|
|
|
void changeInput(TextEditingController controller) {
|
|
if (controller == state.accountController) {
|
|
state.inputAccount.value = controller.text;
|
|
state.accountIsOK.value = state.inputAccount.value.isNotEmpty;
|
|
}
|
|
if (controller == state.codeController) {
|
|
state.verificationCode.value = controller.text;
|
|
}
|
|
|
|
_resetCanSub();
|
|
}
|
|
|
|
void _resetCanSub() {
|
|
state.canSub.value = state.codeIsOK;
|
|
}
|
|
|
|
@override
|
|
void onReady() {
|
|
super.onReady();
|
|
}
|
|
|
|
@override
|
|
void onInit() {
|
|
super.onInit();
|
|
}
|
|
|
|
@override
|
|
void onClose() {
|
|
super.onClose();
|
|
}
|
|
}
|