fix:重新优化猫眼设置项逻辑,增加省电模式下的监控和远程开锁限制
This commit is contained in:
parent
602050b90c
commit
f6f10f1bcd
@ -1131,6 +1131,8 @@
|
||||
"已静音": "The sound has been turned off",
|
||||
"该锁的远程开锁功能未启用": "The remote unlocking function of this lock is not enabled",
|
||||
"下载完成,请到相册查看": "Download completed, please go to the album to view",
|
||||
"猫眼设置为省电模式时无法进行监控,请在猫眼设置中切换为其他模式": "When Cat Eye is set to power-saving mode, monitoring cannot be performed. Please switch to other modes in Cat Eye settings",
|
||||
"猫眼设置为省电模式时无法进行远程开锁,请在猫眼设置中切换为其他模式": "Remote unlocking is not possible when Cat Eye is set to power-saving mode. Please switch to another mode in Cat Eye settings",
|
||||
"重置后,该锁的遥控都将被删除哦,确认要重置吗?": "After reset, the remote control of the lock will be deleted. Do you want to reset it?",
|
||||
"版本说明": "Version description",
|
||||
"网关通电后,长按重置按钮5秒,蓝色指示灯闪烁时点击下一步": "After the gateway is powered on, press and hold the reset button for 5 seconds. Click Next when the blue indicator light flashes",
|
||||
|
||||
@ -1132,6 +1132,8 @@
|
||||
"已静音": "已静音",
|
||||
"该锁的远程开锁功能未启用": "该锁的远程开锁功能未启用",
|
||||
"下载完成,请到相册查看": "下载完成,请到相册查看",
|
||||
"猫眼设置为省电模式时无法进行监控,请在猫眼设置中切换为其他模式": "猫眼设置为省电模式时无法进行监控,请在猫眼设置中切换为其他模式",
|
||||
"猫眼设置为省电模式时无法进行远程开锁,请在猫眼设置中切换为其他模式": "猫眼设置为省电模式时无法进行远程开锁,请在猫眼设置中切换为其他模式",
|
||||
"重置后,该锁的遥控都将被删除哦,确认要重置吗?": "重置后,该锁的遥控都将被删除哦,确认要重置吗?",
|
||||
"版本说明": "版本说明",
|
||||
"网关添加成功": "网关添加成功"
|
||||
|
||||
@ -1132,6 +1132,8 @@
|
||||
"已静音": "已静音",
|
||||
"该锁的远程开锁功能未启用": "该锁的远程开锁功能未启用",
|
||||
"下载完成,请到相册查看": "下载完成,请到相册查看",
|
||||
"猫眼设置为省电模式时无法进行监控,请在猫眼设置中切换为其他模式": "猫眼设置为省电模式时无法进行监控,请在猫眼设置中切换为其他模式",
|
||||
"猫眼设置为省电模式时无法进行远程开锁,请在猫眼设置中切换为其他模式": "猫眼设置为省电模式时无法进行远程开锁,请在猫眼设置中切换为其他模式",
|
||||
"重置后,该锁的遥控都将被删除哦,确认要重置吗?": "重置后,该锁的遥控都将被删除哦,确认要重置吗?",
|
||||
"版本说明": "版本说明",
|
||||
"网关添加成功": "网关添加成功"
|
||||
|
||||
@ -638,12 +638,19 @@ class LockDetailLogic extends BaseGetXController {
|
||||
|
||||
// 远程开锁
|
||||
Future<void> remoteOpenLock() async {
|
||||
final LoginEntity entity = await ApiRepository.to.remoteOpenLock(
|
||||
lockId: state.keyInfos.value.lockId.toString(),
|
||||
timeOut: 60,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast('已开锁'.tr);
|
||||
final catEyeConfig = state.keyInfos.value.lockSetting?.catEyeConfig ?? [];
|
||||
if (catEyeConfig.isNotEmpty &&
|
||||
catEyeConfig.length > 0 &&
|
||||
catEyeConfig[0].catEyeMode != 0) {
|
||||
final LoginEntity entity = await ApiRepository.to.remoteOpenLock(
|
||||
lockId: state.keyInfos.value.lockId.toString(),
|
||||
timeOut: 60,
|
||||
);
|
||||
if (entity.errorCode!.codeIsSuccessful) {
|
||||
showToast('已开锁'.tr);
|
||||
}
|
||||
} else {
|
||||
showToast('猫眼设置为省电模式时无法进行远程开锁,请在猫眼设置中切换为其他模式'.tr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -752,14 +759,21 @@ class LockDetailLogic extends BaseGetXController {
|
||||
|
||||
/// 发送监控消息
|
||||
void sendMonitorMessage() {
|
||||
if (StartChartManage().lockNetworkInfo.wifiName == null ||
|
||||
StartChartManage().lockNetworkInfo.wifiName == '') {
|
||||
showToast('设备未配网'.tr);
|
||||
return;
|
||||
final catEyeConfig = state.keyInfos.value.lockSetting?.catEyeConfig ?? [];
|
||||
if (catEyeConfig.isNotEmpty &&
|
||||
catEyeConfig.length > 0 &&
|
||||
catEyeConfig[0].catEyeMode != 0) {
|
||||
if (StartChartManage().lockNetworkInfo.wifiName == null ||
|
||||
StartChartManage().lockNetworkInfo.wifiName == '') {
|
||||
showToast('设备未配网'.tr);
|
||||
return;
|
||||
}
|
||||
// 发送监控id
|
||||
StartChartManage().startCallRequestMessageTimer(
|
||||
ToPeerId: StartChartManage().lockPeerId ?? '');
|
||||
} else {
|
||||
showToast('猫眼设置为省电模式时无法进行监控,请在猫眼设置中切换为其他模式'.tr);
|
||||
}
|
||||
// 发送监控id
|
||||
StartChartManage().startCallRequestMessageTimer(
|
||||
ToPeerId: StartChartManage().lockPeerId ?? '');
|
||||
}
|
||||
|
||||
@override
|
||||
@ -769,6 +783,18 @@ class LockDetailLogic extends BaseGetXController {
|
||||
await PermissionDialog.request(Permission.location);
|
||||
await PermissionDialog.requestBluetooth();
|
||||
_requestDeviceNetworkInfo();
|
||||
eventBus
|
||||
.on<PassCurrentLockInformationEvent>()
|
||||
.listen((PassCurrentLockInformationEvent event) {
|
||||
if (event.lockSetInfoData.lockSettingInfo != null &&
|
||||
event.lockSetInfoData.lockSettingInfo!.catEyeConfig != null &&
|
||||
event.lockSetInfoData.lockSettingInfo!.catEyeConfig!.length > 0) {
|
||||
state.keyInfos.value.lockSetting!.catEyeConfig![0].catEyeMode = event
|
||||
.lockSetInfoData.lockSettingInfo!.catEyeConfig![0].catEyeMode ??
|
||||
1;
|
||||
state.keyInfos.refresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@ -11,6 +11,7 @@ import 'package:star_lock/main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dar
|
||||
import 'package:star_lock/network/api_repository.dart';
|
||||
import 'package:star_lock/talk/starChart/star_chart_manage.dart';
|
||||
import 'package:star_lock/tools/baseGetXController.dart';
|
||||
import 'package:star_lock/tools/eventBusEventManage.dart';
|
||||
import 'package:star_lock/tools/storage.dart';
|
||||
|
||||
import '../../../../../blue/sender_manage.dart';
|
||||
@ -54,7 +55,7 @@ class CatEyeCustomModeLogic extends BaseGetXController {
|
||||
}
|
||||
|
||||
void updateCustomModeConfig(clickIndex) {
|
||||
catEyeSetState.catEyeConfig.value.catEyeMode = 4;
|
||||
catEyeSetState.catEyeConfig.value.catEyeMode = 3;
|
||||
catEyeSetState.catEyeConfig.value.recordTime =
|
||||
state.showsUpVideoList.value.indexOf(state.recordTime.value);
|
||||
catEyeSetState.catEyeConfig.value.detectionDistance =
|
||||
@ -75,10 +76,23 @@ class CatEyeCustomModeLogic extends BaseGetXController {
|
||||
.value[catEyeSetState.catEyeConfig.value.recordTime ?? 0];
|
||||
state.detectionDistance.value = state.detectionRangeList
|
||||
.value[catEyeSetState.catEyeConfig.value.detectionDistance ?? 0];
|
||||
|
||||
state.realTimeMode.value =
|
||||
catEyeSetState.catEyeConfig.value.realTimeMode == 0
|
||||
? '发生事件时查看'.tr
|
||||
: '实时查看'.tr;
|
||||
eventBus
|
||||
.on<PassCurrentLockInformationEvent>()
|
||||
.listen((PassCurrentLockInformationEvent event) {
|
||||
if (event.lockSetInfoData.lockSettingInfo != null &&
|
||||
event.lockSetInfoData.lockSettingInfo!.catEyeConfig != null &&
|
||||
event.lockSetInfoData.lockSettingInfo!.catEyeConfig!.length > 0) {
|
||||
state.realTimeMode.value = event.lockSetInfoData.lockSettingInfo!
|
||||
.catEyeConfig![0].catEyeModeConfig!.realTimeMode ==
|
||||
0
|
||||
? '发生事件时查看'.tr
|
||||
: '实时查看'.tr;
|
||||
state.realTimeMode.refresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -29,80 +29,82 @@ class _CatEyeCustomModePageState extends State<CatEyeCustomModePage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
backgroundColor: Colors.white,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: '自定义模式'.tr,
|
||||
haveBack: true,
|
||||
backAction: () {
|
||||
Navigator.pop(context, true);
|
||||
},
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Obx(() => Column(
|
||||
children: [
|
||||
Container(
|
||||
margin: EdgeInsets.only(left: 20.w),
|
||||
child: CommonItem(
|
||||
leftTitel: '录像时段'.tr,
|
||||
rightTitle: '',
|
||||
isHaveLine: false,
|
||||
isHaveDirection: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: Text(state.selectVideoSlot.value,
|
||||
style: TextStyle(
|
||||
fontSize: 22.sp,
|
||||
color: AppColors.darkGrayTextColor)),
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.videoSlotPage,
|
||||
arguments: {
|
||||
'lockSetInfoData': state.lockSetInfoData.value,
|
||||
'catEyeConfigData': state.lockSetInfoData.value
|
||||
.lockSettingInfo!.catEyeConfig!.isNotEmpty
|
||||
? state.lockSetInfoData.value.lockSettingInfo!
|
||||
.catEyeConfig![0]
|
||||
: null
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
_buildSubTitleItem(
|
||||
'有人出现时录像'.tr,
|
||||
'有人在门口出现10秒后开始录像。'.tr + '\n' + '有人按门铃时立即录像'.tr,
|
||||
state.recordTime.value, () {
|
||||
_openBottomItemSheet(state.showsUpVideoList.value, 0);
|
||||
}),
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
_buildSubTitleItem('人体侦测距离'.tr, '有人出现在门前1.5米范围时启动录像'.tr,
|
||||
state.detectionDistance.value, () {
|
||||
_openBottomItemSheet(state.detectionRangeList.value, 1);
|
||||
}),
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.only(left: 20.w),
|
||||
child: CommonItem(
|
||||
leftTitel: '实时画面'.tr,
|
||||
rightTitle: state.realTimeMode.value,
|
||||
isHaveLine: false,
|
||||
isHaveDirection: true,
|
||||
isHaveRightWidget: false,
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.liveVideoPage,
|
||||
arguments: {
|
||||
'lockSetInfoData': state.lockSetInfoData.value,
|
||||
'catEyeConfigData': state.lockSetInfoData.value
|
||||
.lockSettingInfo!.catEyeConfig!.isNotEmpty
|
||||
? state.lockSetInfoData.value.lockSettingInfo!
|
||||
.catEyeConfig![0]
|
||||
: null
|
||||
});
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
)));
|
||||
backgroundColor: Colors.white,
|
||||
appBar: TitleAppBar(
|
||||
barTitle: '自定义模式'.tr,
|
||||
haveBack: true,
|
||||
backAction: () {
|
||||
Navigator.pop(context, true);
|
||||
},
|
||||
backgroundColor: AppColors.mainColor),
|
||||
body: Obx(
|
||||
() => Column(
|
||||
children: [
|
||||
Container(
|
||||
margin: EdgeInsets.only(left: 20.w),
|
||||
child: CommonItem(
|
||||
leftTitel: '录像时段'.tr,
|
||||
rightTitle: '',
|
||||
isHaveLine: false,
|
||||
isHaveDirection: true,
|
||||
isHaveRightWidget: true,
|
||||
rightWidget: Text(state.selectVideoSlot.value,
|
||||
style: TextStyle(
|
||||
fontSize: 22.sp, color: AppColors.darkGrayTextColor)),
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.videoSlotPage,
|
||||
arguments: {
|
||||
'lockSetInfoData': state.lockSetInfoData.value,
|
||||
'catEyeConfigData': state.lockSetInfoData.value
|
||||
.lockSettingInfo!.catEyeConfig!.isNotEmpty
|
||||
? state.lockSetInfoData.value.lockSettingInfo!
|
||||
.catEyeConfig![0]
|
||||
: null
|
||||
});
|
||||
},
|
||||
),
|
||||
),
|
||||
_buildSubTitleItem(
|
||||
'有人出现时录像'.tr,
|
||||
'有人在门口出现10秒后开始录像。'.tr + '\n' + '有人按门铃时立即录像'.tr,
|
||||
state.recordTime.value, () {
|
||||
_openBottomItemSheet(state.showsUpVideoList.value, 0);
|
||||
}),
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
_buildSubTitleItem('人体侦测距离'.tr, '有人出现在门前1.5米范围时启动录像'.tr,
|
||||
state.detectionDistance.value, () {
|
||||
_openBottomItemSheet(state.detectionRangeList.value, 1);
|
||||
}),
|
||||
SizedBox(
|
||||
height: 30.h,
|
||||
),
|
||||
Container(
|
||||
margin: EdgeInsets.only(left: 20.w),
|
||||
child: CommonItem(
|
||||
leftTitel: '实时画面'.tr,
|
||||
rightTitle: state.realTimeMode.value,
|
||||
isHaveLine: false,
|
||||
isHaveDirection: true,
|
||||
isHaveRightWidget: false,
|
||||
action: () {
|
||||
Navigator.pushNamed(context, Routers.liveVideoPage,
|
||||
arguments: {
|
||||
'lockSetInfoData': state.lockSetInfoData.value,
|
||||
'catEyeConfigData': state.lockSetInfoData.value
|
||||
.lockSettingInfo!.catEyeConfig!.isNotEmpty
|
||||
? state.lockSetInfoData.value.lockSettingInfo!
|
||||
.catEyeConfig![0]
|
||||
: null
|
||||
});
|
||||
},
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSubTitleItem(
|
||||
|
||||
@ -131,7 +131,6 @@ class CatEyeSetLogic extends BaseGetXController {
|
||||
}
|
||||
state.updateCatEyeSetByState();
|
||||
|
||||
state.catEyeConfig.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -21,9 +21,10 @@ class LiveVideoLogic extends BaseGetXController {
|
||||
|
||||
void updateCatEyeModeConfig() {
|
||||
catEyeSetState.settingOptions.value = 5;
|
||||
catEyeSetState.catEyeConfig.value.catEyeMode = 4;
|
||||
catEyeSetState.catEyeConfig.value.catEyeMode = 3;
|
||||
catEyeSetState.catEyeConfig.value.realTimeMode = state.realTimeMode.value;
|
||||
catEyeSetLogic.sendBlueMessage();
|
||||
catEyeSetLogic.refresh();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -31,5 +32,6 @@ class LiveVideoLogic extends BaseGetXController {
|
||||
super.onInit();
|
||||
state.isLiveView.value =
|
||||
catEyeSetState.catEyeConfig.value.realTimeMode == 1;
|
||||
state.isLiveView.refresh();
|
||||
}
|
||||
}
|
||||
|
||||
@ -553,11 +553,13 @@ class LockSettingInfo {
|
||||
stayWarn = json['stayWarn'];
|
||||
abnormalWarn = json['abnormalWarn'];
|
||||
if (json['catEyeConfig'] != null) {
|
||||
catEyeConfig = <CatEyeConfig>[];
|
||||
json['catEyeConfig'].forEach((v) {
|
||||
catEyeConfig!.add(CatEyeConfig.fromJson(v));
|
||||
});
|
||||
catEyeConfig = (json['catEyeConfig'] as List)
|
||||
.map((item) => CatEyeConfig.fromJson(item))
|
||||
.toList();
|
||||
} else {
|
||||
catEyeConfig = [];
|
||||
}
|
||||
|
||||
faceSwitch = json['faceSwitch'];
|
||||
faceAutoLightScreen = json['faceAutoLightScreen'];
|
||||
faceInductionDistance = json['faceInductionDistance'];
|
||||
@ -670,60 +672,68 @@ class PassageModeConfig {
|
||||
}
|
||||
}
|
||||
|
||||
// 定义 CatEyeConfig 类
|
||||
class CatEyeConfig {
|
||||
CatEyeConfig({this.catEyeMode, this.catEyeModeConfig});
|
||||
CatEyeConfig({
|
||||
this.catEyeMode,
|
||||
this.catEyeModeConfig,
|
||||
});
|
||||
|
||||
CatEyeConfig.fromJson(Map<String, dynamic> json) {
|
||||
catEyeMode = json['catEyeMode'];
|
||||
catEyeModeConfig = json['catEyeModeConfig'] != null
|
||||
? CatEyeModeConfig.fromJson(json['catEyeModeConfig'])
|
||||
: null;
|
||||
// 从 JSON 数据构造对象
|
||||
factory CatEyeConfig.fromJson(Map<String, dynamic> json) {
|
||||
return CatEyeConfig(
|
||||
catEyeMode: json['catEyeMode']?.toInt() ?? 0,
|
||||
catEyeModeConfig:
|
||||
CatEyeModeConfig.fromJson(json['catEyeModeConfig'] ?? {}),
|
||||
);
|
||||
}
|
||||
|
||||
int? catEyeMode; //1省电模式 2逗留抓拍模式 3实时监控模式 4自定义模式(自定义模式下存在其他设置参数)
|
||||
int? catEyeMode;
|
||||
CatEyeModeConfig? catEyeModeConfig;
|
||||
|
||||
// 将对象转换为 JSON 数据
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['catEyeMode'] = catEyeMode;
|
||||
if (catEyeModeConfig != null) {
|
||||
data['catEyeModeConfig'] = catEyeModeConfig!.toJson();
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
// 定义 CatEyeModeConfig 类
|
||||
class CatEyeModeConfig {
|
||||
//人体侦测距离
|
||||
CatEyeModeConfig({
|
||||
this.recordMode,
|
||||
this.recordTime,
|
||||
this.realTimeMode,
|
||||
this.recordEndTime,
|
||||
this.recordStartTime,
|
||||
this.detectionDistance,
|
||||
});
|
||||
|
||||
CatEyeModeConfig(
|
||||
{this.recordMode,
|
||||
this.recordTime,
|
||||
this.realTimeMode,
|
||||
this.recordEndTime,
|
||||
this.recordStartTime,
|
||||
this.detectionDistance});
|
||||
|
||||
CatEyeModeConfig.fromJson(Map<String, dynamic> json) {
|
||||
recordMode = json['recordMode'];
|
||||
if (json['recordTime'] != null) {
|
||||
recordTime = json['recordTime'];
|
||||
} else {
|
||||
recordTime = '';
|
||||
}
|
||||
realTimeMode = json['realTimeMode'];
|
||||
recordEndTime = json['recordEndTime'];
|
||||
recordStartTime = json['recordStartTime'];
|
||||
detectionDistance = json['detectionDistance'];
|
||||
// 从 JSON 数据构造对象
|
||||
factory CatEyeModeConfig.fromJson(Map<String, dynamic> json) {
|
||||
return CatEyeModeConfig(
|
||||
recordMode: json['recordMode']?.toInt(),
|
||||
recordTime: json['recordTime']?.toInt(),
|
||||
realTimeMode: json['realTimeMode']?.toInt(),
|
||||
recordEndTime: json['recordEndTime']?.toInt(),
|
||||
recordStartTime: json['recordStartTime']?.toInt(),
|
||||
detectionDistance: json['detectionDistance']?.toInt(),
|
||||
);
|
||||
}
|
||||
|
||||
int? recordMode; //录像时段 0全天 1自定义时间
|
||||
String? recordTime; //有人出现时录像
|
||||
int? realTimeMode; //实时画面 0发生事件事查看 1实时查看
|
||||
int? recordEndTime; //录像时段自定义时间-结束时间
|
||||
int? recordStartTime; //录像时段自定义时间-开始时间
|
||||
String? detectionDistance;
|
||||
int? recordMode;
|
||||
int? recordTime;
|
||||
int? realTimeMode;
|
||||
int? recordEndTime;
|
||||
int? recordStartTime;
|
||||
int? detectionDistance;
|
||||
|
||||
// 将对象转换为 JSON 数据
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['recordMode'] = recordMode;
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
import 'dart:convert';
|
||||
|
||||
class LockListInfoEntity {
|
||||
LockListInfoEntity(
|
||||
{this.errorCode, this.description, this.errorMsg, this.data});
|
||||
@ -193,9 +195,8 @@ class LockListInfoItemEntity {
|
||||
mac = json['mac'];
|
||||
initUserNo = json['initUserNo'];
|
||||
updateDate = json['updateDate'];
|
||||
network = json['network'] != null
|
||||
? NetworkInfo.fromJson(json['network'])
|
||||
: null;
|
||||
network =
|
||||
json['network'] != null ? NetworkInfo.fromJson(json['network']) : null;
|
||||
}
|
||||
|
||||
int? keyId;
|
||||
@ -298,6 +299,33 @@ class LockListInfoItemEntity {
|
||||
}
|
||||
}
|
||||
|
||||
class NetworkInfo {
|
||||
NetworkInfo({
|
||||
this.peerId,
|
||||
this.isOnline,
|
||||
this.wifiName,
|
||||
});
|
||||
|
||||
NetworkInfo.fromJson(Map<String, dynamic> json) {
|
||||
peerId = json['peerId'];
|
||||
isOnline = json['isOnline'];
|
||||
wifiName = json['wifiName'];
|
||||
}
|
||||
|
||||
String? peerId;
|
||||
String? wifiName;
|
||||
int? isOnline;
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['peerId'] = peerId;
|
||||
data['wifiName'] = wifiName;
|
||||
data['isOnline'] = isOnline;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Bluetooth {
|
||||
Bluetooth(
|
||||
{this.bluetoothDeviceId,
|
||||
@ -406,50 +434,112 @@ class LockSetting {
|
||||
this.attendance,
|
||||
this.appUnlockOnline,
|
||||
this.remoteUnlock,
|
||||
this.catEyeConfig,
|
||||
});
|
||||
|
||||
LockSetting.fromJson(Map<String, dynamic> json) {
|
||||
attendance = json['attendance'];
|
||||
appUnlockOnline = json['appUnlockOnline'];
|
||||
remoteUnlock = json['remoteUnlock'];
|
||||
// 从 JSON 数据构造对象
|
||||
factory LockSetting.fromJson(Map<String, dynamic> json) {
|
||||
return LockSetting(
|
||||
attendance: json['attendance']?.toInt(),
|
||||
appUnlockOnline: json['appUnlockOnline']?.toInt(),
|
||||
remoteUnlock: json['remoteUnlock']?.toInt(),
|
||||
|
||||
// 解析 catEyeConfig 字段
|
||||
catEyeConfig: json['catEyeConfig'] != null
|
||||
? (json['catEyeConfig'] as List)
|
||||
.map((item) => CatEyeConfig.fromJson(item))
|
||||
.toList()
|
||||
: [],
|
||||
);
|
||||
}
|
||||
|
||||
int? attendance;
|
||||
int? appUnlockOnline;
|
||||
int? remoteUnlock;
|
||||
List<CatEyeConfig>? catEyeConfig;
|
||||
|
||||
// 将对象转换为 JSON 数据
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['attendance'] = attendance;
|
||||
data['appUnlockOnline'] = appUnlockOnline;
|
||||
data['remoteUnlock'] = remoteUnlock;
|
||||
|
||||
if (catEyeConfig != null) {
|
||||
data['catEyeConfig'] =
|
||||
catEyeConfig!.map((v) => v.toJson()).toList(); // 序列化为 List
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class NetworkInfo {
|
||||
NetworkInfo({
|
||||
this.peerId,
|
||||
this.isOnline,
|
||||
this.wifiName,
|
||||
|
||||
// 定义 CatEyeConfig 类
|
||||
class CatEyeConfig {
|
||||
CatEyeConfig({
|
||||
required this.catEyeMode,
|
||||
required this.catEyeModeConfig,
|
||||
});
|
||||
|
||||
NetworkInfo.fromJson(Map<String, dynamic> json) {
|
||||
peerId = json['peerId'];
|
||||
isOnline = json['isOnline'];
|
||||
wifiName = json['wifiName'];
|
||||
// 从 JSON 数据构造对象
|
||||
factory CatEyeConfig.fromJson(Map<String, dynamic> json) {
|
||||
return CatEyeConfig(
|
||||
catEyeMode: json['catEyeMode']?.toInt() ?? 0,
|
||||
catEyeModeConfig: CatEyeModeConfig.fromJson(json['catEyeModeConfig'] ?? {}),
|
||||
);
|
||||
}
|
||||
|
||||
String? peerId;
|
||||
String? wifiName;
|
||||
int? isOnline;
|
||||
int catEyeMode;
|
||||
CatEyeModeConfig catEyeModeConfig;
|
||||
|
||||
// 将对象转换为 JSON 数据
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['peerId'] = peerId;
|
||||
data['wifiName'] = wifiName;
|
||||
data['isOnline'] = isOnline;
|
||||
data['catEyeMode'] = catEyeMode;
|
||||
data['catEyeModeConfig'] = catEyeModeConfig.toJson();
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
// 定义 CatEyeModeConfig 类
|
||||
class CatEyeModeConfig {
|
||||
CatEyeModeConfig({
|
||||
this.recordMode,
|
||||
this.recordTime,
|
||||
this.realTimeMode,
|
||||
this.recordEndTime,
|
||||
this.recordStartTime,
|
||||
this.detectionDistance,
|
||||
});
|
||||
|
||||
// 从 JSON 数据构造对象
|
||||
factory CatEyeModeConfig.fromJson(Map<String, dynamic> json) {
|
||||
return CatEyeModeConfig(
|
||||
recordMode: json['recordMode']?.toInt(),
|
||||
recordTime: json['recordTime']?.toInt(),
|
||||
realTimeMode: json['realTimeMode']?.toInt(),
|
||||
recordEndTime: json['recordEndTime']?.toInt(),
|
||||
recordStartTime: json['recordStartTime']?.toInt(),
|
||||
detectionDistance: json['detectionDistance']?.toInt(),
|
||||
);
|
||||
}
|
||||
|
||||
int? recordMode;
|
||||
int? recordTime;
|
||||
int? realTimeMode;
|
||||
int? recordEndTime;
|
||||
int? recordStartTime;
|
||||
int? detectionDistance;
|
||||
|
||||
// 将对象转换为 JSON 数据
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data['recordMode'] = recordMode;
|
||||
data['recordTime'] = recordTime;
|
||||
data['realTimeMode'] = realTimeMode;
|
||||
data['recordEndTime'] = recordEndTime;
|
||||
data['recordStartTime'] = recordStartTime;
|
||||
data['detectionDistance'] = detectionDistance;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user