mirror of
https://github.com/HChaZZY/PiliPlus.git
synced 2025-12-18 08:06:21 +08:00
opt: login dialog
Closes #72 Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
@@ -2,6 +2,7 @@ import 'dart:async';
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:PiliPalaX/common/constants.dart';
|
import 'package:PiliPalaX/common/constants.dart';
|
||||||
|
import 'package:PiliPalaX/common/widgets/icon_button.dart';
|
||||||
import 'package:PiliPalaX/http/init.dart';
|
import 'package:PiliPalaX/http/init.dart';
|
||||||
import 'package:PiliPalaX/utils/extension.dart';
|
import 'package:PiliPalaX/utils/extension.dart';
|
||||||
import 'package:PiliPalaX/utils/storage.dart';
|
import 'package:PiliPalaX/utils/storage.dart';
|
||||||
@@ -303,34 +304,54 @@ class LoginPageController extends GetxController
|
|||||||
}
|
}
|
||||||
TextEditingController textFieldController = TextEditingController();
|
TextEditingController textFieldController = TextEditingController();
|
||||||
String captchaKey = '';
|
String captchaKey = '';
|
||||||
Get.dialog(AlertDialog(
|
Get.dialog(
|
||||||
title: const Text("本次登录需要验证您的手机号"),
|
AlertDialog(
|
||||||
content: Column(mainAxisSize: MainAxisSize.min, children: [
|
titlePadding:
|
||||||
|
EdgeInsets.only(left: 16, top: 18, right: 16, bottom: 12),
|
||||||
|
contentPadding: EdgeInsets.symmetric(horizontal: 16),
|
||||||
|
actionsPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
|
title: const Text(
|
||||||
|
"本次登录需要验证您的手机号",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(fontSize: 18),
|
||||||
|
),
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
Text(
|
Text(
|
||||||
accountInfo['hindTel'] ?? '未能获取手机号',
|
accountInfo['hindTel'] ?? '未能获取手机号',
|
||||||
style: const TextStyle(fontSize: 20),
|
style: const TextStyle(fontSize: 18),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
|
||||||
// 带有清空按钮的输入框
|
// 带有清空按钮的输入框
|
||||||
|
|
||||||
TextField(
|
TextField(
|
||||||
|
style: TextStyle(fontSize: 15),
|
||||||
controller: textFieldController,
|
controller: textFieldController,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
hintText: "请输入短信验证码",
|
hintText: "请输入短信验证码",
|
||||||
suffixIcon: IconButton(
|
hintStyle: TextStyle(fontSize: 15),
|
||||||
icon: const Icon(Icons.clear),
|
suffixIcon: iconButton(
|
||||||
|
context: Get.context!,
|
||||||
|
icon: Icons.clear,
|
||||||
|
size: 32,
|
||||||
|
bgColor: Colors.transparent,
|
||||||
onPressed: textFieldController.clear,
|
onPressed: textFieldController.clear,
|
||||||
),
|
),
|
||||||
|
suffixIconConstraints: BoxConstraints(
|
||||||
|
maxHeight: 32,
|
||||||
|
maxWidth: 32,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
]),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
actions: <Widget>[
|
actions: <Widget>[
|
||||||
TextButton(
|
TextButton(
|
||||||
child: const Text("发送验证码 "),
|
child: const Text("发送验证码"),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
var preCaptureRes = await LoginHttp.preCapture();
|
var preCaptureRes = await LoginHttp.preCapture();
|
||||||
if (!preCaptureRes['status'] || preCaptureRes['data'] == null) {
|
if (!preCaptureRes['status'] ||
|
||||||
|
preCaptureRes['data'] == null) {
|
||||||
SmartDialog.showToast("获取验证码失败,请尝试其它登录方式\n"
|
SmartDialog.showToast("获取验证码失败,请尝试其它登录方式\n"
|
||||||
"(${preCaptureRes['code']}) ${preCaptureRes['msg']} ${preCaptureRes['data']}");
|
"(${preCaptureRes['code']}) ${preCaptureRes['msg']} ${preCaptureRes['data']}");
|
||||||
}
|
}
|
||||||
@@ -343,7 +364,10 @@ class LoginPageController extends GetxController
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
getCaptcha(geeGt, geeChallenge, () async {
|
getCaptcha(
|
||||||
|
geeGt,
|
||||||
|
geeChallenge,
|
||||||
|
() async {
|
||||||
var safeCenterSendSmsCodeRes =
|
var safeCenterSendSmsCodeRes =
|
||||||
await LoginHttp.safeCenterSmsCode(
|
await LoginHttp.safeCenterSmsCode(
|
||||||
tmpCode: currentUri.queryParameters['tmp_token']!,
|
tmpCode: currentUri.queryParameters['tmp_token']!,
|
||||||
@@ -359,13 +383,19 @@ class LoginPageController extends GetxController
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SmartDialog.showToast("短信验证码已发送,请查收");
|
SmartDialog.showToast("短信验证码已发送,请查收");
|
||||||
captchaKey = safeCenterSendSmsCodeRes['data']['captcha_key'];
|
captchaKey =
|
||||||
});
|
safeCenterSendSmsCodeRes['data']['captcha_key'];
|
||||||
|
},
|
||||||
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: Get.back,
|
onPressed: Get.back,
|
||||||
child: const Text(" 取消"),
|
child: Text(
|
||||||
|
"取消",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Theme.of(Get.context!).colorScheme.outline),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
@@ -398,7 +428,8 @@ class LoginPageController extends GetxController
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var data = oauth2AccessTokenRes['data'];
|
var data = oauth2AccessTokenRes['data'];
|
||||||
if (data['token_info'] == null || data['cookie_info'] == null) {
|
if (data['token_info'] == null ||
|
||||||
|
data['cookie_info'] == null) {
|
||||||
SmartDialog.showToast(
|
SmartDialog.showToast(
|
||||||
'登录异常,接口未返回身份信息,可能是因为账号风控,请尝试其它登录方式。\n${oauth2AccessTokenRes["msg"]},\n $data');
|
'登录异常,接口未返回身份信息,可能是因为账号风控,请尝试其它登录方式。\n${oauth2AccessTokenRes["msg"]},\n $data');
|
||||||
return;
|
return;
|
||||||
@@ -412,7 +443,8 @@ class LoginPageController extends GetxController
|
|||||||
child: const Text("确认"),
|
child: const Text("确认"),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
));
|
),
|
||||||
|
);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user