90 lines
2.3 KiB
Dart
90 lines
2.3 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:get/get_core/src/get_main.dart';
|
|
import 'package:get/get_navigation/src/extension_navigation.dart';
|
|
import 'package:get/get_utils/get_utils.dart';
|
|
import 'package:star_lock/appRouters.dart';
|
|
import 'package:star_lock/login/login/entity/LoginEntity.dart';
|
|
import 'package:star_lock/mine/mine/safeVerify/safeVerify_state.dart';
|
|
import 'package:star_lock/network/api_repository.dart';
|
|
import 'package:star_lock/tools/baseGetXController.dart';
|
|
import 'package:star_lock/tools/toast.dart';
|
|
|
|
class SafeVerifyLogic extends BaseGetXController {
|
|
final SafeVerifyState state = SafeVerifyState();
|
|
|
|
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(
|
|
"",
|
|
'',
|
|
'1',
|
|
state.codeType.value,
|
|
"B748F838-94EE-4BDB-A0E6-7B2D16849792",
|
|
state.xWidth.value.toString());
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
_startTimer();
|
|
} else {}
|
|
}
|
|
|
|
//删除账号请求
|
|
Future<void> deleteAccountRequest() async {
|
|
LoginEntity entity =
|
|
await ApiRepository.to.deleteAccount("1", state.verificationCode.value);
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
Toast.show(msg: '验证成功,账号已删除');
|
|
//删除账号成功,
|
|
Get.offNamedUntil(Routers.starLockLoginPage, (route) => false);
|
|
}
|
|
}
|
|
|
|
void checkNext(TextEditingController controller) {
|
|
changeInput(controller);
|
|
}
|
|
|
|
void changeInput(TextEditingController controller) {
|
|
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();
|
|
state.initLoginData();
|
|
}
|
|
|
|
@override
|
|
void onClose() {
|
|
super.onClose();
|
|
}
|
|
}
|