From 72e2e3f57e82bcf86000fa06781bdbcc7f7c9632 Mon Sep 17 00:00:00 2001 From: liyi Date: Fri, 7 Feb 2025 10:05:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E8=BF=9B=E5=85=A5?= =?UTF-8?q?=E9=94=81=E8=AF=A6=E6=83=85=E9=A1=B5=E6=8F=90=E7=A4=BA=E2=80=9C?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=B8=8D=E5=AD=98=E5=9C=A8=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lockDetail/lockDetail_logic.dart | 29 +++++++++++++++ .../lockDetail/lockDetail_page.dart | 36 ++----------------- 2 files changed, 31 insertions(+), 34 deletions(-) diff --git a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 163ded98..b5d3a1aa 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -10,6 +10,7 @@ import 'package:star_lock/apm/apm_helper.dart'; import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/login/login/entity/LoginEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; +import 'package:star_lock/main/lockDetail/lockDetail/device_network_info.dart'; import 'package:star_lock/main/lockDetail/lockSet/lockTime/getServerDatetime_entity.dart'; import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart'; import 'package:star_lock/talk/starChart/constant/talk_status.dart'; @@ -744,12 +745,40 @@ class LockDetailLogic extends BaseGetXController { eventBus.fire(RefreshLockDetailInfoDataEvent()); } + /// 请求设备网络信息并设置 + void _requestDeviceNetworkInfo() async { + final DeviceNetwork deviceNetworkInfo = + await ApiRepository.to.getDeviceNetwork( + deviceType: 2, + deviceMac: state.keyInfos.value.mac!, + ); + if (deviceNetworkInfo.data?.wifiName == null || + deviceNetworkInfo.data?.wifiName == '') { + return; + } else { + final peerId = deviceNetworkInfo?.data?.peerId; + if (peerId == null || peerId.isEmpty || peerId == '') { + throw Exception('设备peerId为空'); + } + // 设置锁的peerID + StartChartManage().lockPeerId = peerId; + } + } + + /// 发送监控消息 + void sendMonitorMessage() { + // 发送监控id + StartChartManage().startCallRequestMessageTimer( + ToPeerId: StartChartManage().lockPeerId ?? ''); + } + @override Future onReady() async { super.onReady(); getServerDatetime(); await PermissionDialog.request(Permission.location); await PermissionDialog.requestBluetooth(); + _requestDeviceNetworkInfo(); } @override diff --git a/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/lib/main/lockDetail/lockDetail/lockDetail_page.dart index ee6895aa..c57b3cbf 100755 --- a/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -68,7 +68,7 @@ class _LockDetailPageState extends State lockListInfoItemEntity: widget.lockListInfoItemEntity, isOnlyOneData: widget.isOnlyOneData); - _handleLockMonitor2(); + } @override @@ -1164,7 +1164,7 @@ class _LockDetailPageState extends State showWidgetArr.add( bottomItem('images/main/icon_catEyes.png', '监控'.tr, state.bottomBtnisEable.value, () async { - await _handleLockMonitor(); + logic.sendMonitorMessage(); }), ); } @@ -1572,36 +1572,4 @@ class _LockDetailPageState extends State BlueManage().disconnect(); } - Future _handleLockMonitor2() async { - final lockId = state.keyInfos.value.lockId; - final LockSetInfoEntity entity = - await ApiRepository.to.getLockSettingInfoData( - lockId: lockId.toString(), - ); - if (entity.errorCode!.codeIsSuccessful) { - final LockSetInfoData data = entity.data!; - final mac = data.lockBasicInfo?.mac; - if (mac != null && mac.isNotEmpty) { - final DeviceNetwork deviceNetworkInfo = await ApiRepository.to - .getDeviceNetwork(deviceType: 2, deviceMac: mac); - if (deviceNetworkInfo.data?.wifiName == null || - deviceNetworkInfo.data?.wifiName == '') { - return; - } else { - final peerId = deviceNetworkInfo?.data?.peerId; - if (peerId == null || peerId.isEmpty || peerId == '') { - throw Exception('设备peerId为空'); - } - // 设置锁的peerID - StartChartManage().lockPeerId = peerId; - } - } - } - } - - Future _handleLockMonitor() async { - // 发送监控id - StartChartManage().startCallRequestMessageTimer( - ToPeerId: StartChartManage().lockPeerId ?? ''); - } }