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;
}
void _syncContactLoginType() {
loginType = _selectedCountryCode.value.isEmpty ? 0 : 1;
}
// 获取验证码
void getVerificationCode() {
_syncContactLoginType();
if (contactController.text.isEmpty) {
Get.snackbar(
'tip'.tr, //提示
@ -311,6 +316,7 @@ class LoginController extends GetxController {
// 切换到验证码页面
void showVerificationView() {
_syncContactLoginType();
if (contactController.text.isEmpty) {
Get.snackbar(
'tip'.tr,
@ -402,6 +408,7 @@ class LoginController extends GetxController {
// 重新发送验证码
void resendVerificationCode() {
_syncContactLoginType();
if (_countdownSeconds.value > 0) return;
_startCountdown();
_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) {
// 邮箱或手机号登录

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

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

2
pubspec.yaml

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

Loading…
Cancel
Save