From 6f1fa89db3ed3b662c57396aeebf9f96382d459d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Thu, 14 Dec 2023 11:40:41 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=94=81=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E5=BC=B9=E7=AA=97=E8=83=8C=E6=99=AF=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 7eddcb8c..2709c92c 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -549,7 +549,7 @@ class LockDetailLogic extends BaseGetXController{ _initReplySubscription(); initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction(); - EasyLoading.show(status: "正在连接设备,请稍等。", maskType: EasyLoadingMaskType.black, dismissOnTap: true); + EasyLoading.show(status: "正在连接设备,请稍等。", maskType: EasyLoadingMaskType.none, dismissOnTap: true); Future.delayed(const Duration(seconds: 12), () { if(EasyLoading.isShow){ EasyLoading.dismiss(); From 45f7851ca20a8969d5b62d25ccb00e80384012e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Sat, 16 Dec 2023 11:20:36 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=AE=8C=E5=96=84=E7=94=B5=E5=AD=90?= =?UTF-8?q?=E9=92=A5=E5=8C=99=E3=80=81=E5=8D=A1=E3=80=81=E6=8C=87=E7=BA=B9?= =?UTF-8?q?bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io_protocol/io_addStressFingerprint.dart | 6 +- .../blue/io_protocol/io_addStressICCard.dart | 10 +- star_lock/lib/blue/sender_manage.dart | 2 + .../card/addCardType/addCardType_logic.dart | 4 +- .../card/addICCard/addICCard_logic.dart | 58 +- .../card/cardDetail/cardDetail_logic.dart | 30 +- .../card/cardDetail/cardDetail_page.dart | 2 +- .../card/cardDetail/cardDetail_state.dart | 4 +- .../card/cardList/cardList_logic.dart | 44 +- .../card/cardList/cardList_page.dart | 46 +- .../card/cardList/cardList_state.dart | 8 +- .../otherTypeKeyChangeDate_logic.dart | 1 + .../otherTypeKeyChangeValidityDate_logic.dart | 1 + .../addFingerprint/addFingerprint_logic.dart | 28 +- .../addFingerprint/addFingerprint_state.dart | 4 +- .../fingerprintDetail_logic.dart | 41 +- .../fingerprintDetail_state.dart | 2 +- .../fingerprintList_logic.dart | 31 +- .../fingerprintList/fingerprintList_page.dart | 21 +- .../fingerprintList_state.dart | 4 +- .../automaticBlocking_page.dart | 18 +- .../automaticBlocking_state.dart | 10 + .../basicInformation_page.dart | 20 +- .../lcokSet/lockSet/lockSetInfo_entity.dart | 11 +- .../lcokSet/lockSet/lockSet_logic.dart | 78 +- .../lcokSet/lockSet/lockSet_page.dart | 1089 +++++++++-------- .../lcokSet/lockSet/lockSet_state.dart | 1 + .../normallyOpenMode_page.dart | 6 +- .../normallyOpenMode_state.dart | 8 + .../lockDetail/lockDetail_logic.dart | 269 ++-- .../lockDetail/lockDetail_main_page.dart | 16 - .../lockDetail/lockDetail_page.dart | 50 +- .../lockDetail/lockDetail_state.dart | 2 + .../lockMian/entity/lockListInfo_entity.dart | 10 +- .../mine/addLock/saveLock/saveLock_logic.dart | 2 +- .../mine/mineSet/mineSet/mineSet_logic.dart | 6 +- star_lock/lib/network/api.dart | 1 + star_lock/lib/network/api_provider.dart | 14 +- star_lock/lib/network/api_repository.dart | 14 +- star_lock/lib/tools/storage.dart | 2 +- 40 files changed, 1136 insertions(+), 838 deletions(-) diff --git a/star_lock/lib/blue/io_protocol/io_addStressFingerprint.dart b/star_lock/lib/blue/io_protocol/io_addStressFingerprint.dart index 2e94ac15..75b567c5 100644 --- a/star_lock/lib/blue/io_protocol/io_addStressFingerprint.dart +++ b/star_lock/lib/blue/io_protocol/io_addStressFingerprint.dart @@ -102,12 +102,12 @@ class SenderAddStressFingerprintCommand extends SenderProtocol { } else { List authCodeData = []; - //authUserID - authCodeData.addAll(utf8.encode(userID!)); - //KeyID authCodeData.addAll(utf8.encode(keyID!)); + //authUserID + authCodeData.addAll(utf8.encode(userID!)); + //token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 authCodeData.addAll(token!); diff --git a/star_lock/lib/blue/io_protocol/io_addStressICCard.dart b/star_lock/lib/blue/io_protocol/io_addStressICCard.dart index 81e416f9..5c9671e2 100644 --- a/star_lock/lib/blue/io_protocol/io_addStressICCard.dart +++ b/star_lock/lib/blue/io_protocol/io_addStressICCard.dart @@ -26,6 +26,7 @@ class SenderAddStressICCardCommand extends SenderProtocol { int? needAuthor; List? publicKey; List? privateKey; + List? signKey; SenderAddStressICCardCommand({ this.keyID, @@ -39,6 +40,7 @@ class SenderAddStressICCardCommand extends SenderProtocol { this.needAuthor, this.publicKey, this.privateKey, + this.signKey }) : super(CommandType.generalExtendedCommond); @override @@ -100,16 +102,16 @@ class SenderAddStressICCardCommand extends SenderProtocol { } else { List authCodeData = []; - //authUserID - authCodeData.addAll(utf8.encode(userID!)); - //KeyID authCodeData.addAll(utf8.encode(keyID!)); + //authUserID + authCodeData.addAll(utf8.encode(userID!)); + //token 4 首次请求 Token 填 0,如果锁需要鉴权操作者身份,则会分配动态口令并在应答消息中返回,二次请求时带上。 authCodeData.addAll(token!); - authCodeData.addAll(publicKey!); + authCodeData.addAll(signKey!); print("${commandType!.typeValue}-authCodeData:$authCodeData"); diff --git a/star_lock/lib/blue/sender_manage.dart b/star_lock/lib/blue/sender_manage.dart index 2df9c664..4a01ce4d 100644 --- a/star_lock/lib/blue/sender_manage.dart +++ b/star_lock/lib/blue/sender_manage.dart @@ -584,6 +584,7 @@ class IoSenderManage { required int? needAuthor, required List? publicKey, required List? privateKey, + required List? signKey, CommandSendCallBack? callBack}) { CommandSenderManager().managerSendData( command: SenderAddStressICCardCommand( @@ -598,6 +599,7 @@ class IoSenderManage { needAuthor: needAuthor, publicKey: publicKey, privateKey: privateKey, + signKey: signKey ), callBack:callBack); } diff --git a/star_lock/lib/main/lockDetail/card/addCardType/addCardType_logic.dart b/star_lock/lib/main/lockDetail/card/addCardType/addCardType_logic.dart index 07342476..c61adf59 100644 --- a/star_lock/lib/main/lockDetail/card/addCardType/addCardType_logic.dart +++ b/star_lock/lib/main/lockDetail/card/addCardType/addCardType_logic.dart @@ -18,6 +18,8 @@ class AddCardTypeLogic extends BaseGetXController{ var endDate = ""; if (state.seletType.value == "0") { fingerprintType = 1; + startDate = "0"; + endDate = "0"; } else if (state.seletType.value == "1") { fingerprintType = 2; if (state.beginTimeTimestamp.value.isEmpty) { @@ -78,7 +80,7 @@ class AddCardTypeLogic extends BaseGetXController{ "endDate": endDate, "addType": "1", "cardName": state.nameController.text, - "cardNumber": (Random().nextInt(100000000) + 10000000).floor().toString(), + "cardNumber": "123456", "cardType": fingerprintType.toString(), "isCoerced": isCoerced, "startDate": startDate, diff --git a/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart b/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart index 04853532..56f1813f 100644 --- a/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart +++ b/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart @@ -45,11 +45,6 @@ class AddICCardLogic extends BaseGetXController{ } Future _replyAddICCardBegin(Reply reply) async { - var token = reply.data.sublist(5, 9); - var saveStrList = changeIntListToStringList(token); - print("_replyAddFingerprintReplyToken:$token"); - Storage.setStringList(saveBlueToken, saveStrList); - int status = reply.data[2]; print("_replyAddFingerprintStatus:$status"); @@ -69,15 +64,20 @@ class AddICCardLogic extends BaseGetXController{ var publicKey = await Storage.getStringList(saveBluePublicKey); List publicKeyDataList = changeStringListToIntList(publicKey!); + var token = reply.data.sublist(5, 9); + var saveStrList = changeIntListToStringList(token); + print("_replyAddFingerprintReplyToken:$token"); + Storage.setStringList(saveBlueToken, saveStrList); + IoSenderManage.senderAddFingerprintCommand( keyID:"1", userID:await Storage.getUid(), fingerNo:1, useCountLimit:0xff, - startTime:0x11223344, - endTime:0x11223344, - // startTime:int.parse(state.startDate.value)~/1000, - // endTime:int.parse(state.endDate.value)~/1000, + // startTime:0x11223344, + // endTime:0x11223344, + startTime:int.parse(state.startDate.value)~/1000, + endTime:int.parse(state.endDate.value)~/1000, needAuthor:1, publicKey:publicKeyDataList, privateKey:getPrivateKeyList, @@ -103,11 +103,6 @@ class AddICCardLogic extends BaseGetXController{ } Future _replyAddICCardConfirmation(Reply reply) async { - var token = reply.data.sublist(2, 6); - // var saveStrList = changeIntListToStringList(token); - // print("_replyAddICCardConfirmationReplyToken:$token"); - // Storage.setStringList(saveBlueToken, saveStrList); - int status = reply.data[2]; print("_replyAddFingerprintstatus:$status"); @@ -117,11 +112,11 @@ class AddICCardLogic extends BaseGetXController{ print("${reply.commandType!.typeValue} 数据解析成功"); // print("添加指纹确认成功,调用添加指纹接口"); if(state.isCoerced.value == "1"){ - // 非胁迫指纹 + // 非胁迫 int addResultStatus = reply.data[5]; if(addResultStatus == 0){ // 成功更新序列号 - state.cardNumber.value = (reply.data[6]+1).toString(); + state.cardNumber.value = (reply.data[6]).toString(); addICCardData(); }else if(addResultStatus == 255){ // 255 自动退出 @@ -155,10 +150,6 @@ class AddICCardLogic extends BaseGetXController{ } Future _replyAddICStressCard(Reply reply) async { - var token = reply.data.sublist(2, 6); - var saveStrList = changeIntListToStringList(token); - print("_replyAddICCardConfirmationReplyToken:$token"); - Storage.setStringList(saveBlueToken, saveStrList); int status = reply.data[2]; print("_replyAddFingerprintstatus:$status"); @@ -178,18 +169,29 @@ class AddICCardLogic extends BaseGetXController{ var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); + var signKey = await Storage.getStringList(saveBlueSignKey); + List getSignKeyList = changeStringListToIntList(signKey!); + + var token = reply.data.sublist(5, 9); + var saveStrList = changeIntListToStringList(token); + print("_replyAddICCardConfirmationReplyToken:$token"); + Storage.setStringList(saveBlueToken, saveStrList); + IoSenderManage.senderAddStressICCardCommand( keyID:"1", userID:await Storage.getUid(), icCardNo:1, cardType:1, useCountLimit:1, - startTime:0x11223344, - endTime:0x11223344, + // startTime:0x11223344, + // endTime:0x11223344, + startTime:int.parse(state.startDate.value)~/1000, + endTime:int.parse(state.endDate.value)~/1000, needAuthor:1, publicKey:publicKeyDataList, privateKey:getPrivateKeyList, token: token, + signKey: getSignKeyList, ); break; case 0x07: @@ -210,7 +212,7 @@ class AddICCardLogic extends BaseGetXController{ } } - // 添加卡片开始 + // 添加卡片 Future senderAddICCard() async { BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { if (deviceConnectionState == DeviceConnectionState.connected){ @@ -229,8 +231,10 @@ class AddICCardLogic extends BaseGetXController{ userID:await Storage.getUid(), cardNo:1, useCountLimit:0xff, - startTime:0x11223344, - endTime:0x11223344, + // startTime:0x11223344, + // endTime:0x11223344, + startTime:int.parse(state.startDate.value)~/1000, + endTime:int.parse(state.endDate.value)~/1000, needAuthor:1, publicKey:publicKeyDataList, privateKey:getPrivateKeyList, @@ -250,6 +254,9 @@ class AddICCardLogic extends BaseGetXController{ var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); + var signKey = await Storage.getStringList(saveBlueSignKey); + List getSignKeyList = changeStringListToIntList(signKey!); + var token = await Storage.getStringList(saveBlueToken); List getTokenList = changeStringListToIntList(token!); print("openDoorTokenPubToken:$getTokenList"); @@ -268,6 +275,7 @@ class AddICCardLogic extends BaseGetXController{ publicKey:publicKeyDataList, privateKey:getPrivateKeyList, token: getTokenList, + signKey: getSignKeyList, ); } }); diff --git a/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart b/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart index 87383d6b..366f4d64 100644 --- a/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_logic.dart @@ -54,13 +54,14 @@ class CardDetailLogic extends BaseGetXController{ var token = await Storage.getStringList(saveBlueToken); List getTokenList = changeStringListToIntList(token!); + String? userID = await Storage.getUid(); IoSenderManage.senderAddICCardCommand( - keyID:"1", - userID:"DeleteAll!@#", - cardNo:255, + keyID:state.keyId.value.toString(), + userID:userID, + cardNo:int.parse(state.typeNumber.value), useCountLimit:0, - startTime:0x11223344, - endTime:0x11223344, + startTime:state.effectiveDateTime.value, + endTime:state.failureDateTime.value, needAuthor:1, publicKey:publicKeyDataList, privateKey:getPrivateKeyList, @@ -86,9 +87,9 @@ class CardDetailLogic extends BaseGetXController{ } // 删除卡片 - Future senderAddICCard(String keyId, String userID, int cardNo) async { - BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async { - if (state == DeviceConnectionState.connected){ + Future senderAddICCard() async { + BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { + if (deviceConnectionState == DeviceConnectionState.connected){ var publicKey = await Storage.getStringList(saveBluePublicKey); List publicKeyDataList = changeStringListToIntList(publicKey!); @@ -99,16 +100,14 @@ class CardDetailLogic extends BaseGetXController{ List getTokenList = changeStringListToIntList(token!); print("openDoorTokenPubToken:$getTokenList"); + String? userID = await Storage.getUid(); IoSenderManage.senderAddICCardCommand( - // keyID:"1", - // userID:"DeleteAll!@#", - // cardNo:255, - keyID:keyId, + keyID:state.keyId.value.toString(), userID:userID, - cardNo:cardNo, + cardNo:int.parse(state.typeNumber.value), useCountLimit:0, - startTime:0x11223344, - endTime:0x11223344, + startTime:state.effectiveDateTime.value, + endTime:state.failureDateTime.value, needAuthor:1, publicKey:publicKeyDataList, privateKey:getPrivateKeyList, @@ -128,6 +127,7 @@ class CardDetailLogic extends BaseGetXController{ endDate: state.failureDateTime.value.toString(), isCoerced: state.isStressFingerprint.value ? "2" : "1", cardName: state.changeNameController.text, + changeType: "1", ); if(entity.errorCode!.codeIsSuccessful){ Toast.show(msg: "修改成功"); diff --git a/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart b/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart index e07a9eee..f1d8c633 100644 --- a/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart +++ b/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_page.dart @@ -349,7 +349,7 @@ class _CardDetailPageState extends State { sureClick: () async { Get.back(); String? idStr = await Storage.getUid(); - logic.senderAddICCard(state.fingerprintItemData.value.cardId.toString(), idStr ?? "", 0); + logic.senderAddICCard(); }, cancelClick: () { Get.back(); diff --git a/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_state.dart b/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_state.dart index 9ea3f875..3fd9f9d7 100644 --- a/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_state.dart +++ b/star_lock/lib/main/lockDetail/card/cardDetail/cardDetail_state.dart @@ -19,7 +19,7 @@ class CardDetailState{ var weekDay = [].obs;// 有效日 var adder = "".obs;// 添加者 var addTime = 0.obs;// 添加时间 - var keyId = 0.obs;// 添加时间 + var keyId = 0.obs;// 卡id final isStressFingerprint = false.obs; CardDetailState() { @@ -34,7 +34,7 @@ class CardDetailState{ keyType.value = fingerprintItemData.value.cardType!; adder.value = fingerprintItemData.value.senderUsername!; addTime.value = fingerprintItemData.value.createDate!; - isStressFingerprint.value = fingerprintItemData.value.isCoerced! == 1 ? true : false; + isStressFingerprint.value = fingerprintItemData.value.isCoerced! == 2 ? true : false; weekDay.value = fingerprintItemData.value.weekDay!; } } \ No newline at end of file diff --git a/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart b/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart index dd1b265a..415ed1c1 100644 --- a/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart +++ b/star_lock/lib/main/lockDetail/card/cardList/cardList_logic.dart @@ -27,7 +27,7 @@ class CardListLogic extends BaseGetXController { _replySubscription = EventBusManager().eventBus!.on().listen((reply) { // 添加卡片开始(重置锁里面所有卡) - if((reply is SenderAddICCardReply) && (state.isDeletICCardData == true)) { + if((reply is SenderAddICCardReply) && (state.isDeletCardData == true)) { _replyAddICCardBegin(reply); } @@ -50,7 +50,7 @@ class CardListLogic extends BaseGetXController { case 0x00: //成功 print("${reply.commandType!.typeValue} 数据解析成功"); - state.isDeletICCardData = false; + state.isDeletCardData = false; deletICCardData(); break; case 0x06: @@ -66,9 +66,9 @@ class CardListLogic extends BaseGetXController { List getTokenList = changeStringListToIntList(token!); IoSenderManage.senderAddICCardCommand( - keyID:"1", - userID:"DeleteAll!@#", - cardNo:255, + keyID:state.deletKeyID, + userID:state.deletUserID, + cardNo:state.deletCardNo, useCountLimit:0, startTime:0x11223344, endTime:0x11223344, @@ -259,9 +259,9 @@ class CardListLogic extends BaseGetXController { } // 删除卡片 - Future senderAddICCard(String keyId, String userID, int cardNo) async { - BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async { - if (state == DeviceConnectionState.connected){ + Future senderAddICCard() async { + BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { + if (deviceConnectionState == DeviceConnectionState.connected){ var publicKey = await Storage.getStringList(saveBluePublicKey); List publicKeyDataList = changeStringListToIntList(publicKey!); @@ -273,12 +273,9 @@ class CardListLogic extends BaseGetXController { print("openDoorTokenPubToken:$getTokenList"); IoSenderManage.senderAddICCardCommand( - // keyID:"1", - // userID:"DeleteAll!@#", - // cardNo:255, - keyID:keyId, - userID:userID, - cardNo:cardNo, + keyID:state.deletKeyID, + userID:state.deletUserID, + cardNo:state.deletCardNo, useCountLimit:0, startTime:0x11223344, endTime:0x11223344, @@ -306,14 +303,27 @@ class CardListLogic extends BaseGetXController { // 删除所有IC卡 void deletICCardData() async{ + var cardId = ""; + var type = "1"; + if(state.isDeletAll == false){ + cardId = state.deletKeyID; + type = "0"; + } + print("delet fingerprintId $cardId"); var entity = await ApiRepository.to.deletIcCardData( - cardId: "", + cardId: cardId, lockId: state.lockId.value.toString(), - type: "1", + type: type, deleteType:"1" ); if(entity.errorCode!.codeIsSuccessful){ - Toast.show(msg: "重置成功"); + if(state.isDeletAll == false){ + Toast.show(msg: "删除成功"); + }else{ + Toast.show(msg: "重置成功"); + } + + state.isDeletCardData = false; getICCardListData(); } } diff --git a/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart b/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart index 83e80676..0d8e272c 100644 --- a/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart +++ b/star_lock/lib/main/lockDetail/card/cardList/cardList_page.dart @@ -82,27 +82,6 @@ class _CardListPageState extends State { ); } - String getAppBarTitle(int type) { - String title = ""; - switch (type) { - case 0: - title = TranslationLoader.lanKeys!.card!.tr; - break; - case 1: - title = TranslationLoader.lanKeys!.fingerprint!.tr; - break; - case 2: - title = TranslationLoader.lanKeys!.remoteControl!.tr; - break; - case 3: - title = TranslationLoader.lanKeys!.face!.tr; - break; - default: - break; - } - return title; - } - Widget _searchWidget() { return Container( height: 60.h, @@ -157,7 +136,7 @@ class _CardListPageState extends State { key: Key(fingerprintItemData.cardName!), actionsWidth: 60, actions: [ - _buildDeleteBtn(fingerprintItemData.cardId.toString()), + _buildDeleteBtn(fingerprintItemData), ], decoration: const BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(1)), @@ -190,11 +169,13 @@ class _CardListPageState extends State { ) : const NoData()); } - Widget _buildDeleteBtn(String idStr) { + Widget _buildDeleteBtn(FingerprintItemData fingerprintItemData) { return GestureDetector( onTap: () { // 省略: 弹出是否删除的确认对话框。 - showIosTipViewDialog(context, idStr); + state.deletKeyID = fingerprintItemData.cardId.toString(); + state.deletCardNo = int.parse(fingerprintItemData.cardNumber!); + showIosTipViewDialog(context); }, child: Container( width: 60, @@ -213,7 +194,7 @@ class _CardListPageState extends State { ); } - void showIosTipViewDialog(BuildContext context, String keyId) { + void showIosTipViewDialog(BuildContext context) { showDialog( context: context, builder: (BuildContext context) { @@ -222,9 +203,10 @@ class _CardListPageState extends State { tipTitle: "确定要删除吗?", sureClick: () async { Get.back(); - String? idStr = await Storage.getUid(); - state.isDeletICCardData = true; - logic.senderAddICCard(keyId, idStr ?? "", 0); + state.isDeletCardData = true; + state.isDeletAll = false; + state.deletUserID = (await Storage.getUid())!; + logic.senderAddICCard(); }, cancelClick: () { Get.back(); @@ -306,8 +288,12 @@ class _CardListPageState extends State { child: Text(TranslationLoader.lanKeys!.sure!.tr), onPressed: () { Navigator.pop(context); - state.isDeletICCardData = true; - logic.senderAddICCard("1", "DeleteAll!@#", 255); + state.isDeletCardData = true; + state.isDeletAll = true; + state.deletKeyID = "1"; + state.deletUserID = "DeleteAll!@#"; + state.deletCardNo = 255; + logic.senderAddICCard(); }, ), ], diff --git a/star_lock/lib/main/lockDetail/card/cardList/cardList_state.dart b/star_lock/lib/main/lockDetail/card/cardList/cardList_state.dart index 898c9516..11c97626 100644 --- a/star_lock/lib/main/lockDetail/card/cardList/cardList_state.dart +++ b/star_lock/lib/main/lockDetail/card/cardList/cardList_state.dart @@ -6,8 +6,12 @@ import '../../fingerprint/fingerprintList/fingerprintListData_entity.dart'; class CardListState { final lockId = 0.obs; - var isDeletFingerprintData = false; - var isDeletICCardData = false; + // 因为删除跟添加指纹用的同一个协议 所以这里用做判断 + var isDeletCardData = false; + var isDeletAll = false; + var deletKeyID = ""; + var deletUserID = "DeleteAll!@#"; + var deletCardNo = 0; final fingerprintItemListData = [].obs; final TextEditingController searchController = TextEditingController(); diff --git a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart index 4d7dcac8..c18963b6 100644 --- a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart +++ b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeDate/otherTypeKeyChangeDate_logic.dart @@ -41,6 +41,7 @@ class OtherTypeKeyChangeDateLogic extends BaseGetXController{ endDate: state.endTimeTimestamp.value.toString(), isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1", cardName: state.fingerprintItemData.value.cardName!, + changeType: '1', ); if(entity.errorCode!.codeIsSuccessful){ Toast.show(msg: "修改成功"); diff --git a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart index 06a26690..60056d04 100644 --- a/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart +++ b/star_lock/lib/main/lockDetail/card/otherTypeKeyChangeValidityDate/otherTypeKeyChangeValidityDate_logic.dart @@ -43,6 +43,7 @@ class OtherTypeKeyChangeValidityDateLogic extends BaseGetXController{ endDate: state.endTimeTimestamp.value.toString(), isCoerced: state.fingerprintItemData.value.isCoerced == 1 ? "2" : "1", cardName: state.fingerprintItemData.value.cardName!, + changeType: '1', ); if(entity.errorCode!.codeIsSuccessful){ Toast.show(msg: "修改成功"); diff --git a/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart b/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart index a334e890..486589e2 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_logic.dart @@ -59,7 +59,7 @@ class AddFingerprintLogic extends BaseGetXController { //成功 print("${reply.commandType!.typeValue} 数据解析成功"); state.ifConnectScuess.value = true; - state.fingerprintNumber.value = reply.data.last.toString(); + // state.fingerprintNumber.value = reply.data.last.toString(); break; case 0x06: //无权限 @@ -128,31 +128,7 @@ class AddFingerprintLogic extends BaseGetXController { break; case 0x06: //需要权限 - // var token = reply.data.sublist(5, 9); - // var saveStrList = changeIntListToStringList(token); - // print("_replyAddFingerprintReplyToken:$token"); - // Storage.setStringList(saveBlueToken, saveStrList); - // - // var privateKey = await Storage.getStringList(saveBluePrivateKey); - // List getPrivateKeyList = changeStringListToIntList(privateKey!); - // - // var publicKey = await Storage.getStringList(saveBluePublicKey); - // List publicKeyDataList = changeStringListToIntList(publicKey!); - // - // IoSenderManage.senderAddStressFingerprintCommand( - // keyID:"1", - // userID:await Storage.getUid(), - // fingerNo:1, - // useCountLimit:1, - // // startTime:0x11223344, - // // endTime:0x11223344, - // startTime:int.parse(state.startDate.value)~/1000, - // endTime:int.parse(state.endDate.value)~/1000, - // needAuthor:1, - // publicKey:publicKeyDataList, - // privateKey:getPrivateKeyList, - // token: token, - // ); + break; case 0x07: //无权限 diff --git a/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_state.dart b/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_state.dart index 3914ec93..86f4ce26 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_state.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/addFingerprint/addFingerprint_state.dart @@ -8,7 +8,7 @@ class AddFingerprintState{ final endDate = "".obs; final addType = "".obs; final fingerprintName = "".obs; - final fingerprintNumber = "".obs; + // final fingerprintNumber = "".obs; final fingerprintType = "".obs; final isCoerced = "".obs; final startDate = "".obs; @@ -21,7 +21,7 @@ class AddFingerprintState{ endDate.value = map["endDate"]; addType.value = map["addType"]; fingerprintName.value = map["fingerprintName"]; - fingerprintNumber.value = map["fingerprintNumber"]; + // fingerprintNumber.value = map["fingerprintNumber"]; fingerprintType.value = map["fingerprintType"]; isCoerced.value = map["isCoerced"]; print("isCoerced.valueisCoerced.value:${isCoerced.value}"); diff --git a/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart b/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart index bd998911..8aa48c07 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_logic.dart @@ -55,13 +55,14 @@ class FingerprintDetailLogic extends BaseGetXController{ var token = await Storage.getStringList(saveBlueToken); List getTokenList = changeStringListToIntList(token!); + String? userID = await Storage.getUid(); IoSenderManage.senderAddFingerprintCommand( - keyID:"1", - userID:"DeleteAll!@#", - fingerNo:255, + keyID:state.keyId.value.toString(), + userID:userID, + fingerNo:int.parse(state.typeNumber.value), useCountLimit:0, - startTime:0x11223344, - endTime:0x11223344, + startTime:state.effectiveDateTime.value, + endTime:state.failureDateTime.value, needAuthor:1, publicKey:publicKeyDataList, privateKey:getPrivateKeyList, @@ -104,7 +105,7 @@ class FingerprintDetailLogic extends BaseGetXController{ IoSenderManage.senderAddFingerprintCommand( keyID:state.keyId.value.toString(), userID:userID, - fingerNo:1, + fingerNo:int.parse(state.typeNumber.value), useCountLimit:0, startTime:state.effectiveDateTime.value, endTime:state.failureDateTime.value, @@ -117,6 +118,20 @@ class FingerprintDetailLogic extends BaseGetXController{ }); } + // 删除指纹 + void deletFingerprintsData() async{ + var entity = await ApiRepository.to.deletFingerprintsData( + fingerprintId: state.fingerprintItemData.value.fingerprintId.toString(), + lockId: state.fingerprintItemData.value.lockId.toString(), + type: "0", + deleteType:"1" + ); + if(entity.errorCode!.codeIsSuccessful){ + Toast.show(msg: "删除成功"); + Get.back(result: "addScuess"); + } + } + // 编辑指纹 void editFingerprintsData() async{ var entity = await ApiRepository.to.editFingerprintsData( @@ -135,20 +150,6 @@ class FingerprintDetailLogic extends BaseGetXController{ } } - // 删除指纹 - void deletFingerprintsData() async{ - var entity = await ApiRepository.to.deletFingerprintsData( - fingerprintId: state.fingerprintItemData.value.fingerprintId.toString(), - lockId: state.fingerprintItemData.value.lockId.toString(), - type: "0", - deleteType:"1" - ); - if(entity.errorCode!.codeIsSuccessful){ - Toast.show(msg: "删除成功"); - Get.back(result: "addScuess"); - } - } - @override void onReady() { // TODO: implement onReady diff --git a/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_state.dart b/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_state.dart index e5789f80..a66a59b2 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_state.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/fingerprintDetail/fingerprintDetail_state.dart @@ -17,7 +17,7 @@ class FingerprintDetailState{ var weekDay = [].obs;// 有效日 var adder = "".obs;// 添加者 var addTime = 0.obs;// 添加时间 - var keyId = 0.obs;// 添加时间 + var keyId = 0.obs; final isStressFingerprint = false.obs; FingerprintDetailState() { diff --git a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart index f65476f0..8d34d2fc 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_logic.dart @@ -67,9 +67,9 @@ class FingerprintListLogic extends BaseGetXController{ List getTokenList = changeStringListToIntList(token!); IoSenderManage.senderAddFingerprintCommand( - keyID:"1", - userID:"DeleteAll!@#", - fingerNo:255, + keyID:state.deletKeyID, + userID:state.deletUserID, + fingerNo:state.deletFingerNo, useCountLimit:0, startTime:0x11223344, endTime:0x11223344, @@ -292,7 +292,7 @@ class FingerprintListLogic extends BaseGetXController{ } // 删除指纹 - Future senderAddFingerprint(String keyId, String userID, int cardNo) async { + Future senderAddFingerprint() async { BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { if (deviceConnectionState == DeviceConnectionState.connected){ var publicKey = await Storage.getStringList(saveBluePublicKey); @@ -305,12 +305,9 @@ class FingerprintListLogic extends BaseGetXController{ List getTokenList = changeStringListToIntList(token!); IoSenderManage.senderAddFingerprintCommand( - // keyID:"1", - // userID:"DeleteAll!@#", - // fingerNo:255, - keyID:keyId, - userID:userID, - fingerNo:cardNo, + keyID:state.deletKeyID, + userID:state.deletUserID, + fingerNo:state.deletFingerNo, useCountLimit:0, startTime:0x11223344, endTime:0x11223344, @@ -339,17 +336,25 @@ class FingerprintListLogic extends BaseGetXController{ // 重置所有的指纹 void deletAllFingerprintsData() async{ var fingerprintId = ""; + var type = "1"; if(state.isDeletAll == false){ - // fingerprintId = + fingerprintId = state.deletKeyID; + type = "0"; } + print("delet fingerprintId $fingerprintId"); var entity = await ApiRepository.to.deletFingerprintsData( fingerprintId: fingerprintId, lockId: state.lockId.value.toString(), - type: "1", + type: type, deleteType:"1" ); if(entity.errorCode!.codeIsSuccessful){ - Toast.show(msg: "重置成功"); + if(state.isDeletAll == false){ + Toast.show(msg: "删除成功"); + }else{ + Toast.show(msg: "重置成功"); + } + state.isDeletFingerprintData = false; getFingerprintsListData(); } diff --git a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart index c09eca7d..7dde045c 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_page.dart @@ -125,7 +125,6 @@ class _FingerprintListPageState extends State { } Widget _buildMainUI() { - return Obx(() => state.fingerprintItemListData.value.isNotEmpty ? ListView.separated( itemCount: state.fingerprintItemListData.value.length, @@ -137,7 +136,7 @@ class _FingerprintListPageState extends State { key: Key(fingerprintItemData.fingerprintName!), actionsWidth: 60, actions: [ - _buildDeleteBtn(fingerprintItemData.fingerprintId.toString()), + _buildDeleteBtn(fingerprintItemData), ], decoration: const BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(1)), @@ -172,12 +171,13 @@ class _FingerprintListPageState extends State { : const NoData()); } - Widget _buildDeleteBtn(String idStr) { + Widget _buildDeleteBtn(FingerprintItemData fingerprintItemData) { return GestureDetector( onTap: () { // 省略: 弹出是否删除的确认对话框。 - state.deletFingerprintId = idStr; - showIosTipViewDialog(context, idStr); + state.deletKeyID = fingerprintItemData.fingerprintId.toString(); + state.deletFingerNo = int.parse(fingerprintItemData.fingerprintNumber!); + showIosTipViewDialog(context); }, child: Container( width: 60, @@ -196,7 +196,7 @@ class _FingerprintListPageState extends State { ); } - void showIosTipViewDialog(BuildContext context, String keyId) { + void showIosTipViewDialog(BuildContext context) { showDialog( context: context, builder: (BuildContext context) { @@ -205,10 +205,10 @@ class _FingerprintListPageState extends State { tipTitle: "确定要删除吗?", sureClick: () async { Get.back(); - String? idStr = await Storage.getUid(); state.isDeletFingerprintData = true; state.isDeletAll = false; - logic.senderAddFingerprint(keyId, idStr ?? "", 0); + state.deletUserID = (await Storage.getUid())!; + logic.senderAddFingerprint(); }, cancelClick: () { Get.back(); @@ -290,7 +290,10 @@ class _FingerprintListPageState extends State { Navigator.pop(context); state.isDeletFingerprintData = true; state.isDeletAll = true; - logic.senderAddFingerprint("1", "DeleteAll!@#", 255); + state.deletKeyID = "1"; + state.deletUserID = "DeleteAll!@#"; + state.deletFingerNo = 255; + logic.senderAddFingerprint(); }, ), ], diff --git a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_state.dart b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_state.dart index bcd866dc..e0d301fb 100644 --- a/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_state.dart +++ b/star_lock/lib/main/lockDetail/fingerprint/fingerprintList/fingerprintList_state.dart @@ -10,7 +10,9 @@ class FingerprintListState{ // 因为删除跟添加指纹用的同一个协议 所以这里用做判断 var isDeletFingerprintData = false; var isDeletAll = false; - var deletFingerprintId = "0"; + var deletKeyID = ""; + var deletUserID = "DeleteAll!@#"; + var deletFingerNo = 0; final fingerprintItemListData = [].obs; final TextEditingController searchController = TextEditingController(); diff --git a/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_page.dart b/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_page.dart index bcb893aa..985c4bd7 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_page.dart @@ -31,16 +31,18 @@ class _AutomaticBlockingPageState extends State { barTitle: TranslationLoader.lanKeys!.automaticBlocking!.tr, haveBack: true, actionsList: [ - TextButton( + Obx(() => TextButton( child: Text( - TranslationLoader.lanKeys!.save!.tr, + state.isJustForShow.value == true ? "" : TranslationLoader.lanKeys!.save!.tr, style: TextStyle(color: Colors.white, fontSize: 24.sp), ), onPressed: () { - // logic.sendAutoLock(); + if(state.isJustForShow.value == true){ + return; + } logic.sendAutoLock(); }, - ), + )), ], backgroundColor: AppColors.mainColor), body: ListView( @@ -60,6 +62,9 @@ class _AutomaticBlockingPageState extends State { isHaveLine: false, isHaveDirection: true, action: () { + if(state.isJustForShow.value == true){ + return; + } var list = [ "5", "10", @@ -110,11 +115,12 @@ class _AutomaticBlockingPageState extends State { ), ], ), - TextField( + Obx(() => TextField( //输入框一行 maxLines: 1, controller: state.timeController, autofocus: false, + readOnly: state.isJustForShow.value == true ? false : true, decoration: InputDecoration( //输入里面输入文字内边距设置 contentPadding: @@ -125,7 +131,7 @@ class _AutomaticBlockingPageState extends State { //不需要输入框下划线 border: InputBorder.none, ), - ), + )), Container( height: 0.5.h, color: Colors.grey, diff --git a/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_state.dart b/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_state.dart index 4892c72d..80aac784 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_state.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/automaticBlocking/automaticBlocking_state.dart @@ -7,6 +7,9 @@ import '../lockSet/lockSetInfo_entity.dart'; class AutomaticBlockingState { var lockSetInfoData = LockSetInfoData().obs; + final lockBasicInfo = LockBasicInfo().obs; + + var isJustForShow = false.obs;// 是否只是作为展示作用,因为普通用户只是展示,不可修改 var isOpen = false.obs;// 是否开启自动落锁 var autoLockTime = "5".obs; @@ -16,10 +19,17 @@ class AutomaticBlockingState { AutomaticBlockingState() { var map = Get.arguments; lockSetInfoData.value = map["lockSetInfoData"]; + lockBasicInfo.value = map["lockBasicInfo"]; isOpen.value = lockSetInfoData.value.lockSettingInfo!.autoLock! == 1 ? true : false; autoLockTime.value = lockSetInfoData.value.lockSettingInfo!.autoLockSecond!.toString(); + if(lockBasicInfo.value.isLockOwner == 1 || lockBasicInfo.value.keyRight == 1){ + isJustForShow.value = false; + }else{ + isJustForShow.value = true; + } + if((lockSetInfoData.value.lockSettingInfo!.autoLock! > 0) && (lockSetInfoData.value.lockSettingInfo!.autoLockSecond! != 5) && (lockSetInfoData.value.lockSettingInfo!.autoLockSecond! != 10) diff --git a/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_page.dart b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_page.dart index e90c047f..a96903b7 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/basicInformation/basicInformation/basicInformation_page.dart @@ -107,15 +107,17 @@ class _BasicInformationPageState extends State { } }); }), - CommonItem( - leftTitel: TranslationLoader.lanKeys!.adminOpenLockPassword!.tr, - rightTitle: "", - isHaveLine: true, - isHaveDirection: true, - action: () { - Navigator.pushNamed(context, - Routers.adminOpenLockPasswordPage); - }), + Visibility( + visible: (state.lockBasicInfo.value.isLockOwner == 1 || state.lockBasicInfo.value.keyRight == 1) ? true : false, + child: CommonItem( + leftTitel: TranslationLoader.lanKeys!.adminOpenLockPassword!.tr, + rightTitle: "", + isHaveLine: true, + isHaveDirection: true, + action: () { + Navigator.pushNamed(context, Routers.adminOpenLockPasswordPage); + }), + ), CommonItem( leftTitel: TranslationLoader.lanKeys!.unlockQRCode!.tr, diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSetInfo_entity.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSetInfo_entity.dart index cc2c0212..ee6a22b5 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSetInfo_entity.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSetInfo_entity.dart @@ -314,6 +314,8 @@ class LockBasicInfo { int? startDate; int? endDate; String? mac; + int? keyRight; + int? senderUserId; LockBasicInfo( {this.keyId, @@ -328,7 +330,9 @@ class LockBasicInfo { this.keyType, this.startDate, this.endDate, - this.mac}); + this.mac, + this.keyRight, + this.senderUserId}); LockBasicInfo.fromJson(Map json) { keyId = json['keyId']; @@ -349,6 +353,9 @@ class LockBasicInfo { startDate = json['startDate']; endDate = json['endDate']; mac = json['mac']; + keyRight = json['keyRight']; + senderUserId = json['senderUserId']; + } Map toJson() { @@ -368,6 +375,8 @@ class LockBasicInfo { data['startDate'] = startDate; data['endDate'] = endDate; data['mac'] = mac; + data['keyRight'] = keyRight; + data['senderUserId'] = senderUserId; return data; } } diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart index 08ccd6e6..c8662fba 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_logic.dart @@ -1,5 +1,6 @@ import 'dart:async'; +import 'package:flutter/cupertino.dart'; import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; import 'package:get/get.dart'; import 'package:star_lock/blue/io_protocol/io_deletUser.dart'; @@ -19,6 +20,7 @@ import '../../../../tools/baseGetXController.dart'; import '../../../../tools/eventBusEventManage.dart'; import '../../../../tools/storage.dart'; import '../../../../tools/toast.dart'; +import '../../../../translations/trans_lib.dart'; import 'checkingInInfoData_entity.dart'; import 'lockSet_state.dart'; @@ -248,9 +250,7 @@ class LockSetLogic extends BaseGetXController { // 删除用户 Future deletUserAction() async { - BlueManage().judgeReconnect( - BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, - (DeviceConnectionState connectionState) async { + BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState connectionState) async { if (connectionState == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -263,13 +263,18 @@ class LockSetLogic extends BaseGetXController { IoSenderManage.deletUser( lockID: BlueManage().connectDeviceName, - authUserID: "100001", - keyID: "1", - delUserID: "100001", + authUserID:state.lockBasicInfo.value.senderUserId.toString(), + keyID:state.lockBasicInfo.value.keyId.toString(), + delUserID:await Storage.getUid(), + // authUserID: "100001", + // keyID: "1", + // delUserID: "100001", needAuthor: 1, publicKey: publicKeyDataList, privateKey: getPrivateKeyList, token: getTokenList); + }else{ + showDeletAlertTipDialog(Get.context!); } }); } @@ -296,6 +301,8 @@ class LockSetLogic extends BaseGetXController { privateKey:getPrivateKeyList, token: getTokenList ); + }else{ + showDeletAlertTipDialog(Get.context!); } }); } @@ -378,6 +385,8 @@ class LockSetLogic extends BaseGetXController { state.lockSettingInfo.value = state.lockSetInfoData.value.lockSettingInfo!; state.lockFeature.value = state.lockSetInfoData.value.lockFeature!; state.lockStatus.value = state.lockSetInfoData.value.lockStatus!; + state.lockBasicInfo.value = state.lockSetInfoData.value.lockBasicInfo!; + state.isAttendance.value = state.lockSettingInfo.value.attendance!; state.isOpenLockNeedOnline.value = state.lockSettingInfo.value.appUnlockOnline!; @@ -395,6 +404,7 @@ class LockSetLogic extends BaseGetXController { lockId: state.lockSetInfoData.value.lockId.toString(), ); if (entity.errorCode!.codeIsSuccessful) { + BlueManage().connectDeviceMacAddress = ""; Get.offAllNamed(Routers.starLockMain); } } @@ -406,6 +416,7 @@ class LockSetLogic extends BaseGetXController { keyId: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(), ); if (entity.errorCode!.codeIsSuccessful) { + BlueManage().connectDeviceMacAddress = ""; Get.offAllNamed(Routers.starLockMain); } } @@ -416,7 +427,7 @@ class LockSetLogic extends BaseGetXController { password: state.passwordTF.text, ); if (entity.errorCode!.codeIsSuccessful) { - deletLockInfoData(); + // deletLockInfoData(); blockDeletNumberCheckPasswordCallback(); // if(state.currentDeviceUUid.value.isEmpty){ @@ -425,13 +436,23 @@ class LockSetLogic extends BaseGetXController { // } // if(state.currentDeviceUUid.value[31] == "1"){ - // 已配对 + // 判断是否是锁的拥有者 if(state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1){ - // 调用删除锁协议 - factoryDataResetAction(); + // 判断是否扫描到当前设备 + if(BlueManage().connectDeviceMacAddress.isNotEmpty){ + // 调用删除锁协议 + factoryDataResetAction(); + }else{ + showDeletAlertTipDialog(Get.context!); + } }else{ - // 调用删除钥匙协议 - deletUserAction(); + // 判断是否扫描到当前设备 + if(BlueManage().connectDeviceMacAddress.isNotEmpty){ + // 调用删除钥匙协议 + deletUserAction(); + }else{ + showDeletAlertTipDialog(Get.context!); + } } // }else if(state.currentDeviceUUid.value[31] == "0"){ @@ -528,6 +549,39 @@ class LockSetLogic extends BaseGetXController { }); } + void showDeletAlertTipDialog(BuildContext context) { + showCupertinoDialog( + context: context, + builder: (context) { + return CupertinoAlertDialog( + title: const Text("提示"), + content: const Text('删除门锁后如需重新添加需要在门锁设置的"蓝牙功能"选项下先"清除配对",确定吗?'), + actions: [ + CupertinoDialogAction( + child: Text(TranslationLoader.lanKeys!.cancel!.tr), + onPressed: () { + Navigator.pop(context); + }, + ), + CupertinoDialogAction( + child: Text(TranslationLoader.lanKeys!.sure!.tr), + onPressed: () { + Navigator.pop(context); + if(state.lockSetInfoData.value.lockBasicInfo!.isLockOwner == 1){ + // 直接调用删除锁接口 + deletLockInfoData(); + }else{ + // 直接调用删除要是接口 + deletKeyData(); + } + }, + ), + ], + ); + }, + ); + } + @override void onReady() { // TODO: implement onReady diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart index 92e77479..a778b5aa 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart @@ -49,489 +49,598 @@ class _LockSetPageState extends State with RouteAware { children: [ Expanded( child: ListView( - children: [ - // 基本信息 - CommonItem( - leftTitel: - TranslationLoader.lanKeys!.basicInformation!.tr, - rightTitle: "", - isHaveLine: false, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.basicInformationPage, arguments: { - 'lockSetInfoData': state.lockSetInfoData.value - }); - }), - SizedBox(height: 10.h), - // 门磁 - Obx(() => Visibility( - visible: state.lockFeature.value.doorStatus == 1 - ? true - : false, - child: CommonItem( - leftTitel: - TranslationLoader.lanKeys!.doorMagnetic!.tr, - rightTitle: "", - isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.doorMagneticPage); - // Toast.show(msg: "功能暂未开放"); - }))), - // 无线键盘 - Obx(() => Visibility( - visible: state.lockFeature.value.wirelessKeyboard == 1 - ? true - : false, - child: CommonItem( - leftTitel: - TranslationLoader.lanKeys!.wirelessKeyboard!.tr, - rightTitle: "", - isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.wirelessKeyboardPage); - // Toast.show(msg: "功能暂未开放"); - }))), - // 照明 - Obx(() => Visibility( - visible: state.lockFeature.value.lightingTime == 1 - ? true - : false, - child: CommonItem( - leftTitel: TranslationLoader.lanKeys!.illumination!.tr, - rightTitle: "", - isHaveLine: true, - isHaveDirection: true, - action: () { - Toast.show(msg: "功能暂未开放"); - }))), - // 开门器 - Visibility( - visible: true, - child: CommonItem( - leftTitel: TranslationLoader.lanKeys!.doorOpener!.tr, - rightTitle: "", - isHaveLine: false, - isHaveDirection: true, - action: () { - Toast.show(msg: "功能暂未开放"); - })), - SizedBox(height: 10.h), - // 自动闭锁 - Obx(() => Visibility( - visible: - state.lockFeature.value.autoLock == 1 ? true : false, - child: CommonItem( - leftTitel: - TranslationLoader.lanKeys!.automaticBlocking!.tr, - rightTitle: (state.lockSettingInfo.value.autoLock ?? 0) > 0 - ? "${state.lockSetInfoData.value.lockSettingInfo!.autoLockSecond ?? 0}s" - : TranslationLoader.lanKeys!.closed!.tr, - isHaveLine: true, - isHaveDirection: true, - // isHaveRightWidget: true, - // rightWidget: rightText((state.lockSetInfoData.value.lockSetting!.autoLock ?? 0) > 0 - // ? "${state.lockSetInfoData.value.lockSetting!.autoLockSecond ?? 0}s" - // : TranslationLoader.lanKeys!.closed!.tr), - action: () { - Get.toNamed(Routers.automaticBlockingPage, - arguments: { - 'lockSetInfoData': state.lockSetInfoData.value - }); - }))), - // 锁声音 - Obx(() { - var titleStr = ""; - if ((state.lockSettingInfo.value.lockSound ?? 0) == 1) { - switch ( - state.lockSettingInfo.value.lockSoundVolume ?? 0) { - case 1: - titleStr = TranslationLoader.lanKeys!.low!.tr; - break; - case 2: - titleStr = TranslationLoader.lanKeys!.lower!.tr; - break; - case 3: - titleStr = TranslationLoader.lanKeys!.medium!.tr; - break; - case 4: - titleStr = TranslationLoader.lanKeys!.high!.tr; - break; - case 5: - titleStr = TranslationLoader.lanKeys!.higher!.tr; - break; - } - } else { - titleStr = TranslationLoader.lanKeys!.closed!.tr; - } - return Visibility( - visible: state.lockFeature.value.lockSound == 1 - ? true - : false, - child: CommonItem( - leftTitel: TranslationLoader.lanKeys!.lockSound!.tr, - rightTitle: titleStr, - isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.lockSoundSetPage, arguments: { - 'lockSetInfoData': state.lockSetInfoData.value - }); - })); - }), - // 防撬报警 - Obx(() => Visibility( - visible: state.lockFeature.value.antiPrySwitch == 1 - ? true - : false, - child: CommonItem( - leftTitel: - TranslationLoader.lanKeys!.burglarAlarm!.tr, - rightTitle: - (state.lockSettingInfo.value.antiPrySwitch ?? 0) == 1 - ? TranslationLoader.lanKeys!.opened!.tr - : TranslationLoader.lanKeys!.closed!.tr, - isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.burglarAlarmPage, arguments: { - 'lockSetInfoData': state.lockSetInfoData.value - }); - }))), - SizedBox(height: 10.h), - // 常开模式 - Obx(() => Visibility( - visible: state.lockFeature.value.passageMode == 1 - ? true - : false, - // visible:true, - child: CommonItem( - leftTitel: - TranslationLoader.lanKeys!.normallyOpenMode!.tr, - rightTitle: - (state.lockSettingInfo.value.passageMode ?? 0) == - 1 - ? TranslationLoader.lanKeys!.opened!.tr - : TranslationLoader.lanKeys!.closed!.tr, - isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.normallyOpenModePage, - arguments: { - 'lockSetInfoData': state.lockSetInfoData.value - }); - }))), - // 远程开锁 - Obx(() => Visibility( - visible: state.lockFeature.value.remoteUnlock == 1 - ? true - : false, - child: CommonItem( - leftTitel: - TranslationLoader.lanKeys!.remoteUnlocking!.tr, - rightTitle: - (state.lockSettingInfo.value.remoteUnlock ?? 0) == - 1 - ? TranslationLoader.lanKeys!.opened!.tr - : TranslationLoader.lanKeys!.closed!.tr, - isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.remoteUnlockingPage, - arguments: { - 'lockSetInfoData': state.lockSetInfoData.value - }); - }))), - // 重置键 - Obx(() => Visibility( - visible: state.lockFeature.value.resetSwitch == 1 - ? true - : false, - child: CommonItem( - leftTitel: TranslationLoader.lanKeys!.resetButton!.tr, - rightTitle: - (state.lockSettingInfo.value.resetSwitch ?? 0) == - 1 - ? TranslationLoader.lanKeys!.opened!.tr - : TranslationLoader.lanKeys!.closed!.tr, - isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.resetButtonPage, arguments: { - 'lockSetInfoData': state.lockSetInfoData.value - }); - }))), - SizedBox(height: 10.h), - //---田总新增展示 - // Obx(() => - Visibility( - visible: true, - child: CommonItem( - leftTitel: TranslationLoader.lanKeys!.faceUnlocks!.tr, - rightTitle: "", - isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.faceUnlockPage); - })), - // ), - Visibility( - visible: true, - child: CommonItem( - leftTitel: TranslationLoader.lanKeys!.messageReminding!.tr, - rightTitle: "", - isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.msgNotificationPage); - })), - Visibility( - visible: true, - child: CommonItem( - leftTitel: TranslationLoader.lanKeys!.catEyeSet!.tr, - rightTitle: "", - isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.catEyeSetPage); - })), - // Obx(() => - //自动亮屏已包括至面容开锁模块 - // Visibility( - // visible: true, - // child: CommonItem( - // leftTitel: '自动亮屏', - // rightTitle: "", - // isHaveLine: true, - // isHaveDirection: true, - // action: () {})), - // ), - - // Obx(() => - //感应距离已包括至面容开锁模块 - // Visibility( - // visible: true, - // child: CommonItem( - // leftTitel: '感应距离', - // rightTitle: "", - // isHaveLine: true, - // isHaveDirection: true, - // action: () { - // Toast.show(msg: "功能暂未开放"); - // })), - // ), - // Obx(() => - Visibility( - visible: true, - child: CommonItem( - leftTitel: TranslationLoader.lanKeys!.openingDirectionSet!.tr, - rightTitle: "", - isHaveDirection: true, - isHaveLine: true, - action: () { - // Toast.show(msg: "功能暂未开放"); - Get.toNamed(Routers.openDoorDirectionPage, arguments: { - 'lockSetInfoData': state.lockSetInfoData.value - }); - })), - Visibility( - visible: true, - child: CommonItem( - leftTitel: TranslationLoader.lanKeys!.motorPowerSetting!.tr, - rightTitle: "", - isHaveLine: true, - isHaveDirection: true, - action: () { - // Toast.show(msg: "功能暂未开放"); - Get.toNamed(Routers.motorPowerPage); - })), - // 支持蓝牙广播(关闭则不能使用蓝牙主动开锁) - Obx(() => Visibility( - visible: true, - child: CommonItem( - leftTitel: TranslationLoader.lanKeys!.bluetoothBroadcast!.tr, - rightTitle: "", - isHaveLine: true, - isHaveRightWidget: true, - rightWidget: _lockBlueBroadcastSwitch()))), - SizedBox(height: 10.h), - //-----新增至此 - // 标记房态 - Obx(() { - var title = ""; - if (state.lockStatus.value.roomStatus == 1) { - title = TranslationLoader.lanKeys!.checkedIn!.tr; - } else if (state.lockStatus.value.roomStatus == 0) { - title = TranslationLoader.lanKeys!.leisure!.tr; - } - return Visibility( - visible: state.lockStatus.value.roomStatus == 1 - ? true - : false, - child: CommonItem( - leftTitel: - TranslationLoader.lanKeys!.markedHouseState!.tr, - rightTitle: title, - isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.markedHouseStatePage, - arguments: { - 'lockSetInfoData': - state.lockSetInfoData.value - }); - })); - }), - // 考勤 - Obx( - () => Visibility( - visible: state.lockFeature.value.attendance == 1 - ? true - : false, - child: CommonItem( - leftTitel: - TranslationLoader.lanKeys!.checkingIn!.tr, - rightTitle: "", - isHaveLine: true, - isHaveRightWidget: true, - rightWidget: _openCheckInSwitch())), - ), - // 开锁提醒 - Obx( - () => Visibility( - visible: state.lockFeature.value.unlockReminder == 1 ? true : false, - child: CommonItem( - leftTitel: TranslationLoader.lanKeys!.unlockReminder!.tr, - rightTitle: "", - isHaveLine: false, - isHaveRightWidget: true, - rightWidget: _lockRemindSwitch())), - ), - // APP开锁时是否需联网 - Obx(() => - Visibility( - visible: state.lockFeature.value.appUnlockOnline == 1 ? true : false, - child: - CommonItem( - leftTitel: TranslationLoader.lanKeys!.whetherInternetRequiredWhenUnlocking!.tr, - rightTitle: "", - isHaveLine: false, - isHaveRightWidget: true, - rightWidget: _openLockNeedOnlineSwitch()), - ), - ), - SizedBox(height: 10.h), - // wifi配网 - Obx( - () => Visibility( - visible: - state.lockFeature.value.wifi == 1 ? true : false, - child: - CommonItem( - leftTitel: TranslationLoader.lanKeys!.wifiDistributionNetwork!.tr, - rightTitle: "", - isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.configuringWifiPage, - arguments: { - 'lockSetInfoData': - state.lockSetInfoData.value - }); - }) - ), - ), - // Obx(() => - // 锁时间 - Visibility( - visible: true, - child: CommonItem( - leftTitel: TranslationLoader.lanKeys!.lockTime!.tr, - rightTitle: "", - isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.lockTimePage, arguments: { - 'lockSetInfoData': state.lockSetInfoData.value - }); - })), - // ), - // Obx(() => - // 诊断 - Visibility( - visible: true, - child: CommonItem( - leftTitel: TranslationLoader.lanKeys!.diagnose!.tr, - rightTitle: "", - isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.diagnosePage, arguments: { - 'lockSetInfoData': state.lockSetInfoData.value - }); - })), - // ), - // Obx(() => - // 上传数据 - Visibility( - visible: true, - child: CommonItem( - leftTitel: TranslationLoader.lanKeys!.uploadData!.tr, - rightTitle: "", - isHaveLine: true, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.uploadDataPage); - })), - // ), - // Obx(() => - // Visibility( - // visible: true, - // child: CommonItem( - // leftTitel: TranslationLoader - // .lanKeys!.importOtherLockData!.tr, - // rightTitle: "", - // isHaveLine: true, - // isHaveDirection: true, - // action: () { - // Get.toNamed(Routers.importOtherLockDataPage); - // })), - // ), - // Obx(() => - // 锁升级 - Visibility( - visible: true, - child: CommonItem( - leftTitel: - TranslationLoader.lanKeys!.lockEscalation!.tr, - rightTitle: "", - isHaveLine: false, - isHaveDirection: true, - action: () { - Get.toNamed(Routers.lockEscalationPage); - })), - // ), - SizedBox(height: 30.h), - Container( - padding: - EdgeInsets.only(left: 20.w, right: 20.w, bottom: 30.h), - child: SubmitBtn( - btnName: TranslationLoader.lanKeys!.delete!.tr, - isDelete: true, - onClick: () { - // logic.deletUserAction(); - - // logic.deletLockInfoData(); - showDeletAlertDialog(context); - // showDeletPasswordAlertDialog(context); - }), - ), - ], + children: getListWidget(), ), ), ], - )); + ) + ); + } + + // 根据权限显示不同的列表 + List getListWidget(){ + if(state.lockBasicInfo.value.isLockOwner == 1 || state.lockBasicInfo.value.keyRight == 1){ + // 超级管理员、授权管理员 + return getAllWidget(); + }else{ + return getNormalWidget(); + } + } + + // 普通用户 + List getNormalWidget() { + var showWidgetArr = [ + // 基本信息 + CommonItem( + leftTitel: + TranslationLoader.lanKeys!.basicInformation!.tr, + rightTitle: "", + isHaveLine: false, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.basicInformationPage, arguments: { + 'lockSetInfoData': state.lockSetInfoData.value + }); + }), + SizedBox(height: 10.h), + // 自动闭锁 + Obx(() => Visibility( + visible: + state.lockFeature.value.autoLock == 1 ? true : false, + child: CommonItem( + leftTitel: + TranslationLoader.lanKeys!.automaticBlocking!.tr, + rightTitle: (state.lockSettingInfo.value.autoLock ?? 0) > 0 + ? "${state.lockSetInfoData.value.lockSettingInfo!.autoLockSecond ?? 0}s" + : TranslationLoader.lanKeys!.closed!.tr, + isHaveLine: true, + isHaveDirection: true, + // isHaveRightWidget: true, + // rightWidget: rightText((state.lockSetInfoData.value.lockSetting!.autoLock ?? 0) > 0 + // ? "${state.lockSetInfoData.value.lockSetting!.autoLockSecond ?? 0}s" + // : TranslationLoader.lanKeys!.closed!.tr), + action: () { + Get.toNamed(Routers.automaticBlockingPage, + arguments: { + 'lockSetInfoData': state.lockSetInfoData.value, + 'lockBasicInfo': state.lockBasicInfo.value + }); + }))), + // 常开模式 + Obx(() => Visibility( + visible: state.lockFeature.value.passageMode == 1 ? true : false, + // visible:true, + child: CommonItem( + leftTitel: + TranslationLoader.lanKeys!.normallyOpenMode!.tr, + rightTitle: + (state.lockSettingInfo.value.passageMode ?? 0) == + 1 + ? TranslationLoader.lanKeys!.opened!.tr + : TranslationLoader.lanKeys!.closed!.tr, + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.normallyOpenModePage, + arguments: { + 'lockSetInfoData': state.lockSetInfoData.value, + 'lockBasicInfo': state.lockBasicInfo.value + }); + }))), + Visibility( + visible: true, + child: CommonItem( + leftTitel: TranslationLoader.lanKeys!.lockTime!.tr, + rightTitle: "", + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.lockTimePage, arguments: { + 'lockSetInfoData': state.lockSetInfoData.value + }); + })), + SizedBox(height: 30.h), + Container( + padding: + EdgeInsets.only(left: 20.w, right: 20.w, bottom: 30.h), + child: SubmitBtn( + btnName: TranslationLoader.lanKeys!.delete!.tr, + isDelete: true, + onClick: () { + // logic.deletUserAction(); + + // logic.deletLockInfoData(); + showDeletAlertDialog(context); + // showDeletPasswordAlertDialog(context); + }), + ), + ]; + return showWidgetArr; + } + + // 授权管理员、超级管理员字段 + List getAllWidget() { + var showWidgetArr = [ + // 基本信息 + CommonItem( + leftTitel: + TranslationLoader.lanKeys!.basicInformation!.tr, + rightTitle: "", + isHaveLine: false, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.basicInformationPage, arguments: { + 'lockSetInfoData': state.lockSetInfoData.value + }); + }), + SizedBox(height: 10.h), + // 门磁 + Obx(() => Visibility( + visible: state.lockFeature.value.doorStatus == 1 + ? true + : false, + child: CommonItem( + leftTitel: + TranslationLoader.lanKeys!.doorMagnetic!.tr, + rightTitle: "", + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.doorMagneticPage); + // Toast.show(msg: "功能暂未开放"); + }))), + // 无线键盘 + Obx(() => Visibility( + visible: state.lockFeature.value.wirelessKeyboard == 1 + ? true + : false, + child: CommonItem( + leftTitel: + TranslationLoader.lanKeys!.wirelessKeyboard!.tr, + rightTitle: "", + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.wirelessKeyboardPage); + // Toast.show(msg: "功能暂未开放"); + }))), + // 照明 + Obx(() => Visibility( + visible: state.lockFeature.value.lightingTime == 1 + ? true + : false, + child: CommonItem( + leftTitel: TranslationLoader.lanKeys!.illumination!.tr, + rightTitle: "", + isHaveLine: true, + isHaveDirection: true, + action: () { + Toast.show(msg: "功能暂未开放"); + }))), + // 开门器 + Visibility( + visible: true, + child: CommonItem( + leftTitel: TranslationLoader.lanKeys!.doorOpener!.tr, + rightTitle: "", + isHaveLine: false, + isHaveDirection: true, + action: () { + Toast.show(msg: "功能暂未开放"); + })), + SizedBox(height: 10.h), + // 自动闭锁 + Obx(() => Visibility( + visible: + state.lockFeature.value.autoLock == 1 ? true : false, + child: CommonItem( + leftTitel: + TranslationLoader.lanKeys!.automaticBlocking!.tr, + rightTitle: (state.lockSettingInfo.value.autoLock ?? 0) > 0 + ? "${state.lockSetInfoData.value.lockSettingInfo!.autoLockSecond ?? 0}s" + : TranslationLoader.lanKeys!.closed!.tr, + isHaveLine: true, + isHaveDirection: true, + // isHaveRightWidget: true, + // rightWidget: rightText((state.lockSetInfoData.value.lockSetting!.autoLock ?? 0) > 0 + // ? "${state.lockSetInfoData.value.lockSetting!.autoLockSecond ?? 0}s" + // : TranslationLoader.lanKeys!.closed!.tr), + action: () { + Get.toNamed(Routers.automaticBlockingPage, + arguments: { + 'lockSetInfoData': state.lockSetInfoData.value + }); + }))), + // 锁声音 + Obx(() { + var titleStr = ""; + if ((state.lockSettingInfo.value.lockSound ?? 0) == 1) { + switch ( + state.lockSettingInfo.value.lockSoundVolume ?? 0) { + case 1: + titleStr = TranslationLoader.lanKeys!.low!.tr; + break; + case 2: + titleStr = TranslationLoader.lanKeys!.lower!.tr; + break; + case 3: + titleStr = TranslationLoader.lanKeys!.medium!.tr; + break; + case 4: + titleStr = TranslationLoader.lanKeys!.high!.tr; + break; + case 5: + titleStr = TranslationLoader.lanKeys!.higher!.tr; + break; + } + } else { + titleStr = TranslationLoader.lanKeys!.closed!.tr; + } + return Visibility( + visible: state.lockFeature.value.lockSound == 1 + ? true + : false, + child: CommonItem( + leftTitel: TranslationLoader.lanKeys!.lockSound!.tr, + rightTitle: titleStr, + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.lockSoundSetPage, arguments: { + 'lockSetInfoData': state.lockSetInfoData.value + }); + })); + }), + // 防撬报警 + Obx(() => Visibility( + visible: state.lockFeature.value.antiPrySwitch == 1 + ? true + : false, + child: CommonItem( + leftTitel: + TranslationLoader.lanKeys!.burglarAlarm!.tr, + rightTitle: + (state.lockSettingInfo.value.antiPrySwitch ?? 0) == 1 + ? TranslationLoader.lanKeys!.opened!.tr + : TranslationLoader.lanKeys!.closed!.tr, + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.burglarAlarmPage, arguments: { + 'lockSetInfoData': state.lockSetInfoData.value + }); + }))), + SizedBox(height: 10.h), + // 常开模式 + Obx(() => Visibility( + visible: state.lockFeature.value.passageMode == 1 + ? true + : false, + // visible:true, + child: CommonItem( + leftTitel: + TranslationLoader.lanKeys!.normallyOpenMode!.tr, + rightTitle: + (state.lockSettingInfo.value.passageMode ?? 0) == + 1 + ? TranslationLoader.lanKeys!.opened!.tr + : TranslationLoader.lanKeys!.closed!.tr, + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.normallyOpenModePage, + arguments: { + 'lockSetInfoData': state.lockSetInfoData.value + }); + }))), + // 远程开锁 + Obx(() => Visibility( + visible: state.lockFeature.value.remoteUnlock == 1 + ? true + : false, + child: CommonItem( + leftTitel: + TranslationLoader.lanKeys!.remoteUnlocking!.tr, + rightTitle: + (state.lockSettingInfo.value.remoteUnlock ?? 0) == + 1 + ? TranslationLoader.lanKeys!.opened!.tr + : TranslationLoader.lanKeys!.closed!.tr, + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.remoteUnlockingPage, + arguments: { + 'lockSetInfoData': state.lockSetInfoData.value + }); + }))), + // 重置键 + Obx(() => Visibility( + visible: state.lockFeature.value.resetSwitch == 1 + ? true + : false, + child: CommonItem( + leftTitel: TranslationLoader.lanKeys!.resetButton!.tr, + rightTitle: + (state.lockSettingInfo.value.resetSwitch ?? 0) == + 1 + ? TranslationLoader.lanKeys!.opened!.tr + : TranslationLoader.lanKeys!.closed!.tr, + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.resetButtonPage, arguments: { + 'lockSetInfoData': state.lockSetInfoData.value + }); + }))), + SizedBox(height: 10.h), + //---田总新增展示 + // Obx(() => + Visibility( + visible: true, + child: CommonItem( + leftTitel: TranslationLoader.lanKeys!.faceUnlocks!.tr, + rightTitle: "", + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.faceUnlockPage); + })), + // ), + Visibility( + visible: true, + child: CommonItem( + leftTitel: TranslationLoader.lanKeys!.messageReminding!.tr, + rightTitle: "", + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.msgNotificationPage); + })), + Visibility( + visible: true, + child: CommonItem( + leftTitel: TranslationLoader.lanKeys!.catEyeSet!.tr, + rightTitle: "", + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.catEyeSetPage); + })), + // Obx(() => + //自动亮屏已包括至面容开锁模块 + // Visibility( + // visible: true, + // child: CommonItem( + // leftTitel: '自动亮屏', + // rightTitle: "", + // isHaveLine: true, + // isHaveDirection: true, + // action: () {})), + // ), + + // Obx(() => + //感应距离已包括至面容开锁模块 + // Visibility( + // visible: true, + // child: CommonItem( + // leftTitel: '感应距离', + // rightTitle: "", + // isHaveLine: true, + // isHaveDirection: true, + // action: () { + // Toast.show(msg: "功能暂未开放"); + // })), + // ), + // Obx(() => + Visibility( + visible: true, + child: CommonItem( + leftTitel: TranslationLoader.lanKeys!.openingDirectionSet!.tr, + rightTitle: "", + isHaveDirection: true, + isHaveLine: true, + action: () { + // Toast.show(msg: "功能暂未开放"); + Get.toNamed(Routers.openDoorDirectionPage, arguments: { + 'lockSetInfoData': state.lockSetInfoData.value + }); + })), + Visibility( + visible: true, + child: CommonItem( + leftTitel: TranslationLoader.lanKeys!.motorPowerSetting!.tr, + rightTitle: "", + isHaveLine: true, + isHaveDirection: true, + action: () { + // Toast.show(msg: "功能暂未开放"); + Get.toNamed(Routers.motorPowerPage); + })), + // 支持蓝牙广播(关闭则不能使用蓝牙主动开锁) + Obx(() => Visibility( + visible: true, + child: CommonItem( + leftTitel: TranslationLoader.lanKeys!.bluetoothBroadcast!.tr, + rightTitle: "", + isHaveLine: true, + isHaveRightWidget: true, + rightWidget: _lockBlueBroadcastSwitch()))), + SizedBox(height: 10.h), + //-----新增至此 + // 标记房态 + Obx(() { + var title = ""; + if (state.lockStatus.value.roomStatus == 1) { + title = TranslationLoader.lanKeys!.checkedIn!.tr; + } else if (state.lockStatus.value.roomStatus == 0) { + title = TranslationLoader.lanKeys!.leisure!.tr; + } + return Visibility( + visible: state.lockStatus.value.roomStatus == 1 + ? true + : false, + child: CommonItem( + leftTitel: + TranslationLoader.lanKeys!.markedHouseState!.tr, + rightTitle: title, + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.markedHouseStatePage, + arguments: { + 'lockSetInfoData': + state.lockSetInfoData.value + }); + })); + }), + // 考勤 + Obx( + () => Visibility( + visible: state.lockFeature.value.attendance == 1 + ? true + : false, + child: CommonItem( + leftTitel: + TranslationLoader.lanKeys!.checkingIn!.tr, + rightTitle: "", + isHaveLine: true, + isHaveRightWidget: true, + rightWidget: _openCheckInSwitch())), + ), + // 开锁提醒 + Obx( + () => Visibility( + visible: state.lockFeature.value.unlockReminder == 1 ? true : false, + child: CommonItem( + leftTitel: TranslationLoader.lanKeys!.unlockReminder!.tr, + rightTitle: "", + isHaveLine: false, + isHaveRightWidget: true, + rightWidget: _lockRemindSwitch())), + ), + // APP开锁时是否需联网 + Obx(() => + Visibility( + visible: state.lockFeature.value.appUnlockOnline == 1 ? true : false, + child: + CommonItem( + leftTitel: TranslationLoader.lanKeys!.whetherInternetRequiredWhenUnlocking!.tr, + rightTitle: "", + isHaveLine: false, + isHaveRightWidget: true, + rightWidget: _openLockNeedOnlineSwitch()), + ), + ), + SizedBox(height: 10.h), + // wifi配网 + Obx( + () => Visibility( + visible: + state.lockFeature.value.wifi == 1 ? true : false, + child: + CommonItem( + leftTitel: TranslationLoader.lanKeys!.wifiDistributionNetwork!.tr, + rightTitle: "", + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.configuringWifiPage, + arguments: { + 'lockSetInfoData': + state.lockSetInfoData.value + }); + }) + ), + ), + // Obx(() => + // 锁时间 + Visibility( + visible: true, + child: CommonItem( + leftTitel: TranslationLoader.lanKeys!.lockTime!.tr, + rightTitle: "", + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.lockTimePage, arguments: { + 'lockSetInfoData': state.lockSetInfoData.value + }); + })), + // ), + // Obx(() => + // 诊断 + Visibility( + visible: true, + child: CommonItem( + leftTitel: TranslationLoader.lanKeys!.diagnose!.tr, + rightTitle: "", + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.diagnosePage, arguments: { + 'lockSetInfoData': state.lockSetInfoData.value + }); + })), + // ), + // Obx(() => + // 上传数据 + Visibility( + visible: true, + child: CommonItem( + leftTitel: TranslationLoader.lanKeys!.uploadData!.tr, + rightTitle: "", + isHaveLine: true, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.uploadDataPage); + })), + // ), + // Obx(() => + // Visibility( + // visible: true, + // child: CommonItem( + // leftTitel: TranslationLoader + // .lanKeys!.importOtherLockData!.tr, + // rightTitle: "", + // isHaveLine: true, + // isHaveDirection: true, + // action: () { + // Get.toNamed(Routers.importOtherLockDataPage); + // })), + // ), + // Obx(() => + // 锁升级 + Visibility( + visible: true, + child: CommonItem( + leftTitel: + TranslationLoader.lanKeys!.lockEscalation!.tr, + rightTitle: "", + isHaveLine: false, + isHaveDirection: true, + action: () { + Get.toNamed(Routers.lockEscalationPage); + })), + // ), + SizedBox(height: 30.h), + Container( + padding: + EdgeInsets.only(left: 20.w, right: 20.w, bottom: 30.h), + child: SubmitBtn( + btnName: TranslationLoader.lanKeys!.delete!.tr, + isDelete: true, + onClick: () { + // logic.deletUserAction(); + + // logic.deletLockInfoData(); + showDeletAlertDialog(context); + // showDeletPasswordAlertDialog(context); + }), + ), + ]; + + return showWidgetArr; } Widget rightText(String rightTitle) { @@ -678,25 +787,7 @@ class _LockSetPageState extends State with RouteAware { ); } - void showDeletAlertDialog( - BuildContext context, - ) { - // showDialog( - // context: context, - // builder: (BuildContext context) { - // return ShowIosTipView( - // title: "提示", - // tipTitle: "删除锁后,所有信息都会一起删除,确定删除锁吗?", - // sureClick: () { - // Navigator.pop(context); - // showDeletPasswordAlertDialog(context); - // }, - // cancelClick: () { - // Navigator.pop(context); - // }, - // ); - // }, - // ); + void showDeletAlertDialog(BuildContext context) { showCupertinoDialog( context: context, builder: (context) { diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_state.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_state.dart index a49a2fed..a6362fee 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_state.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_state.dart @@ -8,6 +8,7 @@ class LockSetState { final lockFeature = LockFeature().obs; final lockSettingInfo = LockSettingInfo().obs; final lockStatus = LockStatus().obs; + final lockBasicInfo = LockBasicInfo().obs; final lockId = 0.obs; diff --git a/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_page.dart b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_page.dart index bf3d2bd4..18147155 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_page.dart @@ -109,14 +109,14 @@ class _NormallyOpenModePageState extends State { ], ), )), - Container( + Obx(() => Container( margin: EdgeInsets.only(left: 20.w, right: 20.w, top: 30.h), - child: SubmitBtn( + child: state.isJustForShow.value == true ? Container() :SubmitBtn( btnName: TranslationLoader.lanKeys!.save!.tr, onClick: () { logic.sendAutoLock(); }), - ), + )), ], ))); } diff --git a/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_state.dart b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_state.dart index c4e9c643..2b5585ba 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_state.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/normallyOpenMode/normallyOpenMode_state.dart @@ -4,6 +4,8 @@ import '../lockSet/lockSetInfo_entity.dart'; class NormallyOpenModeState{ var lockSetInfoData = LockSetInfoData().obs; + final lockBasicInfo = LockBasicInfo().obs; + var isJustForShow = false.obs;// 是否只是作为展示作用,因为普通用户只是展示,不可修改 // var getPassageModeConfigData = GetPassageModeConfigEntity().obs; var isOpenNormallyOpenMode = false.obs;// 是否开启常开模式 常开模式:1-开启、2-关闭 @@ -20,6 +22,12 @@ class NormallyOpenModeState{ lockSetInfoData.value = map["lockSetInfoData"]; isOpenNormallyOpenMode.value = lockSetInfoData.value.lockSettingInfo!.passageMode! == 1 ? true : false; + if(lockBasicInfo.value.isLockOwner == 1 || lockBasicInfo.value.keyRight == 1){ + isJustForShow.value = false; + }else{ + isJustForShow.value = true; + } + if((isOpenNormallyOpenMode.value == true) && (lockSetInfoData.value.lockSettingInfo!.passageModeConfig!.isNotEmpty)){ isAllDay.value = lockSetInfoData.value.lockSettingInfo!.passageModeConfig![0].isAllDay!; weekDays.value = lockSetInfoData.value.lockSettingInfo!.passageModeConfig![0].weekDays!; diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 2709c92c..c88ea485 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -11,6 +11,7 @@ import 'package:star_lock/blue/io_type.dart'; import 'package:star_lock/tools/toast.dart'; import '../../../blue/blue_manage.dart'; +import '../../../blue/io_protocol/io_addUser.dart'; import '../../../blue/io_protocol/io_getStarLockStatusInfo.dart'; import '../../../blue/io_protocol/io_openLock.dart'; import '../../../blue/io_protocol/io_referEventRecordTime.dart'; @@ -53,6 +54,11 @@ class LockDetailLogic extends BaseGetXController{ if(reply is SenderReferEventRecordTimeReply) { _replyReferEventRecordTime(reply); } + + // 添加用户 + if(reply is AddUserReply) { + _replyAddUserKey(reply); + } }); } @@ -60,7 +66,7 @@ class LockDetailLogic extends BaseGetXController{ Future _replyOpenLock(Reply reply) async { var tokenData = reply.data.sublist(2, 6); var saveStrList = changeIntListToStringList(tokenData); - // print("openDoorToken:$tokenData"); + print("openDoorToken:$tokenData"); Storage.setStringList(saveBlueToken, saveStrList); int status = reply.data[6]; @@ -122,66 +128,6 @@ class LockDetailLogic extends BaseGetXController{ } } - // 编辑用户数据解析 - // Future _replyEditUserKey(Reply reply) async { - // var token = reply.data.sublist(2, 6); - // var saveStrList = changeIntListToStringList(token); - // print("_replyEditUserKeyToken:$token"); - // Storage.setStringList(saveBlueToken, saveStrList); - // - // int status = reply.data[6]; - // print("status:$status"); - // - // switch(status){ - // case 0x00: - // //成功 - // print("${reply.commandType!.typeValue} 数据解析成功"); - // - // break; - // case 0x06: - // //无权限 - // print("${reply.commandType!.typeValue} 需要鉴权"); - // var privateKey = await Storage.getStringList(saveBluePrivateKey); - // List getPrivateKeyList = changeStringListToIntList(privateKey!); - // - // var publicKey = await Storage.getStringList(saveBluePublicKey); - // List publicKeyDataList = changeStringListToIntList(publicKey!); - // - // IoSenderManage.senderEditUser( - // lockID:BlueManage().connectDeviceName, - // authUserID:await Storage.getUid(), - // keyID:"1", - // userID:await Storage.getUid(), - // openMode:1, - // keyType:1, - // startDate:0x11223344, - // expireDate:0x11223344, - // role:255, - // password:"123456", - // needAuthor:1, - // publicKey:publicKeyDataList, - // privateKey:getPrivateKeyList, - // token: token - // ); - // break; - // case 0x07: - // //无权限 - // print("${reply.commandType!.typeValue} 用户无权限"); - // - // break; - // case 0x09: - // // 权限校验错误 - // print("${reply.commandType!.typeValue} 权限校验错误"); - // - // break; - // default: - // //失败 - // print("${reply.commandType!.typeValue} 失败"); - // - // break; - // } - // } - // 获取锁状态数据解析 Future _replyGetStarLockStatusInfo(Reply reply) async { int status = reply.data[2]; @@ -325,6 +271,78 @@ class LockDetailLogic extends BaseGetXController{ } } + // 添加用户 + Future _replyAddUserKey(Reply reply) async { + var lockId = reply.data.sublist(2, 42); + // print("lockId:$lockId"); + + var token = reply.data.sublist(42, 46); + List strTokenList = changeIntListToStringList(token); + Storage.setStringList(saveBlueToken, strTokenList); + // print("token:$token"); + + int status = reply.data[46]; + // print("status:$status reply.data:${reply.data}"); + + print("status:$status"); + switch(status){ + case 0x00: + //成功 + print("添加用户数据解析成功"); + state.lockUserNo = reply.data[47] + 1; + // updateLockUserNo(); + + if(state.isOpenLockNeedOnline.value == 0){ + openDoorAction(); + }else{ + getLockNetToken(); + } + + break; + case 0x06: + //无权限 + print("需要鉴权"); + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var publicKey = await Storage.getStringList(saveBluePublicKey); + List publicKeyDataList = changeStringListToIntList(publicKey!); + + IoSenderManage.senderAddUser( + lockID: BlueManage().connectDeviceName, + authUserID:state.senderUserId.toString(), + keyID:state.keyInfos.value.keyId.toString(), + userID:await Storage.getUid(), + openMode:1, + keyType:0, + startDate:DateTime.now().millisecondsSinceEpoch, + expireDate:0x11223344, + role:0, + password:"123456", + needAuthor:1, + publicKey:publicKeyDataList, + privateKey:getPrivateKeyList, + token: token + ); + break; + case 0x07: + //无权限 + print("用户无权限"); + + break; + case 0x09: + // 权限校验错误 + print("添加用户权限校验错误"); + + break; + default: + //失败 + print("领锁失败"); + + break; + } + } + // 点击开门事件 Future openDoorAction() async { // if(BlueManage().connectDeviceMacAddress.isEmpty){ @@ -366,39 +384,39 @@ class LockDetailLogic extends BaseGetXController{ } // 编辑用户事件 - Future editLockUserAction() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async { - if (state == DeviceConnectionState.connected){ - var publicKey = await Storage.getStringList(saveBluePublicKey); - List publicKeyDataList = changeStringListToIntList(publicKey!); - - var privateKey = await Storage.getStringList(saveBluePrivateKey); - List getPrivateKeyList = changeStringListToIntList(privateKey!); - - var token = await Storage.getStringList(saveBlueToken); - List getTokenList = changeStringListToIntList(token!); - print("openDoorTokenPubToken:$getTokenList"); - - print("publicKey:$publicKey publicKeyDataList:$publicKeyDataList privateKey:$privateKey getPrivateKeyList:$getPrivateKeyList token:$token getTokenList:$getTokenList"); - IoSenderManage.senderEditUser( - lockID:BlueManage().connectDeviceName, - authUserID:await Storage.getUid(), - keyID:"1", - userID:await Storage.getUid(), - openMode:1, - keyType:1, - startDate:0x11223344, - expireDate:0x11223344, - role:255, - password:"123456", - needAuthor:1, - publicKey:publicKeyDataList, - privateKey:getPrivateKeyList, - token: getTokenList - ); - } - }); - } + // Future editLockUserAction() async { + // BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async { + // if (state == DeviceConnectionState.connected){ + // var publicKey = await Storage.getStringList(saveBluePublicKey); + // List publicKeyDataList = changeStringListToIntList(publicKey!); + // + // var privateKey = await Storage.getStringList(saveBluePrivateKey); + // List getPrivateKeyList = changeStringListToIntList(privateKey!); + // + // var token = await Storage.getStringList(saveBlueToken); + // List getTokenList = changeStringListToIntList(token!); + // print("openDoorTokenPubToken:$getTokenList"); + // + // print("publicKey:$publicKey publicKeyDataList:$publicKeyDataList privateKey:$privateKey getPrivateKeyList:$getPrivateKeyList token:$token getTokenList:$getTokenList"); + // IoSenderManage.senderEditUser( + // lockID:BlueManage().connectDeviceName, + // authUserID:await Storage.getUid(), + // keyID:"1", + // userID:await Storage.getUid(), + // openMode:1, + // keyType:1, + // startDate:0x11223344, + // expireDate:0x11223344, + // role:255, + // password:"123456", + // needAuthor:1, + // publicKey:publicKeyDataList, + // privateKey:getPrivateKeyList, + // token: getTokenList + // ); + // } + // }); + // } // 备用逻辑,进入管理钥匙界面获取锁状态 @@ -453,6 +471,44 @@ class LockDetailLogic extends BaseGetXController{ }, isShowLoading: false); } + // 添加用户(普通用户接收电子钥匙) + Future addUserConnectBlue() async { + // 进来之后首先连接 + BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState deviceConnectionState) async { + if (deviceConnectionState == DeviceConnectionState.connected){ + // 私钥 + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var publicKey = await Storage.getStringList(saveBluePublicKey); + List publicKeyDataList = changeStringListToIntList(publicKey!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = [0,0,0,0]; + if(token != null){ + getTokenList = changeStringListToIntList(token); + } + print("BlueManage().connectDeviceName:${BlueManage().connectDeviceName} authUserID:${state.senderUserId.toString()} keyID:${state.keyInfos.value.keyId.toString()} userID:${await Storage.getUid()}"); + IoSenderManage.senderAddUser( + lockID: BlueManage().connectDeviceName, + authUserID:state.senderUserId.toString(), + keyID:state.keyInfos.value.keyId.toString(), + userID:await Storage.getUid(), + openMode:1, + keyType:0, + startDate:DateTime.now().millisecondsSinceEpoch, + expireDate:0x11223344, + role:0, + password:"123456", + needAuthor:1, + publicKey:publicKeyDataList, + privateKey:getPrivateKeyList, + token: getTokenList + ); + } + }); + } + void startScanAction(){ BlueManage().startScan(true, (v){ // print("startScanAllDevice:${v}"); @@ -472,10 +528,14 @@ class LockDetailLogic extends BaseGetXController{ state.lockState.value = 1; state.animationController.forward(); - if(state.isOpenLockNeedOnline.value == 0){ - openDoorAction(); + if(state.lockUserNo == 0){ + addUserConnectBlue(); }else{ - getLockNetToken(); + if(state.isOpenLockNeedOnline.value == 0){ + openDoorAction(); + }else{ + getLockNetToken(); + } } Future.delayed(const Duration(seconds: 10), () { @@ -504,10 +564,21 @@ class LockDetailLogic extends BaseGetXController{ } } + // 普通用户接收电子钥匙之后 更新锁用户NO + void updateLockUserNo() async { + LockNetTokenEntity entity = await ApiRepository.to.updateLockUserNo(keyId: state.keyInfos.value.keyId.toString(), lockUserNo: state.lockUserNo.toString()); + if (entity.errorCode!.codeIsSuccessful) { + if(state.isOpenLockNeedOnline.value == 0){ + openDoorAction(); + }else{ + getLockNetToken(); + } + } + } + // 查询锁记录最后时间 void getLockRecordLastUploadDataTime() async { - LockOperatingRecordGetLastRecordTimeEntity entity = - await ApiRepository.to.getLockRecordLastUploadDataTime(lockId: state.keyInfos.value.lockId.toString()); + LockOperatingRecordGetLastRecordTimeEntity entity = await ApiRepository.to.getLockRecordLastUploadDataTime(lockId: state.keyInfos.value.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { senderReferEventRecordTime(entity.data!.operateDate!~/1000); } diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_main_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_main_page.dart index 2bf1d1e1..aafce16f 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_main_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_main_page.dart @@ -3,15 +3,12 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import '../../../app_settings/app_colors.dart'; -import '../../../network/api_repository.dart'; import '../../../tools/titleAppBar.dart'; import '../../../translations/trans_lib.dart'; -// import '../../lockMian/entity/lockInfoEntity.dart'; import '../../lockMian/entity/lockListInfo_entity.dart'; import 'lockDetail_page.dart'; class LockDetailMainPage extends StatefulWidget { - const LockDetailMainPage({Key? key}) : super(key: key); @override @@ -19,19 +16,6 @@ class LockDetailMainPage extends StatefulWidget { } class _LockDetailMainPageState extends State { - - // void getLockInfo() async{ - // var entity = await ApiRepository.to.getLockInfo( - // lastUpdateDate:DateTime.now().millisecondsSinceEpoch.toString(), - // pageNo:"1", - // ); - // if(entity.errorCode!.codeIsSuccessful){ - // - // }else{ - // - // } - // } - @override void initState() { // TODO: implement initState diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 0b223d34..02bfbd1f 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -37,6 +37,8 @@ class _LockDetailPageState extends State with TickerProviderStat super.initState(); state.keyInfos.value = widget.lockListInfoItemEntity; + state.lockUserNo = state.keyInfos.value.lockUserNo!; + state.senderUserId = state.keyInfos.value.senderUserId!; state.isAttendance.value = state.keyInfos.value.lockSetting!.attendance!; state.isOpenLockNeedOnline.value = state.keyInfos.value.lockSetting!.appUnlockOnline!; state.electricQuantity.value = state.keyInfos.value.electricQuantity!; @@ -94,10 +96,8 @@ class _LockDetailPageState extends State with TickerProviderStat SizedBox( width: 1.sw - 120.w * 2, child: Center( - child: Text( - widget.lockListInfoItemEntity!.lockAlias!, - style: - TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w400), + child: + Text(widget.lockListInfoItemEntity.lockAlias!, style: TextStyle(fontSize: 22.sp, fontWeight: FontWeight.w400), ))), Positioned( child: Obx(() => Row( @@ -124,14 +124,11 @@ class _LockDetailPageState extends State with TickerProviderStat child: Obx(() => Stack( children: [ Image.asset( - state.lockState.value == 4 - ? 'images/main/icon_main_openLockBtn_grey.png' - : 'images/main/icon_main_openLockBtn_center.png', + state.lockState.value == 4 ? 'images/main/icon_main_openLockBtn_grey.png' : 'images/main/icon_main_openLockBtn_center.png', width: 330.w, height: 330.w, ), - (state.lockState.value == 1 || - state.lockState.value == 3) + (state.lockState.value == 1 || state.lockState.value == 3) ? buildRotationTransition() : Positioned( child: Image.asset( @@ -267,11 +264,42 @@ class _LockDetailPageState extends State with TickerProviderStat crossAxisSpacing: 20.w, mainAxisSpacing: 0.h, physics: const NeverScrollableScrollPhysics(), - children: getShowWidget()), + children: getBottomWidget()), ); } - List getShowWidget() { + // 根据权限显示不同的底部按钮 + List getBottomWidget(){ + if(state.keyInfos.value.isLockOwner == 1 || state.keyInfos.value.keyRight == 1){ + // 超级管理员、授权管理员 + return getAllWidget(); + }else{ + return getNormalWidget(); + } + } + + // 普通用户 + List getNormalWidget() { + var showWidgetArr = [ + // 操作记录 + bottomItem('images/main/icon_main_operatingRecord.png', + TranslationLoader.lanKeys!.operatingRecord!.tr, () { + Get.toNamed(Routers.lockOperatingRecordPage, + arguments: {"keyInfo": widget.lockListInfoItemEntity}); + }), + + // 设置 + bottomItem('images/main/icon_main_set.png', TranslationLoader.lanKeys!.set!.tr, () { + BlueManage().stopScan(); + Get.toNamed(Routers.lockSetPage, + arguments: {"lockId": widget.lockListInfoItemEntity.lockId}); + }), + ]; + return showWidgetArr; + } + + // 授权管理员、超级管理员字段 + List getAllWidget() { var showWidgetArr = []; // 考勤 if (state.isAttendance.value == 1) { diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart index 84c20393..878d3fde 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart @@ -17,6 +17,8 @@ class LockDetailState { Rx keyInfos = LockListInfoItemEntity().obs; String lockNetToken = ""; + var lockUserNo = 0; + var senderUserId = 0; var isAttendance = 0.obs;// 是否开启考勤 var isOpenLockNeedOnline = 0.obs; // APP开锁时是否需联网 diff --git a/star_lock/lib/main/lockMian/entity/lockListInfo_entity.dart b/star_lock/lib/main/lockMian/entity/lockListInfo_entity.dart index e87b6e0e..944571eb 100644 --- a/star_lock/lib/main/lockMian/entity/lockListInfo_entity.dart +++ b/star_lock/lib/main/lockMian/entity/lockListInfo_entity.dart @@ -115,6 +115,8 @@ class LockListInfoItemEntity { int? keyStatus; int? isLockOwner; int? sendDate; + int? lockUserNo; + int? senderUserId; Bluetooth? bluetooth; LockFeature? lockFeature; LockSetting? lockSetting; @@ -142,7 +144,9 @@ class LockListInfoItemEntity { this.bluetooth, this.lockFeature, this.lockSetting, - this.sendDate}); + this.sendDate, + this.lockUserNo, + this.senderUserId}); LockListInfoItemEntity.fromJson(Map json) { keyId = json['keyId']; @@ -165,6 +169,8 @@ class LockListInfoItemEntity { keyStatus = json['keyStatus']; isLockOwner = json['isLockOwner']; sendDate = json['sendDate']; + lockUserNo = json['lockUserNo']; + senderUserId = json['senderUserId']; bluetooth = json['bluetooth'] != null ? Bluetooth.fromJson(json['bluetooth']) : null; @@ -198,6 +204,8 @@ class LockListInfoItemEntity { data['keyStatus'] = keyStatus; data['isLockOwner'] = isLockOwner; data['sendDate'] = sendDate; + data['lockUserNo'] = lockUserNo; + data['senderUserId'] = senderUserId; if (bluetooth != null) { data['bluetooth'] = bluetooth!.toJson(); } diff --git a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart index 1f29526d..06083b47 100644 --- a/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart +++ b/star_lock/lib/mine/addLock/saveLock/saveLock_logic.dart @@ -49,7 +49,7 @@ class SaveLockLogic extends BaseGetXController { case 0x00: //成功 print("添加用户数据解析成功"); - state.lockUserNo = reply.data[47]; + state.lockUserNo = reply.data[47] + 1; bindBlueAdmin(); break; diff --git a/star_lock/lib/mine/mineSet/mineSet/mineSet_logic.dart b/star_lock/lib/mine/mineSet/mineSet/mineSet_logic.dart index a8831ed0..6b758a3c 100644 --- a/star_lock/lib/mine/mineSet/mineSet/mineSet_logic.dart +++ b/star_lock/lib/mine/mineSet/mineSet/mineSet_logic.dart @@ -7,6 +7,7 @@ import 'package:star_lock/mine/mineSet/mineSet/mineSet_state.dart'; import 'package:star_lock/tools/storage.dart'; import '../../../../network/api_repository.dart'; import '../../../../tools/baseGetXController.dart'; +import '../../../blue/blue_manage.dart'; import '../../../tools/eventBusEventManage.dart'; import '../../../tools/toast.dart'; @@ -52,13 +53,16 @@ class MineSetLogic extends BaseGetXController { LoginEntity entity = await ApiRepository.to.userLogout(); if (entity.errorCode!.codeIsSuccessful) { logOut(); + BlueManage().stopScan(); + BlueManage().disconnect(BlueManage().connectDeviceMacAddress); Get.offNamedUntil(Routers.starLockLoginPage, (route) => false); } } ///退出登录 void logOut() async { - await Storage.setString('userLoginData', ''); + Storage.clearAll(); + // await Storage.setString('userLoginData', ''); } //更新触摸开锁 diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index 73432872..ad6f23a6 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -27,6 +27,7 @@ abstract class Api { final String getLockRecordLastUploadDataTimeURL = '/lockRecords/getLastRecordTime'; //查询锁记录最后时间 final String getLockNetTokenURL = '/lock/getLockNetToken'; //获取手机联网token + final String updateLockUserNoURL = '/key/updateLockUserNo'; //更新锁用户NO final String bindingBlueAdminURL = '/lock/bindAdmin'; //绑定蓝牙管理员 final String modifyKeyNameURL = '/key/modifyKeyName'; //修改锁名称 diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index 925211a1..d727c5b6 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -279,6 +279,15 @@ class ApiProvider extends BaseProvider { }), isUnShowLoading: true); + // 更新锁用户NO + Future updateLockUserNo(String keyId, String lockUserNo) => post( + updateLockUserNoURL.toUrl, + jsonEncode({ + 'keyId': keyId, + 'lockUserNo': lockUserNo, + }), + isUnShowLoading: true); + // 绑定蓝牙管理员 Future bindingBlueAdmin( String lockAlias, @@ -1036,7 +1045,7 @@ class ApiProvider extends BaseProvider { // 编辑ICCard Future editICCardData(String lockId, String cardId, String cardName, - String startDate, String endDate, String isCoerced, List weekDay) => + String startDate, String endDate, String isCoerced, List weekDay, String changeType) => post( editICCardURL.toUrl, jsonEncode({ @@ -1046,7 +1055,8 @@ class ApiProvider extends BaseProvider { 'startDate': startDate, 'endDate': endDate, 'isCoerced': isCoerced, - 'weekDay': weekDay + 'weekDay': weekDay, + 'changeType': changeType })); // 删除卡 diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 6be2c703..ee55448d 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -217,8 +217,7 @@ class ApiRepository { } //操作记录上传 - Future lockRecordUploadData( - {required String lockId, required List records}) async { + Future lockRecordUploadData({required String lockId, required List records}) async { final res = await apiProvider.lockRecordUploadData(lockId, records); return KeyOperationRecordEntity.fromJson(res.body); } @@ -236,6 +235,12 @@ class ApiRepository { return LockNetTokenEntity.fromJson(res.body); } + // 更新锁用户NO + Future updateLockUserNo({required String keyId, required String lockUserNo}) async { + final res = await apiProvider.updateLockUserNo(keyId, lockUserNo); + return LockNetTokenEntity.fromJson(res.body); + } + // 绑定蓝牙管理员 Future bindingBlueAdmin( { required String lockAlias, @@ -1180,9 +1185,10 @@ class ApiRepository { required String startDate, required String endDate, required String isCoerced, - required List weekDay}) async { + required List weekDay, + required String changeType}) async { final res = await apiProvider.editICCardData( - lockId, cardId, cardName, startDate, endDate, isCoerced, weekDay); + lockId, cardId, cardName, startDate, endDate, isCoerced, weekDay, changeType); return LoginEntity.fromJson(res.body); } diff --git a/star_lock/lib/tools/storage.dart b/star_lock/lib/tools/storage.dart index dbc50b2c..b1253c7e 100644 --- a/star_lock/lib/tools/storage.dart +++ b/star_lock/lib/tools/storage.dart @@ -139,7 +139,7 @@ class Storage { String? userId = ''; final data = await Storage.getString('userLoginData'); if (data != null && data.isNotEmpty) { - userId = LoginData.fromJson(jsonDecode(data)).userid.toString(); + userId = LoginData.fromJson(jsonDecode(data)).uid.toString(); } print("pubUserId:$userId"); return userId; From f212d5dcb1ec29192ba1c18758c25a076b3d2b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AD=8F=E5=B0=91=E9=98=B3?= <786612630@qq.com> Date: Sat, 16 Dec 2023 14:31:49 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=8C=E7=BB=99=E5=A7=9C=E6=80=BB=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../card/addCardType/addCardType_state.dart | 2 +- .../card/addICCard/addICCard_logic.dart | 23 ++++++++++++------- .../lcokSet/lockSet/lockSet_page.dart | 6 +++-- .../lockDetail/lockDetail_logic.dart | 3 ++- star_lock/lib/mine/about/about_page.dart | 2 +- star_lock/lib/network/api_provider.dart | 2 +- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/star_lock/lib/main/lockDetail/card/addCardType/addCardType_state.dart b/star_lock/lib/main/lockDetail/card/addCardType/addCardType_state.dart index 326592cc..caa9da92 100644 --- a/star_lock/lib/main/lockDetail/card/addCardType/addCardType_state.dart +++ b/star_lock/lib/main/lockDetail/card/addCardType/addCardType_state.dart @@ -19,7 +19,7 @@ class AddCardTypeState{ var weekdaysList = [].obs; final TextEditingController nameController = TextEditingController(); - AddCardState() { + AddCardTypeState() { // Map map = Get.arguments; // lockId.value = map["lockId"]; // fromType.value = map["fromType"]; diff --git a/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart b/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart index 56f1813f..f0ba5332 100644 --- a/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart +++ b/star_lock/lib/main/lockDetail/card/addICCard/addICCard_logic.dart @@ -295,6 +295,13 @@ class AddICCardLogic extends BaseGetXController{ ); if (entity.errorCode!.codeIsSuccessful) { Toast.show(msg: "添加成功"); + if(state.fromType.value == 2){ + // 回调指纹号 + eventBus.fire(ChickInAddStaffCardAndFingerprintBlockNumberEvent(entity.data!.cardId.toString())); + }else if(state.fromType.value == 1){ + eventBus.fire(OtherTypeRefreshListEvent()); + } + Get.close(2); updateIdCardUserNoLoadData(entity.data!.cardId.toString()); } } @@ -306,14 +313,14 @@ class AddICCardLogic extends BaseGetXController{ cardUserNo: state.cardNumber.value, ); if(entity.errorCode!.codeIsSuccessful){ - Toast.show(msg: "添加成功"); - if(state.fromType.value == 2){ - // 回调指纹号 - eventBus.fire(ChickInAddStaffCardAndFingerprintBlockNumberEvent(cardId)); - }else if(state.fromType.value == 1){ - eventBus.fire(OtherTypeRefreshListEvent()); - } - Get.close(2); + // Toast.show(msg: "添加成功"); + // if(state.fromType.value == 2){ + // // 回调指纹号 + // eventBus.fire(ChickInAddStaffCardAndFingerprintBlockNumberEvent(cardId)); + // }else if(state.fromType.value == 1){ + // eventBus.fire(OtherTypeRefreshListEvent()); + // } + // Get.close(2); } } diff --git a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart index a778b5aa..dd8af270 100644 --- a/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart +++ b/star_lock/lib/main/lockDetail/lcokSet/lockSet/lockSet_page.dart @@ -48,9 +48,9 @@ class _LockSetPageState extends State with RouteAware { body: Column( children: [ Expanded( - child: ListView( + child: Obx(() => ListView( children: getListWidget(), - ), + )), ), ], ) @@ -59,6 +59,8 @@ class _LockSetPageState extends State with RouteAware { // 根据权限显示不同的列表 List getListWidget(){ + + print("state.lockBasicInfo.value.isLockOwner:${state.lockBasicInfo.value.isLockOwner} state.lockBasicInfo.value.keyRight:${state.lockBasicInfo.value.keyRight}"); if(state.lockBasicInfo.value.isLockOwner == 1 || state.lockBasicInfo.value.keyRight == 1){ // 超级管理员、授权管理员 return getAllWidget(); diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index c88ea485..7c94d88a 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -506,7 +506,7 @@ class LockDetailLogic extends BaseGetXController{ token: getTokenList ); } - }); + }, isShowLoading: false); } void startScanAction(){ @@ -617,6 +617,7 @@ class LockDetailLogic extends BaseGetXController{ // TODO: implement onReady super.onReady(); print("onReady()"); + _initReplySubscription(); initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction(); diff --git a/star_lock/lib/mine/about/about_page.dart b/star_lock/lib/mine/about/about_page.dart index 960de892..50c7bc18 100644 --- a/star_lock/lib/mine/about/about_page.dart +++ b/star_lock/lib/mine/about/about_page.dart @@ -38,7 +38,7 @@ class _AbountPageState extends State { ), SizedBox(height: 20.h), Text( - "星锁 1.0.0.02(preRelease-20231124)", + "星锁 1.0.0.03(preRelease-20231216)", style: TextStyle(fontSize: 24.sp, color: AppColors.blackColor), ), SizedBox( diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index d727c5b6..af5e9971 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -345,7 +345,7 @@ class ApiProvider extends BaseProvider { // 删除拥有的当前钥匙 Future deletOwnerKeyInfo(String lockId, String keyId) => post( - deletLockURL.toUrl, + deleteElectronicKeyURL.toUrl, jsonEncode({ 'lockId': lockId, 'keyId': keyId