diff --git a/lib/pages/device/instant_body_page.dart b/lib/pages/device/instant_body_page.dart index 8960096..d64359c 100644 --- a/lib/pages/device/instant_body_page.dart +++ b/lib/pages/device/instant_body_page.dart @@ -57,6 +57,58 @@ class _InstantBodyPageState extends State // type: 1, // data: {"mac": widget.personInfo['mac']}))); // _startOnlineTimer(); // 初始化时启动定时器 + + try { + Future.delayed(Duration(seconds: 0), () { + CommonVariables.callMap["/vsbs/web/rt/marttress"] = (data) { + edm.EasyDartModule.logger.info("[websocket]实时体征页面数据-->${data}]"); + ef.log("[websocket]实时体征页面数据-->${data}]"); + if (data['status'] == "离线") { + inBed = "-"; + bodyMotion = -1; + heartrate = -1; + snores = "-"; + breathrate = -1; + breathState = "-"; + onlineState = "离线".tr; + return; + } + inBed = data["inBed"]; + // 心率 呼吸 体动 呼吸暂停 + if ("离床".tr == inBed) { + breathState = "否".tr; + bodyMotion = 0; + breathrate = 0; + heartrate = 0; + snores = "否".tr; + } else { + onlineState = "在线".tr; // 接收到数据,设置为在线 + breathState = + data["breathState"] == null || data["breathState"] == "" + ? "-" + : data["breathState"].toString().tr; + + bodyMotion = data['bodyMotion'] == null ? -1 : data['bodyMotion']; + breathrate = data["breathRate"] == null ? -1 : data["breathRate"]; + heartrate = data['heartRate'] == null ? -1 : data['heartRate']; + snores = data['snores'] == null || data['snores'] == "" + ? "否".tr + : "是".tr; + } + + if (mounted) { + setState(() { + onlineState = "在线".tr; // 接收到数据,设置为在线 + }); + } + _startOnlineTimer(); // 重置定时器 + }; + }); + } catch (e) { + print(e); + edm.EasyDartModule.logger + .error("[webscoekt]格式化数据错误-->${{"mac": widget.personInfo['mac']}}"); + } _initWebSocket(); super.initState(); } @@ -92,6 +144,7 @@ class _InstantBodyPageState extends State WidgetsBinding.instance.removeObserver(this); // 移除生命周期观察者 _onlineTimer?.cancel(); _closeWebSocket(); + CommonVariables.callMap.remove("/vsbs/web/rt/marttress"); super.dispose(); } @@ -129,50 +182,6 @@ class _InstantBodyPageState extends State @override Widget build(BuildContext context) { Map device = widget.personInfo; - try { - CommonVariables.callMap["/vsbs/web/rt/marttress"] = (data) { - if (data['status'] == "离线") { - inBed = "-"; - bodyMotion = -1; - heartrate = -1; - snores = "-"; - breathrate = -1; - breathState = "-"; - return; - } - inBed = data["inBed"]; - // 心率 呼吸 体动 呼吸暂停 - if ("离床".tr == inBed) { - breathState = "否".tr; - bodyMotion = 0; - breathrate = 0; - heartrate = 0; - snores = "否".tr; - } else { - onlineState = "在线".tr; // 接收到数据,设置为在线 - breathState = data["breathState"] == null || data["breathState"] == "" - ? "-" - : data["breathState"].toString().tr; - - bodyMotion = data['bodyMotion'] == null ? -1 : data['bodyMotion']; - breathrate = data["breathRate"] == null ? -1 : data["breathRate"]; - heartrate = data['heartRate'] == null ? -1 : data['heartRate']; - snores = - data['snores'] == null || data['snores'] == "" ? "否".tr : "是".tr; - } - - if (mounted) { - setState(() { - onlineState = "在线".tr; // 接收到数据,设置为在线 - }); - } - _startOnlineTimer(); // 重置定时器 - }; - } catch (e) { - print(e); - edm.EasyDartModule.logger - .error("[webscoekt]格式化数据错误-->${{"mac": widget.personInfo['mac']}}"); - } return LayoutBuilder( builder: (context, bodySize) => GestureDetector( diff --git a/lib/pages/main_bottom/mine_page.dart b/lib/pages/main_bottom/mine_page.dart index 90865b4..c959852 100644 --- a/lib/pages/main_bottom/mine_page.dart +++ b/lib/pages/main_bottom/mine_page.dart @@ -674,7 +674,7 @@ class _MinePageState extends State { mainAxisSize: MainAxisSize.max, children: [ Text( - 'V1.0.2509.04', + 'V1.0.2509.19', style: TextStyle( fontFamily: 'Inter', color: Color(0xFFD9E3EB),