From 30027f40c27068b7bfddcc6b0ff7b5061520da99 Mon Sep 17 00:00:00 2001
From: czz <862977248@qq.com>
Date: Thu, 10 Jul 2025 11:16:26 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=97=A5=E5=8E=86=E6=A0=B7?=
=?UTF-8?q?=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
assets/img/icon/calendar.svg | 2 +-
lib/component/base/SleepCalendarWidget.dart | 101 ++-
lib/component/base/SleepdateWidget.dart | 84 ++-
lib/pages/common/selectDialog.dart | 55 +-
lib/pages/login/other_login.dart | 1 +
lib/pages/mh_page/edit_address_page.dart | 666 +++++++-----------
lib/pages/mh_page/message/messageDetail.dart | 54 +-
lib/pages/mh_page/repair_history_widget.dart | 2 +-
.../mh_page/user/page/mht_login_page.dart | 8 +-
.../sleep_report/new_sleep_report_page.dart | 9 +-
10 files changed, 502 insertions(+), 480 deletions(-)
diff --git a/assets/img/icon/calendar.svg b/assets/img/icon/calendar.svg
index 74d3b59..b603c28 100644
--- a/assets/img/icon/calendar.svg
+++ b/assets/img/icon/calendar.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/lib/component/base/SleepCalendarWidget.dart b/lib/component/base/SleepCalendarWidget.dart
index 06d920a..7e5c707 100644
--- a/lib/component/base/SleepCalendarWidget.dart
+++ b/lib/component/base/SleepCalendarWidget.dart
@@ -3,8 +3,11 @@ import 'package:get/get.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/common/util/requestWithLog.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';
+import 'package:vbvs_app/pages/main_bottom/component/main_page_b_bottom_change.dart';
import 'SleepdateWidget.dart';
class SleepCalendarWidget extends StatefulWidget {
@@ -12,9 +15,11 @@ class SleepCalendarWidget extends StatefulWidget {
final ValueChanged? onDateSelected;
final int? type; // 新增参数,默认日历类型为日
final Color highlightColor; // ✅ 新增
+ final String? mac;
const SleepCalendarWidget({
super.key,
+ this.mac,
this.timestamp,
this.onDateSelected,
this.type = 1,
@@ -27,27 +32,89 @@ class SleepCalendarWidget extends StatefulWidget {
class _SleepCalendarWidgetState extends State {
CalendarController calendarController = Get.find();
-
+ RxMap sleepDate = {}.obs;
+ RxList showLabel = [
+ {"level": 5, "name": "无报告", "color": "#9E9E9E"}
+ ].obs;
+ // @override
+ // void initState() {
+ // super.initState();
+ // final initialDate = widget.timestamp != null
+ // ? DateTime.fromMillisecondsSinceEpoch(widget.timestamp!)
+ // : DateTime.now();
+ // calendarController.displayedMonth.value = initialDate;
+ // calendarController.selectedDate.value = initialDate;
+ // }
@override
void initState() {
super.initState();
+
final initialDate = widget.timestamp != null
? DateTime.fromMillisecondsSinceEpoch(widget.timestamp!)
: DateTime.now();
calendarController.displayedMonth.value = initialDate;
calendarController.selectedDate.value = initialDate;
+
+ // 初始化请求
+ fetchDate(initialDate);
+
+ // 每当月份变化时,重新请求数据
+ ever(calendarController.displayedMonth, (DateTime newMonth) {
+ fetchDate(newMonth);
+ });
+ }
+
+ Future fetchDate(DateTime timeStamp) async {
+ final dateStr = timeStamp.toString().split(' ')[0];
+
+ await requestWithLog(
+ logTitle: "查询睡眠报告",
+ method: MyHttpMethod.get,
+ queryUrl:
+ "https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${widget.mac}&time=$dateStr&type=3",
+ onSuccess: (res) {
+ sleepDate.value = res.data;
+ showLabel.value = [
+ ...res.data['scoreList']['type'],
+ {"level": 5, "name": "无报告", "color": "#9E9E9E"},
+ // ✅ 注意拼写是 scoreList
+ ];
+ },
+ onFailure: (res) {
+ sleepDate.value = {};
+ showLabel.value = [
+ {"level": 5, "name": "无报告", "color": "#9E9E9E"},
+ ];
+ },
+ );
+ }
+
+ Future fetchSleepColor(DateTime timeStamp) async {
+ final dateStr = timeStamp.toString().split(' ')[0];
+
+ await requestWithLog(
+ logTitle: "查询睡眠报告",
+ method: MyHttpMethod.get,
+ queryUrl: "https://sleepdata.he-info.com/api/analysis/sleep/score/type",
+ onSuccess: (res) {
+ sleepDate.value = res.data;
+ showLabel.value = [
+ ...res.data['scoreList']['type'],
+ {"level": 5, "name": "无报告", "color": "#9E9E9E"},
+ // ✅ 注意拼写是 scoreList
+ ];
+ },
+ onFailure: (res) {
+ sleepDate.value = {};
+ showLabel.value = [
+ {"level": 5, "name": "无报告", "color": "#9E9E9E"},
+ ];
+ },
+ );
}
@override
Widget build(BuildContext context) {
- List