fix: 登录页面

This commit is contained in:
guozhigq
2024-10-02 22:27:20 +08:00
parent d4851701d6
commit b93504328e
3 changed files with 67 additions and 25 deletions

View File

@ -244,12 +244,25 @@ class LoginHttp {
), ),
); );
if (res.data['code'] == 0) { if (res.data['code'] == 0) {
return { if (res.data['data']['status'] == 0) {
'status': true, return {
'data': res.data['data'], 'status': true,
}; 'data': res.data['data'],
};
} else {
return {
'status': false,
'code': 1,
'data': res.data['data'],
'msg': res.data['data']['message'],
};
}
} else { } else {
return {'status': false, 'data': [], 'msg': res.data['message']}; return {
'status': false,
'data': [],
'msg': res.data['message'],
};
} }
} }

View File

@ -45,6 +45,7 @@ class LoginPageController extends GetxController {
RxInt validSeconds = 180.obs; RxInt validSeconds = 180.obs;
Timer? validTimer; Timer? validTimer;
late String qrcodeKey; late String qrcodeKey;
RxBool passwordVisible = false.obs;
// 监听pageView切换 // 监听pageView切换
void onPageChange(int index) { void onPageChange(int index) {
@ -128,7 +129,14 @@ class LoginPageController extends GetxController {
if (res['status']) { if (res['status']) {
await LoginUtils.confirmLogin('', null); await LoginUtils.confirmLogin('', null);
} else { } else {
SmartDialog.showToast(res['msg']); await SmartDialog.showToast(res['msg']);
if (res.containsKey('code') && res['code'] == 1) {
Get.toNamed('/webview', parameters: {
'url': res['data']['data']['url'],
'type': 'url',
'pageTitle': '登录验证',
});
}
} }
} else { } else {
SmartDialog.showToast(webKeyRes['msg']); SmartDialog.showToast(webKeyRes['msg']);

View File

@ -269,25 +269,46 @@ class _LoginPageState extends State<LoginPage> {
), ),
Container( Container(
margin: const EdgeInsets.only(top: 38, bottom: 15), margin: const EdgeInsets.only(top: 38, bottom: 15),
child: TextFormField( child: Obx(() => TextFormField(
controller: _loginPageCtr.passwordTextController, controller:
focusNode: _loginPageCtr.passwordTextFieldNode, _loginPageCtr.passwordTextController,
keyboardType: TextInputType.visiblePassword, focusNode:
decoration: InputDecoration( _loginPageCtr.passwordTextFieldNode,
isDense: true, keyboardType: TextInputType.visiblePassword,
labelText: '输入密码', obscureText:
border: OutlineInputBorder( _loginPageCtr.passwordVisible.value,
borderRadius: BorderRadius.circular(6.0), decoration: InputDecoration(
), isDense: true,
), labelText: '输入密码',
// 校验用户名 border: OutlineInputBorder(
validator: (v) { borderRadius: BorderRadius.circular(6.0),
return v!.trim().isNotEmpty ? null : "密码不能为空"; ),
}, suffixIcon: IconButton(
onSaved: (val) { icon: Icon(
print(val); _loginPageCtr.passwordVisible.value
}, ? Icons.visibility
), : Icons.visibility_off,
color: Theme.of(context)
.colorScheme
.primary,
),
onPressed: () {
_loginPageCtr.passwordVisible.value =
!_loginPageCtr
.passwordVisible.value;
},
),
),
// 校验用户名
validator: (v) {
return v!.trim().isNotEmpty
? null
: "密码不能为空";
},
onSaved: (val) {
print(val);
},
)),
), ),
const Spacer(), const Spacer(),
Row( Row(