From 63305851cc2bc899c6e0f330abb8d59a2535e960 Mon Sep 17 00:00:00 2001 From: czz <862977248@qq.com> Date: Mon, 7 Jul 2025 16:13:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E6=8A=A5=E5=91=A8=E6=8A=A5=E6=9C=88?= =?UTF-8?q?=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/pages/mh_page/test/WebviewTestModel.dart | 10 ++---- .../component/MonthDataWidget.dart | 35 ++++++++++++++++++- 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/lib/pages/mh_page/test/WebviewTestModel.dart b/lib/pages/mh_page/test/WebviewTestModel.dart index c970690..028877a 100644 --- a/lib/pages/mh_page/test/WebviewTestModel.dart +++ b/lib/pages/mh_page/test/WebviewTestModel.dart @@ -32,17 +32,11 @@ class WebviewTestController extends GetControllerEx { WebviewTestController() : super(WebviewTestModel()) { web = WebviewHelper( jsbridge: buildsdk( -<<<<<<< HEAD + // father: this, // clientId: '494641114', // dbgserverUrl: 'ws://192.168.1.2:9001', ), -======= - father: this, - clientId: '494641114', - // dbgserverUrl: 'ws://192.168.1.2:9001', - ), ->>>>>>> 58b2bebe936bdd7239529662ef20b531f2143de4 settings: buildsettings(), params: PlatformHeadlessInAppWebViewCreationParams( initialUrlRequest: URLRequest( @@ -120,7 +114,7 @@ class WebviewTestController extends GetControllerEx { ef.log('queryInstantData: $args'); // bluetooth = args[0]; return instantData; - }); + }); bridge.sdk.startTimer((args) async { ef.log('queryInstantData: $args'); MHTHomeController homeController = Get.find(); diff --git a/lib/pages/sleep_report/component/MonthDataWidget.dart b/lib/pages/sleep_report/component/MonthDataWidget.dart index 5b4ef4a..e612ad3 100644 --- a/lib/pages/sleep_report/component/MonthDataWidget.dart +++ b/lib/pages/sleep_report/component/MonthDataWidget.dart @@ -172,7 +172,7 @@ Widget MonthDataWidget( }, ), ], - tips: buildValueTexts(sleepReport['scoreList']['data'], '小时', 1), + tips: buildSleepValueTexts(sleepReport['csd']['data'], '小时', 1), xCount: buildMonthlyChartData(sleepReport['scoreList'])['daysInMonth'] .toInt(), yCount: sleepReport['csd']['yLable'].length, @@ -560,6 +560,39 @@ List buildValueTexts( }).toList(); } +List buildSleepValueTexts( + List data, + String unit, + int direction, // 0 左侧,1 右侧 +) { + if (data.isEmpty) return []; + + return data.map((item) { + final dst = (item['dst'] ?? 0).toString(); + final lst = (item['lst'] ?? 0).toString(); + final slt = (item['slt'] ?? 0).toString(); + + final prefix = direction == 1 ? '' : unit; + final suffix = direction == 1 ? unit : ''; + + // 格式化日期(不带时间) + String dateStr = ''; + if (item['st'] != null) { + final dt = DateTime.fromMillisecondsSinceEpoch(item['st']); + dateStr = "${dt.year}年${dt.month.toString().padLeft(2, '0')}月${dt.day.toString().padLeft(2, '0')}日"; + } + + var q = [ + "睡眠时长:$prefix$slt$suffix", + "深睡:$prefix$dst$suffix", + "浅睡:$prefix$lst$suffix", + dateStr, + ].join("\n"); + print(q); + return q; + }).toList(); +} + Map buildMonthlyChartData(Map dyspData) { final List> data = (dyspData['data'] as List?)?.whereType>().toList() ??