mcy_new #1
|
|
@ -5,7 +5,9 @@ enum AppStorageKey {
|
||||||
xToken(value: 'XTOKEN', label: "登录用户的Xtoken,刷新token信息"),
|
xToken(value: 'XTOKEN', label: "登录用户的Xtoken,刷新token信息"),
|
||||||
userMobile(value: 'USERMOBILE', label: "用户输入过的手机号码"),
|
userMobile(value: 'USERMOBILE', label: "用户输入过的手机号码"),
|
||||||
userInfo(value: 'USERINFO', label: "登录用户的基本信息 及 token过期时间"),
|
userInfo(value: 'USERINFO', label: "登录用户的基本信息 及 token过期时间"),
|
||||||
userDetailInfo(value: 'USERDETAILINFO', label: "用户的详细信息");
|
userDetailInfo(value: 'USERDETAILINFO', label: "用户的详细信息"),
|
||||||
|
account(value: 'ACCOUNT', label: "用户名"),
|
||||||
|
pwd(value: 'PWD', label: "密码");
|
||||||
|
|
||||||
final String label;
|
final String label;
|
||||||
final String value;
|
final String value;
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ import 'package:making_school_asignment_app/common/utils/storage.dart';
|
||||||
import 'package:making_school_asignment_app/common/utils/toast_utils.dart';
|
import 'package:making_school_asignment_app/common/utils/toast_utils.dart';
|
||||||
import 'package:making_school_asignment_app/common/utils/utils.dart';
|
import 'package:making_school_asignment_app/common/utils/utils.dart';
|
||||||
import 'package:making_school_asignment_app/routes/app_pages.dart';
|
import 'package:making_school_asignment_app/routes/app_pages.dart';
|
||||||
|
import 'package:making_school_asignment_app/common/utils/storage.dart';
|
||||||
|
import 'package:making_school_asignment_app/common/store/app_storage_key.dart';
|
||||||
|
|
||||||
import 'login_state.dart';
|
import 'login_state.dart';
|
||||||
|
|
||||||
|
|
@ -23,8 +25,19 @@ class LoginLogic extends GetxController with RequestToolMixin {
|
||||||
@override
|
@override
|
||||||
void onInit() {
|
void onInit() {
|
||||||
super.onInit();
|
super.onInit();
|
||||||
state.userNameController = TextEditingController()..addListener(userNameListener);
|
|
||||||
state.passwordController = TextEditingController();
|
/* state.userNameController = TextEditingController()
|
||||||
|
..addListener(userNameListener);
|
||||||
|
state.passwordController = TextEditingController();*/
|
||||||
|
|
||||||
|
String account = StorageService.to.read(AppStorageKey.account.value)?? '';
|
||||||
|
String pwd = StorageService.to.read(AppStorageKey.pwd.value) ?? '';
|
||||||
|
if (account != '' && pwd != '') {
|
||||||
|
state.userNameController.text = account;
|
||||||
|
state.passwordController.text = pwd;
|
||||||
|
state.keepPwd.value = true;
|
||||||
|
}
|
||||||
|
|
||||||
state.pwdFocus = FocusNode();
|
state.pwdFocus = FocusNode();
|
||||||
state.theFocus = FocusNode();
|
state.theFocus = FocusNode();
|
||||||
}
|
}
|
||||||
|
|
@ -77,6 +90,12 @@ class LoginLogic extends GetxController with RequestToolMixin {
|
||||||
}
|
}
|
||||||
UserStore.to.setUserDetailInfo(data);
|
UserStore.to.setUserDetailInfo(data);
|
||||||
EasyLoading.dismiss();
|
EasyLoading.dismiss();
|
||||||
|
|
||||||
|
if (state.keepPwd.value) {
|
||||||
|
StorageService.to.write(AppStorageKey.account.value, userName);
|
||||||
|
StorageService.to.write(AppStorageKey.pwd.value, userPwd);
|
||||||
|
}
|
||||||
|
|
||||||
Get.offAllNamed(Routes.startPage);
|
Get.offAllNamed(Routes.startPage);
|
||||||
// if (resultData.code != 200 || userData?.accessToken == null || userData?.accessToken == '') {
|
// if (resultData.code != 200 || userData?.accessToken == null || userData?.accessToken == '') {
|
||||||
// return toMsg(resultData.message ?? '登录失败,请重试');
|
// return toMsg(resultData.message ?? '登录失败,请重试');
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ class LoginState {
|
||||||
late final FocusNode pwdFocus; // 密码
|
late final FocusNode pwdFocus; // 密码
|
||||||
late final FocusNode theFocus;
|
late final FocusNode theFocus;
|
||||||
//文本输入框控制器
|
//文本输入框控制器
|
||||||
late final TextEditingController userNameController;
|
late TextEditingController userNameController = TextEditingController();
|
||||||
late final TextEditingController passwordController;
|
late TextEditingController passwordController = TextEditingController();
|
||||||
bool hasNameVal = false;
|
bool hasNameVal = false;
|
||||||
late RxBool isShowPwd = true.obs;
|
late RxBool isShowPwd = true.obs;
|
||||||
late RxBool keepPwd = false.obs;
|
late RxBool keepPwd = false.obs;
|
||||||
|
|
|
||||||
|
|
@ -190,49 +190,51 @@ class _LoginPageState extends State<LoginPage> {
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: 22.h,
|
height: 22.h,
|
||||||
),
|
),
|
||||||
/* Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
width: 30.w,
|
width: 25.w,
|
||||||
padding: EdgeInsets.only(right: 10.w),
|
padding: EdgeInsets.only(right: 0.w),
|
||||||
child: Obx(() {
|
child: Obx(() {
|
||||||
return Checkbox(
|
return Transform.scale(
|
||||||
|
scale: 1.2,
|
||||||
|
child: Checkbox(
|
||||||
activeColor: Theme.of(context).primaryColor,
|
activeColor: Theme.of(context).primaryColor,
|
||||||
checkColor: Colors.white,
|
checkColor: Colors.white,
|
||||||
value: state.keepPwd.value,
|
value: state.keepPwd.value,
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
Get.focusScope?.nextFocus();
|
Get.focusScope?.nextFocus();
|
||||||
*/ /* FocusScope.of(context).requestFocus(
|
FocusScope.of(context).requestFocus(
|
||||||
state.pwdFocus);
|
state.pwdFocus);
|
||||||
FocusScope.of(context).requestFocus(
|
FocusScope.of(context).requestFocus(
|
||||||
state.theFocus);*/ /*
|
state.theFocus);
|
||||||
state.keepPwd.value = value ?? false;
|
state.keepPwd.value = value ?? false;
|
||||||
},
|
},
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Utils.hideKeyboard();
|
Utils.hideKeyboard();
|
||||||
*/ /*Get.focusScope?.nextFocus();
|
Get.focusScope?.nextFocus();
|
||||||
Get.focusScope?.nextFocus();*/ /*
|
Get.focusScope?.nextFocus();
|
||||||
|
FocusScope.of(context).requestFocus(
|
||||||
*/ /* FocusScope.of(context).requestFocus(
|
|
||||||
state.pwdFocus);
|
state.pwdFocus);
|
||||||
FocusScope.of(context).requestFocus(
|
FocusScope.of(context).requestFocus(
|
||||||
state.theFocus);*/ /*
|
state.theFocus);
|
||||||
state.keepPwd.value = !state.keepPwd.value;
|
state.keepPwd.value = !state.keepPwd.value;
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
'记住密码',
|
'记住密码',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14.sp,
|
fontSize: 11.sp,
|
||||||
color: Colors.white,
|
color: Colors.white,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),*/
|
),
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
logic.toLogin();
|
logic.toLogin();
|
||||||
|
|
@ -293,7 +295,7 @@ class _LoginPageState extends State<LoginPage> {
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Get.toNamed(Routes.agreementPage, arguments: {"type": AGREEMENT_KEY.USER_AGREEMENT.name});
|
Get.toNamed(Routes.agreementPage, arguments: {"type": AGREEMENT_KEY.USER_AGREEMENT.name});
|
||||||
},
|
},
|
||||||
child: quickText('请仔细阅读', size: 11.sp),
|
child: quickText('请仔细阅读', size: 11.sp,),
|
||||||
),
|
),
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue