diff --git a/star_lock/images/lan/lan_en.json b/star_lock/images/lan/lan_en.json index eabf1dd9..2b11ca5c 100644 --- a/star_lock/images/lan/lan_en.json +++ b/star_lock/images/lan/lan_en.json @@ -772,5 +772,12 @@ "关锁":"关锁", "功能":"功能", "配件":"配件", - "N天未开门提醒":"N days did not open the door reminder" + "N天未开门提醒":"N days did not open the door reminder", + "当被胁迫要求强行开锁时,使用胁迫指纹会触发报警,报警消息会推送给管理员,该功能需要锁联网":"When forced to open the lock, the use of coercive fingerprint will trigger the alarm, the alarm message will be pushed to the administrator, the function requires the lock network", + "胁迫指纹":"Stress fingerprint", + "指纹列表":"Fingerprint list", + "经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网":"After the above set time, the lock is not opened, the system will send a reminder message to the specified object, this function requires the lock network", + "打开提醒后,当锁电量低于20%、10%和5%,系统会给指定对象发送提醒消息。电量读取方式:网关读取或APP读取。":"After the reminder is enabled, when the lock power is below 20%, 10%, and 5%, the system will send a reminder message to the specified object. Power reading mode: gateway reading or APP reading.", + "门未开时间":"Door not open time", + "添加和使用面容开锁时:":"Add and use Face when unlocking:" } diff --git a/star_lock/images/lan/lan_keys.json b/star_lock/images/lan/lan_keys.json index 30a992c3..1a9e0990 100644 --- a/star_lock/images/lan/lan_keys.json +++ b/star_lock/images/lan/lan_keys.json @@ -771,5 +771,12 @@ "关锁":"Close Lock", "功能":"Function", "配件":"Parts", - "N天未开门提醒":"N天未开门提醒" + "N天未开门提醒":"N天未开门提醒", + "当被胁迫要求强行开锁时,使用胁迫指纹会触发报警,报警消息会推送给管理员,该功能需要锁联网":"当被胁迫要求强行开锁时,使用胁迫指纹会触发报警,报警消息会推送给管理员,该功能需要锁联网", + "胁迫指纹":"胁迫指纹", + "指纹列表":"指纹列表", + "经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网":"经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网", + "打开提醒后,当锁电量低于20%、10%和5%,系统会给指定对象发送提醒消息。电量读取方式:网关读取或APP读取。":"打开提醒后,当锁电量低于20%、10%和5%,系统会给指定对象发送提醒消息。电量读取方式:网关读取或APP读取。", + "门未开时间":"门未开时间", + "添加和使用面容开锁时:":"添加和使用面容开锁时:" } diff --git a/star_lock/images/lan/lan_zh.json b/star_lock/images/lan/lan_zh.json index fce57f55..12cbd4d7 100644 --- a/star_lock/images/lan/lan_zh.json +++ b/star_lock/images/lan/lan_zh.json @@ -774,5 +774,12 @@ "关锁":"关锁", "功能":"功能", "配件":"配件", - "N天未开门提醒":"N天未开门提醒" + "N天未开门提醒":"N天未开门提醒", + "当被胁迫要求强行开锁时,使用胁迫指纹会触发报警,报警消息会推送给管理员,该功能需要锁联网":"当被胁迫要求强行开锁时,使用胁迫指纹会触发报警,报警消息会推送给管理员,该功能需要锁联网", + "胁迫指纹":"胁迫指纹", + "指纹列表":"指纹列表", + "经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网":"经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网", + "打开提醒后,当锁电量低于20%、10%和5%,系统会给指定对象发送提醒消息。电量读取方式:网关读取或APP读取。":"打开提醒后,当锁电量低于20%、10%和5%,系统会给指定对象发送提醒消息。电量读取方式:网关读取或APP读取。", + "门未开时间":"门未开时间", + "添加和使用面容开锁时:":"添加和使用面容开锁时:" } 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 1d8af4f9..68b14f94 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_page.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/lockUser/lockUser_page.dart @@ -116,7 +116,6 @@ class _LockUserPageState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( lockUserKeys.currentKeyName ?? '', diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprint/coerceFingerprint_logic.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprint/coerceFingerprint_logic.dart index e69de29b..a8060112 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprint/coerceFingerprint_logic.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprint/coerceFingerprint_logic.dart @@ -0,0 +1,147 @@ +import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprint/coerceFingerprint_state.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_entity.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/notificationMode/notificationMode_data.dart'; +import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; + +class CoerceFingerprintLogic extends BaseGetXController { + final CoerceFingerprintState state = CoerceFingerprintState(); + +//添加胁迫开门通知 + void addLockNoticeSetting() async { + var entity = await ApiRepository.to.addLockNoticeSetting( + lockId: state.getLockId.value, + noticeType: 20, + settingValue: { + 'openDoorId': state.fingerprintData.value.fingerprintId, + 'openDoorType': 4, + 'remark': state.fingerprintData.value.fingerprintName ?? '', + 'noticeWay': [ + {'type': 'mail', 'accounts': getEmailAndSMSAccountList(true)}, + {'type': 'sms', 'accounts': getEmailAndSMSAccountList(false)} + ] + }, + ); + if (entity.errorCode!.codeIsSuccessful) { + showToast('添加成功'.tr); + Get.back(result: true); + } + } + + //删除开门通知 + void deleteLockNoticeSetting() async { + var entity = await ApiRepository.to.deleteLockNoticeSettingAccount( + lockNoticeSettingAccountId: state.familyData.value.id!, + ); + if (entity.errorCode!.codeIsSuccessful) { + showToast('删除成功'.tr); + Get.back(result: true); + } + } + +//获取到家人信息的请求数组 + List getEmailAndSMSAccountList(bool isEmail) { + List list = []; + List accountList = []; + isEmail + ? accountList = state.emailReceiverList.value + : accountList = state.phoneReceiverList.value; + for (int i = 0; i < accountList.length; i++) { + MsgNoticeModeData item = accountList[i]; + Map map = {}; + map['countryCode'] = isEmail ? 0 : item.countryCode; + map['account'] = isEmail ? item.receiveEmail : item.receivePhone; + list.add(map); + } + return list; + } + + String getEmailListStr(Map val) { + String emailListStr = ''; + if (val['emailReceiverList'] != null) { + state.emailReceiverList.value = val['emailReceiverList']; + List emailReceiverList = state.emailReceiverList.value; + for (int i = 0; i < emailReceiverList.length; i++) { + MsgNoticeModeData item = emailReceiverList[i]; + emailListStr += item.receiveEmail; + // 检查是否为最后一个元素 + if (i < emailReceiverList.length - 1) { + emailListStr += ','; + } + } + } + return emailListStr; + } + + String getPhoneListStr(Map val) { + String phoneListStr = ''; + + if (val['phoneReceiverList'] != null) { + state.phoneReceiverList.value = val['phoneReceiverList']; + List phoneReceiverList = state.phoneReceiverList.value; + for (int i = 0; i < phoneReceiverList.length; i++) { + MsgNoticeModeData item = phoneReceiverList[i]; + phoneListStr += item.receivePhone; + // 检查是否为最后一个元素 + if (i < phoneReceiverList.length - 1) { + phoneListStr += ','; + } + } + } + return phoneListStr; + } + + //检查按钮是否可用 + bool checkBtnDisable() { + // if ((state.emailListStr.value.isEmpty || + // state.phontListStr.value.isEmpty)) { + // return false; + // } else { + // return true; + // } + return true; + } + + //根据列表返回值得到邮箱、手机列表 + Map> getAccountsMap() { + List mailAccounts = []; + List smsAccounts = []; + + if (state.familyData.value.settingValue != null) { + for (NoticeWay item + in state.familyData.value.settingValue!.noticeWayList!) { + if (item.type == 'mail' && item.accounts != null) { + for (Accounts account in item.accounts!) { + if (account.account != null) { + MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData(); + msgNoticeModeData.receiveEmail = account.account!; + mailAccounts.add(msgNoticeModeData); + } + } + } else if (item.type == 'sms' && item.accounts != null) { + for (Accounts account in item.accounts!) { + if (account.account != null && account.countryCode != null) { + MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData(); + msgNoticeModeData.receivePhone = account.account!; + msgNoticeModeData.countryCode = account.countryCode!; + smsAccounts.add(msgNoticeModeData); + } + } + } + } + } + + return { + 'emailReceiverList': mailAccounts, + 'phoneReceiverList': smsAccounts, + }; + } + + @override + onInit() { + super.onInit(); + state.emailListStr.value = getEmailListStr(getAccountsMap()); + state.phontListStr.value = getPhoneListStr(getAccountsMap()); + } +} diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprint/coerceFingerprint_page.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprint/coerceFingerprint_page.dart index cbdb6227..36b0c3f4 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprint/coerceFingerprint_page.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprint/coerceFingerprint_page.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprint/coerceFingerprint_logic.dart'; import 'package:star_lock/tools/commonItem.dart'; import 'package:star_lock/tools/submitBtn.dart'; @@ -16,27 +17,39 @@ class CoerceFingerprintPage extends StatefulWidget { } class _CoerceFingerprintPageState extends State { + final logic = Get.put(CoerceFingerprintLogic()); + final state = Get.find().state; + @override Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( - barTitle: '胁迫指纹', + barTitle: state.isDetail.value == true ? '指纹详情'.tr : '胁迫指纹'.tr, haveBack: true, backgroundColor: AppColors.mainColor), body: Container( padding: EdgeInsets.all(30.w), child: Column( children: [ - CommonItem( - leftTitel: '胁迫指纹', - rightTitle: '请选择', - isHaveLine: true, - isHaveDirection: true, - action: () { - //锁用户 - Get.toNamed(Routers.coerceFingerprintListPage); - }), + Obx(() => CommonItem( + leftTitel: '胁迫指纹'.tr, + rightTitle: state.isDetail.value == true + ? state.familyData.value.settingValue!.remark! + : state.fingerprintData.value.fingerprintName ?? '请选择'.tr, + isHaveLine: true, + isHaveDirection: true, + action: () { + //锁用户 + Get.toNamed(Routers.coerceFingerprintListPage, + arguments: {'lockId': state.getLockId.value}) + ?.then((val) { + if (val != null) { + state.fingerprintData.value = val; + } + }); + }, + )), SizedBox( height: 20.h, ), @@ -45,29 +58,44 @@ class _CoerceFingerprintPageState extends State { margin: EdgeInsets.only(bottom: 10.h), child: Column( children: [ - CommonItem( - leftTitel: '提醒方式'.tr, - rightTitle: "", - isHaveLine: false, - isHaveRightWidget: false, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.notificationModePage); + GestureDetector( + onTap: () { + Get.toNamed(Routers.notificationModePage, + arguments: {'familyData': state.familyData.value}) + ?.then((val) { + if (val != null) { + state.emailListStr.value = logic.getEmailListStr(val); + state.phontListStr.value = logic.getPhoneListStr(val); + print( + 'emailListStr:${state.emailListStr.value},phontListStr:${state.phontListStr.value}'); + } + }); }, + child: Container( + color: Colors.white, + margin: EdgeInsets.only(bottom: 10.h), + child: Column( + children: [ + CommonItem( + leftTitel: '提醒方式'.tr, + rightTitle: "", + isHaveLine: false, + isHaveRightWidget: false, + isHaveDirection: true, + ), + _buildNotifyContain('APP推送'.tr, '管理员'.tr), + Obx(() => state.emailListStr.value.isNotEmpty + ? _buildNotifyContain( + '邮件提醒'.tr, state.emailListStr.value) + : Container()), + Obx(() => state.phontListStr.value.isNotEmpty + ? _buildNotifyContain( + '短信提醒'.tr, state.phontListStr.value) + : Container()), + ], + ), + ), ), - Container( - padding: EdgeInsets.only( - left: 10.w, right: 10.w, top: 12.h, bottom: 12.h), - margin: EdgeInsets.only(bottom: 20.h, top: 10.h), - decoration: BoxDecoration( - color: AppColors.mainBackgroundColor, - borderRadius: BorderRadius.circular(6.0.w), - ), - child: Text( - 'APP推送 管理员', - style: TextStyle(color: Colors.black, fontSize: 20.sp), - ), - ) ], ), ), @@ -75,11 +103,20 @@ class _CoerceFingerprintPageState extends State { child: SizedBox( height: 40.h, )), - SubmitBtn( - btnName: '保存', - isDisabled: false, - onClick: () {}, - ), + Obx(() => SubmitBtn( + btnName: state.isDetail.value == true ? '删除'.tr : '保存'.tr, + isDisabled: state.isDetail.value == true + ? true + : logic.checkBtnDisable(), + isDelete: state.isDetail.value, + onClick: () { + if (state.isDetail.value) { + logic.deleteLockNoticeSetting(); + } else { + logic.addLockNoticeSetting(); + } + }, + )), SizedBox( height: 60.h, ) @@ -88,4 +125,32 @@ class _CoerceFingerprintPageState extends State { ), ); } + + Widget _buildNotifyContain(String notifyTitle, String notifyContent) { + return Container( + padding: + EdgeInsets.only(left: 10.w, right: 10.w, top: 12.h, bottom: 12.h), + margin: EdgeInsets.only(bottom: 20.h, top: 10.h, left: 20.w, right: 20.w), + decoration: BoxDecoration( + color: AppColors.mainBackgroundColor, + borderRadius: BorderRadius.circular(6.0.w), + ), + child: Row( + children: [ + Text( + notifyTitle, + style: TextStyle(color: Colors.black, fontSize: 20.sp), + ), + Expanded( + child: SizedBox( + width: 20.w, + )), + Text(notifyContent, + textAlign: TextAlign.end, + style: TextStyle( + color: AppColors.placeholderTextColor, fontSize: 20.sp)), + ], + ), + ); + } } diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprint/coerceFingerprint_state.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprint/coerceFingerprint_state.dart index e69de29b..97ca0573 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprint/coerceFingerprint_state.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprint/coerceFingerprint_state.dart @@ -0,0 +1,32 @@ +import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_entity.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_entity.dart'; + +class CoerceFingerprintState { + var pageNum = 1.obs; //请求页码 + final pageSize = 20.obs; //请求每页数据条数 + final itemDataList = [].obs; + var getLockId = 0.obs; + var fingerprintData = CoerceFingerprintItemData().obs; + var emailReceiverList = [].obs; + var phoneReceiverList = [].obs; + var emailListStr = ''.obs; + var phontListStr = ''.obs; + var isDetail = false.obs; + var familyData = DataList().obs; + + CoerceFingerprintState() { + Map map = Get.arguments; + if (map['lockId'] != null) { + getLockId.value = map['lockId']; + } + + if (map['isDetail'] != null) { + isDetail.value = map['isDetail']; + } + + if (map['itemData'] != null) { + familyData.value = map['itemData']; + } + } +} diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_entity.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_entity.dart new file mode 100644 index 00000000..c82534e2 --- /dev/null +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_entity.dart @@ -0,0 +1,145 @@ +import 'dart:core'; + +class CoerceFingerprintListEntity { + int? errorCode; + String? description; + String? errorMsg; + Data? data; + + CoerceFingerprintListEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + CoerceFingerprintListEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null ? Data.fromJson(json['data']) : null; + } + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} + +class Data { + List? list; + int? pageNo; + int? pageSize; + int? pages; + int? total; + + Data({this.list, this.pageNo, this.pageSize, this.pages, this.total}); + + Data.fromJson(Map json) { + if (json['list'] != null) { + list = []; + json['list'].forEach((v) { + list!.add(CoerceFingerprintItemData.fromJson(v)); + }); + } + pageNo = json['pageNo']; + pageSize = json['pageSize']; + pages = json['pages']; + total = json['total']; + } + + Map toJson() { + final Map data = {}; + if (list != null) { + data['list'] = list!.map((v) => v.toJson()).toList(); + } + data['pageNo'] = pageNo; + data['pageSize'] = pageSize; + data['pages'] = pages; + data['total'] = total; + return data; + } +} + +class CoerceFingerprintItemData { + int? lockId; + int? apiUserId; + String? fingerprintNumber; + int? fingerprintType; + String? fingerprintName; + int? startDate; + int? endDate; + List? weekDay; + int? fingerprintStatus; + int? isCoerced; + int? fingerRight; + int? fingerprintId; + String? senderUsername; + int? createDate; + String? validTimeStr; + bool? isCurrentSelect = false; + + CoerceFingerprintItemData( + {this.lockId, + this.apiUserId, + this.fingerprintNumber, + this.fingerprintType, + this.fingerprintName, + this.startDate, + this.endDate, + this.weekDay, + this.fingerprintStatus, + this.isCoerced, + this.fingerRight, + this.fingerprintId, + this.senderUsername, + this.createDate, + this.validTimeStr}); + + CoerceFingerprintItemData.fromJson(Map json) { + lockId = json['lockId']; + apiUserId = json['apiUserId']; + fingerprintNumber = json['fingerprintNumber']; + fingerprintType = json['fingerprintType']; + fingerprintName = json['fingerprintName']; + startDate = json['startDate']; + endDate = json['endDate']; + if (json['weekDay'] != null) { + weekDay = []; + json['weekDay'].forEach((v) { + weekDay!.add(v); + }); + } + fingerprintStatus = json['fingerprintStatus']; + isCoerced = json['isCoerced']; + fingerRight = json['fingerRight']; + fingerprintId = json['fingerprintId']; + senderUsername = json['senderUsername']; + createDate = json['createDate']; + validTimeStr = json['validTimeStr']; + } + + Map toJson() { + final Map data = {}; + data['lockId'] = lockId; + data['apiUserId'] = apiUserId; + data['fingerprintNumber'] = fingerprintNumber; + data['fingerprintType'] = fingerprintType; + data['fingerprintName'] = fingerprintName; + data['startDate'] = startDate; + data['endDate'] = endDate; + if (weekDay != null) { + data['weekDay'] = weekDay!.map((v) => v.toJson()).toList(); + } + data['fingerprintStatus'] = fingerprintStatus; + data['isCoerced'] = isCoerced; + data['fingerRight'] = fingerRight; + data['fingerprintId'] = fingerprintId; + data['senderUsername'] = senderUsername; + data['createDate'] = createDate; + data['validTimeStr'] = validTimeStr; + return data; + } +} diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_logic.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_logic.dart index 038090c1..4a17b077 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_logic.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_logic.dart @@ -1,6 +1,39 @@ +import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_entity.dart'; import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_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 CoerceFingerprintListLogic extends BaseGetXController { final CoerceFingerprintListState state = CoerceFingerprintListState(); + + // 锁用户列表 + void getCoercedFingerprintList() async { + var entity = await ApiRepository.to.getCoercedFingerprintList( + lockId: state.getLockId.value, + pageNo: state.pageNum.value, + pageSize: state.pageSize.value, + ); + if (entity.errorCode!.codeIsSuccessful) { + state.fingerprintList.value = entity.data!.list!; + state.fingerprintList.refresh(); + } + } + + //获取指纹有效期 + String getfingerprintUseDateStr( + CoerceFingerprintItemData 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; + } } diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_page.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_page.dart index 5fcf84e0..dc1e5d52 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_page.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_page.dart @@ -1,12 +1,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_entity.dart'; import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_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 CoerceFingerprintListPage extends StatefulWidget { const CoerceFingerprintListPage({Key? key}) : super(key: key); @@ -20,25 +21,41 @@ class _CoerceFingerprintListPageState extends State { final logic = Get.put(CoerceFingerprintListLogic()); final state = Get.find().state; + @override + initState() { + super.initState(); + logic.getCoercedFingerprintList(); + } + @override Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( - barTitle: '指纹列表', + barTitle: '指纹列表'.tr, haveBack: true, backgroundColor: AppColors.mainColor, ), body: Column( children: [ - _searchWidget(), + KeySearchWidget( + editingController: state.searchController, + onSubmittedAction: () { + logic.pageNo = 1; + logic.getCoercedFingerprintList(); + }, + ), SizedBox( height: 20.h, ), - Expanded(child: _buildMainUI()), + Expanded(child: Obx(() => _buildMainUI())), SubmitBtn( - btnName: '确定', - onClick: () {}, + btnName: '确定'.tr, + onClick: () { + Get.back( + result: + state.fingerprintList.value[state.isSelectIndex.value]); + }, ), SizedBox( height: 64.h, @@ -47,50 +64,12 @@ class _CoerceFingerprintListPageState 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 ListView.separated( shrinkWrap: true, - itemCount: 3, + itemCount: state.fingerprintList.length, itemBuilder: (c, index) { - return _electronicKeyItem('images/icon_fingerprint.png', '我', '永久', () { - state.isCheck.value = !state.isCheck.value; - }); + return _electronicKeyItem(state.fingerprintList[index], index); }, separatorBuilder: (BuildContext context, int index) { return const Divider( @@ -102,9 +81,21 @@ class _CoerceFingerprintListPageState extends State { } Widget _electronicKeyItem( - String avatarURL, String receiveUser, String useDate, Function() action) { + CoerceFingerprintItemData itemData, int selectIndex) { return GestureDetector( - onTap: action, + onTap: () { + for (int i = 0; i < state.fingerprintList.value.length; i++) { + CoerceFingerprintItemData item = state.fingerprintList.value[i]; + if (selectIndex == i) { + item.isCurrentSelect = true; + } else { + item.isCurrentSelect = true; + } + } + setState(() { + state.isSelectIndex.value = selectIndex; + }); + }, child: Container( color: Colors.white, height: 90.h, @@ -114,7 +105,7 @@ class _CoerceFingerprintListPageState extends State { width: 30.w, ), Image.asset( - avatarURL, + 'images/icon_fingerprint.png', width: 60.w, height: 60.w, ), @@ -126,10 +117,9 @@ class _CoerceFingerprintListPageState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - receiveUser, + itemData.fingerprintName ?? '', style: TextStyle( fontSize: 24.sp, color: AppColors.blackColor), ), @@ -145,7 +135,7 @@ class _CoerceFingerprintListPageState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - useDate, + logic.getfingerprintUseDateStr(itemData), style: TextStyle( fontSize: 18.sp, color: AppColors.placeholderTextColor), @@ -156,13 +146,13 @@ class _CoerceFingerprintListPageState 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/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_state.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_state.dart index 4778129c..97c6c736 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_state.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_state.dart @@ -3,5 +3,16 @@ import 'package:get/get.dart'; class CoerceFingerprintListState { TextEditingController searchController = TextEditingController(); //邮箱/手机号输入框 - var isCheck = false.obs; + var isSelectIndex = 0.obs; + var getLockId = 0.obs; + var fingerprintList = [].obs; //指纹列表 + var pageNum = 1.obs; //请求页码 + var pageSize = 20.obs; //请求每页数据条数 + + CoerceFingerprintListState() { + Map map = Get.arguments; + if (map['lockId'] != null) { + getLockId.value = map['lockId']; + } + } } diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceOpenDoor/coerceOpenDoor_logic.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceOpenDoor/coerceOpenDoor_logic.dart index dbd8306c..9302a21a 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceOpenDoor/coerceOpenDoor_logic.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceOpenDoor/coerceOpenDoor_logic.dart @@ -1,7 +1,40 @@ +import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_entity.dart'; +import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'coerceOpenDoor_state.dart'; class CoerceOpenDoorLogic extends BaseGetXController { final CoerceOpenDoorState state = CoerceOpenDoorState(); + + void lockNoticeSettingAccountList() async { + OpenDoorNotifyEntity entity = + await ApiRepository.to.lockNoticeSettingAccountList( + lockId: state.getLockId.value, + noticeType: 20, + ); + if (entity.errorCode!.codeIsSuccessful) { + state.itemDataList.value = entity.data!.list!; + state.itemDataList.refresh(); + } + } + + //当前钥匙类型 1:电子钥匙 2:密码钥匙 3:指纹钥匙 4:卡钥匙 5:人脸钥匙 + String getKeyTypeStr(DataList itemData) { + int keyType = itemData.settingValue!.openDoorType!; + switch (keyType) { + case 1: + return '电子钥匙'; + case 2: + return '密码'; + case 3: + return '指纹'; + case 4: + return '卡'; + case 5: + return '人脸'; + default: + return ''; + } + } } diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceOpenDoor/coerceOpenDoor_page.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceOpenDoor/coerceOpenDoor_page.dart index 4171e4de..a7f88a61 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceOpenDoor/coerceOpenDoor_page.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceOpenDoor/coerceOpenDoor_page.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:star_lock/appRouters.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_entity.dart'; +import 'package:star_lock/tools/noData.dart'; import '../../../../../../app_settings/app_colors.dart'; import '../../../../../../tools/submitBtn.dart'; @@ -22,6 +24,8 @@ class _CoerceOpenDoorPageState extends State { @override void initState() { super.initState(); + + logic.lockNoticeSettingAccountList(); } @override @@ -29,7 +33,7 @@ class _CoerceOpenDoorPageState extends State { return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( - barTitle: '胁迫开门', + barTitle: '胁迫开门'.tr, haveBack: true, backgroundColor: AppColors.mainColor, ), @@ -39,15 +43,21 @@ class _CoerceOpenDoorPageState extends State { SizedBox( height: 20.h, ), - Expanded(child: _buildMainUI()), - // Expanded( - // child: Obx(() => state.itemDataList.value.isEmpty - // ? const NoData() - // : _buildMainUI(state.itemDataList.value))), + Expanded( + child: Obx(() => state.itemDataList.value.isNotEmpty + ? _buildMainUI() + : NoData())), AddBottomWhiteBtn( - btnName: '胁迫指纹', + btnName: '胁迫指纹'.tr, onClick: () { - Get.toNamed(Routers.coerceFingerprintPage); + Get.toNamed(Routers.coerceFingerprintPage, arguments: { + 'lockId': state.getLockId.value, + 'isDetail': false, + })?.then((value) { + if (value != null) { + logic.lockNoticeSettingAccountList(); + } + }); }, ), SizedBox( @@ -62,7 +72,7 @@ class _CoerceOpenDoorPageState 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), )); } @@ -70,12 +80,9 @@ class _CoerceOpenDoorPageState extends State { Widget _buildMainUI() { return ListView.separated( shrinkWrap: true, - itemCount: 3, + itemCount: state.itemDataList.length, itemBuilder: (c, index) { - return _electronicKeyItem( - 'images/icon_fingerprint.png', '18682150237', '指纹', () { - //指纹详情 - }); + return _electronicKeyItem(state.itemDataList.value[index]); }, separatorBuilder: (BuildContext context, int index) { return const Divider( @@ -86,10 +93,19 @@ class _CoerceOpenDoorPageState extends State { ); } - Widget _electronicKeyItem(String avatarURL, String familyAccount, - String openDoorWay, Function() action) { + Widget _electronicKeyItem(DataList itemData) { return GestureDetector( - onTap: action, + onTap: () { + Get.toNamed(Routers.coerceFingerprintPage, arguments: { + 'itemData': itemData, + 'lockId': state.getLockId.value, + 'isDetail': true + })?.then((value) { + if (value != null) { + logic.lockNoticeSettingAccountList(); + } + }); + }, child: Container( color: Colors.white, height: 90.h, @@ -99,7 +115,7 @@ class _CoerceOpenDoorPageState extends State { width: 30.w, ), Image.asset( - avatarURL, + 'images/controls_user.png', width: 60.w, height: 60.w, ), @@ -111,10 +127,9 @@ class _CoerceOpenDoorPageState extends State { mainAxisAlignment: MainAxisAlignment.center, children: [ Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - familyAccount, + itemData.settingValue!.remark ?? '', style: TextStyle( fontSize: 24.sp, color: AppColors.blackColor), ), @@ -130,7 +145,7 @@ class _CoerceOpenDoorPageState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - openDoorWay, + logic.getKeyTypeStr(itemData), style: TextStyle( fontSize: 18.sp, color: AppColors.placeholderTextColor), diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceOpenDoor/coerceOpenDoor_state.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceOpenDoor/coerceOpenDoor_state.dart index 34d6f155..0f505db1 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceOpenDoor/coerceOpenDoor_state.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceOpenDoor/coerceOpenDoor_state.dart @@ -4,4 +4,12 @@ class CoerceOpenDoorState { var pageNum = 1.obs; //请求页码 final pageSize = 20.obs; //请求每页数据条数 final itemDataList = [].obs; + var getLockId = 0.obs; + + CoerceOpenDoorState() { + Map map = Get.arguments; + if (map['lockId'] != null) { + getLockId.value = map['lockId']; + } + } } diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/lowBatteryReminder/lowBatteryReminder_logic.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/lowBatteryReminder/lowBatteryReminder_logic.dart index b080d53f..aa76671c 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/lowBatteryReminder/lowBatteryReminder_logic.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/lowBatteryReminder/lowBatteryReminder_logic.dart @@ -1,7 +1,118 @@ +import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_entity.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/notificationMode/notificationMode_data.dart'; +import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; import 'lowBatteryReminder_state.dart'; class LowBatteryReminderLogic extends BaseGetXController { LowBatteryReminderState state = LowBatteryReminderState(); + + void lockNoticeSettingAccountList() async { + var entity = await ApiRepository.to.updatelowElecNoticeStateSetting( + lockId: state.getLockId.value, + lowElecNoticeState: state.isLowBatteryNotify.value == true ? 1 : 0, + lowElecNoticeWayList: [ + {'type': 'mail', 'accounts': getEmailAndSMSAccountList(true)}, + {'type': 'sms', 'accounts': getEmailAndSMSAccountList(false)} + ]); + if (entity.errorCode!.codeIsSuccessful) { + showToast('设置成功'.tr); + Get.back(result: true); + } + } + + //获取到家人信息的请求数组 + List getEmailAndSMSAccountList(bool isEmail) { + List list = []; + List accountList = []; + isEmail + ? accountList = state.emailReceiverList.value + : accountList = state.phoneReceiverList.value; + for (int i = 0; i < accountList.length; i++) { + MsgNoticeModeData item = accountList[i]; + Map map = {}; + map['countryCode'] = isEmail ? 0 : item.countryCode; + map['account'] = isEmail ? item.receiveEmail : item.receivePhone; + list.add(map); + } + return list; + } + + String getEmailListStr(Map val) { + String emailListStr = ''; + if (val['emailReceiverList'] != null) { + state.emailReceiverList.value = val['emailReceiverList']; + List emailReceiverList = state.emailReceiverList.value; + for (int i = 0; i < emailReceiverList.length; i++) { + MsgNoticeModeData item = emailReceiverList[i]; + emailListStr += item.receiveEmail; + // 检查是否为最后一个元素 + if (i < emailReceiverList.length - 1) { + emailListStr += ','; + } + } + } + return emailListStr; + } + + String getPhoneListStr(Map val) { + String phoneListStr = ''; + + if (val['phoneReceiverList'] != null) { + state.phoneReceiverList.value = val['phoneReceiverList']; + List phoneReceiverList = state.phoneReceiverList.value; + for (int i = 0; i < phoneReceiverList.length; i++) { + MsgNoticeModeData item = phoneReceiverList[i]; + phoneListStr += item.receivePhone; + // 检查是否为最后一个元素 + if (i < phoneReceiverList.length - 1) { + phoneListStr += ','; + } + } + } + return phoneListStr; + } + + //根据列表返回值得到邮箱、手机列表 + Map> getAccountsMap() { + List mailAccounts = []; + List smsAccounts = []; + + if (state.msgNoticeInfo.value.lowElecNoticeWayList != null) { + for (NoticeWay item in state.msgNoticeInfo.value.lowElecNoticeWayList!) { + if (item.type == 'mail' && item.accounts != null) { + for (Accounts account in item.accounts!) { + if (account.account != null) { + MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData(); + msgNoticeModeData.receiveEmail = account.account!; + mailAccounts.add(msgNoticeModeData); + } + } + } else if (item.type == 'sms' && item.accounts != null) { + for (Accounts account in item.accounts!) { + if (account.account != null && account.countryCode != null) { + MsgNoticeModeData msgNoticeModeData = MsgNoticeModeData(); + msgNoticeModeData.receivePhone = account.account!; + msgNoticeModeData.countryCode = account.countryCode!; + smsAccounts.add(msgNoticeModeData); + } + } + } + } + } + + return { + 'emailReceiverList': mailAccounts, + 'phoneReceiverList': smsAccounts, + }; + } + + @override + onInit() { + super.onInit(); + state.emailListStr.value = getEmailListStr(getAccountsMap()); + state.phontListStr.value = getPhoneListStr(getAccountsMap()); + } } 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 e6c715f5..c47f6a2f 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 @@ -29,94 +29,138 @@ class _LowBatteryReminderPageState extends State { barTitle: '低电量提醒'.tr, haveBack: true, backgroundColor: AppColors.mainColor), - body: Container( - padding: EdgeInsets.all(30.w), - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( - child: Text( - "打开提醒后,当锁电量低于20%、10%和5%,系统会给指定对象发送提醒消息。电量读取方式:网关读取或APP读取。", - style: TextStyle( - fontSize: 20.sp, color: AppColors.darkGrayTextColor), - )), - ], - ), - SizedBox( - height: 20.h, - ), - CommonItem( + body: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.all(30.w), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + child: Text( + "打开提醒后,当锁电量低于20%、10%和5%,系统会给指定对象发送提醒消息。电量读取方式:网关读取或APP读取。" + .tr, + style: TextStyle( + fontSize: 20.sp, + color: AppColors.darkGrayTextColor, + ), + softWrap: true, + )) + ], + ), + SizedBox( + height: 20.h, + ), + CommonItem( leftTitel: '低电量提醒'.tr, rightTitle: '', isHaveLine: true, isHaveDirection: false, isHaveRightWidget: true, - rightWidget: _unOpenDoorSwitch(), - action: () {}), - Visibility( + rightWidget: _lowBatterySwitch(), + ), + Visibility( visible: state.isLowBatteryNotify.value, child: Column( children: [ SizedBox( height: 20.h, ), - Container( - color: Colors.white, - margin: EdgeInsets.only(bottom: 10.h), - child: Column( - children: [ - CommonItem( - leftTitel: '提醒方式'.tr, - rightTitle: "", - isHaveLine: false, - isHaveRightWidget: false, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.notificationModePage); - }, - ), - Container( - padding: EdgeInsets.only( - left: 10.w, - right: 10.w, - top: 12.h, - bottom: 12.h), - margin: EdgeInsets.only(bottom: 20.h, top: 10.h), - decoration: BoxDecoration( - color: AppColors.mainBackgroundColor, - borderRadius: BorderRadius.circular(6.0.w), + GestureDetector( + onTap: () { + Get.toNamed(Routers.notificationModePage, arguments: { + 'msgNoticeInfo': state.msgNoticeInfo.value, + })?.then((val) { + if (val != null) { + state.emailListStr.value = + logic.getEmailListStr(val); + state.phontListStr.value = + logic.getPhoneListStr(val); + } + }); + }, + child: Container( + color: Colors.white, + margin: EdgeInsets.only(bottom: 10.h), + child: Column( + children: [ + CommonItem( + leftTitel: '提醒方式'.tr, + rightTitle: "", + isHaveLine: false, + isHaveRightWidget: false, + isHaveDirection: true, ), - child: Text( - 'APP推送 管理员', - style: TextStyle( - color: Colors.black, fontSize: 20.sp), - ), - ) - ], + _buildNotifyContain('APP推送'.tr, '管理员'.tr), + Obx(() => state.emailListStr.value.isNotEmpty + ? _buildNotifyContain( + '邮件提醒'.tr, state.emailListStr.value) + : Container()), + Obx(() => state.phontListStr.value.isNotEmpty + ? _buildNotifyContain( + '短信提醒'.tr, state.phontListStr.value) + : Container()), + ], + ), ), - ) + ), ], - )), - Expanded( - child: SizedBox( - height: 20.h, - )), - SubmitBtn( - btnName: '保存'.tr, - onClick: () {}, - ), - SizedBox( - height: 60.h, - ) - ], + ), + ), + SizedBox( + height: 20.h, + ), + SubmitBtn( + btnName: '保存'.tr, + onClick: () { + logic.lockNoticeSettingAccountList(); + }, + ), + SizedBox( + height: 60.h, + ), + ], + ), ), ), ); } - CupertinoSwitch _unOpenDoorSwitch() { + Widget _buildNotifyContain(String notifyTitle, String notifyContent) { + return Container( + padding: + EdgeInsets.only(left: 10.w, right: 10.w, top: 12.h, bottom: 12.h), + margin: EdgeInsets.only(bottom: 20.h, top: 10.h, left: 20.w, right: 20.w), + decoration: BoxDecoration( + color: AppColors.mainBackgroundColor, + borderRadius: BorderRadius.circular(6.0.w), + ), + child: Row( + children: [ + Text( + notifyTitle, + style: TextStyle(color: Colors.black, fontSize: 20.sp), + ), + Expanded( + child: SizedBox( + width: 20.w, + ), + ), + Text( + notifyContent, + textAlign: TextAlign.end, + style: TextStyle( + color: AppColors.placeholderTextColor, + fontSize: 20.sp, + ), + ), + ], + ), + ); + } + + CupertinoSwitch _lowBatterySwitch() { return CupertinoSwitch( activeColor: CupertinoColors.activeBlue, trackColor: CupertinoColors.systemGrey5, diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/lowBatteryReminder/lowBatteryReminder_state.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/lowBatteryReminder/lowBatteryReminder_state.dart index d1af398d..6554ff81 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/lowBatteryReminder/lowBatteryReminder_state.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/lowBatteryReminder/lowBatteryReminder_state.dart @@ -1,5 +1,29 @@ import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_entity.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart'; class LowBatteryReminderState { var isLowBatteryNotify = false.obs; // 是否低电量提醒 + + var getLockId = 0.obs; + var lockUserKeys = LockUserListKeys().obs; + var emailReceiverList = [].obs; + var phoneReceiverList = [].obs; + var emailListStr = ''.obs; + var phontListStr = ''.obs; + + var msgNoticeInfo = MsgNoticeData().obs; + + LowBatteryReminderState() { + Map map = Get.arguments; + if (map['lockId'] != null) { + getLockId.value = map['lockId']; + } + + if (map['lockSetInfoData'] != null) { + msgNoticeInfo.value = map['lockSetInfoData']; + isLowBatteryNotify.value = + msgNoticeInfo.value.lowElecNoticeState == 1 ? true : false; + } + } } diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart index 312aa0e5..2aaa8e51 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart @@ -35,7 +35,7 @@ class MsgNoticeData { int? doorNotCloseState; int? tamperAlarmState; int? lowElecNoticeState; - List? lowElecNoticeWayList; + List? lowElecNoticeWayList; List? coercionOpenDoorNoticeList; int? doorbellNoticeState; int? someoneAtDoorNoticeState; @@ -65,11 +65,12 @@ class MsgNoticeData { tamperAlarmState = json['tamperAlarmState']; lowElecNoticeState = json['lowElecNoticeState']; if (json['lowElecNoticeWayList'] != null) { - lowElecNoticeWayList = []; + lowElecNoticeWayList = []; json['lowElecNoticeWayList'].forEach((v) { - lowElecNoticeWayList!.add(v); + lowElecNoticeWayList!.add(NoticeWay.fromJson(v)); }); } + if (json['coercionOpenDoorNoticeList'] != null) { coercionOpenDoorNoticeList = []; json['coercionOpenDoorNoticeList'].forEach((v) { 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 fc22ca2f..50d4156d 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 @@ -28,7 +28,7 @@ class _MsgNotificationPageState extends State { TextStyle(color: AppColors.placeholderTextColor, fontSize: 22.sp); late InlineSpan tipsPreviewSpan = TextSpan(children: [ - TextSpan(text: '添加和使用面容开锁时:\n', style: titleStyle), + TextSpan(text: '${'添加和使用面容开锁时:'.tr}\n', style: titleStyle), TextSpan( text: '\n1、请尽量保持单人在门前操作;\n2、请站立在门锁正前方约0.5~0.8米,面向门锁;\n3、请保持脸部无遮挡,露出五官;\n4、面容识别异常时,可触摸数字键盘任意按键,手动重启人脸识别。', @@ -57,20 +57,6 @@ class _MsgNotificationPageState extends State { Widget _buildMainItem() { return Column( children: [ - // Container( - // alignment: Alignment.centerLeft, - // margin: EdgeInsets.only(left: 40.w, top: 20.h, bottom: 20.h), - // child: Text( - // '门锁通知', - // style: TextStyle(color: Colors.black, fontSize: 26.sp, fontWeight: FontWeight.w500), - // ), - // ), - // Divider( - // color: AppColors.greyLineColor, - // indent: 20.w, - // endIndent: 20.w, - // height: 1, - // ), CommonItem( leftTitel: '开门通知'.tr, rightTitle: "", @@ -99,16 +85,6 @@ class _MsgNotificationPageState extends State { }); }, )), - // SizedBox( - // height: 20.h, - // ), - // Obx(() => CommonItem( - // leftTitel: '离家开门', - // rightTitle: "", - // isHaveLine: false, - // isHaveRightWidget: true, - // rightWidget: - // SizedBox(width: 60.w, height: 50.h, child: _switch(1)))), Obx(() => CommonItem( leftTitel: '门未关好'.tr, rightTitle: "", @@ -132,7 +108,14 @@ class _MsgNotificationPageState extends State { isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.lowBatteryReminderPage); + Get.toNamed(Routers.lowBatteryReminderPage, arguments: { + 'lockSetInfoData': state.msgNoticeInfo.value, + 'lockId': state.getLockId.value + })?.then((value) { + if (value != null) { + logic.getLockNoticeSetting(); + } + }); }, )), CommonItem( @@ -141,17 +124,12 @@ class _MsgNotificationPageState extends State { isHaveLine: true, isHaveDirection: true, action: () { - Get.toNamed(Routers.coerceOpenDoorPage); + Get.toNamed(Routers.coerceOpenDoorPage, arguments: { + 'lockSetInfoData': state.msgNoticeInfo.value, + 'lockId': state.getLockId.value + }); }, ), - // Container( - // alignment: Alignment.centerLeft, - // margin: EdgeInsets.only(left: 40.w, top: 20.h, bottom: 20.h), - // child: Text( - // '门铃通知', - // style: TextStyle(color: Colors.black, fontSize: 26.sp, fontWeight: FontWeight.w500), - // ), - // ), SizedBox( height: 10.h, ), @@ -162,14 +140,6 @@ class _MsgNotificationPageState extends State { isHaveRightWidget: true, rightWidget: SizedBox(width: 60.w, height: 50.h, child: _switch(3)))), - // Container( - // alignment: Alignment.centerLeft, - // margin: EdgeInsets.only(left: 40.w, top: 40.h, bottom: 30.h), - // child: Text( - // '猫眼通知', - // style:TextStyle(color: Colors.black, fontSize: 26.sp, fontWeight: FontWeight.w500) - // ), - // ), SizedBox( height: 10.h, ), diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart index 4e89157b..0235db0a 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_page.dart @@ -32,111 +32,110 @@ class _NDaysUnopenedPageState extends State { barTitle: 'N天未开门'.tr, haveBack: true, backgroundColor: AppColors.mainColor), - body: Container( + body: ListView( padding: EdgeInsets.all(30.w), - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( - child: Text( - "经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网", - style: TextStyle( - fontSize: 20.sp, color: AppColors.darkGrayTextColor), - )), - ], - ), - SizedBox( - height: 20.h, - ), - CommonItem( - leftTitel: 'N天未开门提醒'.tr, - rightTitle: '', - isHaveLine: true, - isHaveDirection: false, - isHaveRightWidget: true, - rightWidget: _unOpenDoorSwitch(), - action: () {}), - Visibility( - visible: state.isUnOpenNotice.value, - child: Column( - children: [ - Obx(() => CommonItem( - leftTitel: '门未开时间', - rightTitle: '${state.unOpenDoorTime.value}天', - isHaveLine: true, - isHaveRightWidget: false, - isHaveDirection: true, - action: () { - _openBottomItemSheet( - context, state.unopenDoorTimeList); - }, - )), - SizedBox( - height: 20.h, - ), - GestureDetector( - onTap: () { - Get.toNamed(Routers.notificationModePage, arguments: { - 'msgNoticeInfo': state.msgNoticeInfo.value - })?.then((val) { - if (val != null) { - state.emailListStr.value = - logic.getEmailListStr(val); - state.phontListStr.value = - logic.getPhoneListStr(val); - print( - 'emailListStr:${state.emailListStr.value},phontListStr:${state.phontListStr.value}'); - } - }); - }, - child: Container( - color: Colors.white, - margin: EdgeInsets.only(bottom: 10.h), - child: Column( - children: [ - CommonItem( - leftTitel: '提醒方式'.tr, - rightTitle: "", - isHaveLine: false, - isHaveRightWidget: false, - isHaveDirection: true, - ), - _buildNotifyContain('APP推送'.tr, '管理员'.tr), - Obx(() => state.emailListStr.value.isNotEmpty - ? _buildNotifyContain( - '邮件提醒'.tr, state.emailListStr.value) - : Container()), - Obx(() => state.phontListStr.value.isNotEmpty - ? _buildNotifyContain( - '短信提醒'.tr, state.phontListStr.value) - : Container()), - ], - ), - ), - ), - ], - )), - Expanded( - child: SizedBox( - height: 20.h, - )), - SubmitBtn( - btnName: '保存', - onClick: () { - logic.lockNoticeSettingAccountList(); - }, - ), - SizedBox( - height: 60.h, - ) - ], - ), + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Expanded( + child: Text( + "经过以上设定的时间,锁没有被开启,系统会给指定对象发送提醒消息,该功能需要锁联网".tr, + style: TextStyle( + fontSize: 20.sp, color: AppColors.darkGrayTextColor), + )), + ], + ), + SizedBox( + height: 20.h, + ), + CommonItem( + leftTitel: 'N天未开门提醒'.tr, + rightTitle: '', + isHaveLine: true, + isHaveDirection: false, + isHaveRightWidget: true, + rightWidget: _unOpenDoorSwitch(), + action: () {}), + _buildOpenNoticeWidget(), + Expanded( + child: SizedBox( + height: 20.h, + )), + SubmitBtn( + btnName: '保存'.tr, + onClick: () { + logic.lockNoticeSettingAccountList(); + }, + ), + SizedBox( + height: 60.h, + ) + ], ), ); } + Widget _buildOpenNoticeWidget() { + return Visibility( + visible: state.isUnOpenNotice.value, + child: Column( + children: [ + Obx(() => CommonItem( + leftTitel: '门未开时间'.tr, + rightTitle: '${state.unOpenDoorTime.value}${'天'.tr}', + isHaveLine: true, + isHaveRightWidget: false, + isHaveDirection: true, + action: () { + _openBottomItemSheet(context, state.unopenDoorTimeList); + }, + )), + SizedBox( + height: 20.h, + ), + GestureDetector( + onTap: () { + Get.toNamed(Routers.notificationModePage, + arguments: {'msgNoticeInfo': state.msgNoticeInfo.value}) + ?.then((val) { + if (val != null) { + state.emailListStr.value = logic.getEmailListStr(val); + state.phontListStr.value = logic.getPhoneListStr(val); + print( + 'emailListStr:${state.emailListStr.value},phontListStr:${state.phontListStr.value}'); + } + }); + }, + child: Container( + color: Colors.white, + margin: EdgeInsets.only(bottom: 10.h), + child: Column( + children: [ + CommonItem( + leftTitel: '提醒方式'.tr, + rightTitle: "", + isHaveLine: false, + isHaveRightWidget: false, + isHaveDirection: true, + ), + _buildNotifyContain('APP推送'.tr, '管理员'.tr), + Obx(() => state.emailListStr.value.isNotEmpty + ? _buildNotifyContain( + '邮件提醒'.tr, state.emailListStr.value) + : Container()), + Obx(() => state.phontListStr.value.isNotEmpty + ? _buildNotifyContain( + '短信提醒'.tr, state.phontListStr.value) + : Container()), + ], + ), + ), + ), + ], + )); + } + Widget _buildNotifyContain(String notifyTitle, String notifyContent) { return Container( padding: diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_state.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_state.dart index 6ef90838..3a23a139 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_state.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/nDaysUnopened/nDaysUnopened_state.dart @@ -1,7 +1,6 @@ import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_entity.dart'; import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart'; -import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_entity.dart'; class NDaysUnopenedState { final List unopenDoorTimeList = [ diff --git a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_entity.dart b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_entity.dart index 0b3fc846..923d3669 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_entity.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/msgNotification/openDoorNotify/openDoorNotify_entity.dart @@ -1,5 +1,3 @@ -import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart'; - class OpenDoorNotifyEntity { int? errorCode; String? description; diff --git a/star_lock/lib/main/lockDetail/messageWarn/notificationMode/notificationMode_page.dart b/star_lock/lib/main/lockDetail/messageWarn/notificationMode/notificationMode_page.dart index ab5e4920..3b9745a6 100644 --- a/star_lock/lib/main/lockDetail/messageWarn/notificationMode/notificationMode_page.dart +++ b/star_lock/lib/main/lockDetail/messageWarn/notificationMode/notificationMode_page.dart @@ -196,7 +196,7 @@ class _NotificationModePageState extends State { }, ) : Container(), - getReceiverTFWidget(isEmail ? '请输入Email'.tr : '请输入手机号', index, + getReceiverTFWidget(isEmail ? '请输入Email'.tr : '请输入手机号'.tr, index, isEmail: isEmail) ], ), diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index 121bc19e..4a8ed97f 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -208,6 +208,8 @@ abstract class Api { '/lockNoticeSettingAccount/delete'; //删除开门通知 final String updateLockNoticeSettingAccountURL = '/lockNoticeSettingAccount/update'; //更新开门通知 + final String getCoercedFingerprintListURL = + '/fingerprint/getCoercedList'; //获取胁迫指纹列表 final String setWechatPushSwitchURL = '/user/setMpWechatPushSwitch'; //设置微信公众号推送 diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index 6bac8a11..3c68f0d8 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -1837,6 +1837,17 @@ class ApiProvider extends BaseProvider { 'dayNotOpenDoorNoticeWayList': dayNotOpenDoorNoticeWayList })); + // 设置低电量提醒 + Future updatelowElecNoticeStateSetting( + int lockId, int lowElecNoticeState, List lowElecNoticeWayList) => + post( + updateLockNoticeSettingURL.toUrl, + jsonEncode({ + 'lockId': lockId, + 'lowElecNoticeState': lowElecNoticeState, + 'lowElecNoticeWayList': lowElecNoticeWayList + })); + // 设置门未关好 Future updateDoorNotCloseSetting( int lockId, @@ -1923,6 +1934,14 @@ class ApiProvider extends BaseProvider { 'settingValue': settingValue })); + // 获取胁迫指纹列表 + Future getCoercedFingerprintList( + int lockId, int pageNo, int pageSize) => + post( + getCoercedFingerprintListURL.toUrl, + jsonEncode( + {'lockId': lockId, 'pageNo': pageNo, 'pageSize': pageSize})); + // 设置微信公众号推送 Future setMpWechatPushSwitch(int mpWechatPushSwitch) => post( setWechatPushSwitchURL.toUrl, diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index f1522ab1..049d0237 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -8,6 +8,7 @@ import 'package:star_lock/main/lockDetail/electronicKey/massSendElectronicKey/ma import 'package:star_lock/main/lockDetail/face/addFace/addFace_entity.dart'; import 'package:star_lock/main/lockDetail/lockSet/basicInformation/basicInformation/KeyDetailEntity.dart'; import 'package:star_lock/main/lockDetail/messageWarn/lockUser/lockUser_entity.dart'; +import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/coerceOpenDoor/coerceFingerprintList/coerceFingerprintList_entity.dart'; import 'package:star_lock/main/lockDetail/messageWarn/msgNotification/msgNotification/msgNotification_entity.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart'; @@ -1860,6 +1861,16 @@ class ApiRepository { return OpenDoorNotifyEntity.fromJson(res.body); } + // 设置低电量提醒 + Future updatelowElecNoticeStateSetting( + {required int lockId, + required int lowElecNoticeState, + required List lowElecNoticeWayList}) async { + final res = await apiProvider.updatelowElecNoticeStateSetting( + lockId, lowElecNoticeState, lowElecNoticeWayList); + return OpenDoorNotifyEntity.fromJson(res.body); + } + // 设置门未关好 Future updateDoorNotCloseSetting({ required int lockId, @@ -1941,6 +1952,14 @@ class ApiRepository { return OpenDoorNotifyEntity.fromJson(res.body); } + // 获取胁迫指纹列表 + Future getCoercedFingerprintList( + {required int lockId, required int pageNo, required int pageSize}) async { + final res = + await apiProvider.getCoercedFingerprintList(lockId, pageNo, pageSize); + return CoerceFingerprintListEntity.fromJson(res.body); + } + // 设置微信公众号推送 Future setMpWechatPushSwitch( {required int mpWechatPushSwitch}) async {