|
@@ -1,6 +1,7 @@
|
|
|
import 'dart:async';
|
|
import 'dart:async';
|
|
|
|
|
|
|
|
import 'package:electronic_assistant/data/api/atmob_api.dart';
|
|
import 'package:electronic_assistant/data/api/atmob_api.dart';
|
|
|
|
|
+import 'package:electronic_assistant/utils/event_bus.dart';
|
|
|
import 'package:electronic_assistant/utils/mmkv_util.dart';
|
|
import 'package:electronic_assistant/utils/mmkv_util.dart';
|
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
|
import 'package:get/get.dart';
|
|
import 'package:get/get.dart';
|
|
@@ -11,6 +12,9 @@ import '../api/request/login_request.dart';
|
|
|
import '../api/request/verification_code_request.dart';
|
|
import '../api/request/verification_code_request.dart';
|
|
|
import '../api/response/login_response.dart';
|
|
import '../api/response/login_response.dart';
|
|
|
|
|
|
|
|
|
|
+const String EventUserLogin = 'EventUserLogin';
|
|
|
|
|
+const String EventUserLogout = 'EventUserLogout';
|
|
|
|
|
+
|
|
|
class AccountRepository {
|
|
class AccountRepository {
|
|
|
final ACCOUNT_TOKEN = 'account_token';
|
|
final ACCOUNT_TOKEN = 'account_token';
|
|
|
final ACCOUNT_PHONE = 'account_phone';
|
|
final ACCOUNT_PHONE = 'account_phone';
|
|
@@ -55,6 +59,8 @@ class AccountRepository {
|
|
|
KVUtil.putString(ACCOUNT_TOKEN, token);
|
|
KVUtil.putString(ACCOUNT_TOKEN, token);
|
|
|
KVUtil.putString(ACCOUNT_PHONE, phone);
|
|
KVUtil.putString(ACCOUNT_PHONE, phone);
|
|
|
isLogin.value = true;
|
|
isLogin.value = true;
|
|
|
|
|
+
|
|
|
|
|
+ eventBus.emit(EventUserLogin);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void logout() {
|
|
void logout() {
|
|
@@ -63,6 +69,16 @@ class AccountRepository {
|
|
|
KVUtil.putString(ACCOUNT_TOKEN, null);
|
|
KVUtil.putString(ACCOUNT_TOKEN, null);
|
|
|
KVUtil.putString(ACCOUNT_PHONE, null);
|
|
KVUtil.putString(ACCOUNT_PHONE, null);
|
|
|
isLogin.value = false;
|
|
isLogin.value = false;
|
|
|
|
|
+
|
|
|
|
|
+ eventBus.emit(EventUserLogout);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ void cleanLoginInfo() {
|
|
|
|
|
+ _phone = null;
|
|
|
|
|
+ _phone = null;
|
|
|
|
|
+ KVUtil.putString(ACCOUNT_TOKEN, null);
|
|
|
|
|
+ KVUtil.putString(ACCOUNT_PHONE, null);
|
|
|
|
|
+ isLogin.value = false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void refreshUserInfo() {}
|
|
void refreshUserInfo() {}
|