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