|
|
@ -1,5 +1,7 @@
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
import 'package:flutter_background_service/flutter_background_service.dart';
|
|
|
|
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import '../constants/api.dart';
|
|
|
|
import '../constants/api.dart';
|
|
|
|
import '../model/login_info_model.dart';
|
|
|
|
import '../model/login_info_model.dart';
|
|
|
@ -10,16 +12,21 @@ import '../utils/toast/cloud_toast.dart';
|
|
|
|
|
|
|
|
|
|
|
|
class UserProvider extends ChangeNotifier {
|
|
|
|
class UserProvider extends ChangeNotifier {
|
|
|
|
bool _isLogin = false;
|
|
|
|
bool _isLogin = false;
|
|
|
|
bool _kg=false;
|
|
|
|
bool _kg = false;
|
|
|
|
|
|
|
|
|
|
|
|
bool get kg => _kg;
|
|
|
|
bool get kg => _kg;
|
|
|
|
|
|
|
|
|
|
|
|
bool get isLogin => _isLogin;
|
|
|
|
bool get isLogin => _isLogin;
|
|
|
|
late UserInfoModel _userInfo;
|
|
|
|
late UserInfoModel _userInfo;
|
|
|
|
|
|
|
|
|
|
|
|
UserInfoModel get userInfo => _userInfo;
|
|
|
|
UserInfoModel get userInfo => _userInfo;
|
|
|
|
late String _contentCon;
|
|
|
|
late String _contentCon;
|
|
|
|
String get contentCon=>_contentCon;
|
|
|
|
|
|
|
|
|
|
|
|
String get contentCon => _contentCon;
|
|
|
|
late String _contentRef;
|
|
|
|
late String _contentRef;
|
|
|
|
String get contentRef=>_contentRef;
|
|
|
|
|
|
|
|
|
|
|
|
String get contentRef => _contentRef;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future<bool> init() async {
|
|
|
|
Future<bool> init() async {
|
|
|
|
if (HiveStore.appBox?.containsKey('token') ?? false) {
|
|
|
|
if (HiveStore.appBox?.containsKey('token') ?? false) {
|
|
|
@ -34,11 +41,10 @@ class UserProvider extends ChangeNotifier {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future setKg(bool lockage) async{
|
|
|
|
Future setKg(bool lockage) async {
|
|
|
|
_kg = lockage;
|
|
|
|
_kg = lockage;
|
|
|
|
notifyListeners();
|
|
|
|
notifyListeners();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future setToken(String token, {User? user}) async {
|
|
|
|
Future setToken(String token, {User? user}) async {
|
|
|
|
apiClient.setToken(token);
|
|
|
|
apiClient.setToken(token);
|
|
|
@ -68,9 +74,14 @@ Future setKg(bool lockage) async{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future updateConSms() async {
|
|
|
|
Future updateConSms() async {
|
|
|
|
var base = await apiClient.request(API.app.find,data: {'status': 1});
|
|
|
|
final prefs = await SharedPreferences.getInstance();
|
|
|
|
|
|
|
|
var base = await apiClient.request(API.app.find, data: {'status': 1});
|
|
|
|
if (base.code == 0) {
|
|
|
|
if (base.code == 0) {
|
|
|
|
_contentCon = base.data['content'];
|
|
|
|
await prefs.remove('refSms');
|
|
|
|
|
|
|
|
await prefs.setString('conSms', base.data['content']);
|
|
|
|
|
|
|
|
print(prefs.getString('action'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// _contentCon = base.data['content'];
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
CloudToast.show(base.msg);
|
|
|
|
CloudToast.show(base.msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -78,9 +89,16 @@ Future setKg(bool lockage) async{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Future updateRefSms() async {
|
|
|
|
Future updateRefSms() async {
|
|
|
|
var base = await apiClient.request(API.app.find,data: {'status': 2});
|
|
|
|
final prefs = await SharedPreferences.getInstance();
|
|
|
|
|
|
|
|
final service=FlutterBackgroundService();
|
|
|
|
|
|
|
|
var base = await apiClient.request(API.app.find, data: {'status': 2});
|
|
|
|
if (base.code == 0) {
|
|
|
|
if (base.code == 0) {
|
|
|
|
_contentRef = base.data['content'];
|
|
|
|
// await prefs.remove('refSms');
|
|
|
|
|
|
|
|
print(base.data['content']);
|
|
|
|
|
|
|
|
await prefs.setString('refSms', base.data['content']);
|
|
|
|
|
|
|
|
print(prefs.getString('refSms'));
|
|
|
|
|
|
|
|
service.startService();
|
|
|
|
|
|
|
|
// _contentRef = base.data['content'];
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
CloudToast.show(base.msg);
|
|
|
|
CloudToast.show(base.msg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|