封装图形验证码

This commit is contained in:
魏少阳 2023-07-29 18:33:48 +08:00
parent f53921fa5d
commit e1660e1544
22 changed files with 619 additions and 592 deletions

View File

@ -305,6 +305,7 @@
"email":"Email",
"countryAndRegion":"Country And Region",
"selet":"Selet",
"getVerificationCode":"Get Verification Code",
"businessCooperation":"Business Cooperation",
"officialWebsite":"Official Website",

View File

@ -305,6 +305,7 @@
"email":"email",
"countryAndRegion":"countryAndRegion",
"selet":"selet",
"getVerificationCode":"getVerificationCode",
"businessCooperation":"businessCooperation",
"officialWebsite":"officialWebsite",

View File

@ -305,6 +305,7 @@
"email":"邮箱",
"countryAndRegion":"国家/地区",
"selet":"选择",
"getVerificationCode":"获取验证码",
"businessCooperation":"商务合作",
"officialWebsite":"官网",

View File

@ -40,7 +40,7 @@
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Release"
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"

View File

@ -10,7 +10,8 @@ import 'package:star_lock/mine/mineSet/transferSmartLock/recipientInformation_pa
import 'package:star_lock/mine/mineSet/transferSmartLock/selectBranch_page.dart';
import 'package:star_lock/mine/mineSet/transferSmartLock/transferSmartLock_page.dart';
import 'common/safetyVerification_page.dart';
import 'common/safetyVerification/safetyVerification_binding.dart';
import 'common/safetyVerification/safetyVerification_page.dart';
import 'login/forgetPassword/starLock_forgetPassword_page.dart';
import 'login/login/starLock_login_page.dart';
import 'login/register/starLock_register_page.dart';
@ -385,7 +386,8 @@ abstract class AppRouters {
),
GetPage(
name: Routers.starLockRegisterPage,
page: () => const StarLockRegisterPage(), binding:StarLockRegisterBinding()
page: () => const StarLockRegisterPage(),
binding:StarLockRegisterBinding()
),
GetPage(
name: Routers.starLockForgetPasswordPage,
@ -668,10 +670,12 @@ abstract class AppRouters {
page: () => const LockUserManageListListPage()
),
GetPage(
name: Routers.lockGroupListPage, page: () => const LockGroupListPage()
name: Routers.lockGroupListPage,
page: () => const LockGroupListPage()
),
GetPage(
name: Routers.lockItemListPage, page: () => const LockItemListPage()
name: Routers.lockItemListPage,
page: () => const LockItemListPage()
),
GetPage(
name: Routers.transferSmartLockPage,
@ -682,7 +686,8 @@ abstract class AppRouters {
page: () => const RecipientInformationPage()
),
GetPage(
name: Routers.selectBranchPage, page: () => const SelectBranchPage()
name: Routers.selectBranchPage,
page: () => const SelectBranchPage()
),
GetPage(
name: Routers.selectGetewayListPage,
@ -698,10 +703,12 @@ abstract class AppRouters {
),
GetPage(
name: Routers.safetyVerificationPage,
page: () => const SafetyVerificationPage()
page: () => const SafetyVerificationPage(),
binding: SafetyVerificationBinding()
),
GetPage(
name: Routers.ownedKeyListPage, page: () => const OwnedKeyListPage()
name: Routers.ownedKeyListPage,
page: () => const OwnedKeyListPage()
)
];
}

View File

@ -0,0 +1,26 @@
import 'Data.dart';
class CheckSafetyVerificationEntity {
CheckSafetyVerificationEntity({
this.description,
this.errorCode,
this.errorMsg,});
CheckSafetyVerificationEntity.fromJson(dynamic json) {
description = json['description'];
errorCode = json['errorCode'];
errorMsg = json['errorMsg'];
}
String? description;
int? errorCode;
String? errorMsg;
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['description'] = description;
map['errorCode'] = errorCode;
map['errorMsg'] = errorMsg;
return map;
}
}

View File

@ -0,0 +1,25 @@
class Data {
Data({
this.bigImg,
this.smallImg,
this.yHeight,});
Data.fromJson(dynamic json) {
bigImg = json['bigImg'];
smallImg = json['smallImg'];
yHeight = json['yHeight'];
}
String? bigImg;
String? smallImg;
int? yHeight;
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['bigImg'] = bigImg;
map['smallImg'] = smallImg;
map['yHeight'] = yHeight;
return map;
}
}

