提交 13c95356 authored 作者: 祁增奎's avatar 祁增奎

bug fix

上级 ed1682c0
...@@ -6,17 +6,11 @@ import 'package:fluttertoast/fluttertoast.dart'; ...@@ -6,17 +6,11 @@ import 'package:fluttertoast/fluttertoast.dart';
import '../utils/code_send_enum.dart'; import '../utils/code_send_enum.dart';
class CLXCodeManageLogic extends GetxController { class CLXCodeManageLogic extends GetxController {
CLXCodeManageLogic( CLXCodeManageLogic({this.maxLength = 6, this.isFirstResponsed = false});
{this.maxLength = 6,
this.isFirstResponsed = false,
this.countdownTime = 60});
/// 验证码长度 /// 验证码长度
final int maxLength; final int maxLength;
/// 倒计时时间
final int countdownTime;
/// 是否是成为第一响应者 /// 是否是成为第一响应者
final bool isFirstResponsed; final bool isFirstResponsed;
...@@ -27,7 +21,7 @@ class CLXCodeManageLogic extends GetxController { ...@@ -27,7 +21,7 @@ class CLXCodeManageLogic extends GetxController {
final TextEditingController codeInoutCtrl = TextEditingController(); final TextEditingController codeInoutCtrl = TextEditingController();
/// 倒计时 /// 倒计时
RxInt countdown = 0.obs; RxInt countdown = 60.obs;
/// 定时器 /// 定时器
Timer? timer; Timer? timer;
...@@ -64,7 +58,6 @@ class CLXCodeManageLogic extends GetxController { ...@@ -64,7 +58,6 @@ class CLXCodeManageLogic extends GetxController {
super.onInit(); super.onInit();
codeInoutCtrl.addListener(_verifyCodeInput); codeInoutCtrl.addListener(_verifyCodeInput);
countdown.value = countdownTime;
if (isFirstResponsed) { if (isFirstResponsed) {
codeInoutFocus.requestFocus(); codeInoutFocus.requestFocus();
...@@ -91,7 +84,7 @@ class CLXCodeManageLogic extends GetxController { ...@@ -91,7 +84,7 @@ class CLXCodeManageLogic extends GetxController {
/// 发送短信验证码 /// 发送短信验证码
sendSmsCode() async { sendSmsCode() async {
if (countdown.value != countdownTime) { if (countdown.value != 60) {
return; return;
} }
final result = await getSmsVerificationCode?.call(); final result = await getSmsVerificationCode?.call();
...@@ -103,7 +96,7 @@ class CLXCodeManageLogic extends GetxController { ...@@ -103,7 +96,7 @@ class CLXCodeManageLogic extends GetxController {
/// 发送语音验证码 /// 发送语音验证码
sendVoiceCode() async { sendVoiceCode() async {
if (countdown.value != countdownTime) { if (countdown.value != 60) {
return; return;
} }
final result = await obtainVoiceVerificationCode?.call(); final result = await obtainVoiceVerificationCode?.call();
...@@ -130,7 +123,7 @@ class CLXCodeManageLogic extends GetxController { ...@@ -130,7 +123,7 @@ class CLXCodeManageLogic extends GetxController {
if (countdown.value == 0) { if (countdown.value == 0) {
timer.cancel(); timer.cancel();
codeSendBtn.value = ''; codeSendBtn.value = '';
countdown.value = countdownTime; countdown.value = 60;
handleCodeSendType(isSmsSend: isSmsSend); handleCodeSendType(isSmsSend: isSmsSend);
handleTipInfo(); handleTipInfo();
} else { } else {
...@@ -183,7 +176,6 @@ class CLXCodeManageLogic extends GetxController { ...@@ -183,7 +176,6 @@ class CLXCodeManageLogic extends GetxController {
/// 处理提示信息 /// 处理提示信息
handleTipInfo() { handleTipInfo() {
/// 如果输入框内容不为空,则不展示提示信息 /// 如果输入框内容不为空,则不展示提示信息
isShowTip.value = isShowTip.value = codeInoutCtrl.text.isEmpty && countdown.value == 60;
codeInoutCtrl.text.isEmpty && countdown.value == countdownTime;
} }
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论