Browse Source

fix(登录): 修复社交登录和验证码登录的逻辑问题

同步登录类型判断逻辑到各登录相关方法
修改登录按钮调用方式以支持社交登录参数
更新版本号至1.0.21+72
newdev_shunjiawei
lxm 9 months ago
parent
commit
6426d6200d
  1. 12
      lib/modules/login/controllers/login_controller.dart
  2. 4
      lib/modules/login/views/login_view.dart
  3. 2
      pubspec.yaml

12
lib/modules/login/controllers/login_controller.dart

@ -256,8 +256,13 @@ class LoginController extends GetxController {
_countdownSeconds.value = 0; _countdownSeconds.value = 0;
} }
void _syncContactLoginType() {
loginType = _selectedCountryCode.value.isEmpty ? 0 : 1;
}
// 获取验证码 // 获取验证码
void getVerificationCode() { void getVerificationCode() {
_syncContactLoginType();
if (contactController.text.isEmpty) { if (contactController.text.isEmpty) {
Get.snackbar( Get.snackbar(
'tip'.tr, //提示 'tip'.tr, //提示
@ -311,6 +316,7 @@ class LoginController extends GetxController {
// 切换到验证码页面 // 切换到验证码页面
void showVerificationView() { void showVerificationView() {
_syncContactLoginType();
if (contactController.text.isEmpty) { if (contactController.text.isEmpty) {
Get.snackbar( Get.snackbar(
'tip'.tr, 'tip'.tr,
@ -402,6 +408,7 @@ class LoginController extends GetxController {
// 重新发送验证码 // 重新发送验证码
void resendVerificationCode() { void resendVerificationCode() {
_syncContactLoginType();
if (_countdownSeconds.value > 0) return; if (_countdownSeconds.value > 0) return;
_startCountdown(); _startCountdown();
_sendVerificationCode(); _sendVerificationCode();
@ -467,7 +474,10 @@ class LoginController extends GetxController {
} }
// 登录 // 登录
Future<void> login() async { Future<void> login({bool fromSocial = false}) async {
if (!fromSocial) {
_syncContactLoginType();
}
// 添加基础验证 // 添加基础验证
if (loginType == 0 || loginType == 1) { if (loginType == 0 || loginType == 1) {
// 邮箱或手机号登录 // 邮箱或手机号登录

4
lib/modules/login/views/login_view.dart

@ -575,7 +575,7 @@ class LoginView extends GetView<LoginController> {
break; break;
} }
} }
controller.login(); await controller.login(fromSocial: true);
} }
// 用户协议和隐私政策 // 用户协议和隐私政策
@ -816,7 +816,7 @@ class LoginView extends GetView<LoginController> {
return SizedBox( return SizedBox(
width: double.infinity, width: double.infinity,
child: Obx(() => ElevatedButton( child: Obx(() => ElevatedButton(
onPressed: controller.isLoading ? null : controller.login, onPressed: controller.isLoading ? null : () => controller.login(),
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(
backgroundColor: const Color(0xFF3B82F6), backgroundColor: const Color(0xFF3B82F6),
foregroundColor: Colors.white, foregroundColor: Colors.white,

2
pubspec.yaml

@ -1,7 +1,7 @@
name: voitrans name: voitrans
description: "Voitrans - AI Voice Assistant." description: "Voitrans - AI Voice Assistant."
publish_to: "none" publish_to: "none"
version: 1.0.21+71 version: 1.0.21+72
environment: environment:
sdk: ">=3.3.0 <4.0.0" sdk: ">=3.3.0 <4.0.0"

Loading…
Cancel
Save