主页睡眠信息点击跳转页面修改
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
import 'package:vbvs_app/common/color/ServiceConstant.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/common/util/requestWithLog.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/pages/main_bottom/component/main_page_b_bottom_change.dart';
|
||||
|
||||
part 'sleep_report_controller.g.dart'; // 由json_serializable自动生成的部分
|
||||
|
||||
@@ -28,10 +34,58 @@ class SleepReportController extends GetControllerEx<SleepReportModel> {
|
||||
Rx<DateTime?> selectedDate = Rx<DateTime?>(null);
|
||||
RxMap<String, dynamic> sleepReport = <String, dynamic>{}.obs;
|
||||
RxBool isLoading = false.obs;
|
||||
// 下拉框的设备 mac
|
||||
RxString mac = "".obs;
|
||||
|
||||
// 日历选择的日期
|
||||
RxInt date = 0.obs;
|
||||
|
||||
// 初始化方法(外部跳转时调用)
|
||||
void initParams({String? macValue, int? dateValue}) {
|
||||
if (macValue != null) mac.value = macValue;
|
||||
if (dateValue != null) {
|
||||
date.value = dateValue;
|
||||
}
|
||||
}
|
||||
|
||||
// 每种类型对应一份数据
|
||||
|
||||
SleepReportController() {
|
||||
attr = GetModel(SleepReportModel()).obs;
|
||||
}
|
||||
|
||||
void loadSleepReport(String data, String mac, BuildContext context) async {
|
||||
isLoading.value = true;
|
||||
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.sleep_report;
|
||||
String queryUrl =
|
||||
"$serviceAddress$serviceName$serviceApi?mac=${mac}&time=${data}&type=1&sleepType=2";
|
||||
await requestWithLog(
|
||||
logTitle: "查询睡眠报告",
|
||||
method: MyHttpMethod.get,
|
||||
queryUrl: queryUrl,
|
||||
onSuccess: (res) {
|
||||
isLoading.value = false;
|
||||
print(res);
|
||||
sleepReport.value = res.data;
|
||||
updateAll();
|
||||
},
|
||||
onFailure: (res) {
|
||||
isLoading.value = false;
|
||||
if (MainPageBBottomChange.getCurrentIndex() != null) {
|
||||
if (MainPageBBottomChange.getCurrentIndex() == 1) {
|
||||
TopSlideNotification.show(context,
|
||||
text: res.msg!, textColor: themeController.currentColor.sc9);
|
||||
}
|
||||
} else {
|
||||
TopSlideNotification.show(context,
|
||||
text: res.msg!, textColor: themeController.currentColor.sc9);
|
||||
}
|
||||
sleepReport.value = {};
|
||||
updateAll();
|
||||
print(res);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user