|
|
@@ -14,6 +14,7 @@ import 'package:get/get.dart';
|
|
|
import '../../resource/string.gen.dart';
|
|
|
import '../../utils/http_handler.dart';
|
|
|
import '../api/request/login_request.dart';
|
|
|
+import '../api/request/user_info_update_request.dart';
|
|
|
import '../api/request/verification_code_request.dart';
|
|
|
import '../api/response/login_response.dart';
|
|
|
import '../api/response/user_info_response.dart';
|
|
|
@@ -29,7 +30,8 @@ class AccountRepository {
|
|
|
String? _token;
|
|
|
String? _phone;
|
|
|
final isLogin = false.obs;
|
|
|
- Rxn<MemberInfo> memberInfo = Rxn();
|
|
|
+
|
|
|
+ UserInfoResponse? _userInfo;
|
|
|
|
|
|
CancelableFuture? _getUserInfoFuture;
|
|
|
|
|
|
@@ -46,6 +48,8 @@ class AccountRepository {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ UserInfoResponse? get userInfo => _userInfo;
|
|
|
+
|
|
|
String? get phone => _phone;
|
|
|
|
|
|
String? get token => _token;
|
|
|
@@ -56,6 +60,12 @@ class AccountRepository {
|
|
|
.then(HttpHandler.handle(true));
|
|
|
}
|
|
|
|
|
|
+ Future<void> updateUserInfo(String profession, String post) {
|
|
|
+ return atmobApi
|
|
|
+ .updateUserInfo(UserInfoUpdateRequest(profession, post))
|
|
|
+ .then(HttpHandler.handle(true));
|
|
|
+ }
|
|
|
+
|
|
|
Future<void>? refreshUserInfo() {
|
|
|
if (_getUserInfoFuture != null) {
|
|
|
_getUserInfoFuture?.cancel();
|
|
|
@@ -75,7 +85,7 @@ class AccountRepository {
|
|
|
.userInfo(AppBaseRequest())
|
|
|
.then(HttpHandler.handle(false))
|
|
|
.then((response) {
|
|
|
- memberInfo.value = response.memberInfo;
|
|
|
+ _userInfo = response;
|
|
|
return response;
|
|
|
});
|
|
|
}
|
|
|
@@ -104,18 +114,18 @@ class AccountRepository {
|
|
|
|
|
|
void logout() {
|
|
|
_phone = null;
|
|
|
- _phone = null;
|
|
|
+ _token = null;
|
|
|
KVUtil.putString(ACCOUNT_TOKEN, null);
|
|
|
KVUtil.putString(ACCOUNT_PHONE, null);
|
|
|
isLogin.value = false;
|
|
|
taskRepository.stopTask();
|
|
|
- memberInfo.value = null;
|
|
|
+ _userInfo = null;
|
|
|
|
|
|
eventBus.emit(EventUserLogout);
|
|
|
}
|
|
|
|
|
|
void cleanLoginInfo() {
|
|
|
- _phone = null;
|
|
|
+ _token = null;
|
|
|
_phone = null;
|
|
|
KVUtil.putString(ACCOUNT_TOKEN, null);
|
|
|
KVUtil.putString(ACCOUNT_PHONE, null);
|