From dc73c789b96d49e0efe9a8e4b10602d01d229e73 Mon Sep 17 00:00:00 2001 From: fdp <1286779656@qq.com> Date: Wed, 26 Mar 2025 15:46:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=8B=E6=9C=BA=E7=99=BB=E9=99=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../login/controllers/login_controller.dart | 51 ++++++++++++++----- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/lib/modules/login/controllers/login_controller.dart b/lib/modules/login/controllers/login_controller.dart index 239880cba..f3057192e 100644 --- a/lib/modules/login/controllers/login_controller.dart +++ b/lib/modules/login/controllers/login_controller.dart @@ -27,10 +27,10 @@ class LoginController extends GetxController { String get selectedCountryCode => _selectedCountryCode.value; String get selectedCountryFlag => _selectedCountryFlag.value; // 预设国家编码列表 - final List> countryCodes = [ - {'name': '邮箱', 'code': '', 'flag': '✉️'}, // 保持首位 - {'name': '中国', 'code': '+86', 'flag': '🇨🇳'}, // 保持第二位 - + final List> countryCodes = [ + {'name': '邮箱', 'code': '', 'flag': '✉️'}, // 保持首位 + {'name': '中国', 'code': '+86', 'flag': '🇨🇳'}, // 保持第二位 + // 按国家代码数字升序排列(去除+号后排序) {'name': '俄罗斯', 'code': '+7', 'flag': '🇷🇺'}, {'name': '英国', 'code': '+44', 'flag': '🇬🇧'}, @@ -59,13 +59,12 @@ class LoginController extends GetxController { {'name': '阿根廷', 'code': '+54', 'flag': '🇦🇷'}, {'name': '澳大利亚', 'code': '+61', 'flag': '🇦🇺'}, {'name': '新西兰', 'code': '+64', 'flag': '🇳🇿'}, - + // 中国地区(保持最后) {'name': '中国香港', 'code': '+852', 'flag': '🇭🇰'}, {'name': '中国澳门', 'code': '+853', 'flag': '🇲🇴'}, {'name': '中国台湾', 'code': '+886', 'flag': '🇹🇼'}, ]; - // 状态管理 final _viewState = LoginViewState.welcome.obs; @@ -248,8 +247,8 @@ class LoginController extends GetxController { if (isEmialContactController() || isPhoneContactController()) { _startCountdown(); var response = await Api.getCode({ - "addr": contactController.text, - "vtype": 0, + "addr": selectedCountryCode + contactController.text, + "vtype": loginType, }); if (response != null) { print("请求后台数据验证码params=${response}"); @@ -295,8 +294,8 @@ class LoginController extends GetxController { // 检查每个元素是否为单个字母或数字字符 final text = contactController.text; return (text.length > 5 && - RegExp(r'^[A-Za-z0-9+_.-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$') - .hasMatch(text)); + RegExp(r'^[A-Za-z0-9+_.-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$') + .hasMatch(text)); } // 检查手机号码格式 @@ -310,7 +309,7 @@ class LoginController extends GetxController { bool isVerificationCodeComplete() { // 检查每个元素是否为单个字母或数字字符 final text = verificationCodeController.text; - print("数据获取Facebook${text.length}"); + print("数据获取Facebook${text.length}"); return text.length == 4 && RegExp(r'^[0-9]+$').hasMatch(text); } @@ -323,7 +322,7 @@ class LoginController extends GetxController { // 模拟验证过程 switch (loginType) { - case 0 || 1: + case 0: { if (!isVerificationCodeComplete()) { Get.snackbar( @@ -337,7 +336,32 @@ class LoginController extends GetxController { } requestLogin({ "mail": contactController.text, - "phone": "", + "phone": selectedCountryCode + contactController.text, + "stype": loginType, + "vcode": verificationCodeController.text, + "ttoken": "", + "phonemodel": "", + "phonemac": "", + "name": "", + "avatar": "", + }); + break; + } + case 1: + { + if (!isVerificationCodeComplete()) { + Get.snackbar( + '提示', + '请输入完整的验证码', + snackPosition: SnackPosition.TOP, + backgroundColor: Colors.red.withOpacity(0.1), + colorText: Colors.red, + ); + break; + } + requestLogin({ + "mail": "", + "phone": selectedCountryCode + contactController.text, "stype": loginType, "vcode": verificationCodeController.text, "ttoken": "", @@ -348,7 +372,6 @@ class LoginController extends GetxController { }); break; } - case 4: { print("数据获取Facebook");