From e70d1c09e28e92fcb73d3c75a1915280022b2b66 Mon Sep 17 00:00:00 2001 From: lxm <1274844347@qq.com> Date: Fri, 25 Jul 2025 15:49:49 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=99=BB=E5=BD=95):=20=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=9C=B0=E5=8C=BA=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E7=99=BB=E5=BD=95=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 为中国大陆用户默认选择手机号登录(+86),非中国大陆用户默认选择邮箱登录 隐藏中国大陆用户的国家选择器和相关提示 调整社交登录按钮的显示逻辑 --- .../login/controllers/login_controller.dart | 19 +++++++- lib/modules/login/views/login_view.dart | 48 ++++++++++++------- 2 files changed, 48 insertions(+), 19 deletions(-) diff --git a/lib/modules/login/controllers/login_controller.dart b/lib/modules/login/controllers/login_controller.dart index 818e94b8e..c17147ef4 100644 --- a/lib/modules/login/controllers/login_controller.dart +++ b/lib/modules/login/controllers/login_controller.dart @@ -180,6 +180,21 @@ class LoginController extends GetxController { {'name': '所罗门群岛', 'code': '+677', 'flag': '🇸🇧'}, ]; + // 初始化默认选择的国家代码 + void _initDefaultCountryCode() { + if (isChinaMainland.value) { + // 中国大陆用户默认选择+86 + _selectedCountryCode.value = '+86'; + _selectedCountryFlag.value = '🇨🇳'; + loginType = 1; // 设置为手机号登录类型 + } else { + // 非中国大陆用户默认选择邮箱 + _selectedCountryCode.value = ''; + _selectedCountryFlag.value = '✉️'; + loginType = 0; // 设置为邮箱登录类型 + } + } + // 状态管理 final _viewState = LoginViewState.welcome.obs; final _isLoading = false.obs; @@ -208,6 +223,9 @@ class LoginController extends GetxController { isChinaMainland.value = Get.deviceLocale?.countryCode?.toUpperCase() == 'CN'; + // 初始化默认国家代码 + _initDefaultCountryCode(); + _hasAcceptedPrivacy.value = _storage.read('hasAcceptedPrivacy') ?? false; // 从本地存储中读取是否已接受隐私政策 @@ -1041,5 +1059,4 @@ class LoginController extends GetxController { return false; } } - } diff --git a/lib/modules/login/views/login_view.dart b/lib/modules/login/views/login_view.dart index bd992b5a9..c38fae252 100644 --- a/lib/modules/login/views/login_view.dart +++ b/lib/modules/login/views/login_view.dart @@ -161,13 +161,14 @@ class LoginView extends GetView { ), ), SizedBox(height: 4.h), - Text( - 'loginTips'.tr, // 请使用手机号或邮箱登录/注册 - style: TextStyle( - fontSize: 14.sp, - color: isDarkMode ? Colors.grey[400] : Colors.black54, + if (!controller.isChinaMainland.value) + Text( + 'loginTips'.tr, // 请使用手机号或邮箱登录/注册 + style: TextStyle( + fontSize: 14.sp, + color: isDarkMode ? Colors.grey[400] : Colors.black54, + ), ), - ), ], ); } @@ -214,11 +215,12 @@ class LoginView extends GetView { color: isDarkMode ? Colors.white : Colors.black, ), )), - Icon( - Icons.arrow_drop_down, - color: isDarkMode ? Colors.grey[400] : Colors.black54, - size: 20.sp, - ), + if (!controller.isChinaMainland.value) + Icon( + Icons.arrow_drop_down, + color: isDarkMode ? Colors.grey[400] : Colors.black54, + size: 20.sp, + ), ], ), ), @@ -263,6 +265,10 @@ class LoginView extends GetView { // 添加国家选择底部弹窗 void _showCountryPicker(bool isDarkMode) { + // 中国大陆用户不显示国家选择器 + if (controller.isChinaMainland.value) { + return; + } Get.bottomSheet( Container( height: 400.h, @@ -477,14 +483,20 @@ class LoginView extends GetView { Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - _buildSocialButton(FontAwesomeIcons.google, Colors.red, isDarkMode), - SizedBox(width: 24.w), - _buildSocialButton( - FontAwesomeIcons.weixin, Colors.green, isDarkMode), + if (controller.isChinaMainland.value) ...[ + _buildSocialButton( + FontAwesomeIcons.weixin, Colors.green, isDarkMode), + SizedBox(width: 24.w) + ] else ...[ + _buildSocialButton( + FontAwesomeIcons.google, Colors.red, isDarkMode), + SizedBox(width: 24.w), + ], + // Apple登录按钮(仅在iOS上显示) if (GetPlatform.isIOS) ...[ - SizedBox(width: 24.w), - _buildSocialButton(FontAwesomeIcons.apple, Colors.black, isDarkMode), + _buildSocialButton( + FontAwesomeIcons.apple, Colors.black, isDarkMode), ], // SizedBox(width: 24.w), // _buildSocialButton( @@ -492,7 +504,7 @@ class LoginView extends GetView { // 根据配置显示游客登录按钮 if (controller.isGuestLoginVisible) ...[ SizedBox(width: 24.w), - _buildSocialButton(FontAwesomeIcons.userSecret, Colors.grey, + _buildSocialButton(FontAwesomeIcons.userSecret, Colors.black, isDarkMode), // 游客登录按钮 ], ],