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,116 +304,147 @@ 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:
|
||||||
Text(
|
EdgeInsets.only(left: 16, top: 18, right: 16, bottom: 12),
|
||||||
accountInfo['hindTel'] ?? '未能获取手机号',
|
contentPadding: EdgeInsets.symmetric(horizontal: 16),
|
||||||
style: const TextStyle(fontSize: 20),
|
actionsPadding: EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||||
),
|
title: const Text(
|
||||||
const SizedBox(height: 10),
|
"本次登录需要验证您的手机号",
|
||||||
// 带有清空按钮的输入框
|
|
||||||
|
|
||||||
TextField(
|
|
||||||
controller: textFieldController,
|
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
decoration: InputDecoration(
|
style: TextStyle(fontSize: 18),
|
||||||
hintText: "请输入短信验证码",
|
|
||||||
suffixIcon: IconButton(
|
|
||||||
icon: const Icon(Icons.clear),
|
|
||||||
onPressed: textFieldController.clear,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
]),
|
content: Column(
|
||||||
actions: <Widget>[
|
mainAxisSize: MainAxisSize.min,
|
||||||
TextButton(
|
children: [
|
||||||
child: const Text("发送验证码 "),
|
Text(
|
||||||
onPressed: () async {
|
accountInfo['hindTel'] ?? '未能获取手机号',
|
||||||
var preCaptureRes = await LoginHttp.preCapture();
|
style: const TextStyle(fontSize: 18),
|
||||||
if (!preCaptureRes['status'] || preCaptureRes['data'] == null) {
|
),
|
||||||
SmartDialog.showToast("获取验证码失败,请尝试其它登录方式\n"
|
// 带有清空按钮的输入框
|
||||||
"(${preCaptureRes['code']}) ${preCaptureRes['msg']} ${preCaptureRes['data']}");
|
TextField(
|
||||||
}
|
style: TextStyle(fontSize: 15),
|
||||||
String? geeGt = preCaptureRes['data']['gee_gt'];
|
controller: textFieldController,
|
||||||
String? geeChallenge = preCaptureRes['data']['gee_challenge'];
|
textAlign: TextAlign.center,
|
||||||
captchaData.token = preCaptureRes['data']['recaptcha_token'];
|
decoration: InputDecoration(
|
||||||
if (!isGeeArgumentValid(geeGt, geeChallenge)) {
|
hintText: "请输入短信验证码",
|
||||||
SmartDialog.showToast("获取极验参数为空,请尝试其它登录方式\n"
|
hintStyle: TextStyle(fontSize: 15),
|
||||||
"(${preCaptureRes['code']}) ${preCaptureRes['msg']} ${preCaptureRes['data']}");
|
suffixIcon: iconButton(
|
||||||
return;
|
context: Get.context!,
|
||||||
}
|
icon: Icons.clear,
|
||||||
|
size: 32,
|
||||||
getCaptcha(geeGt, geeChallenge, () async {
|
bgColor: Colors.transparent,
|
||||||
var safeCenterSendSmsCodeRes =
|
onPressed: textFieldController.clear,
|
||||||
await LoginHttp.safeCenterSmsCode(
|
),
|
||||||
tmpCode: currentUri.queryParameters['tmp_token']!,
|
suffixIconConstraints: BoxConstraints(
|
||||||
geeChallenge: geeChallenge,
|
maxHeight: 32,
|
||||||
geeSeccode: captchaData.seccode,
|
maxWidth: 32,
|
||||||
geeValidate: captchaData.validate,
|
),
|
||||||
recaptchaToken: captchaData.token,
|
),
|
||||||
refererUrl: url,
|
),
|
||||||
);
|
],
|
||||||
if (!safeCenterSendSmsCodeRes['status']) {
|
),
|
||||||
SmartDialog.showToast("发送短信验证码失败,请尝试其它登录方式\n"
|
actions: <Widget>[
|
||||||
"(${safeCenterSendSmsCodeRes['code']}) ${safeCenterSendSmsCodeRes['msg']}");
|
TextButton(
|
||||||
|
child: const Text("发送验证码"),
|
||||||
|
onPressed: () async {
|
||||||
|
var preCaptureRes = await LoginHttp.preCapture();
|
||||||
|
if (!preCaptureRes['status'] ||
|
||||||
|
preCaptureRes['data'] == null) {
|
||||||
|
SmartDialog.showToast("获取验证码失败,请尝试其它登录方式\n"
|
||||||
|
"(${preCaptureRes['code']}) ${preCaptureRes['msg']} ${preCaptureRes['data']}");
|
||||||
|
}
|
||||||
|
String? geeGt = preCaptureRes['data']['gee_gt'];
|
||||||
|
String? geeChallenge = preCaptureRes['data']['gee_challenge'];
|
||||||
|
captchaData.token = preCaptureRes['data']['recaptcha_token'];
|
||||||
|
if (!isGeeArgumentValid(geeGt, geeChallenge)) {
|
||||||
|
SmartDialog.showToast("获取极验参数为空,请尝试其它登录方式\n"
|
||||||
|
"(${preCaptureRes['code']}) ${preCaptureRes['msg']} ${preCaptureRes['data']}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SmartDialog.showToast("短信验证码已发送,请查收");
|
|
||||||
captchaKey = safeCenterSendSmsCodeRes['data']['captcha_key'];
|
getCaptcha(
|
||||||
});
|
geeGt,
|
||||||
},
|
geeChallenge,
|
||||||
),
|
() async {
|
||||||
TextButton(
|
var safeCenterSendSmsCodeRes =
|
||||||
onPressed: Get.back,
|
await LoginHttp.safeCenterSmsCode(
|
||||||
child: const Text(" 取消"),
|
tmpCode: currentUri.queryParameters['tmp_token']!,
|
||||||
),
|
geeChallenge: geeChallenge,
|
||||||
TextButton(
|
geeSeccode: captchaData.seccode,
|
||||||
onPressed: () async {
|
geeValidate: captchaData.validate,
|
||||||
String? code = textFieldController.text;
|
recaptchaToken: captchaData.token,
|
||||||
if (code.isEmpty) {
|
refererUrl: url,
|
||||||
SmartDialog.showToast("请输入短信验证码");
|
);
|
||||||
return;
|
if (!safeCenterSendSmsCodeRes['status']) {
|
||||||
}
|
SmartDialog.showToast("发送短信验证码失败,请尝试其它登录方式\n"
|
||||||
var safeCenterSmsVerifyRes =
|
"(${safeCenterSendSmsCodeRes['code']}) ${safeCenterSendSmsCodeRes['msg']}");
|
||||||
await LoginHttp.safeCenterSmsVerify(
|
return;
|
||||||
code: code,
|
}
|
||||||
tmpCode: currentUri.queryParameters['tmp_token']!,
|
SmartDialog.showToast("短信验证码已发送,请查收");
|
||||||
requestId: currentUri.queryParameters['request_id']!,
|
captchaKey =
|
||||||
source: currentUri.queryParameters['source']!,
|
safeCenterSendSmsCodeRes['data']['captcha_key'];
|
||||||
captchaKey: captchaKey,
|
},
|
||||||
refererUrl: url,
|
);
|
||||||
);
|
},
|
||||||
if (!safeCenterSmsVerifyRes['status']) {
|
),
|
||||||
SmartDialog.showToast("验证短信验证码失败,请尝试其它登录方式\n"
|
TextButton(
|
||||||
"(${safeCenterSmsVerifyRes['code']}) ${safeCenterSmsVerifyRes['msg']}");
|
onPressed: Get.back,
|
||||||
return;
|
child: Text(
|
||||||
}
|
"取消",
|
||||||
SmartDialog.showToast("验证成功,正在登录");
|
style: TextStyle(
|
||||||
var oauth2AccessTokenRes = await LoginHttp.oauth2AccessToken(
|
color: Theme.of(Get.context!).colorScheme.outline),
|
||||||
code: safeCenterSmsVerifyRes['data']['code'],
|
),
|
||||||
);
|
),
|
||||||
if (!oauth2AccessTokenRes['status']) {
|
TextButton(
|
||||||
SmartDialog.showToast("登录失败,请尝试其它登录方式\n"
|
onPressed: () async {
|
||||||
"(${oauth2AccessTokenRes['code']}) ${oauth2AccessTokenRes['msg']}");
|
String? code = textFieldController.text;
|
||||||
return;
|
if (code.isEmpty) {
|
||||||
}
|
SmartDialog.showToast("请输入短信验证码");
|
||||||
var data = oauth2AccessTokenRes['data'];
|
return;
|
||||||
if (data['token_info'] == null || data['cookie_info'] == null) {
|
}
|
||||||
SmartDialog.showToast(
|
var safeCenterSmsVerifyRes =
|
||||||
'登录异常,接口未返回身份信息,可能是因为账号风控,请尝试其它登录方式。\n${oauth2AccessTokenRes["msg"]},\n $data');
|
await LoginHttp.safeCenterSmsVerify(
|
||||||
return;
|
code: code,
|
||||||
}
|
tmpCode: currentUri.queryParameters['tmp_token']!,
|
||||||
SmartDialog.showToast('正在保存身份信息');
|
requestId: currentUri.queryParameters['request_id']!,
|
||||||
await Utils.afterLoginByApp(
|
source: currentUri.queryParameters['source']!,
|
||||||
data['token_info'], data['cookie_info']);
|
captchaKey: captchaKey,
|
||||||
Get.back();
|
refererUrl: url,
|
||||||
Get.back();
|
);
|
||||||
},
|
if (!safeCenterSmsVerifyRes['status']) {
|
||||||
child: const Text("确认"),
|
SmartDialog.showToast("验证短信验证码失败,请尝试其它登录方式\n"
|
||||||
),
|
"(${safeCenterSmsVerifyRes['code']}) ${safeCenterSmsVerifyRes['msg']}");
|
||||||
],
|
return;
|
||||||
));
|
}
|
||||||
|
SmartDialog.showToast("验证成功,正在登录");
|
||||||
|
var oauth2AccessTokenRes = await LoginHttp.oauth2AccessToken(
|
||||||
|
code: safeCenterSmsVerifyRes['data']['code'],
|
||||||
|
);
|
||||||
|
if (!oauth2AccessTokenRes['status']) {
|
||||||
|
SmartDialog.showToast("登录失败,请尝试其它登录方式\n"
|
||||||
|
"(${oauth2AccessTokenRes['code']}) ${oauth2AccessTokenRes['msg']}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var data = oauth2AccessTokenRes['data'];
|
||||||
|
if (data['token_info'] == null ||
|
||||||
|
data['cookie_info'] == null) {
|
||||||
|
SmartDialog.showToast(
|
||||||
|
'登录异常,接口未返回身份信息,可能是因为账号风控,请尝试其它登录方式。\n${oauth2AccessTokenRes["msg"]},\n $data');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SmartDialog.showToast('正在保存身份信息');
|
||||||
|
await Utils.afterLoginByApp(
|
||||||
|
data['token_info'], data['cookie_info']);
|
||||||
|
Get.back();
|
||||||
|
Get.back();
|
||||||
|
},
|
||||||
|
child: const Text("确认"),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user