|
@@ -1,6 +1,8 @@
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
import 'package:vitalapp/architecture/defines.dart';
|
|
|
+import 'package:vitalapp/architecture/utils/prompt_box.dart';
|
|
|
+import 'package:vitalapp/global.dart';
|
|
|
// import 'package:vitalapp/architecture/utils/prompt_box.dart';
|
|
|
import 'package:vitalapp/managers/interfaces/account.dart';
|
|
|
import 'package:vitalapp/managers/interfaces/diagnosis.dart';
|
|
@@ -19,39 +21,33 @@ class LoginController extends FControllerBase {
|
|
|
final state = LoginState();
|
|
|
|
|
|
void onSubmit() async {
|
|
|
+ if (!kIsOnline) {
|
|
|
+ PromptBox.toast("请检查网络连接");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
setBusy('登录中');
|
|
|
// busy = true;
|
|
|
try {
|
|
|
final result = await Get.find<IAccountManager>()
|
|
|
.login(state.account, state.password, state.isAutoLogin);
|
|
|
if (result) {
|
|
|
- await Get.find<IDoctorManager>().syncInfo();
|
|
|
- await Future.wait([
|
|
|
- // 更新应用级配置
|
|
|
- Get.find<ISystemSettingManager>().getSettings(true),
|
|
|
- // 更新机构相关配置
|
|
|
- Get.find<IOrganizationManager>().syncConfigurations(),
|
|
|
- //更新本地离线居民数据userCode等于空的数据
|
|
|
- Get.find<IPatientManager>().resettingUsercodeIsEmptyData(),
|
|
|
- //更新本地离线测试数据userCode等于空的数据
|
|
|
- Get.find<IDiagnosisManager>().resettingUsercodeIsEmptyData(),
|
|
|
- ]);
|
|
|
-
|
|
|
+ await _syncAfterLogin();
|
|
|
// PromptBox.toast("登录成功");
|
|
|
busy = false;
|
|
|
Get.offAllNamed("/");
|
|
|
|
|
|
/// 主页不确定 先跳检测页面
|
|
|
// Get.offAllNamed('/medical', id: 1001);
|
|
|
-
|
|
|
- return;
|
|
|
+ } else {
|
|
|
+ busy = false;
|
|
|
+ PromptBox.toast("登录失败");
|
|
|
}
|
|
|
} catch (e) {
|
|
|
logger.e("LoginController login error", e);
|
|
|
- } finally {
|
|
|
- // busy = false;
|
|
|
+ busy = false;
|
|
|
+ PromptBox.error("登录异常");
|
|
|
}
|
|
|
- // PromptBox.error("登录失败");
|
|
|
}
|
|
|
|
|
|
@override
|
|
@@ -94,5 +90,19 @@ class LoginController extends FControllerBase {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ Future<void> _syncAfterLogin() async {
|
|
|
+ await Get.find<IDoctorManager>().syncInfo();
|
|
|
+ await Future.wait([
|
|
|
+ // 更新应用级配置
|
|
|
+ Get.find<ISystemSettingManager>().getSettings(true),
|
|
|
+ // 更新机构相关配置
|
|
|
+ Get.find<IOrganizationManager>().syncConfigurations(),
|
|
|
+ //更新本地离线居民数据userCode等于空的数据
|
|
|
+ Get.find<IPatientManager>().resettingUsercodeIsEmptyData(),
|
|
|
+ //更新本地离线测试数据userCode等于空的数据
|
|
|
+ Get.find<IDiagnosisManager>().resettingUsercodeIsEmptyData(),
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
void _doDispose() {}
|
|
|
}
|