Merge branch 'develop_liuyf' into develop
This commit is contained in:
commit
b57a071ce9
@ -104,7 +104,7 @@ class StarLockLoginLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
Future<void> oneClickLoginAction(BuildContext context) async {
|
||||
await JverifyOneClickLoginManage().loginAuth(context,(e) async {
|
||||
await JverifyOneClickLoginManage().loginAuth(context, (e) async {
|
||||
final int? code = e.code;
|
||||
final String? content = e.message;
|
||||
// final String operator = map['operator'];
|
||||
@ -199,10 +199,15 @@ class StarLockLoginLogic extends BaseGetXController {
|
||||
if (entity.data!.abbreviation?.toLowerCase() == 'cn' &&
|
||||
currentLanguage == 'zh_CN') {
|
||||
// 初始化一键登录服务
|
||||
await JverifyOneClickLoginManage();
|
||||
state.isCheckVerifyEnable.value =
|
||||
await JverifyOneClickLoginManage().checkVerifyEnable();
|
||||
AppLog.log('一键登录初始化认证结果:${state.isCheckVerifyEnable.value}');
|
||||
JverifyOneClickLoginManage.instance.initSDK().then((value) async {
|
||||
final bool isCheckVerifyEnable =
|
||||
await JverifyOneClickLoginManage.instance.checkVerifyEnable();
|
||||
state.isCheckVerifyEnable.value = isCheckVerifyEnable;
|
||||
AppLog.log('一键登录初始化认证结果:${state.isCheckVerifyEnable.value}');
|
||||
if (isCheckVerifyEnable) {
|
||||
oneClickLoginAction(Get.context!);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -25,12 +25,18 @@ class StarLockLoginXHJPage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _StarLockLoginPageState extends State<StarLockLoginXHJPage> {
|
||||
final StarLockLoginLogic logic = Get.put(StarLockLoginLogic());
|
||||
final StarLockLoginState state = Get.find<StarLockLoginLogic>().state;
|
||||
late StarLockLoginLogic logic ;
|
||||
late StarLockLoginState state;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
if (Get.isRegistered<StarLockLoginLogic>()) {
|
||||
logic = Get.find<StarLockLoginLogic>();
|
||||
} else {
|
||||
logic = Get.put(StarLockLoginLogic());
|
||||
}
|
||||
state = logic.state;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
||||
AppFirstEnterHandle().getAppFirstEnter(isAgreePrivacy);
|
||||
});
|
||||
|
||||
@ -115,10 +115,10 @@ Future<void> privacySDKInitialization() async {
|
||||
if (entity.data!.abbreviation?.toLowerCase() == 'cn' &&
|
||||
currentLanguage == 'zh_CN') {
|
||||
// 初始化一键登录服务
|
||||
final StarLockLoginLogic loginLogic = Get.put(StarLockLoginLogic());
|
||||
await JverifyOneClickLoginManage();
|
||||
loginLogic.state.isCheckVerifyEnable.value =
|
||||
await JverifyOneClickLoginManage().checkVerifyEnable();
|
||||
// final StarLockLoginLogic loginLogic = Get.put(StarLockLoginLogic());
|
||||
// await JverifyOneClickLoginManage();
|
||||
// loginLogic.state.isCheckVerifyEnable.value =
|
||||
// await JverifyOneClickLoginManage().checkVerifyEnable();
|
||||
eventBus.fire(AgreePrivacyAgreement());
|
||||
}
|
||||
}
|
||||
|
||||
@ -11,20 +11,19 @@ import '../common/XSConstantMacro/XSConstantMacro.dart';
|
||||
import '../flavors.dart';
|
||||
|
||||
class JverifyOneClickLoginManage {
|
||||
factory JverifyOneClickLoginManage() => shareManager()!;
|
||||
factory JverifyOneClickLoginManage() => _getInstance()!;
|
||||
|
||||
JverifyOneClickLoginManage._init() {
|
||||
_initSDK();
|
||||
JverifyOneClickLoginManage._init() {}
|
||||
|
||||
static JverifyOneClickLoginManage get instance => _getInstance();
|
||||
static JverifyOneClickLoginManage? _instance;
|
||||
|
||||
static JverifyOneClickLoginManage _getInstance() {
|
||||
_instance ??= JverifyOneClickLoginManage._init();
|
||||
return _instance!;
|
||||
}
|
||||
|
||||
static JverifyOneClickLoginManage? _manager;
|
||||
|
||||
static JverifyOneClickLoginManage? shareManager() {
|
||||
_manager ??= JverifyOneClickLoginManage._init();
|
||||
return _manager;
|
||||
}
|
||||
|
||||
JverifyOneClickLoginManage? get manager => shareManager();
|
||||
JverifyOneClickLoginManage? get manager => _getInstance();
|
||||
Jverify jverify = Jverify();
|
||||
|
||||
/// 统一 key
|
||||
@ -39,15 +38,15 @@ class JverifyOneClickLoginManage {
|
||||
/// 运营商信息
|
||||
String f_opr_key = 'operator';
|
||||
|
||||
Future<void> _initSDK() async {
|
||||
Future<void> initSDK() async {
|
||||
try {
|
||||
await initPlatformState();
|
||||
|
||||
isInitSuccess();
|
||||
// isInitSuccess();
|
||||
|
||||
getToken();
|
||||
// getToken();
|
||||
|
||||
preLogin();
|
||||
// preLogin();
|
||||
} catch (e) {
|
||||
AppLog.log('SDK 初始化错误: $e');
|
||||
}
|
||||
@ -80,65 +79,60 @@ class JverifyOneClickLoginManage {
|
||||
}
|
||||
|
||||
/// sdk 初始化是否完成
|
||||
void isInitSuccess() {
|
||||
jverify.isInitSuccess().then((map) {
|
||||
final bool result = map[f_result_key];
|
||||
AppLog.log('sdk 初始化结果:$map');
|
||||
if (result) {
|
||||
AppLog.log('sdk 初始化成功');
|
||||
} else {
|
||||
AppLog.log('sdk 初始化失败');
|
||||
}
|
||||
});
|
||||
Future<bool> isInitSuccess() async {
|
||||
final Map<dynamic, dynamic> map = await jverify.isInitSuccess();
|
||||
final bool result = map[f_result_key];
|
||||
AppLog.log('sdk 初始化结果:$map');
|
||||
if (result) {
|
||||
AppLog.log('sdk 初始化成功');
|
||||
} else {
|
||||
AppLog.log('sdk 初始化失败');
|
||||
}
|
||||
return Future.value(result);
|
||||
}
|
||||
|
||||
/// 判断当前网络环境是否可以发起认证
|
||||
Future<bool> checkVerifyEnable() async {
|
||||
final isInitSuccess = await this.isInitSuccess();
|
||||
if (!isInitSuccess) {
|
||||
return false;
|
||||
}
|
||||
final Map map = await jverify.checkVerifyEnable();
|
||||
AppLog.log('一家登录 sdk 初始化结果:$map');
|
||||
print('一家登录 sdk 初始化结果:$map');
|
||||
final bool result = map[f_result_key];
|
||||
return result;
|
||||
// state.jverify.checkVerifyEnable().then((map) {
|
||||
// final bool result = map[f_result_key];
|
||||
// if (result) {
|
||||
// AppLog.log('当前网络环境【支持认证】!');
|
||||
// } else {
|
||||
// AppLog.log('当前网络环境【不支持认证】!');
|
||||
// }
|
||||
// return result;
|
||||
// });
|
||||
}
|
||||
|
||||
void getToken() {
|
||||
jverify.checkVerifyEnable().then((map) {
|
||||
final bool result = map[f_result_key];
|
||||
if (result) {
|
||||
jverify.getToken().then((map) {
|
||||
final int code = map[f_code_key];
|
||||
final String token = map[f_msg_key];
|
||||
final String operator = map[f_opr_key];
|
||||
AppLog.log('getToken code:$code token:$token operator:$operator');
|
||||
});
|
||||
} else {
|
||||
AppLog.log('[2016],msg = 当前网络环境不支持认证');
|
||||
}
|
||||
});
|
||||
}
|
||||
// void getToken() {
|
||||
// jverify.checkVerifyEnable().then((map) {
|
||||
// final bool result = map[f_result_key];
|
||||
// if (result) {
|
||||
// jverify.getToken().then((map) {
|
||||
// final int code = map[f_code_key];
|
||||
// final String token = map[f_msg_key];
|
||||
// final String operator = map[f_opr_key];
|
||||
// AppLog.log('getToken code:$code token:$token operator:$operator');
|
||||
// });
|
||||
// } else {
|
||||
// AppLog.log('[2016],msg = 当前网络环境不支持认证');
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
/// 登录预取号
|
||||
void preLogin() {
|
||||
jverify.checkVerifyEnable().then((map) {
|
||||
final bool result = map[f_result_key];
|
||||
if (result) {
|
||||
jverify.preLogin().then((map) {
|
||||
AppLog.log('预取号接口回调:${map.toString()}');
|
||||
final int code = map[f_code_key];
|
||||
final String message = map[f_msg_key];
|
||||
});
|
||||
} else {
|
||||
AppLog.log('[2016],msg = 当前网络环境不支持认证');
|
||||
}
|
||||
});
|
||||
Future<bool> preLogin() async {
|
||||
final networkSupportVerify = await this.checkVerifyEnable();
|
||||
if (!networkSupportVerify) {
|
||||
return false;
|
||||
}
|
||||
final Map map = await jverify.preLogin();
|
||||
final int code = map[f_code_key];
|
||||
final String message = map[f_msg_key];
|
||||
if (code > 0) {
|
||||
return true;
|
||||
}
|
||||
AppLog.log('[2016],msg = 当前网络环境不支持认证');
|
||||
return false;
|
||||
}
|
||||
|
||||
/// SDK 请求授权一键登录
|
||||
|
||||
@ -62,7 +62,7 @@ class _LoginInputState extends State<LoginInput> {
|
||||
|
||||
Widget androidView() {
|
||||
bool isPwd = widget.isPwd ?? false;
|
||||
String pwd = (widget.controller?.text ?? '').replaceAll(RegExp(r'.'), '●');
|
||||
// String pwd = (widget.controller?.text ?? '').replaceAll(RegExp(r'.'), '●');
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border(bottom: BorderSide(width: 0.5.h, color: Colors.grey)),
|
||||
@ -95,14 +95,10 @@ class _LoginInputState extends State<LoginInput> {
|
||||
inputFormatters: widget.inputFormatters,
|
||||
textInputAction: TextInputAction.next,
|
||||
keyboardType: isPwd ? TextInputType.emailAddress : null,
|
||||
style: isPwd
|
||||
? TextStyle(
|
||||
style: TextStyle(
|
||||
fontSize: 22.sp,
|
||||
color: Colors.transparent,
|
||||
letterSpacing: 2.5,
|
||||
fontFamily: 'Monospace',
|
||||
)
|
||||
: null,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
//输入里面输入文字内边距设置
|
||||
contentPadding: const EdgeInsets.only(
|
||||
@ -122,20 +118,20 @@ class _LoginInputState extends State<LoginInput> {
|
||||
: null,
|
||||
),
|
||||
),
|
||||
if (isPwd)
|
||||
Padding(
|
||||
padding: EdgeInsets.only(
|
||||
top: F.sw(skyCall: () => 27.h, xhjCall: () => widget.isLogin! ? 27.h : 39.h)),
|
||||
child: Text(
|
||||
pwd,
|
||||
style: TextStyle(
|
||||
fontSize: 22.sp,
|
||||
color: AppColors.darkGrayTextColor,
|
||||
letterSpacing: 2.0,
|
||||
fontFamily: 'Monospace',
|
||||
),
|
||||
),
|
||||
),
|
||||
// if (isPwd)
|
||||
// Padding(
|
||||
// padding: EdgeInsets.only(
|
||||
// top: F.sw(skyCall: () => 27.h, xhjCall: () => widget.isLogin! ? 27.h : 39.h)),
|
||||
// child: Text(
|
||||
// pwd,
|
||||
// style: TextStyle(
|
||||
// fontSize: 22.sp,
|
||||
// color: AppColors.darkGrayTextColor,
|
||||
// letterSpacing: 2.0,
|
||||
// fontFamily: 'Monospace',
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user