no message
This commit is contained in:
parent
4eb28224d3
commit
41bfa32ad6
|
|
@ -20,8 +20,7 @@ class Register extends StatefulWidget {
|
|||
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 _pwdFocus; // 密码
|
||||
//文本输入框控制器
|
||||
|
|
@ -33,7 +32,7 @@ class _RegisterState extends State<Register> with CommonMixin{
|
|||
bool canLogin = true;
|
||||
|
||||
@override
|
||||
void initState(){
|
||||
void initState() {
|
||||
super.initState();
|
||||
_userNameController = TextEditingController();
|
||||
_passwordController = TextEditingController();
|
||||
|
|
@ -50,7 +49,7 @@ class _RegisterState extends State<Register> with CommonMixin{
|
|||
_theFocus.dispose();
|
||||
}
|
||||
|
||||
void toRegister() async{
|
||||
void toRegister() async {
|
||||
if (!canLogin) return;
|
||||
setState(() => canLogin = false);
|
||||
void toMsg(msg) {
|
||||
|
|
@ -60,25 +59,29 @@ class _RegisterState extends State<Register> with CommonMixin{
|
|||
|
||||
FocusScope.of(context).requestFocus(_theFocus);
|
||||
|
||||
String userName = _userNameController.text.trim();
|
||||
String userPwd = _passwordController.text.trim();
|
||||
if (userName == '') return toMsg('请填写用户账号');
|
||||
if (userPwd == '') return toMsg('请填写密码');
|
||||
if (!readAgreement) return toMsg('请勾选我已阅读用户协议和隐私协议');
|
||||
try {
|
||||
String userName = _userNameController.text.trim();
|
||||
String userPwd = _passwordController.text.trim();
|
||||
if (userName == '') return toMsg('请填写用户账号');
|
||||
if (userPwd == '') return toMsg('请填写密码');
|
||||
if (!readAgreement) return toMsg('请勾选我已阅读用户协议和隐私协议');
|
||||
|
||||
String userPwdMd5 = CommonUtils.generateMD5(userPwd);
|
||||
print('注册userPwdMd5=$userPwdMd5');
|
||||
EasyLoading.show(status: 'loading...');
|
||||
RestClient client = await getClientLogin();
|
||||
BaseStructureResult<dynamic> resultData = await client.toRegister(UserLoginParams(userName, userPwdMd5));
|
||||
String userPwdMd5 = CommonUtils.generateMD5(userPwd);
|
||||
print('注册userPwdMd5=$userPwdMd5');
|
||||
EasyLoading.show(status: 'loading...');
|
||||
RestClient client = await getClientLogin();
|
||||
BaseStructureResult<dynamic> resultData = await client.toRegister(UserLoginParams(userName, userPwdMd5, 0));
|
||||
|
||||
if (resultData.code != 200) {
|
||||
return toMsg(resultData.message ?? '注册失败,请重试');
|
||||
if (resultData.code != 200) {
|
||||
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() {
|
||||
|
|
@ -232,10 +235,8 @@ class _RegisterState extends State<Register> with CommonMixin{
|
|||
checkColor: Colors.white,
|
||||
value: readAgreement,
|
||||
onChanged: (value) {
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_pwdFocus);
|
||||
FocusScope.of(context)
|
||||
.requestFocus(_theFocus);
|
||||
FocusScope.of(context).requestFocus(_pwdFocus);
|
||||
FocusScope.of(context).requestFocus(_theFocus);
|
||||
setState(() {
|
||||
readAgreement = value ?? false;
|
||||
});
|
||||
|
|
@ -270,18 +271,15 @@ class _RegisterState extends State<Register> with CommonMixin{
|
|||
),
|
||||
]),
|
||||
)
|
||||
|
||||
|
||||
],
|
||||
),
|
||||
)),
|
||||
Positioned(
|
||||
top: MediaQuery.of(context).padding.top+20.r,
|
||||
top: MediaQuery.of(context).padding.top + 20.r,
|
||||
left: 20.r,
|
||||
child: InkWell(
|
||||
onTap: () => Navigator.pop(context),
|
||||
child: Icon(Icons.arrow_back_ios_new_rounded,
|
||||
color: Colors.white, size: 24.sp),
|
||||
child: Icon(Icons.arrow_back_ios_new_rounded, color: Colors.white, size: 24.sp),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
|||
Loading…
Reference in New Issue