|
|
|
@ -10,11 +10,13 @@ import '../utils/toast/cloud_toast.dart';
|
|
|
|
|
|
|
|
|
|
class UserProvider extends ChangeNotifier {
|
|
|
|
|
bool _isLogin = false;
|
|
|
|
|
|
|
|
|
|
bool get isLogin => _isLogin;
|
|
|
|
|
late UserInfoModel _userInfo;
|
|
|
|
|
|
|
|
|
|
UserInfoModel get userInfo => _userInfo;
|
|
|
|
|
late String _contentCon;
|
|
|
|
|
String get contentCon=>_contentCon;
|
|
|
|
|
late String _contentRef;
|
|
|
|
|
String get contentRef=>_contentRef;
|
|
|
|
|
|
|
|
|
|
Future<bool> init() async {
|
|
|
|
|
if (HiveStore.appBox?.containsKey('token') ?? false) {
|
|
|
|
@ -29,14 +31,14 @@ class UserProvider extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future setToken(String token, {User? user}) async {
|
|
|
|
|
apiClient.setToken(token);
|
|
|
|
|
await HiveStore.appBox!.put('token', token);
|
|
|
|
|
_isLogin = true;
|
|
|
|
|
//每次打开app更新用户信息
|
|
|
|
|
await updateUserInfo();
|
|
|
|
|
await updateConSms();
|
|
|
|
|
await updateRefSms();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future logout() async {
|
|
|
|
@ -55,4 +57,24 @@ class UserProvider extends ChangeNotifier {
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future updateConSms() async {
|
|
|
|
|
var base = await apiClient.request(API.app.find,data: {'status': 1});
|
|
|
|
|
if (base.code == 0) {
|
|
|
|
|
_contentCon = base.data['content'];
|
|
|
|
|
} else {
|
|
|
|
|
CloudToast.show(base.msg);
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Future updateRefSms() async {
|
|
|
|
|
var base = await apiClient.request(API.app.find,data: {'status': 2});
|
|
|
|
|
if (base.code == 0) {
|
|
|
|
|
_contentRef = base.data['content'];
|
|
|
|
|
} else {
|
|
|
|
|
CloudToast.show(base.msg);
|
|
|
|
|
}
|
|
|
|
|
notifyListeners();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|