2024-01-16 16:52:05 +08:00

74 lines
1.8 KiB
Dart

import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:get/get_utils/get_utils.dart';
import 'package:star_lock/mine/minePersonInfo/minePersonInfoEditAccount/minePersonInfoEditAccountNext/minePersonInfoEditAccountNext_state.dart';
import 'package:star_lock/network/api_repository.dart';
import 'package:star_lock/tools/baseGetXController.dart';
class PersonInfoEditAccountLogic extends BaseGetXController {
final PersonInfoEditAccountState state = PersonInfoEditAccountState();
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.countryCode.value,
state.loginData.value.mobile!,
state.channel.value,
state.codeType.value,
state.uniqueid.value,
state.xWidth.value.toString());
if (entity.errorCode!.codeIsSuccessful) {
_startTimer();
} else {}
}
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();
}
}