View File

@ -0,0 +1,32 @@
import 'Data.dart';
class SafetyVerificationEntity {
SafetyVerificationEntity({
this.description,
this.errorCode,
this.data,
this.errorMsg,});
SafetyVerificationEntity.fromJson(dynamic json) {
description = json['description'];
errorCode = json['errorCode'];
data = json['data'] != null ? Data.fromJson(json['data']) : null;
errorMsg = json['errorMsg'];
}
String? description;
int? errorCode;
Data? data;
String? errorMsg;
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['description'] = description;
map['errorCode'] = errorCode;
if (data != null) {
map['data'] = data!.toJson();
}
map['errorMsg'] = errorMsg;
return map;
}
}

View File

@ -0,0 +1,10 @@
import 'package:get/get.dart';
import 'safetyVerification_logic.dart';
class SafetyVerificationBinding extends Bindings {
@override
void dependencies() {
Get.lazyPut(() => SafetyVerificationLogic());
}
}

View File

@ -0,0 +1,12 @@
import 'package:star_lock/common/safetyVerification/safetyVerification_state.dart';
import '../../network/api_repository.dart';
import '../../tools/baseGetXController.dart';
import 'entity/SafetyVerificationEntity.dart';
class SafetyVerificationLogic extends BaseGetXController{
final SafetyVerificationState state = SafetyVerificationState();
}

View File

