提交 db20dff5 authored 作者: yueweilu's avatar yueweilu

修正回显逻辑

上级 ea5b1d3f
part of change_pwd;
class ChangePwdController extends GetxController {
final UserInfoModel userInfo;
ChangePwdController(this.userInfo);
// 新密码
final TextEditingController pwdInput = TextEditingController();
// 确认密码
......@@ -40,7 +41,14 @@ class ChangePwdController extends GetxController {
}
Future <bool> changePwd() async {
final result = await MineAPI.changePwd(password: EncryptUtil.encodeMd5(EncryptUtil.encodeMd5(pwdInput.text)), rePassword: EncryptUtil.encodeMd5(EncryptUtil.encodeMd5(pwd2Input.text)));
final result = await MineAPI.changePwd(
password: EncryptUtil.encodeMd5(EncryptUtil.encodeMd5(pwdInput.text)),
rePassword: EncryptUtil.encodeMd5(EncryptUtil.encodeMd5(pwd2Input.text))
);
if(result){
userInfo.password = EncryptUtil.encodeMd5(EncryptUtil.encodeMd5(pwdInput.text));
update();
}
return result;
}
......
......@@ -8,6 +8,7 @@ import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import '../../apis/index.dart';
import '../../models/index.dart';
import '../../routes/index.dart';
import '../../widgets/index.dart';
......
part of change_pwd;
class ChangePwdPage extends StatefulWidget {
final String type;
final UserInfoModel userInfo;
const ChangePwdPage({
Key? key ,
required this.type,
required this.userInfo,
}) : super(key: key);
// const ResetPwdPage({Key? key}) : super(key: key);
......@@ -17,11 +17,11 @@ class _ChangePwdPageState extends State<ChangePwdPage> {
Widget build(BuildContext context) {
final currentContext = context;
return GetBuilder<ChangePwdController>(
init: ChangePwdController(),
init: ChangePwdController(widget.userInfo),
builder: (controller) =>Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text(widget.type =='1'?'设置密码':'修改密码'),
title: Text(widget.userInfo.password.toString().isEmpty?'设置密码':'修改密码'),
),
body: Container(
margin: EdgeInsets.only(left: 10.w,top: 15.w,right: 10.w),
......@@ -117,7 +117,7 @@ class _ChangePwdPageState extends State<ChangePwdPage> {
),
Gaps.vGaps40,
CustomGradientButton(
text: widget.type == '1'?'确认':'确认修改',
text: widget.userInfo.password.toString().isEmpty ?'确认':'确认修改',
isEnabled: controller.enable,
onPressed: () async {
Tools.unfocus();
......
library user_security;
import 'package:flutter/material.dart';
import 'package:flutter_book/apis/index.dart';
import 'package:flutter_book/models/index.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:go_router/go_router.dart';
import '../../routes/index.dart';
import '../../store/index.dart';
import '../../utils/index.dart';
import '../../widgets/index.dart';
part 'view.dart';
\ No newline at end of file
......@@ -51,7 +51,7 @@ class _UserSecurityPageState extends State<UserSecurityPage> {
),
GestureDetector(
onTap: (){
context.pushNamed(Routes.changePwd,queryParameters: {'type':widget.model.password.toString().isEmpty?'1':'2'});
context.pushNamed(Routes.changePwd,extra: widget.model);
},
child: _buildItem(title: '修改密码', value: widget.model.password.toString().isEmpty?'未设置':'')
),
......@@ -76,8 +76,16 @@ class _UserSecurityPageState extends State<UserSecurityPage> {
children: [
GestureDetector(
child: _buildItem(title: '账号注销', value: ''),
onTap: (){
onTap: () async {
final result = await AccountAPI.delete();
if (result){
CustomToast.loading();
await UserStore.to.logout();
CustomToast.dismiss();
if(context.mounted){
context.goNamed(Routes.splash);
}
}
},
),
],
......
......@@ -416,7 +416,7 @@ abstract class Routes {
pageBuilder: (context, state) =>CupertinoPage(
name: state.uri.toString(),
key: state.pageKey,
child: ChangePwdPage(type:state.uri.queryParameters['type'].toString())
child: ChangePwdPage(userInfo: state.extra as UserInfoModel)
)
),
GoRoute(
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论