更新天气获取方式;更新关于我们和操作说明地址配置

This commit is contained in:
wyf
2025-08-25 14:09:51 +08:00
parent 523979750d
commit 8f601d498f
524 changed files with 2009 additions and 55 deletions

View File

@@ -7,9 +7,11 @@ import 'package:geocoding/geocoding.dart';
import 'package:geolocator/geolocator.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:path/path.dart';
import 'package:vbvs_app/common/color/ServiceConstant.dart';
import 'package:vbvs_app/common/color/appConstants.dart';
import 'package:vbvs_app/common/util/CommonVariables.dart';
import 'package:vbvs_app/common/util/MyUtils.dart';
import 'package:vbvs_app/common/util/requestWithLog.dart';
import 'package:vbvs_app/controller/setting/language/language_controller.dart';
import 'package:vbvs_app/controller/user_info_controller.dart';
import 'package:vbvs_app/enum/APPPackageType.dart';
@@ -59,8 +61,8 @@ class WeatherModelController extends GetControllerEx<WeatherModel> {
try {
await _getCurrentLocation();
_weatherTimer = Timer.periodic(Duration(seconds: 5), (timer) {
getCurrentWeather(); // 每 5 秒更新一次天气
_weatherTimer = Timer.periodic(Duration(minutes: 10), (timer) {
getCurrentWeather(); // 每 60 秒更新一次天气
});
_locationTimer = Timer.periodic(Duration(minutes: 10), (timer) {
@@ -92,7 +94,7 @@ class WeatherModelController extends GetControllerEx<WeatherModel> {
}
String? language = "zh_CN";
if (AppConstants().ent_type == APPPackageType.MHT.code) {
if (AppConstants().ent_type == APPPackageType.MHT.code) {
if (mhLanguageController.selectLanguage != null) {
language = mhLanguageController.selectLanguage.value!.language_code;
}
@@ -188,7 +190,7 @@ class WeatherModelController extends GetControllerEx<WeatherModel> {
try {
weatherFactory.language = Language.CHINESE_SIMPLIFIED;
String? language = "zh_CN";
if (AppConstants().ent_type == APPPackageType.MHT.code) {
if (AppConstants().ent_type == APPPackageType.MHT.code) {
if (mhLanguageController.selectLanguage != null) {
language = mhLanguageController.selectLanguage.value!.language_code;
}
@@ -202,19 +204,40 @@ class WeatherModelController extends GetControllerEx<WeatherModel> {
} else {
weatherFactory.language = Language.ENGLISH;
}
Weather weather = await weatherFactory.currentWeatherByLocation(
model.latitude!, model.longitude!);
model.weather_info = weather.weatherDescription;
model.min_temperature = weather.tempMin?.celsius?.toInt();
model.max_temperature = weather.tempMax?.celsius?.toInt();
model.current_temperature = weather.temperature?.celsius?.toInt();
model.wind_speed = weather.windSpeed?.toInt();
model.weatherIcon = weather.weatherIcon;
if (model.weatherIcon != null) {
model.weatherIconurl =
"https://openweathermap.org/img/w/${model.weatherIcon}.png";
}
// Weather weather = await weatherFactory.currentWeatherByLocation(
// model.latitude!, model.longitude!);
String location = "${model.longitude},${model.latitude}";
String serviceAddress = ServiceConstant.service_address;
String serviceName = ServiceConstant.server_service;
String serviceApi = ServiceConstant.weather_url;
String queryUrl =
"${serviceAddress}${serviceName}${serviceApi}?location=$location";
await requestWithLog(
logTitle: "获取天气信息",
method: MyHttpMethod.get,
queryUrl: queryUrl,
onSuccess: (res) {
print(res.data);
model.weather_info = res.data["info"];
model.current_temperature = int.parse(res.data["temp"]);
if (res.data['icon'] != null) {
model.weatherIconurl = "${res.data['icon']}";
}
model.cityName = res.data["city"];
},
onFailure: (res) {
print(res.data);
});
// model.weather_info = weather.weatherDescription;
// model.min_temperature = weather.tempMin?.celsius?.toInt();
// model.max_temperature = weather.tempMax?.celsius?.toInt();
// model.current_temperature = weather.temperature?.celsius?.toInt();
// model.wind_speed = weather.windSpeed?.toInt();
// model.weatherIcon = weather.weatherIcon;
// if (model.weatherIcon != null) {
// model.weatherIconurl =
// "https://openweathermap.org/img/w/${model.weatherIcon}.png";
// }
updateAll(); // 更新 UI
} catch (e) {
EasyDartModule.logger.error("获取天气失败: $e");