|
|
@@ -8,6 +8,7 @@ import 'package:location/utils/http_handler.dart';
|
|
|
import 'package:location/utils/toast_util.dart';
|
|
|
|
|
|
import '../../data/repositories/account_repository.dart';
|
|
|
+import '../../utils/de_bounce.dart';
|
|
|
|
|
|
@injectable
|
|
|
class LoginController extends BaseController {
|
|
|
@@ -31,6 +32,9 @@ class LoginController extends BaseController {
|
|
|
|
|
|
LoginController(this.accountRepository);
|
|
|
|
|
|
+ final Debounce _saveDebounce = Debounce(debounceTime: 1000);
|
|
|
+ bool isRequestLogin = false;
|
|
|
+
|
|
|
@override
|
|
|
void onReady() {
|
|
|
super.onReady();
|
|
|
@@ -49,6 +53,12 @@ class LoginController extends BaseController {
|
|
|
}
|
|
|
|
|
|
void onSendVerificationCode() {
|
|
|
+ _saveDebounce.onClick(() {
|
|
|
+ sendVerificationCode();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ void sendVerificationCode() {
|
|
|
if (_countDown.value != null) {
|
|
|
return;
|
|
|
}
|
|
|
@@ -101,6 +111,15 @@ class LoginController extends BaseController {
|
|
|
}
|
|
|
|
|
|
void onLoginClick() {
|
|
|
+ _saveDebounce.onClick(() {
|
|
|
+ login();
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ void login() {
|
|
|
+ if (isRequestLogin) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (!RegExp(r'^1\d{10}$').hasMatch(phone)) {
|
|
|
ToastUtil.show(StringName.loginPrintPhoneVerification);
|
|
|
return;
|
|
|
@@ -113,10 +132,12 @@ class LoginController extends BaseController {
|
|
|
ToastUtil.show(StringName.loginPrintVerificationCode);
|
|
|
return;
|
|
|
}
|
|
|
+ isRequestLogin = true;
|
|
|
accountRepository.loginUserLogin(phone, code).then((data) {
|
|
|
Get.back();
|
|
|
ToastUtil.show(StringName.loginSuccess);
|
|
|
}).catchError((error) {
|
|
|
+ isRequestLogin = false;
|
|
|
if (error is LoginTooOftenException) {
|
|
|
ToastUtil.show(StringName.loginTooOftenToast);
|
|
|
return;
|