更新
This commit is contained in:
@@ -11,6 +11,7 @@ import 'package:vbvs_app/common/color/app_uri_status.dart';
|
||||
import 'package:vbvs_app/common/util/DailyLogUtils.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/enum/APPPackageType.dart';
|
||||
import 'package:vbvs_app/enum/DataStatus.dart';
|
||||
import 'package:vbvs_app/model/api_response.dart';
|
||||
|
||||
part 'body_device_controller.g.dart'; // 由json_serializable自动生成的部分
|
||||
@@ -51,6 +52,8 @@ class BodyDeviceController extends GetControllerEx<BodyDeviceModel> {
|
||||
|
||||
Timer? _sleepReportTimer; // 定时器
|
||||
|
||||
RxMap homePageSleepFlag = {}.obs; //正在请求睡眠报告数据
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
super.onInit();
|
||||
@@ -220,6 +223,7 @@ class BodyDeviceController extends GetControllerEx<BodyDeviceModel> {
|
||||
try {
|
||||
ef.log("刷新睡眠报告");
|
||||
sleepReportData.value = {};
|
||||
homePageSleepFlag = {}.obs;
|
||||
ApiResponse<Map<String, List<dynamic>>> apiResponse = ApiResponse(
|
||||
code: -1,
|
||||
msg: "请求失败".tr,
|
||||
@@ -241,7 +245,7 @@ class BodyDeviceController extends GetControllerEx<BodyDeviceModel> {
|
||||
if (mac.isEmpty) continue;
|
||||
|
||||
sleepReportData[mac] = []; // 初始化当前设备的数据列表
|
||||
|
||||
homePageSleepFlag[mac] = DataStatus.Loading.code;
|
||||
String queryUrl =
|
||||
"$serviceAddress$serviceName$serviceApi?mac=$mac&time=${DateTime.now().millisecondsSinceEpoch}&sleepType=1";
|
||||
try {
|
||||
@@ -258,6 +262,7 @@ class BodyDeviceController extends GetControllerEx<BodyDeviceModel> {
|
||||
}
|
||||
var response = await EasyDartModule.dio.get(queryUrl);
|
||||
if (response != null) {
|
||||
homePageSleepFlag[mac] = DataStatus.success.code;
|
||||
var responseData = response.data is String
|
||||
? jsonDecode(response.data)
|
||||
: response.data;
|
||||
@@ -276,6 +281,7 @@ class BodyDeviceController extends GetControllerEx<BodyDeviceModel> {
|
||||
}
|
||||
} catch (e) {
|
||||
EasyDartModule.logger.warning("请求设备 $mac 的睡眠数据失败: $e");
|
||||
homePageSleepFlag[mac] = DataStatus.Fail.code;
|
||||
}
|
||||
}
|
||||
if (sleepReportData.value.isNotEmpty) {
|
||||
|
||||
@@ -152,7 +152,8 @@ class PersonController extends GetControllerEx<PersonModel> {
|
||||
}
|
||||
}
|
||||
if (name.value.isEmpty) {
|
||||
apiResponse.msg = "请输入姓名".tr;
|
||||
// apiResponse.msg = "请输入姓名".tr;
|
||||
apiResponse.code = 1;
|
||||
return apiResponse;
|
||||
}
|
||||
if (person == null) {
|
||||
|
||||
@@ -455,18 +455,19 @@ class WeatherModelController extends GetControllerEx<WeatherModel> {
|
||||
Future<void> onInit() async {
|
||||
super.onInit();
|
||||
|
||||
try {
|
||||
await getCurrentLocation();
|
||||
_weatherTimer = Timer.periodic(Duration(minutes: 10), (timer) {
|
||||
getCurrentWeather(); // 每 60 秒更新一次天气
|
||||
});
|
||||
//去掉天气
|
||||
// try {
|
||||
// await getCurrentLocation();
|
||||
// _weatherTimer = Timer.periodic(Duration(minutes: 10), (timer) {
|
||||
// getCurrentWeather(); // 每 60 秒更新一次天气
|
||||
// });
|
||||
|
||||
_locationTimer = Timer.periodic(Duration(minutes: 10), (timer) {
|
||||
getCurrentLocation(); // 每 10 分钟更新一次位置
|
||||
});
|
||||
} catch (e) {
|
||||
ef.log("[天气和定位请求失败]");
|
||||
}
|
||||
// _locationTimer = Timer.periodic(Duration(minutes: 10), (timer) {
|
||||
// getCurrentLocation(); // 每 10 分钟更新一次位置
|
||||
// });
|
||||
// } catch (e) {
|
||||
// ef.log("[天气和定位请求失败]");
|
||||
// }
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user