@ -0,0 +1,409 @@
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:star_lock/common/safetyVerification/safetyVerification_logic.dart';
import 'dart:convert';
import 'dart:math';
import '../../app_settings/app_colors.dart';
import '../../network/api_repository.dart';
import '../../tools/titleAppBar.dart';
import '../../translations/trans_lib.dart';
import 'entity/SafetyVerificationEntity.dart';
class SafetyVerificationPage extends StatefulWidget {
const SafetyVerificationPage({Key? key}) : super(key: key);
@override
State<SafetyVerificationPage> createState() => _SafetyVerificationPageState();
}
class _SafetyVerificationPageState extends State<SafetyVerificationPage> with TickerProviderStateMixin {
final logic = Get.find<SafetyVerificationLogic>();
final state = Get.find<SafetyVerificationLogic>().state;
String baseImageBase64 = "";
String slideImageBase64 = "";
Size baseSize = Size.zero; //
Size slideSize = Size.zero; //
double sliderStartX = 0; //X坐标
bool sliderMoveFinish = false; //
bool checkResultAfterDrag = false; //
//-------------------------
int _checkMilliseconds = 0; //
bool _showTimeLine = false; //
bool _checkSuccess = false; //
AnimationController? controller;
//
Animation<double>? offsetAnimation;
final double _bottomSliderSize = 60;
//
Future<void> loadCaptcha() async {
setState(() {
_showTimeLine = false;
sliderMoveFinish = false;
checkResultAfterDrag = false;
});
print("countryCode:${state.getData["countryCode"]} getAccount:${state.getData["getAccount"]}");
var entity = await ApiRepository.to.getSliderVerifyImg(state.getData["countryCode"], state.getData["account"]);
if(entity.errorCode! == 0){
state.sliderXMoved.value = 0;
sliderStartX = 0;
checkResultAfterDrag = false;
baseImageBase64 = entity.data!.bigImg!;
slideImageBase64 = entity.data!.smallImg!;
var baseR = await WidgetUtil.getImageWH(
image: Image.memory(const Base64Decoder().convert(baseImageBase64)));
baseSize = baseR.size;
var silderR = await WidgetUtil.getImageWH(
image: Image.memory(const Base64Decoder().convert(slideImageBase64)));
slideSize = silderR.size;
setState(() {});
} else {
}
}
//
Future<void> checkCaptcha(sliderMovedX, {BuildContext? myContext}) async {
setState(() {
sliderMoveFinish = true;
});
var entity = await ApiRepository.to.checkSliderVerifyImg(state.getData["countryCode"], state.getData["account"], sliderMovedX.toString());
if(entity.errorCode! == 0){
checkSuccess("captchaVerification");
}else{
state.sliderXMoved.value = 0;
sliderStartX = 0;
checkResultAfterDrag = false;
setState(() {});
}
}
@override
void initState() {
super.initState();
initAnimation();
loadCaptcha();
}
//
void initAnimation() {
controller =
AnimationController(duration: const Duration(milliseconds: 500), vsync: this);
offsetAnimation = Tween<double>(begin: 0.5, end: 0)
.animate(CurvedAnimation(parent: controller!, curve: Curves.ease))
..addListener(() {
setState(() {});
});
}
@override
void didUpdateWidget(SafetyVerificationPage oldWidget) {
// TODO: implement didUpdateWidget
super.didUpdateWidget(oldWidget);
}
@override
Widget build(BuildContext context) {
return MaxScaleTextWidget(
child: buildContent(context),
);
}
Widget buildContent(BuildContext context) {
var mediaQuery = MediaQuery.of(context);
var dialogWidth = 0.9 * mediaQuery.size.width;
if (dialogWidth < 330) {
dialogWidth = mediaQuery.size.width;
}
return Scaffold(
backgroundColor: Colors.white,
appBar: TitleAppBar(
barTitle: TranslationLoader.lanKeys!.about!.tr,
haveBack: true,
backgroundColor: AppColors.mainColor),
body: Container(
// key: _containerKey,
width: 1.sw,
// height: 340,
color: Colors.white,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
_topContainer(),
_middleContainer(),
_bottomContainer(),
],
),
),
);
}
//
void checkSuccess(String content) {
setState(() {
checkResultAfterDrag = true;
_checkSuccess = true;
_showTimeLine = true;
});
_forwardAnimation();
//
Future.delayed(const Duration(milliseconds: 1000)).then((v) {
_reverseAnimation().then((v) {
setState(() {
_showTimeLine = false;
});
//
Navigator.pop(context);
});
});
}
//
void checkFail() {
setState(() {
_showTimeLine = true;
_checkSuccess = false;
checkResultAfterDrag = false;
});
_forwardAnimation();
//
Future.delayed(Duration(milliseconds: 1000)).then((v) {
_reverseAnimation().then((v) {
setState(() {
_showTimeLine = false;
});
loadCaptcha();
//
// if (widget.onFail != null) {
// widget.onFail!();
// }
});
});
}
//
_reverseAnimation() async {
await controller!.reverse();
}
//
_forwardAnimation() async {
await controller!.forward();
}
///+
_topContainer() {
return Container(
height: 70.h,
padding: const EdgeInsets.fromLTRB(10, 0, 10, 0),
decoration: const BoxDecoration(
border: Border(bottom: BorderSide(width: 1, color: Color(0xffe5e5e5))),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text('拖动下方滑块完成拼图', style: TextStyle(fontSize: 26.sp),),
IconButton(
icon: const Icon(Icons.refresh),
iconSize: 30,
color: Colors.black54,
onPressed: () {
//
loadCaptcha();
}),
],
),
);
}
_middleContainer() {
////
return Container(
margin: const EdgeInsets.symmetric(vertical: 10),
child: Stack(
children: <Widget>[
/// 310*155
baseImageBase64.isNotEmpty ?
Image.memory(
const Base64Decoder().convert(baseImageBase64),
fit: BoxFit.fitWidth,
// key: _baseImageKey,
gaplessPlayback: true,
):
Container(
width: 310,
height: 155,
alignment: Alignment.center,
child: const CircularProgressIndicator(),
),
///
slideImageBase64.isNotEmpty ?
Obx(() => Container(
margin: EdgeInsets.fromLTRB(state.sliderXMoved.value, 0, 0, 0),
child: Image.memory(const Base64Decoder().convert(slideImageBase64),
fit: BoxFit.fitHeight,
// key: _slideImageKey,
gaplessPlayback: true,
),
)) : Container(),
Positioned(
bottom: 0,
left: -10,
right: -10,
child: Offstage(
offstage: !_showTimeLine,
child: FractionalTranslation(
translation: Offset(0, offsetAnimation!.value),
child: Container(
margin: const EdgeInsets.only(left: 10, right: 10),
height: 40,
color: _checkSuccess ? const Color(0x7F66BB6A) : const Color.fromRGBO(200, 100, 100, 0.4),
alignment: Alignment.centerLeft,
child: Text(
_checkSuccess
? "${(_checkMilliseconds / (60.0 * 12)).toStringAsFixed(2)}s验证成功"
: "验证失败",
style: const TextStyle(color: Colors.white),
),
),
),
)),
Positioned(
bottom: -20,
left: 0,
right: 0,
child: Offstage(
offstage: !_showTimeLine,
child: Container(
margin: const EdgeInsets.only(left: 10, right: 10),
height: 20,
color: Colors.white,
),
))
],
),
);
}
///
_bottomContainer() {
return baseSize.width >0 ?
Container(
height: 70,
width: baseSize.width,
child: Stack(
alignment: AlignmentDirectional.centerStart,
children: <Widget>[
Container(
height: _bottomSliderSize,
decoration: BoxDecoration(
border: Border.all(
width: 1,
color: const Color(0xffe5e5e5),
),
color: const Color(0xfff8f9fb),
),
),
Container(
alignment: Alignment.center,
child: Text('向右拖动滑块填充拼图', style: TextStyle(fontSize: 16),),
),
Obx(() => Container(
width: state.sliderXMoved.value,
height: _bottomSliderSize-2,
color: const Color(0xfff3fef1),
)),
GestureDetector(
onPanStart: (startDetails) {
///
_checkMilliseconds = DateTime.now().millisecondsSinceEpoch;
print(startDetails.localPosition);
sliderStartX = startDetails.localPosition.dx;
},
onPanUpdate: (updateDetails) {
///
print(updateDetails.localPosition);
double offset = updateDetails.localPosition.dx - sliderStartX;
if(offset < 0){
offset = 0;
}
print("offset ------ $offset");
setState(() {
state.sliderXMoved.value = offset;
});
},
onPanEnd: (endDetails) { //
print("endDetails sliderXMoved:${state.sliderXMoved.value}");
checkCaptcha(state.sliderXMoved.value);
int nowTime = DateTime.now().millisecondsSinceEpoch;
_checkMilliseconds = nowTime - _checkMilliseconds;
},
child: Obx(() {
return Container(
width: _bottomSliderSize,
height: _bottomSliderSize,
margin: EdgeInsets.only(left: state.sliderXMoved.value > 0 ? state.sliderXMoved.value : 1),
decoration: const BoxDecoration(
border: Border(
top: BorderSide(width: 1, color: Color(0xffe5e5e5)),
right: BorderSide(width: 1, color: Color(0xffe5e5e5)),
bottom: BorderSide(width: 1, color: Color(0xffe5e5e5)),
),
color: Colors.white,
),
child: IconButton(
icon: const Icon(Icons.arrow_forward),
iconSize: 30,
color: Colors.black54, onPressed: () {},
),
);
}),
)
],
))
: Container();
}
@override
void dispose() {
controller!.dispose();
super.dispose();
}
}
class MaxScaleTextWidget extends StatelessWidget {
final double max;
final Widget child;
const MaxScaleTextWidget({Key? key, this.max = 1.0, required this.child}) : super(key: key);
@override
Widget build(BuildContext context) {
var data = MediaQuery.of(context);
var textScaleFactor = min(max, data.textScaleFactor);
return MediaQuery(data: data.copyWith(textScaleFactor: textScaleFactor), child: child);
}
}

