no message
This commit is contained in:
parent
4eb28224d3
commit
41bfa32ad6
|
|
@ -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,25 +59,29 @@ class _RegisterState extends State<Register> with CommonMixin{
|
||||||
|
|
||||||
FocusScope.of(context).requestFocus(_theFocus);
|
FocusScope.of(context).requestFocus(_theFocus);
|
||||||
|
|
||||||
String userName = _userNameController.text.trim();
|
try {
|
||||||
String userPwd = _passwordController.text.trim();
|
String userName = _userNameController.text.trim();
|
||||||
if (userName == '') return toMsg('请填写用户账号');
|
String userPwd = _passwordController.text.trim();
|
||||||
if (userPwd == '') return toMsg('请填写密码');
|
if (userName == '') return toMsg('请填写用户账号');
|
||||||
if (!readAgreement) return toMsg('请勾选我已阅读用户协议和隐私协议');
|
if (userPwd == '') return toMsg('请填写密码');
|
||||||
|
if (!readAgreement) return toMsg('请勾选我已阅读用户协议和隐私协议');
|
||||||
|
|
||||||
String userPwdMd5 = CommonUtils.generateMD5(userPwd);
|
String userPwdMd5 = CommonUtils.generateMD5(userPwd);
|
||||||
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 ?? '注册失败,请重试');
|
||||||
|
}
|
||||||
|
|
||||||
|
ToastUtils.showSuccess('注册成功,请登录');
|
||||||
|
// 跳转登录页
|
||||||
|
RouterManager.router.navigateTo(context, RouterManager.loginPath);
|
||||||
|
} finally {
|
||||||
|
EasyLoading.dismiss();
|
||||||
}
|
}
|
||||||
EasyLoading.dismiss();
|
|
||||||
ToastUtils.showSuccess('注册成功,请登录');
|
|
||||||
// 跳转登录页
|
|
||||||
RouterManager.router.navigateTo(context, RouterManager.loginPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue