fix:修复进入锁详情页提示“数据不存在问题”
This commit is contained in:
parent
2f00a6280d
commit
72e2e3f57e
@ -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<void> onReady() async {
|
||||
super.onReady();
|
||||
getServerDatetime();
|
||||
await PermissionDialog.request(Permission.location);
|
||||
await PermissionDialog.requestBluetooth();
|
||||
_requestDeviceNetworkInfo();
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -68,7 +68,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
lockListInfoItemEntity: widget.lockListInfoItemEntity,
|
||||
isOnlyOneData: widget.isOnlyOneData);
|
||||
|
||||
_handleLockMonitor2();
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
@ -1164,7 +1164,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
||||
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<LockDetailPage>
|
||||
BlueManage().disconnect();
|
||||
}
|
||||
|
||||
Future<void> _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<void> _handleLockMonitor() async {
|
||||
// 发送监控id
|
||||
StartChartManage().startCallRequestMessageTimer(
|
||||
ToPeerId: StartChartManage().lockPeerId ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user