101 lines
2.9 KiB
Dart
Executable File
101 lines
2.9 KiB
Dart
Executable File
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/mine/minePersonInfo/minePersonInfoEditAccount/minePersonInfoEditAccount/mineUnbindPhoneOrEmail_entity.dart';
|
|
import 'package:star_lock/mine/minePersonInfo/minePersonInfoEditAccount/minePersonInfoEditAccount/mineUnbindPhoneOrEmail_state.dart';
|
|
import 'package:star_lock/network/api_repository.dart';
|
|
import 'package:star_lock/tools/baseGetXController.dart';
|
|
|
|
class MineUnbindPhoneOrEmailLogic extends BaseGetXController {
|
|
final MineUnbindPhoneOrEmailState state = MineUnbindPhoneOrEmailState();
|
|
|
|
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.sendValidationCodeAuth(
|
|
countryCode: '',
|
|
account: '',
|
|
channel:state.channel.value,
|
|
codeType: state.codeType.value,
|
|
xWidth: state.xWidth.value.toString());
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
_startTimer();
|
|
} else {}
|
|
}
|
|
|
|
//获取解绑手机号Token
|
|
Future<void> unbindPhoneTokenRequest() async {
|
|
MineUnbindPhoneOrEmailEntity entity =
|
|
await ApiRepository.to.unbindPhoneToken(state.verificationCode.value);
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
state.unbindToken.value = entity.data!.token!;
|
|
Get.toNamed(Routers.mineBindPhoneOrEmailPage, arguments: {
|
|
"isFrom": state.channel.value,
|
|
"unbindToken": state.unbindToken.value
|
|
});
|
|
}
|
|
}
|
|
|
|
//获取解绑邮箱Token
|
|
Future<void> unbindEmailTokenRequest() async {
|
|
MineUnbindPhoneOrEmailEntity entity =
|
|
await ApiRepository.to.unbindEmailToken(state.verificationCode.value);
|
|
if (entity.errorCode!.codeIsSuccessful) {
|
|
state.unbindToken.value = entity.data!.token!;
|
|
Get.toNamed(Routers.mineBindPhoneOrEmailPage, arguments: {
|
|
"isFrom": state.channel.value,
|
|
"unbindToken": state.unbindToken.value
|
|
});
|
|
}
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
@override
|
|
void onClose() {
|
|
super.onClose();
|
|
}
|
|
}
|