更新一级睡眠报告页面
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
class ServiceConstant {
|
||||
static const String baseHost = "zhmht.swes.com.cn:27021"; //服务地址 眠花糖测试地址
|
||||
// static const String baseHost = "zhmht.swes.com.cn:27020"; //服务地址 眠花糖正式地址
|
||||
// static const String baseHost = "zhmht.swes.com.cn:27021"; //服务地址 眠花糖测试地址
|
||||
static const String baseHost = "zhmht.swes.com.cn:27020"; //服务地址 眠花糖正式地址
|
||||
// static const String baseHost = "vsbs-test.he-info.cn"; //服务地址 本地测试地址
|
||||
// static const String baseHost = "vsbst-api.he-info.cn";//服务地址
|
||||
static const String service_address = "http://$baseHost";
|
||||
// static const String service_address = "https://$baseHost";
|
||||
// static const String service_address = "http://$baseHost";
|
||||
static const String service_address = "https://$baseHost";
|
||||
|
||||
static String server_service = "/vsbs_app_server"; //服务名称
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import 'package:vbvs_app/common/color/app_uri_status.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/common/util/requestWithLog.dart';
|
||||
import 'package:vbvs_app/component/NullDataComponentWidget.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/controller/date/CalendarController.dart';
|
||||
@@ -19,10 +20,8 @@ import 'package:vbvs_app/pages/common/selectDialog.dart';
|
||||
import 'package:vbvs_app/pages/main_bottom/component/main_page_b_bottom_change.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/component/SleepScoreWidget.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/component/SleepView.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/component/Vital_signs.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/component/new_sleep_view.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/new_sleep_report_page.dart';
|
||||
|
||||
class MhtSleepReportPage extends StatefulWidget {
|
||||
const MhtSleepReportPage({super.key});
|
||||
@@ -41,6 +40,7 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
|
||||
final RxBool isRightLimit = false.obs;
|
||||
var formFieldController = FormFieldController<String>(null);
|
||||
var personInfo = {}.obs;
|
||||
Rx<bool> isLoading = false.obs;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -332,6 +332,9 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
|
||||
}
|
||||
}).toList(),
|
||||
onChanged: (val) {
|
||||
sleepReportController
|
||||
.sleepReport
|
||||
.value = {};
|
||||
final list =
|
||||
deviceController
|
||||
.personnelList
|
||||
@@ -363,9 +366,15 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
|
||||
.value =
|
||||
formFieldController
|
||||
.value!;
|
||||
deviceController.getSleeps(
|
||||
formFieldController
|
||||
.value);
|
||||
// deviceController.getSleeps(
|
||||
// formFieldController
|
||||
// .value);
|
||||
String data =
|
||||
MyUtils.formatDate(
|
||||
calendarController
|
||||
.selectedDate
|
||||
.value!);
|
||||
loadSleepReport(data);
|
||||
homeController
|
||||
.updateAll();
|
||||
}
|
||||
@@ -469,45 +478,58 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
|
||||
}),
|
||||
|
||||
Obx(() {
|
||||
if (homeController.selectDevcie.value != null &&
|
||||
if (userInfoController.model.login! == null ||
|
||||
userInfoController.model.login! == 0 ||
|
||||
deviceController.personnelList.value.isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
final bool hasValidData = homeController
|
||||
.selectDevcie.value !=
|
||||
null &&
|
||||
homeController.selectDevcie.value!.isNotEmpty &&
|
||||
deviceController.personnelList.value.isNotEmpty &&
|
||||
sleepReportController.sleepReport.value != null) {
|
||||
return Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
getTimeWidget(),
|
||||
SleepScoreWidget(
|
||||
sleepReport:
|
||||
sleepReportController.sleepReport.value,
|
||||
showLabelWrap: false,
|
||||
),
|
||||
NewSleepViewWidget(
|
||||
sleepReport:
|
||||
sleepReportController.sleepReport.value),
|
||||
SizedBox(height: 25.rpx),
|
||||
VitalSignsWidget(
|
||||
sleepReport:
|
||||
sleepReportController.sleepReport.value)
|
||||
],
|
||||
sleepReportController.sleepReport.value != null &&
|
||||
sleepReportController.sleepReport.value.isNotEmpty;
|
||||
|
||||
// child: NewSleepReportPage(
|
||||
// data: {
|
||||
// "tag": "123",
|
||||
// 'date': DateTime.now().millisecondsSinceEpoch,
|
||||
// 'mac'.tr: homeController.selectDevcie.value,
|
||||
// 'person': homeController.selectPerson.value,
|
||||
// 'backgroundImg':
|
||||
// 'assets/images/new_background.png',
|
||||
// 'arrow': false,
|
||||
// 'noBackImg': true,
|
||||
// 'person_show': false,
|
||||
// },
|
||||
// ),
|
||||
)));
|
||||
}
|
||||
return Container();
|
||||
return Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
getTimeWidget(), // 始终显示
|
||||
isLoading.value
|
||||
? Padding(
|
||||
padding: EdgeInsets.fromLTRB(
|
||||
0, 30.rpx, 0, 0),
|
||||
child: Center(
|
||||
child: CircularProgressIndicator()),
|
||||
)
|
||||
: hasValidData
|
||||
? Column(
|
||||
children: [
|
||||
SleepScoreWidget(
|
||||
sleepReport:
|
||||
sleepReportController
|
||||
.sleepReport.value,
|
||||
showLabelWrap: false,
|
||||
),
|
||||
NewSleepViewWidget(
|
||||
sleepReport:
|
||||
sleepReportController
|
||||
.sleepReport.value,
|
||||
),
|
||||
SizedBox(height: 25.rpx),
|
||||
VitalSignsWidget(
|
||||
sleepReport:
|
||||
sleepReportController
|
||||
.sleepReport.value,
|
||||
),
|
||||
],
|
||||
)
|
||||
: NullDataWidget(), // 无数据时
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
],
|
||||
);
|
||||
@@ -636,17 +658,20 @@ class _MhtSleepReportPageState extends State<MhtSleepReportPage> {
|
||||
}
|
||||
|
||||
void loadSleepReport(String data) {
|
||||
isLoading.value = true;
|
||||
requestWithLog(
|
||||
logTitle: "查询睡眠报告",
|
||||
method: MyHttpMethod.get,
|
||||
queryUrl:
|
||||
"https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${homeController.selectDevcie.value}&time=${data}&type=${sleepReportController.model.type}",
|
||||
onSuccess: (res) {
|
||||
isLoading.value = false;
|
||||
print(res);
|
||||
sleepReportController.sleepReport.value = res.data;
|
||||
sleepReportController.updateAll();
|
||||
},
|
||||
onFailure: (res) {
|
||||
isLoading.value = false;
|
||||
if (MainPageBBottomChange.getCurrentIndex() != null) {
|
||||
if (MainPageBBottomChange.getCurrentIndex() == 1) {
|
||||
TopSlideNotification.show(context,
|
||||
|
||||
@@ -632,9 +632,7 @@ class _NewHomePageState extends State<NewHomePage> {
|
||||
personInfo
|
||||
.value,
|
||||
'backgroundImg':
|
||||
'assets/images/new_background.png',
|
||||
'date':
|
||||
timeMillis,
|
||||
'assets/images/new_background.png',
|
||||
// 'backgroundColor':stringToColor("#003058"),
|
||||
'person_show':
|
||||
false,
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
import 'package:EasyDartModule/EasyDartModule.dart' as es;
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:path/path.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/GradientLine.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/SnoreWaveform.dart';
|
||||
import 'package:EasyDartModule/EasyDartModule.dart' as es;
|
||||
import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart';
|
||||
|
||||
//睡眠规律性
|
||||
class VitalSignsWidget extends StatefulWidget {
|
||||
@@ -67,6 +65,38 @@ class _VitalSignsWidgetState extends State<VitalSignsWidget> {
|
||||
orElse: () => {},
|
||||
);
|
||||
|
||||
List svgList = [
|
||||
'assets/img/icon/home_heart.svg',
|
||||
'assets/img/icon/home_hrv.svg',
|
||||
'assets/img/icon/home_breath.svg'
|
||||
];
|
||||
List nameList = ['平均心率'.tr, '平均hrv'.tr, '平均呼吸'.tr];
|
||||
// brs 307【平均呼吸】
|
||||
// hrs 206【平均心率】 203【hrv】
|
||||
final hrsList = widget.sleepReport['hrs'] ?? [];
|
||||
final brsList = widget.sleepReport['brs'] ?? [];
|
||||
|
||||
// 获取对应 id 的原始 value
|
||||
final avgHeartRate = hrsList.firstWhere(
|
||||
(e) => e['id'] == 206,
|
||||
orElse: () => {},
|
||||
);
|
||||
final hrv = hrsList.firstWhere(
|
||||
(e) => e['id'] == 203,
|
||||
orElse: () => {},
|
||||
);
|
||||
final avgBreath = brsList.firstWhere(
|
||||
(e) => e['id'] == 307,
|
||||
orElse: () => {},
|
||||
);
|
||||
|
||||
// 构建 valueList(原始数据,未格式化)
|
||||
List<dynamic> valueList = [
|
||||
avgHeartRate['value'],
|
||||
hrv['value'],
|
||||
avgBreath['value'],
|
||||
];
|
||||
|
||||
List stages = widget.sleepReport['sleepData']['stages'];
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
@@ -102,8 +132,7 @@ class _VitalSignsWidgetState extends State<VitalSignsWidget> {
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
"睡眠规律性是指个体睡眠模式在时间、时长、环境等方面呈现出的稳定性和一致性,是衡量睡眠质量的重要指标之一。"
|
||||
.tr,
|
||||
"生命体征指的是睡眠周期的整体数据。".tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: Colors.black,
|
||||
@@ -133,43 +162,75 @@ class _VitalSignsWidgetState extends State<VitalSignsWidget> {
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 98.rpx,
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
"1",
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().title_text_fontSize),
|
||||
children: List.generate(3, (index) {
|
||||
return Expanded(
|
||||
// 平均宽度
|
||||
child: SizedBox(
|
||||
// height: 120.rpx, // 固定高度,例如 120.rpx,根据实际调整
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Container(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0, 0.rpx, 0.rpx, 0), // 外部 padding 移到内部
|
||||
width: 42.rpx,
|
||||
height: 42.rpx,
|
||||
child: SvgPicture.asset(
|
||||
svgList[index],
|
||||
fit: BoxFit.cover,
|
||||
// color: themeController.currentColor.sc4,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 5.rpx),
|
||||
Text(
|
||||
valueList[index] == null ||
|
||||
valueList[index].toString().isEmpty
|
||||
? "-"
|
||||
: "${valueList[index]}",
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: 60.rpx,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(height: 42.rpx),
|
||||
Text(
|
||||
"${nameList[index]}",
|
||||
style: TextStyle(
|
||||
color: stringToColor("#929699"),
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
"1",
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().title_text_fontSize),
|
||||
)
|
||||
],
|
||||
),
|
||||
Column(
|
||||
children: [
|
||||
Text(
|
||||
"1",
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().title_text_fontSize),
|
||||
)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
);
|
||||
}),
|
||||
),
|
||||
SizedBox(
|
||||
height: 130.rpx,
|
||||
),
|
||||
Row(mainAxisAlignment: MainAxisAlignment.end, children: [
|
||||
OutlinedButton(
|
||||
onPressed: () {},
|
||||
onPressed: () {
|
||||
MHTHomeController homeController = Get.find();
|
||||
Get.toNamed("/newSleepReportPage", arguments: {
|
||||
'date': widget.sleepReport['startTime'],
|
||||
"mac": homeController.selectDevcie.value,
|
||||
'type': 1,
|
||||
'backgroundImg': 'assets/images/new_background.png',
|
||||
'person_show': false,
|
||||
'itemName': 206,
|
||||
});
|
||||
},
|
||||
style: OutlinedButton.styleFrom(
|
||||
side: const BorderSide(color: Color(0XFF85F5FF)),
|
||||
foregroundColor: Color(0XFF85F5FF),
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:EasyDartModule/EasyDartModule.dart' as es;
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
@@ -6,9 +7,8 @@ import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/GradientLine.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/homepage/controller/mht_home_controller.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/SnoreWaveform.dart';
|
||||
import 'package:EasyDartModule/EasyDartModule.dart' as es;
|
||||
|
||||
//睡眠规律性
|
||||
class NewSleepViewWidget extends StatefulWidget {
|
||||
@@ -48,8 +48,27 @@ class _NewSleepViewWidgetState extends State<NewSleepViewWidget> {
|
||||
.where((item) => item['show'] != false)
|
||||
.toList();
|
||||
final bsList = widget.sleepReport['bs'] as List;
|
||||
final deepSleep =
|
||||
bsList.firstWhere((e) => e['id'] == 111, orElse: () => null);
|
||||
final lightSleep =
|
||||
bsList.firstWhere((e) => e['id'] == 117, orElse: () => null);
|
||||
final snore =
|
||||
bsList.firstWhere((e) => e['id'] == 116, orElse: () => null);
|
||||
final movement =
|
||||
bsList.firstWhere((e) => e['id'] == 108, orElse: () => null);
|
||||
final leaveBed =
|
||||
bsList.firstWhere((e) => e['id'] == 114, orElse: () => null);
|
||||
|
||||
final Map<int, int> typeIdMap = {
|
||||
0: 114, // 离床时长
|
||||
1: 117, // 浅睡时长
|
||||
2: 111, // 深睡时长
|
||||
3: 108, // 频繁体动时长
|
||||
4: 116, // 打鼾时长
|
||||
};
|
||||
|
||||
List snoreValues = [];
|
||||
|
||||
List lightSnore = widget.sleepReport['ssp']['data'][0];
|
||||
List heavySnore = widget.sleepReport['ssp']['data'][1];
|
||||
snoreValues = [...lightSnore, ...heavySnore];
|
||||
@@ -156,10 +175,53 @@ class _NewSleepViewWidgetState extends State<NewSleepViewWidget> {
|
||||
SizedBox(
|
||||
height: 70.rpx,
|
||||
),
|
||||
// Wrap(
|
||||
// spacing: 55.rpx,
|
||||
// runSpacing: 20.rpx,
|
||||
// children: showLabel.map<Widget>((item) {
|
||||
// return Container(
|
||||
// padding: EdgeInsets.all(5.rpx),
|
||||
// child: Row(
|
||||
// mainAxisSize: MainAxisSize.min,
|
||||
// children: [
|
||||
// Container(
|
||||
// width: 20.rpx,
|
||||
// height: 20.rpx,
|
||||
// decoration: BoxDecoration(
|
||||
// color: item["color"] == null || item["color"] == ""
|
||||
// ? Colors.transparent
|
||||
// : stringToColor(item["color"]),
|
||||
// borderRadius: BorderRadius.circular(10.rpx),
|
||||
// ),
|
||||
// ),
|
||||
// SizedBox(width: 17.rpx),
|
||||
// Text(
|
||||
// item["name"],
|
||||
// style: TextStyle(
|
||||
// color: Colors.white,
|
||||
// fontSize: 24.rpx,
|
||||
// ),
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// );
|
||||
// }).toList(),
|
||||
// ),
|
||||
Wrap(
|
||||
spacing: 55.rpx,
|
||||
runSpacing: 20.rpx,
|
||||
children: showLabel.map<Widget>((item) {
|
||||
final int type = item["type"];
|
||||
final int? targetId = typeIdMap[type];
|
||||
|
||||
// 在 bsList 中查找对应 id 的元素
|
||||
final matchedItem = bsList.firstWhere(
|
||||
(e) => e["id"] == targetId,
|
||||
orElse: () => {},
|
||||
);
|
||||
|
||||
final dynamic value = matchedItem?["value"];
|
||||
final String displayValue = formatHourToHM(value);
|
||||
return Container(
|
||||
padding: EdgeInsets.all(5.rpx),
|
||||
child: Row(
|
||||
@@ -177,7 +239,9 @@ class _NewSleepViewWidgetState extends State<NewSleepViewWidget> {
|
||||
),
|
||||
SizedBox(width: 17.rpx),
|
||||
Text(
|
||||
item["name"],
|
||||
value != null
|
||||
? "${item["name"]} $displayValue"
|
||||
: "${item["name"]} -",
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 24.rpx,
|
||||
@@ -188,9 +252,19 @@ class _NewSleepViewWidgetState extends State<NewSleepViewWidget> {
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
|
||||
Row(mainAxisAlignment: MainAxisAlignment.end, children: [
|
||||
OutlinedButton(
|
||||
onPressed: () {},
|
||||
onPressed: () {
|
||||
MHTHomeController homeController = Get.find();
|
||||
Get.toNamed("/newSleepReportPage", arguments: {
|
||||
'date': widget.sleepReport['startTime'],
|
||||
"mac": homeController.selectDevcie.value,
|
||||
'type': 1,
|
||||
'backgroundImg': 'assets/images/new_background.png',
|
||||
'person_show': false,
|
||||
});
|
||||
},
|
||||
style: OutlinedButton.styleFrom(
|
||||
side: const BorderSide(color: Color(0XFF85F5FF)),
|
||||
foregroundColor: Color(0XFF85F5FF),
|
||||
@@ -255,4 +329,19 @@ class _NewSleepViewWidgetState extends State<NewSleepViewWidget> {
|
||||
}
|
||||
}).toList();
|
||||
}
|
||||
|
||||
String formatHourToHM(dynamic value) {
|
||||
if (value == null) return "-";
|
||||
if (value is num) {
|
||||
int hours = value.floor();
|
||||
int minutes = ((value - hours) * 60).round();
|
||||
|
||||
if (hours > 0) {
|
||||
return "${hours}h ${minutes}m";
|
||||
} else {
|
||||
return "${minutes}m";
|
||||
}
|
||||
}
|
||||
return "-";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
|
||||
Get.put(tag: widget.data["tag"], SleepReportController());
|
||||
}
|
||||
sleepReportController = Get.find(tag: widget.data["tag"]);
|
||||
sleepReportController.sleepReport.value = {};
|
||||
// sleepReportController.sleepReport.value = {};
|
||||
|
||||
if (widget.data['date'] == null) {
|
||||
widget.data['date'] = DateTime.now().millisecondsSinceEpoch;
|
||||
@@ -109,52 +109,60 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (Get.isRegistered<SleepReportController>(tag: widget.data["tag"]) ==
|
||||
false) {
|
||||
Get.put(tag: widget.data["tag"], SleepReportController());
|
||||
}
|
||||
sleepReportController = Get.find(tag: widget.data["tag"]);
|
||||
sleepReportController.sleepReport.value = {};
|
||||
Future.microtask(() {
|
||||
_initSleepReportData();
|
||||
});
|
||||
// try {
|
||||
// if (Get.isRegistered<SleepReportController>(tag: widget.data["tag"]) ==
|
||||
// false) {
|
||||
// Get.put(tag: widget.data["tag"], SleepReportController());
|
||||
// }
|
||||
// sleepReportController = Get.find(tag: widget.data["tag"]);
|
||||
// // sleepReportController.sleepReport.value = {};
|
||||
|
||||
if (widget.data['date'] == null) {
|
||||
widget.data['date'] = DateTime.now();
|
||||
}
|
||||
calendarController.selectedDate.value =
|
||||
DateTime.fromMillisecondsSinceEpoch(widget.data['date']);
|
||||
sleepReportController.selectedDate.value =
|
||||
DateTime.fromMillisecondsSinceEpoch(widget.data['date']);
|
||||
if (widget.data['type'] != null) {
|
||||
sleepReportController.model.type = widget.data['type'];
|
||||
} else {
|
||||
sleepReportController.model.type = 1;
|
||||
}
|
||||
String date = MyUtils.formatToDate(widget.data['date']);
|
||||
// String date = '2025-5-27';
|
||||
sleepReportController.isLoading.value = true;
|
||||
requestWithLog(
|
||||
logTitle: "查询睡眠报告",
|
||||
method: MyHttpMethod.get,
|
||||
queryUrl:
|
||||
"https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${widget.data['mac']}&time=${date}&type=${sleepReportController.model.type}",
|
||||
onSuccess: (res) {
|
||||
print(res);
|
||||
sleepReportController.isLoading.value = false;
|
||||
sleepReportController.sleepReport.value = res.data;
|
||||
sleepReportController.updateAll();
|
||||
_scrollToTargetComponent(sleepReportController.sleepReport);
|
||||
},
|
||||
onFailure: (res) {
|
||||
if (MainPageBBottomChange.getCurrentIndex() != null) {
|
||||
if (MainPageBBottomChange.getCurrentIndex() == 1) {
|
||||
TopSlideNotification.show(context,
|
||||
text: res.msg!, textColor: themeController.currentColor.sc9);
|
||||
}
|
||||
} else {}
|
||||
sleepReportController.sleepReport.value = {};
|
||||
sleepReportController.isLoading.value = false;
|
||||
sleepReportController.updateAll();
|
||||
print(res);
|
||||
});
|
||||
// if (widget.data['date'] == null) {
|
||||
// widget.data['date'] = DateTime.now();
|
||||
// }
|
||||
// calendarController.selectedDate.value =
|
||||
// DateTime.fromMillisecondsSinceEpoch(widget.data['date']);
|
||||
// sleepReportController.selectedDate.value =
|
||||
// DateTime.fromMillisecondsSinceEpoch(widget.data['date']);
|
||||
// if (widget.data['type'] != null) {
|
||||
// sleepReportController.model.type = widget.data['type'];
|
||||
// } else {
|
||||
// sleepReportController.model.type = 1;
|
||||
// }
|
||||
// String date = MyUtils.formatToDate(widget.data['date']);
|
||||
// // String date = '2025-5-27';
|
||||
// sleepReportController.isLoading.value = true;
|
||||
// requestWithLog(
|
||||
// logTitle: "查询睡眠报告",
|
||||
// method: MyHttpMethod.get,
|
||||
// queryUrl:
|
||||
// "https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${widget.data['mac']}&time=${date}&type=${sleepReportController.model.type}",
|
||||
// onSuccess: (res) {
|
||||
// print(res);
|
||||
// sleepReportController.isLoading.value = false;
|
||||
// sleepReportController.sleepReport.value = res.data;
|
||||
// sleepReportController.updateAll();
|
||||
// _scrollToTargetComponent(sleepReportController.sleepReport);
|
||||
// },
|
||||
// onFailure: (res) {
|
||||
// if (MainPageBBottomChange.getCurrentIndex() != null) {
|
||||
// if (MainPageBBottomChange.getCurrentIndex() == 1) {
|
||||
// TopSlideNotification.show(context,
|
||||
// text: res.msg!,
|
||||
// textColor: themeController.currentColor.sc9);
|
||||
// }
|
||||
// } else {}
|
||||
// sleepReportController.sleepReport.value = {};
|
||||
// sleepReportController.isLoading.value = false;
|
||||
// sleepReportController.updateAll();
|
||||
// print(res);
|
||||
// });
|
||||
// } catch (e) {
|
||||
// ef.log("$e");
|
||||
// }
|
||||
double lineWidth = 115.rpx;
|
||||
return LayoutBuilder(
|
||||
builder: (context, bodySize) => GestureDetector(
|
||||
@@ -174,7 +182,7 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
|
||||
),
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.transparent, // 背景透明
|
||||
|
||||
|
||||
appBar: (widget.data['arrow'] != null &&
|
||||
widget.data['arrow'] == false)
|
||||
? null
|
||||
@@ -655,7 +663,6 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
|
||||
Stack(
|
||||
alignment: Alignment.bottomLeft,
|
||||
children: [
|
||||
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceAround,
|
||||
@@ -1325,7 +1332,6 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
|
||||
return;
|
||||
}
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
final targetName = widget.data['name'];
|
||||
final targetID = widget.data['itemName'];
|
||||
GlobalKey? targetKey;
|
||||
|
||||
@@ -1414,4 +1420,55 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
void _initSleepReportData() {
|
||||
try {
|
||||
if (Get.isRegistered<SleepReportController>(tag: widget.data["tag"]) ==
|
||||
false) {
|
||||
Get.put(tag: widget.data["tag"], SleepReportController());
|
||||
}
|
||||
sleepReportController = Get.find(tag: widget.data["tag"]);
|
||||
|
||||
if (widget.data['date'] == null) {
|
||||
widget.data['date'] = DateTime.now();
|
||||
}
|
||||
|
||||
final dateTime = DateTime.fromMillisecondsSinceEpoch(widget.data['date']);
|
||||
calendarController.selectedDate.value = dateTime;
|
||||
sleepReportController.selectedDate.value = dateTime;
|
||||
|
||||
sleepReportController.model.type = widget.data['type'] ?? 1;
|
||||
|
||||
String dateStr = MyUtils.formatToDate(widget.data['date']);
|
||||
|
||||
sleepReportController.isLoading.value = true;
|
||||
|
||||
requestWithLog(
|
||||
logTitle: "查询睡眠报告",
|
||||
method: MyHttpMethod.get,
|
||||
queryUrl:
|
||||
"https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${widget.data['mac']}&time=$dateStr&type=${sleepReportController.model.type}",
|
||||
onSuccess: (res) {
|
||||
sleepReportController.isLoading.value = false;
|
||||
sleepReportController.sleepReport.value = res.data;
|
||||
sleepReportController.updateAll();
|
||||
_scrollToTargetComponent(sleepReportController.sleepReport);
|
||||
},
|
||||
onFailure: (res) {
|
||||
if (MainPageBBottomChange.getCurrentIndex() == 1) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: res.msg!,
|
||||
textColor: themeController.currentColor.sc9,
|
||||
);
|
||||
}
|
||||
sleepReportController.sleepReport.value = {};
|
||||
sleepReportController.isLoading.value = false;
|
||||
sleepReportController.updateAll();
|
||||
},
|
||||
);
|
||||
} catch (e) {
|
||||
ef.log("$e");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user