From 3a6906f233550cd5c3cbb1349c9380c563a76288 Mon Sep 17 00:00:00 2001 From: Daisy <> Date: Sat, 20 Apr 2024 16:58:31 +0800 Subject: [PATCH] =?UTF-8?q?1=EF=BC=8C=E6=96=B0=E5=A2=9E=E9=94=81=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=8E=A5=E5=8F=A3=E5=AF=B9=E6=8E=A5=E5=8F=8A=E5=B7=AE?= =?UTF-8?q?=E5=BC=82=E5=8C=96=E5=A4=84=E7=90=86=202=EF=BC=8C=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E8=BF=94=E5=9B=9E=E7=9A=84=E4=B8=8D=E5=90=8C=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E9=92=A5=E5=8C=99=E7=94=A8=E6=88=B7=E6=9D=A5=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E7=BB=9F=E4=B8=80=E5=8C=96=E7=AE=A1=E7=90=86=203?= =?UTF-8?q?=EF=BC=8C=E9=80=89=E6=8B=A9=E5=BC=80=E9=97=A8=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E5=8F=8A=E5=AE=B6=E4=BA=BA=E7=9A=84=E9=80=BB=E8=BE=91=E5=A4=84?= =?UTF-8?q?=E7=90=86=E5=8F=8A=E5=90=8C=E6=AD=A5=204=EF=BC=8C=E5=85=A8?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E9=94=81=E8=A7=86=E9=A2=91=E5=AF=B9=E8=AE=B2?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=85=A8=E5=B1=8F=205=EF=BC=8C=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=B6=88=E6=81=AF=E6=8F=90=E9=86=92=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E9=83=A8=E5=88=86=E5=9B=BD=E9=99=85=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/images/lan/lan_en.json | 15 +- star_lock/images/lan/lan_keys.json | 15 +- star_lock/images/lan/lan_zh.json | 16 +- .../messageWarn/addFamily/addFamily_page.dart | 32 ++- .../addFamily/addFamily_state.dart | 2 + .../messageWarn/lockUser/lockUser_entity.dart | 73 +++++- .../messageWarn/lockUser/lockUser_logic.dart | 230 +++++++++++++++++- .../messageWarn/lockUser/lockUser_page.dart | 121 ++++----- .../messageWarn/lockUser/lockUser_state.dart | 6 +- .../lowBatteryReminder_page.dart | 8 +- .../msgNotification/msgNotification_page.dart | 18 +- .../openDoorNotify/openDoorNotify_page.dart | 6 +- .../monitoring/lockMonitoring_page.dart | 2 +- star_lock/lib/talk/udp/udp_manage.dart | 10 +- 14 files changed, 432 insertions(+), 122 deletions(-) diff --git a/star_lock/images/lan/lan_en.json b/star_lock/images/lan/lan_en.json index 7048fe21..f502dd81 100644 --- a/star_lock/images/lan/lan_en.json +++ b/star_lock/images/lan/lan_en.json @@ -728,5 +728,18 @@ "蓝牙":"Bluetooth", "需要访问蓝牙权限才能使用添加钥匙功能的位置信息":"Access to Bluetooth permissions is required to use the location information of the add key function", "请输入Email":"Please enter Email", - "请输入手机号":"Please enter mobile phone number" + "请输入手机号":"Please enter mobile phone number", + "家人到家":"Family gets home", + "添加家人":"Add family", + "若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择":"If the lock is not connected to the Internet, in addition to the electronic key, the password, card, fingerprint and other door reminders can not be sent in time, please choose according to your actual situation", + "消息提醒":"Message reminder", + "开门通知":"Opening notice", + "N天未开门":"N days without opening the door", + "门未关好":"The door is not closed", + "防拆报警":"Tamper alarm", + "低电量提醒":"Low power reminder", + "胁迫开门":"Forced door opening", + "有人按门铃":"Someone rings the doorbell", + "有人出现在门口":"Someone appears at the door", + "提醒方式":"Reminder mode" } diff --git a/star_lock/images/lan/lan_keys.json b/star_lock/images/lan/lan_keys.json index 5d88a3ad..c85fb0ba 100644 --- a/star_lock/images/lan/lan_keys.json +++ b/star_lock/images/lan/lan_keys.json @@ -727,5 +727,18 @@ "蓝牙":"蓝牙", "需要访问蓝牙权限才能使用添加钥匙功能的位置信息":"需要访问蓝牙权限才能使用添加钥匙功能的位置信息", "请输入Email":"请输入Email", - "请输入手机号":"请输入手机号" + "请输入手机号":"请输入手机号", + "家人到家":"家人到家", + "添加家人":"添加家人", + "若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择":"若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择", + "消息提醒":"消息提醒", + "开门通知":"开门通知", + "N天未开门":"N天未开门", + "门未关好":"门未关好", + "防拆报警":"防拆报警", + "低电量提醒":"低电量提醒", + "胁迫开门":"胁迫开门", + "有人按门铃":"有人按门铃", + "有人出现在门口":"有人出现在门口", + "提醒方式":"提醒方式" } diff --git a/star_lock/images/lan/lan_zh.json b/star_lock/images/lan/lan_zh.json index a99fa1c9..56a5d2fa 100644 --- a/star_lock/images/lan/lan_zh.json +++ b/star_lock/images/lan/lan_zh.json @@ -729,5 +729,19 @@ "蓝牙":"蓝牙", "需要访问蓝牙权限才能使用添加钥匙功能的位置信息":"需要访问蓝牙权限才能使用添加钥匙功能的位置信息", "请输入Email":"请输入Email", - "请输入手机号":"请输入手机号" + "请输入手机号":"请输入手机号", + "家人到家":"家人到家", + "添加家人":"添加家人", + "若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择":"若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择", + "消息提醒":"消息提醒", + "开门通知":"开门通知", + "N天未开门":"N天未开门", + "门未关好":"门未关好", + "防拆报警":"防拆报警", + "低电量提醒":"低电量提醒", + "胁迫开门":"胁迫开门", + "有人按门铃":"有人按门铃", + "有人出现在门口":"有人出现在门口", + "提醒方式":"提醒方式", + "电子钥匙":"电子钥匙" } diff --git a/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart b/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart index 0ab589d5..61f12c0e 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_page.dart @@ -32,24 +32,32 @@ class _AddFamilyPageState extends State { padding: EdgeInsets.all(30.w), child: Column( children: [ - CommonItem( + Obx(() => CommonItem( leftTitel: '开门方式', - rightTitle: '请选择', + rightTitle: state.lockUserKeys.value.currentKeyTypeStr ?? '请选择', isHaveLine: true, isHaveDirection: true, action: () { //锁用户 Get.toNamed(Routers.lockUserPage, - arguments: {'getLockId': state.getLockId.value}); - }), - CommonItem( - leftTitel: '家人', - rightTitle: '', - isHaveLine: true, - isHaveRightWidget: true, - isHaveDirection: false, - rightWidget: getFamilyWidget('请输入'), - ), + arguments: {'getLockId': state.getLockId.value}) + ?.then((val) { + if (val != null) { + state.lockUserKeys.value = val; + } + }); + })), + Obx(() => CommonItem( + leftTitel: '家人', + rightTitle: state.lockUserKeys.value.currentKeyName ?? '', + isHaveLine: true, + isHaveRightWidget: + state.lockUserKeys.value.currentKeyName == null + ? true + : false, + isHaveDirection: false, + rightWidget: getFamilyWidget('请输入'), + )), SizedBox( height: 20.h, ), diff --git a/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_state.dart b/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_state.dart index 526d6ba3..ca1643c7 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_state.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/addFamily/addFamily_state.dart @@ -1,7 +1,9 @@ import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_entity.dart'; class AddFamilyState { var getLockId = 0.obs; + var lockUserKeys = LockUserListKeys().obs; AddFamilyState() { Map map = Get.arguments; diff --git a/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_entity.dart b/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_entity.dart index 71de3b6f..df4d38b0 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_entity.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_entity.dart @@ -60,13 +60,13 @@ class LockUserData { } class LockUserListKeys { - int? id; + // int? id; String? clientId; int? lockOwnerId; int? apiUserId; int? lockId; - int? senderUserId; - int? receiverUsernameType; + // int? senderUserId; + // int? receiverUsernameType; String? keyName; int? keyType; int? startDate; @@ -90,8 +90,14 @@ class LockUserListKeys { UserInfo? userInfo; UserInfo? userSender; int? keyboardPwdType; + int? fingerprintType; + int? cardType; + int? faceType; int? keyboardPwdStatus; String? keyboardPwdName; + String? fingerprintName; + String? cardName; + String? faceName; String? keyboardPwd; String? keyboardPwdHash; int? addType; @@ -104,15 +110,22 @@ class LockUserListKeys { String? senderUsername; int? keyboardPwdId; int? sendDate; + int? currentKeyType; //当前钥匙类型 1:电子钥匙 2:密码钥匙 3:指纹钥匙 4:卡钥匙 5:人脸钥匙 + String? currentKeyTypeStr; //当前钥匙类型名称 + String? currentTypeImg; //当前钥匙类型图片 + String? currentKeyName; //当前钥匙名称 + bool? isCurrentSelect; //当前是否选中 + int? currentDateType; //钥匙日期类型 1:永久 2:限期 3:单次 4:循环 LockUserListKeys( - {this.id, + { + // this.id, this.clientId, this.lockOwnerId, this.apiUserId, this.lockId, - this.senderUserId, - this.receiverUsernameType, + // this.senderUserId, + // this.receiverUsernameType, this.keyName, this.keyType, this.startDate, @@ -136,8 +149,14 @@ class LockUserListKeys { this.userInfo, this.userSender, this.keyboardPwdType, + this.fingerprintType, + this.cardType, + this.faceType, this.keyboardPwdStatus, this.keyboardPwdName, + this.fingerprintName, + this.cardName, + this.faceName, this.keyboardPwd, this.keyboardPwdHash, this.addType, @@ -149,16 +168,21 @@ class LockUserListKeys { this.pwdUserNo, this.senderUsername, this.keyboardPwdId, - this.sendDate}); + this.sendDate, + this.currentKeyType, + this.currentTypeImg, + this.currentKeyName, + this.isCurrentSelect, + this.currentDateType}); LockUserListKeys.fromJson(Map json) { - id = json['id']; + // id = json['id']; clientId = json['clientId']; lockOwnerId = json['lockOwnerId']; apiUserId = json['apiUserId']; lockId = json['lockId']; - senderUserId = json['senderUserId']; - receiverUsernameType = json['receiverUsernameType']; + // senderUserId = json['senderUserId']; + // receiverUsernameType = json['receiverUsernameType']; keyName = json['keyName']; keyType = json['keyType']; startDate = json['startDate']; @@ -190,8 +214,14 @@ class LockUserListKeys { ? UserInfo.fromJson(json['user_sender']) : null; keyboardPwdType = json['keyboardPwdType']; + fingerprintType = json['fingerprintType']; + cardType = json['cardType']; + faceType = json['faceType']; keyboardPwdStatus = json['keyboardPwdStatus']; keyboardPwdName = json['keyboardPwdName']; + fingerprintName = json['fingerprintName']; + cardName = json['cardName']; + faceName = json['faceName']; keyboardPwd = json['keyboardPwd']; keyboardPwdHash = json['keyboardPwdHash']; addType = json['addType']; @@ -204,17 +234,22 @@ class LockUserListKeys { senderUsername = json['senderUsername']; keyboardPwdId = json['keyboardPwdId']; sendDate = json['sendDate']; + currentKeyType = json['currentKeyType']; + currentTypeImg = json['currentTypeImg']; + currentKeyName = json['currentKeyName']; + isCurrentSelect = json['isCurrentSelect']; + currentDateType = json['currentDateType']; } Map toJson() { final Map data = {}; - data['id'] = id; + // data['id'] = id; data['clientId'] = clientId; data['lockOwnerId'] = lockOwnerId; data['apiUserId'] = apiUserId; data['lockId'] = lockId; - data['senderUserId'] = senderUserId; - data['receiverUsernameType'] = receiverUsernameType; + // data['senderUserId'] = senderUserId; + // data['receiverUsernameType'] = receiverUsernameType; data['keyName'] = keyName; data['keyType'] = keyType; data['startDate'] = startDate; @@ -244,8 +279,14 @@ class LockUserListKeys { data['user_sender'] = userSender!.toJson(); } data['keyboardPwdType'] = keyboardPwdType; + data['fingerprintType'] = fingerprintType; + data['cardType'] = cardType; + data['faceType'] = faceType; data['keyboardPwdStatus'] = keyboardPwdStatus; data['keyboardPwdName'] = keyboardPwdName; + data['fingerprintName'] = fingerprintName; + data['cardName'] = cardName; + data['faceName'] = faceName; data['keyboardPwd'] = keyboardPwd; data['keyboardPwdHash'] = keyboardPwdHash; data['addType'] = addType; @@ -258,6 +299,12 @@ class LockUserListKeys { data['senderUsername'] = senderUsername; data['keyboardPwdId'] = keyboardPwdId; data['sendDate'] = sendDate; + data['currentKeyType'] = currentKeyType; + data['currentTypeImg'] = currentTypeImg; + data['currentKeyName'] = currentKeyName; + data['isCurrentSelect'] = isCurrentSelect; + data['currentDateType'] = currentDateType; + return data; } } diff --git a/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_logic.dart b/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_logic.dart index 0592f491..64039133 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_logic.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_logic.dart @@ -1,16 +1,242 @@ +import 'package:get/get.dart'; +import 'package:star_lock/common/XSConstantMacro/XSConstantMacro.dart'; import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_entity.dart'; import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_state.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/dateTool.dart'; class LockUserLogic extends BaseGetXController { final LockUserState state = LockUserState(); // 锁用户列表 - void getLockNoticeSetting() async { + void getLockKeysList() async { LockUserEntity entity = await ApiRepository.to.getLockKeysList( lockId: state.getLockId.value, ); - if (entity.errorCode!.codeIsSuccessful) {} + if (entity.errorCode!.codeIsSuccessful) { + //当前钥匙类型 1:电子钥匙 2:密码钥匙 3:指纹钥匙 4:卡钥匙 5:人脸钥匙 + LockUserData data1 = entity.data![0]; + data1.lockUserList?.forEach((element) { + element.currentKeyType = 1; + element.currentKeyTypeStr = '电子钥匙'.tr; + element.currentTypeImg = 'images/controls_user.png'; + element.currentKeyName = element.keyName; + element.isCurrentSelect = false; + element.currentDateType = element.keyType; + }); + LockUserData data2 = entity.data![1]; + data2.lockUserList?.forEach((element) { + element.currentKeyType = 2; + element.currentKeyTypeStr = '密码'.tr; + element.currentTypeImg = 'images/icon_password.png'; + element.currentKeyName = element.keyboardPwdName; + element.isCurrentSelect = false; + element.currentDateType = element.keyboardPwdType; + }); + LockUserData data3 = entity.data![2]; + data3.lockUserList?.forEach((element) { + element.currentKeyType = 3; + element.currentKeyTypeStr = '指纹'.tr; + element.currentTypeImg = 'images/icon_fingerprint.png'; + element.currentKeyName = element.fingerprintName; + element.isCurrentSelect = false; + element.currentDateType = element.fingerprintType; + }); + LockUserData data4 = entity.data![3]; + data4.lockUserList?.forEach((element) { + element.currentKeyType = 4; + element.currentKeyTypeStr = '卡'.tr; + element.currentTypeImg = 'images/icon_card.png'; + element.currentKeyName = element.cardName; + element.isCurrentSelect = false; + element.currentDateType = element.cardType; + }); + LockUserData data5 = entity.data![4]; + data5.lockUserList?.forEach((element) { + element.currentKeyType = 5; + element.currentKeyTypeStr = '人脸'.tr; + element.currentTypeImg = 'images/icon_face.png'; + element.currentKeyName = element.faceName; + element.isCurrentSelect = false; + element.currentDateType = element.faceType; + }); + + state.lockUserList.value.addAll(data1.lockUserList!); + state.lockUserList.value.addAll(data2.lockUserList!); + state.lockUserList.value.addAll(data3.lockUserList!); + state.lockUserList.value.addAll(data4.lockUserList!); + state.lockUserList.value.addAll(data5.lockUserList!); + + state.lockUserList.refresh(); + } + } + + String getKeyUseDateStr(LockUserListKeys itemData) { + var keyDateTypeStr = ""; + switch (itemData.currentKeyType) { + case 1: //电子钥匙 + keyDateTypeStr = getElectronicKeyUseDateStr(itemData); + break; + case 2: //密码钥匙 + keyDateTypeStr = getPasswordUseDateStr(itemData); + break; + case 3: //指纹钥匙 + keyDateTypeStr = getfingerprintUseDateStr(itemData); + break; + case 4: //卡钥匙 + case 5: //人脸钥匙 + keyDateTypeStr = getCardAndFaceDateType(itemData); + break; + default: + keyDateTypeStr = "".tr; + break; + } + + return keyDateTypeStr; + } + + //获取电子钥匙使用期限 + String getElectronicKeyUseDateStr(LockUserListKeys indexEntity) { + String useDateStr = ''; + if (indexEntity.keyType == XSConstantMacro.keyTypeTime) { + //限期 + DateTime startDateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!); + DateTime endDateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!); + useDateStr = + '${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}'; + } else if (indexEntity.keyType == XSConstantMacro.keyTypeLong) { + //永久 + useDateStr = "永久".tr; + } else if (indexEntity.keyType == XSConstantMacro.keyTypeOnce) { + //单次 + useDateStr = "单次".tr; + } else if (indexEntity.keyType == XSConstantMacro.keyTypeLoop) { + //循环 + useDateStr = '循环'.tr; + } + + return useDateStr; + } + +//获取密码有效期 + String getPasswordUseDateStr(LockUserListKeys itemData) { + int? getPwdType = itemData.keyboardPwdType; + String useDateStr = ''; + DateTime sendDateStr = + DateTime.fromMillisecondsSinceEpoch(itemData.sendDate!); + DateTime startDateStr = + DateTime.fromMillisecondsSinceEpoch(itemData.startDate!); + DateTime endDateStr = + DateTime.fromMillisecondsSinceEpoch(itemData.endDate!); + int starHour = startDateStr.hour; + int endHour = endDateStr.hour; + + // print("sendDateStr.toLocal().toString():${sendDateStr.toLocal().toString()}"); + switch (getPwdType) { + case 1: + //单次 1 只能在开始时间后6小时内使用一次 + useDateStr = "单次".tr; + break; + case 2: + //永久 2 从开始时间开始永久有效,必需在开始时间24小时内使用一次,否则将失效 + useDateStr = "永久".tr; + break; + case 3: + //限期 3 在开始和结束时间内有效,必需在开始时间24小时内使用一次,否则将失效 + useDateStr = + '${startDateStr.toLocal().toString().substring(0, 16)} - ${endDateStr.toLocal().toString().substring(0, 16)} ${"限时".tr} ${itemData.isCustom! == 1 ? "自定义".tr : ""}'; + break; + case 4: + //删除 4 在锁上使用后会删除之前在锁上使用过的密码 + useDateStr = + '${endDateStr.toLocal().toString().substring(0, 16)} ${"清空码".tr}'; + break; + case 5: + //周未循环 5 在周未开始和结束时间指定时间段内有效 + useDateStr = + '${endDateStr.toLocal().toString().substring(0, 16)} ${"周末".tr}$starHour:00-$endHour:00 ${"循环".tr}'; + break; + case 6: + //每日循环 6 每天开始和结束时间指定时间段内有效 + useDateStr = + '${endDateStr.toLocal().toString().substring(0, 16)} ${"每日".tr}$starHour:00-$endHour:00 ${"循环"}'; + break; + case 7: + //工作日循环 7 工作日开始和结束时间指定的时间段内有效 + useDateStr = + '${endDateStr.toLocal().toString().substring(0, 16)} ${"工作日".tr}$starHour:00-$endHour:00 ${"循环".tr}'; + break; + case 8: + //周一循环 8 每周一开始和结束时间指定时间段内有效 + useDateStr = + '${endDateStr.toLocal().toString().substring(0, 16)} ${"周一".tr}$starHour:00-$endHour:00 ${"循环".tr}'; + break; + case 9: + //周二循环 9 每周二开始和结束时间指定时间段内有效 + useDateStr = + '${endDateStr.toLocal().toString().substring(0, 16)} ${"周二".tr}$starHour:00-$endHour:00 ${"循环".tr}'; + break; + case 10: + //周三循环 10 每周三开始和结束时间指定时间段内有效 + useDateStr = + '${endDateStr.toLocal().toString().substring(0, 16)} ${"周三".tr}$starHour:00-$endHour:00 ${"循环".tr}'; + break; + case 11: + //周四循环 11 每周四开始和结束时间指定时间段内有效 + useDateStr = + '${endDateStr.toLocal().toString().substring(0, 16)} ${"周四".tr}$starHour:00-$endHour:00 ${"循环".tr}'; + break; + case 12: + //周五循环 12 每周五开始和结束时间指定时间段内有效 + useDateStr = + '${endDateStr.toLocal().toString().substring(0, 16)} ${"周五".tr}$starHour:00-$endHour:00 ${"循环".tr}'; + break; + case 13: + //周六循环 13 每周六开始和结束时间指定时间段内有效 + useDateStr = + '${endDateStr.toLocal().toString().substring(0, 16)} ${"周六".tr}$starHour:00-$endHour:00 ${"循环".tr}'; + break; + case 14: + //周天循环 14 每周日开始和结束时间指定时间段内有效 + useDateStr = + '${endDateStr.toLocal().toString().substring(0, 16)} ${"周日".tr}$starHour:00-$endHour:00 ${"循环".tr}'; + break; + + default: + } + return useDateStr; + } + +//获取指纹有效期 + String getfingerprintUseDateStr(LockUserListKeys fingerprintItemData) { + var keyDateTypeStr = ""; // 永久:1;限时2,单次3,循环:4 + if (fingerprintItemData.fingerprintType! == 1) { + keyDateTypeStr = "永久".tr; + } else if (fingerprintItemData.fingerprintType! == 2) { + keyDateTypeStr = + "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())} 限时"; + } else if (fingerprintItemData.fingerprintType! == 4) { + keyDateTypeStr = + "${DateTool().dateToYMDString(fingerprintItemData.startDate.toString())}-${DateTool().dateToYMDString(fingerprintItemData.endDate.toString())} 循环"; + } + return keyDateTypeStr; + } + +//获取卡片/人脸有效期 + String getCardAndFaceDateType(LockUserListKeys fingerprintItemData) { + var keyDateTypeStr = ""; // 永久:1;限时2,单次3,循环:4 + if (fingerprintItemData.cardType! == 1) { + keyDateTypeStr = "永久".tr; + } else if (fingerprintItemData.cardType! == 2) { + keyDateTypeStr = + "${DateTool().dateToYMDHNString(fingerprintItemData.startDate.toString())} - ${DateTool().dateToYMDHNString(fingerprintItemData.endDate.toString())} 限时"; + } else if (fingerprintItemData.cardType! == 4) { + keyDateTypeStr = + "${DateTool().dateToYMDString(fingerprintItemData.startDate.toString())}-${DateTool().dateToYMDString(fingerprintItemData.endDate.toString())} 循环"; + } + return keyDateTypeStr; } } diff --git a/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_page.dart b/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_page.dart index 32f102e3..9ee4e406 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_page.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_page.dart @@ -1,11 +1,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_entity.dart'; import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_logic.dart'; +import 'package:star_lock/tools/keySearchWidget.dart'; import '../../../../app_settings/app_colors.dart'; import '../../../../tools/submitBtn.dart'; import '../../../../tools/titleAppBar.dart'; -import '../../../../translations/trans_lib.dart'; class LockUserPage extends StatefulWidget { const LockUserPage({Key? key}) : super(key: key); @@ -22,7 +23,7 @@ class _LockUserPageState extends State { initState() { super.initState(); - logic.getLockNoticeSetting(); + logic.getLockKeysList(); } @override @@ -36,14 +37,24 @@ class _LockUserPageState extends State { ), body: Column( children: [ - _searchWidget(), + KeySearchWidget( + editingController: state.searchController, + onSubmittedAction: () { + logic.pageNo = 1; + logic.getLockKeysList(); + }, + ), SizedBox( height: 20.h, ), Expanded(child: _buildMainUI()), SubmitBtn( btnName: '确定'.tr, - onClick: () {}, + onClick: () { + Get.back( + result: + state.lockUserList.value[state.isSelectIndex.value]); + }, ), SizedBox( height: 64.h, @@ -52,66 +63,40 @@ class _LockUserPageState extends State { )); } - Widget _searchWidget() { - return Container( - height: 60.h, - margin: EdgeInsets.only(top: 20.w, left: 20.w, right: 10.w), - decoration: BoxDecoration( - color: Colors.white, borderRadius: BorderRadius.circular(5)), - child: TextField( - //输入框一行 - maxLines: 1, - // controller: _controller, - autofocus: false, - controller: state.searchController, - onSubmitted: (value) {}, - decoration: InputDecoration( - //输入里面输入文字内边距设置 - contentPadding: const EdgeInsets.only( - top: 12.0, left: -19.0, right: -15.0, bottom: 8.0), - hintText: TranslationLoader.lanKeys!.pleaseEnter!.tr, - hintStyle: TextStyle(fontSize: 22.sp, height: 3.0), - //不需要输入框下划线 - border: InputBorder.none, - //左边图标设置 - icon: Padding( - padding: EdgeInsets.only( - top: 20.h, bottom: 20.h, right: 20.w, left: 10.w), - child: Image.asset( - 'images/main/icon_main_search.png', - width: 40.w, - height: 40.w, - ), - ), - ), - ), - ); + Widget _buildMainUI() { + return Obx(() => ListView.separated( + shrinkWrap: true, + itemCount: state.lockUserList.value.length, + itemBuilder: (c, index) { + return _electronicKeyItem(state.lockUserList.value[index], index); + }, + separatorBuilder: (BuildContext context, int index) { + return const Divider( + height: 1, + color: AppColors.greyLineColor, + ); + }, + )); } - Widget _buildMainUI() { - return ListView.separated( - shrinkWrap: true, - itemCount: 3, - itemBuilder: (c, index) { - return _electronicKeyItem('images/controls_user.png', '我', '永久', () { - state.isCheck.value = !state.isCheck.value; + Widget _electronicKeyItem(LockUserListKeys lockUserKeys, int selectIndex) { + return GestureDetector( + onTap: () { + for (int i = 0; i < state.lockUserList.value.length; i++) { + LockUserListKeys item = state.lockUserList.value[i]; + if (selectIndex == i) { + item.isCurrentSelect = true; + } else { + item.isCurrentSelect = true; + } + } + setState(() { + state.isSelectIndex.value = selectIndex; }); }, - separatorBuilder: (BuildContext context, int index) { - return const Divider( - height: 1, - color: AppColors.greyLineColor, - ); - }, - ); - } - - Widget _electronicKeyItem( - String avatarURL, String receiveUser, String useDate, Function() action) { - return GestureDetector( - onTap: action, child: Container( color: Colors.white, + width: 1.sw, height: 90.h, child: Row( children: [ @@ -119,7 +104,7 @@ class _LockUserPageState extends State { width: 30.w, ), Image.asset( - avatarURL, + lockUserKeys.currentTypeImg ?? 'images/controls_user.png', width: 60.w, height: 60.w, ), @@ -134,7 +119,7 @@ class _LockUserPageState extends State { // mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - receiveUser, + lockUserKeys.currentKeyName ?? '未知', style: TextStyle( fontSize: 24.sp, color: AppColors.blackColor), ), @@ -150,7 +135,7 @@ class _LockUserPageState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - useDate, + logic.getKeyUseDateStr(lockUserKeys), style: TextStyle( fontSize: 18.sp, color: AppColors.placeholderTextColor), @@ -161,13 +146,13 @@ class _LockUserPageState extends State { ], ), ), - Obx(() => Image.asset( - state.isCheck.value == true - ? 'images/icon_round_select.png' - : 'images/icon_round_unSelect.png', - width: 30.w, - height: 30.w, - )), + Image.asset( + state.isSelectIndex.value == selectIndex + ? 'images/icon_round_select.png' + : 'images/icon_round_unSelect.png', + width: 30.w, + height: 30.w, + ), SizedBox(width: 20.h), ], ), diff --git a/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_state.dart b/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_state.dart index 6f56953d..1efc82ee 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_state.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_state.dart @@ -1,10 +1,14 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_entity.dart'; class LockUserState { TextEditingController searchController = TextEditingController(); //邮箱/手机号输入框 - var isCheck = false.obs; + var isSelectUser = false.obs; + var isSelectIndex = 0.obs; + var getLockId = 0.obs; + var lockUserList = [].obs; //锁所有用户列表 LockUserState() { Map map = Get.arguments; diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/lowBatteryReminder/lowBatteryReminder_page.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/lowBatteryReminder/lowBatteryReminder_page.dart index 7bdc2f5f..e6c715f5 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/lowBatteryReminder/lowBatteryReminder_page.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/lowBatteryReminder/lowBatteryReminder_page.dart @@ -26,7 +26,7 @@ class _LowBatteryReminderPageState extends State { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( - barTitle: '低电量提醒', + barTitle: '低电量提醒'.tr, haveBack: true, backgroundColor: AppColors.mainColor), body: Container( @@ -48,7 +48,7 @@ class _LowBatteryReminderPageState extends State { height: 20.h, ), CommonItem( - leftTitel: '低电量提醒', + leftTitel: '低电量提醒'.tr, rightTitle: '', isHaveLine: true, isHaveDirection: false, @@ -68,7 +68,7 @@ class _LowBatteryReminderPageState extends State { child: Column( children: [ CommonItem( - leftTitel: '提醒方式', + leftTitel: '提醒方式'.tr, rightTitle: "", isHaveLine: false, isHaveRightWidget: false, @@ -104,7 +104,7 @@ class _LowBatteryReminderPageState extends State { height: 20.h, )), SubmitBtn( - btnName: '保存', + btnName: '保存'.tr, onClick: () {}, ), SizedBox( diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_page.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_page.dart index c446f788..0fe9b209 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_page.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_page.dart @@ -46,7 +46,7 @@ class _MsgNotificationPageState extends State { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( - barTitle: '消息提醒', + barTitle: '消息提醒'.tr, haveBack: true, backgroundColor: AppColors.mainColor), body: SingleChildScrollView( @@ -72,7 +72,7 @@ class _MsgNotificationPageState extends State { // height: 1, // ), CommonItem( - leftTitel: '开门通知', + leftTitel: '开门通知'.tr, rightTitle: "", isHaveLine: true, isHaveDirection: true, @@ -84,7 +84,7 @@ class _MsgNotificationPageState extends State { }, ), Obx(() => CommonItem( - leftTitel: 'N天未开门', + leftTitel: 'N天未开门'.tr, rightTitle: state.nDaysNotOpenDoor.value, isHaveLine: true, isHaveDirection: true, @@ -103,14 +103,14 @@ class _MsgNotificationPageState extends State { // rightWidget: // SizedBox(width: 60.w, height: 50.h, child: _switch(1)))), Obx(() => CommonItem( - leftTitel: '门未关好', + leftTitel: '门未关好'.tr, rightTitle: "", isHaveLine: true, isHaveRightWidget: true, rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch(2)))), Obx(() => CommonItem( - leftTitel: '防拆报警', + leftTitel: '防拆报警'.tr, rightTitle: '', isHaveLine: true, isHaveRightWidget: true, @@ -120,7 +120,7 @@ class _MsgNotificationPageState extends State { child: _switch(5), ))), Obx(() => CommonItem( - leftTitel: '低电量提醒', + leftTitel: '低电量提醒'.tr, rightTitle: state.isLowBattery.value, isHaveLine: true, isHaveDirection: true, @@ -129,7 +129,7 @@ class _MsgNotificationPageState extends State { }, )), CommonItem( - leftTitel: '胁迫开门', + leftTitel: '胁迫开门'.tr, rightTitle: "", isHaveLine: true, isHaveDirection: true, @@ -149,7 +149,7 @@ class _MsgNotificationPageState extends State { height: 10.h, ), Obx(() => CommonItem( - leftTitel: '有人按门铃', + leftTitel: '有人按门铃'.tr, rightTitle: "", isHaveLine: true, isHaveRightWidget: true, @@ -167,7 +167,7 @@ class _MsgNotificationPageState extends State { height: 10.h, ), Obx(() => CommonItem( - leftTitel: '有人出现在门口', + leftTitel: '有人出现在门口'.tr, rightTitle: "", isHaveLine: true, isHaveRightWidget: true, diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_page.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_page.dart index 22517e5c..b59ffcca 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_page.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_page.dart @@ -29,7 +29,7 @@ class _OpenDoorNotifyPageState extends State { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( - barTitle: '家人到家', + barTitle: '家人到家'.tr, haveBack: true, backgroundColor: AppColors.mainColor, ), @@ -41,7 +41,7 @@ class _OpenDoorNotifyPageState extends State { ), Expanded(child: _buildMainUI()), AddBottomWhiteBtn( - btnName: '添加家人', + btnName: '添加家人'.tr, onClick: () { Get.toNamed(Routers.addFamilyPage, arguments: {'getLockId': state.getLockId.value}); @@ -59,7 +59,7 @@ class _OpenDoorNotifyPageState extends State { alignment: Alignment.centerLeft, margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 20.w), child: Text( - '若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择', + '若锁没有联网,除电子钥匙外,密码、卡、指纹等开门提醒无法及时发送,请根据你的实际情况选择'.tr, style: TextStyle(color: AppColors.darkGrayTextColor, fontSize: 20.sp), )); } diff --git a/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart b/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart index fba5c8f6..f267e5be 100644 --- a/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart +++ b/star_lock/lib/main/lockDetail/monitoring/monitoring/lockMonitoring_page.dart @@ -58,7 +58,7 @@ class _LockMonitoringPageState extends State { gaplessPlayback: true, width: 1.sw, height: 1.sh, - fit: BoxFit.none, + fit: BoxFit.cover, //contain-原比例 none-原始图片 filterQuality: FilterQuality.high, errorBuilder: (context, error, stackTrace) { return Container(color: Colors.transparent); diff --git a/star_lock/lib/talk/udp/udp_manage.dart b/star_lock/lib/talk/udp/udp_manage.dart index d6941c7a..2960de4d 100644 --- a/star_lock/lib/talk/udp/udp_manage.dart +++ b/star_lock/lib/talk/udp/udp_manage.dart @@ -42,7 +42,6 @@ class UDPManage { int remoteUnlock = 0; // 是否远程开锁 1:开启 0:关闭 void initUdp() async { - // if (host != '') { var listAddress = InternetAddress.lookup(host); listAddress.then((list) { list.forEach((element) { @@ -50,17 +49,16 @@ class UDPManage { host = element.address; }); }); - // } await _initUdp(); } - Future _initUdp() async { + Future _initUdp() async { if (port == 0) { - print('❌ Udp ----> _port == 0'); + // print('❌ Udp ----> _port == 0'); return; } - print('Udp ----> host:$host port:$port'); + // print('Udp ----> host:$host port:$port'); var addressIListenFrom = InternetAddress.anyIPv4; int portIListenOn = 62288; RawDatagramSocket.bind(addressIListenFrom, portIListenOn) @@ -91,7 +89,7 @@ class UDPManage { void sendData(List data) { if (null == _udpSocket || null == data || data.isEmpty || host == '') { if (null == _udpSocket) { - print('❌ Udp ----> null == _udpSocket'); + // print('❌ Udp ----> null == _udpSocket'); initUdp(); } return;