View File

@ -0,0 +1,19 @@
import 'package:get/get.dart';
import 'entity/SafetyVerificationEntity.dart';
class SafetyVerificationState{
// Rx<SafetyVerificationEntity> safetyVerificationEntity = SafetyVerificationEntity().obs;
var sliderXMoved = 0.0.obs;
var getData = {}.obs;
SafetyVerificationState() {
getData.value = Get.arguments as Map;
}
void onClose() {
}
}

File diff suppressed because one or more lines are too long

View File

@ -2,30 +2,30 @@ import 'Data.dart';
class LoginEntity {
LoginEntity({
this.msg,
this.msgCode,
this.data,
this.code,});
this.description,
this.errorCode,
this.content,
this.errorMsg,});
LoginEntity.fromJson(dynamic json) {
msg = json['msg'];
msgCode = json['msgCode'];
data = json['data'] != null ? Data.fromJson(json['data']) : null;
code = json['code'];
description = json['description'];
errorCode = json['errorCode'];
content = json['content'] != null ? Data.fromJson(json['content']) : null;
errorMsg = json['errorMsg'];
}
String? msg;
int? msgCode;
Data? data;
int? code;
String? description;
int? errorCode;
Data? content;
int? errorMsg;
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['msg'] = msg;
map['msgCode'] = msgCode;
if (data != null) {
map['data'] = data!.toJson();
map['description'] = description;
map['errorCode'] = errorCode;
if (content != null) {
map['data'] = content!.toJson();
}
map['code'] = code;
map['errorMsg'] = errorMsg;
return map;
}

View File

