no message

This commit is contained in:
1147192855@qq.com 2024-06-25 09:55:00 +08:00
parent 4eb28224d3
commit 41bfa32ad6
1 changed files with 27 additions and 29 deletions

View File

@ -20,8 +20,7 @@ class Register extends StatefulWidget {
State<Register> createState() => _RegisterState(); State<Register> createState() => _RegisterState();
} }
class _RegisterState extends State<Register> with CommonMixin{ class _RegisterState extends State<Register> with CommonMixin {
late final FocusNode _theFocus; late final FocusNode _theFocus;
late final FocusNode _pwdFocus; // late final FocusNode _pwdFocus; //
// //
@ -33,7 +32,7 @@ class _RegisterState extends State<Register> with CommonMixin{
bool canLogin = true; bool canLogin = true;
@override @override
void initState(){ void initState() {
super.initState(); super.initState();
_userNameController = TextEditingController(); _userNameController = TextEditingController();
_passwordController = TextEditingController(); _passwordController = TextEditingController();
@ -50,7 +49,7 @@ class _RegisterState extends State<Register> with CommonMixin{
_theFocus.dispose(); _theFocus.dispose();
} }
void toRegister() async{ void toRegister() async {
if (!canLogin) return; if (!canLogin) return;
setState(() => canLogin = false); setState(() => canLogin = false);
void toMsg(msg) { void toMsg(msg) {
@ -60,6 +59,7 @@ class _RegisterState extends State<Register> with CommonMixin{
FocusScope.of(context).requestFocus(_theFocus); FocusScope.of(context).requestFocus(_theFocus);
try {
String userName = _userNameController.text.trim(); String userName = _userNameController.text.trim();
String userPwd = _passwordController.text.trim(); String userPwd = _passwordController.text.trim();
if (userName == '') return toMsg('请填写用户账号'); if (userName == '') return toMsg('请填写用户账号');
@ -70,15 +70,18 @@ class _RegisterState extends State<Register> with CommonMixin{
print('注册userPwdMd5=$userPwdMd5'); print('注册userPwdMd5=$userPwdMd5');
EasyLoading.show(status: 'loading...'); EasyLoading.show(status: 'loading...');
RestClient client = await getClientLogin(); RestClient client = await getClientLogin();
BaseStructureResult<dynamic> resultData = await client.toRegister(UserLoginParams(userName, userPwdMd5)); BaseStructureResult<dynamic> resultData = await client.toRegister(UserLoginParams(userName, userPwdMd5, 0));
if (resultData.code != 200) { if (resultData.code != 200) {
return toMsg(resultData.message ?? '注册失败,请重试'); return toMsg(resultData.message ?? '注册失败,请重试');
} }
EasyLoading.dismiss();
ToastUtils.showSuccess('注册成功,请登录'); ToastUtils.showSuccess('注册成功,请登录');
// //
RouterManager.router.navigateTo(context, RouterManager.loginPath); RouterManager.router.navigateTo(context, RouterManager.loginPath);
} finally {
EasyLoading.dismiss();
}
} }
void _showPassword() { void _showPassword() {
@ -232,10 +235,8 @@ class _RegisterState extends State<Register> with CommonMixin{
checkColor: Colors.white, checkColor: Colors.white,
value: readAgreement, value: readAgreement,
onChanged: (value) { onChanged: (value) {
FocusScope.of(context) FocusScope.of(context).requestFocus(_pwdFocus);
.requestFocus(_pwdFocus); FocusScope.of(context).requestFocus(_theFocus);
FocusScope.of(context)
.requestFocus(_theFocus);
setState(() { setState(() {
readAgreement = value ?? false; readAgreement = value ?? false;
}); });
@ -270,18 +271,15 @@ class _RegisterState extends State<Register> with CommonMixin{
), ),
]), ]),
) )
], ],
), ),
)), )),
Positioned( Positioned(
top: MediaQuery.of(context).padding.top+20.r, top: MediaQuery.of(context).padding.top + 20.r,
left: 20.r, left: 20.r,
child: InkWell( child: InkWell(
onTap: () => Navigator.pop(context), onTap: () => Navigator.pop(context),
child: Icon(Icons.arrow_back_ios_new_rounded, child: Icon(Icons.arrow_back_ios_new_rounded, color: Colors.white, size: 24.sp),
color: Colors.white, size: 24.sp),
), ),
), ),
], ],