logout logic

hmxc
小赖 4 years ago
parent 0ed31f49fd
commit 35da775f44

@ -139,12 +139,15 @@ class AppProvider extends ChangeNotifier {
}
}
Map<String, Object>? _location;
Map<String, Object>? get location => _location;
Map<String, dynamic>? _location;
Map<String, dynamic>? get location => _location;
late AMapFlutterLocation _aMapFlutterLocation;
startLocation() {
if (kIsWeb || Platform.isMacOS) return;
if (kIsWeb || Platform.isMacOS) {
getWeather();
return;
}
_aMapFlutterLocation = AMapFlutterLocation();
_aMapFlutterLocation.onLocationChanged().listen((event) {
_location = event;
@ -164,11 +167,19 @@ class AppProvider extends ChangeNotifier {
_aMapFlutterLocation.destroy();
}
// Location _location;
// Location get location => _location;
getWeather() async {
late num longitude;
late num latitude;
if (kIsWeb || Platform.isMacOS) {
longitude = 116.46;
latitude = 39.92;
} else {
longitude = _location!['longitude'];
latitude = _location!['latitude'];
}
Response response = await Dio().get(
'https://api.caiyunapp.com/v2.5/${AppConfig.caiYunAPI}/${_location!['longitude']},${_location!['latitude']}/realtime.json',
'https://api.caiyunapp.com/v2.5/${AppConfig.caiYunAPI}/$longitude,$latitude/realtime.json',
);
LoggerData.addData(response);
_weatherModel = RealTimeWeatherModel.fromJson(response.data);

@ -32,6 +32,7 @@ class UserProvider extends ChangeNotifier {
}
logout() {
JPush().deleteAlias();
final appProvider = Provider.of<AppProvider>(Get.context!, listen: false);
appProvider.setCurrentHouse(null);
_isLogin = false;
@ -47,7 +48,9 @@ class UserProvider extends ChangeNotifier {
Future updateProfile() async {
_userInfoModel = await SignFunc.getUserInfo();
await JPush().setAlias(_userInfoModel!.id.toString());
if (_userInfoModel != null) {
await JPush().setAlias(_userInfoModel!.id.toString());
}
notifyListeners();
}

Loading…
Cancel
Save