@ -11,13 +11,13 @@ class StarLockRegisterLogic extends BaseGetXController{
void register() async{
var entity = await ApiRepository.to.register(
state.countryCode.value,
state.countryCode.value,
state.countryId.value,
state.phoneOrEmailStr.value,
state.pwd.value,
"gdasdfasdfasdf",
state.verificationCode.value
);
if(entity.code!.codeIsSuccessful){
if(entity.errorCode!.codeIsSuccessful){
await loginSuccess(loginEntity: entity);
} else {

View File

@ -203,14 +203,11 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
print("3333333:${v}");
logic.checkNext(state.phoneOrEmailController);
},
leftWidget: Padding(
padding: EdgeInsets.only(
top: 30.w, bottom: 20.w, right: 20.w, left: 5.w),
child: Image.asset(
'images/icon_login_account.png',
width: 40.w,
height: 40.w,
),
leftWidget:
// Image.asset('images/icon_login_account.png', width: 30.w, height: 30.w,),
Padding(
padding: EdgeInsets.only(right: 10.w, left: 5.w),
child: Image.asset('images/icon_login_account.png', width: 30.w, height: 30.w,),
),
hintText: TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr,
keyboardType: TextInputType.number,
@ -226,13 +223,8 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
},
isPwd: true,
leftWidget: Padding(
padding: EdgeInsets.only(
top: 30.w, bottom: 20.w, right: 20.w, left: 5.w),
child: Image.asset(
'images/icon_login_password.png',
width: 40.w,
height: 40.w,
),
padding: EdgeInsets.only(right: 10.w, left: 5.w),
child: Image.asset('images/icon_login_password.png', width: 30.w, height: 30.w,),
),
hintText:
"${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.password!.tr}",
@ -253,13 +245,8 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
},
isPwd: true,
leftWidget: Padding(
padding: EdgeInsets.only(
top: 30.w, bottom: 20.w, right: 20.w, left: 5.w),
child: Image.asset(
'images/icon_login_password.png',
width: 40.w,
height: 40.w,
),
padding: EdgeInsets.only(right: 10.w, left: 5.w),
child: Image.asset('images/icon_login_password.png', width: 30.w, height: 30.w,),
),
hintText:
"${TranslationLoader.lanKeys!.sure!.tr}${TranslationLoader.lanKeys!.password!.tr}",
@ -277,11 +264,10 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
logic.checkNext(state.codeController);
},
leftWidget: Padding(
padding: EdgeInsets.only(
top: 30.w, bottom: 20.w, right: 20.w, left: 5.w),
padding: EdgeInsets.only(right: 10.w, left: 5.w),
child: SizedBox(
width: 36.w,
height: 36.w,
width: 30.w,
height: 30.w,
),
// Image.asset(
// 'images/main/icon_main_search.png',
@ -289,8 +275,7 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
// height: 40.w,
// ),
),
hintText:
"${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.verificationCode!.tr}",
hintText: "${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.verificationCode!.tr}",
inputFormatters: [
LengthLimitingTextInputFormatter(20),
]),
@ -309,7 +294,7 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
child: Center(
child: Text(
_seconds == 60
? '${TranslationLoader.lanKeys!.getTip!.tr}${TranslationLoader.lanKeys!.verificationCode!.tr}'
? TranslationLoader.lanKeys!.getVerificationCode!.tr
: (_seconds < 10)
? '0$_seconds s'
: '$_seconds s',
@ -321,7 +306,7 @@ class _StarLockRegisterPageState extends State<StarLockRegisterPage> {
),
),
onTap: () {
Navigator.pushNamed(context, Routers.safetyVerificationPage);
Navigator.pushNamed(context, Routers.safetyVerificationPage, arguments: {"countryCode":"+86", "account":"15080825640"});
if (_seconds == 60) {
// _setVerify();
} else {

View File

@ -6,6 +6,8 @@ abstract class Api {
final String getVerificationCodeUrl = '/api/v1/vcode/email';
final String registerUrl = '/user/register';
final String getSliderVerifyImgUrl = '/user/getSliderVerifyImg';
final String checkImgUrl = '/user/isSliderValid';
final String loginUrl = '/api/v1/vcode/email';
}

View File

@ -18,6 +18,17 @@ class ApiProvider extends BaseProvider {
'verificationCode':verificationCode,
});
Future<Response> getSliderVerifyImg(String countryCode, String account) => post(getSliderVerifyImgUrl.toUrl, null,query: {
'countryCode':countryCode,
'account':account,
});
Future<Response> checkSliderVerifyImg(String countryCode, String account, String xWidth) => post(checkImgUrl.toUrl, null,query: {
'countryCode':countryCode,
'account':account,
'xWidth':xWidth,
});
Future<Response> login(String email,String password) => post(loginUrl.toUrl, null,query: {'email':email,'password':password});
}

View File

@ -1,6 +1,8 @@
import 'package:get/get.dart';
import '../common/safetyVerification/entity/CheckSafetyVerificationEntity.dart';
import '../common/safetyVerification/entity/SafetyVerificationEntity.dart';
import '../login/login/entity/LoginEntity.dart';
import 'api_provider.dart';
@ -20,6 +22,16 @@ class ApiRepository {
return LoginEntity.fromJson(res.body);
}
Future<SafetyVerificationEntity> getSliderVerifyImg(String countryCode, String account) async {
final res = await apiProvider.getSliderVerifyImg(countryCode, account);
return SafetyVerificationEntity.fromJson(res.body);
}
Future<CheckSafetyVerificationEntity> checkSliderVerifyImg(String countryCode, String account, String xWidth) async {
final res = await apiProvider.checkSliderVerifyImg(countryCode, account, xWidth);
return CheckSafetyVerificationEntity.fromJson(res.body);
}
// Future<LoginEntity> login({String? email,String? password}) async {
// final res = await apiProvider.login(email,SecrecyUtils.md5EncodeUpperCase(input: password));
// return LoginEntity.fromJson(res.body);

View File

@ -89,6 +89,6 @@ class BaseGetXController extends GetxController{
///Extension_Int
extension Extension_Int on int {
bool get codeIsSuccessful => this == 1;
bool get codeIsSuccessful => this == 0;
bool get msgCodeIsSuccessful => this == 1;
}

View File

@ -37,8 +37,8 @@ class StoreService<T> extends GetxService {
Future saveLogInInfo(LoginEntity entity) async {
_loginEntity = LoginEntity.fromJson(entity.toJson());
save(_loginUserInfoKey, entity.toJson());
if(_loginEntity != null && _loginEntity!.data != null && _loginEntity!.data!.email != null && _loginEntity!.data!.email!.isNotEmpty) {
save(_userAccount, _loginEntity?.data?.email);
if(_loginEntity != null && _loginEntity!.content != null && _loginEntity!.content!.email != null && _loginEntity!.content!.email!.isNotEmpty) {
save(_userAccount, _loginEntity?.content?.email);
}
}
@ -48,8 +48,8 @@ class StoreService<T> extends GetxService {
// String getLanguageCode() => hasData(_languageCode) ? read(_languageCode): "";
Future saveLanguageCode(String code) => save(_languageCode, code);
bool get hadToken => _loginEntity !=null && _loginEntity!.data!.token!.isNotEmpty;
String? get userToken => hadToken ? _loginEntity!.data!.token : "";
bool get hadToken => _loginEntity !=null && _loginEntity!.content!.token!.isNotEmpty;
String? get userToken => hadToken ? _loginEntity!.content!.token : "";
// String getLastUserAccount() => hasData(_userAccount) ? read(_userAccount): "";
void removeLastUserAccount() => remove(_userAccount);

View File

@ -367,6 +367,7 @@ class LanKeyEntity {
this.hideInvalidUnlockPermissionsTip,
this.appUnlockRequiresMobilePhoneAccessToTheLockTip,
this.checkAll,
this.getVerificationCode
});
LanKeyEntity.fromJson(dynamic json) {
@ -764,6 +765,7 @@ class LanKeyEntity {
appUnlockRequiresMobilePhoneAccessToTheLockTip =
json['appUnlockRequiresMobilePhoneAccessToTheLockTip'];
checkAll = json['checkAll'];
getVerificationCode = json['getVerificationCode'];
}
String? starLock;
String? clickUnlockAndHoldDownClose;
@ -1148,6 +1150,7 @@ class LanKeyEntity {
String? hideInvalidUnlockPermissionsTip;
String? appUnlockRequiresMobilePhoneAccessToTheLockTip;
String? checkAll;
String? getVerificationCode;
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
@ -1543,7 +1546,7 @@ class LanKeyEntity {
map['appUnlockRequiresMobilePhoneAccessToTheLockTip'] =
appUnlockRequiresMobilePhoneAccessToTheLockTip;
map['checkAll'] = checkAll;
map['getVerificationCode'] = getVerificationCode;
return map;
}
}