diff --git a/star_lock/images/lan/lan_en.json b/star_lock/images/lan/lan_en.json index ef301a89..811be8c1 100644 --- a/star_lock/images/lan/lan_en.json +++ b/star_lock/images/lan/lan_en.json @@ -703,6 +703,8 @@ "编辑成功": "Edit success", "厂商": "Manufacturer", "型号": "Model", + "密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。": "After the password is generated, please use it once for activation before 23:59 on the same day, otherwise it will be invalid after 0 o'clock. After the password is activated, it can be used unlimited times within the validity period.", + "密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。":"After the password is generated, please use it before 23:59 on the same day, otherwise it will be invalid after 0 o'clock. The clear code is used to clear all the passwords generated before 0 o'clock today.", "相机": "camera", "相册": "photos", diff --git a/star_lock/images/lan/lan_keys.json b/star_lock/images/lan/lan_keys.json index dee45a31..3f898ed2 100644 --- a/star_lock/images/lan/lan_keys.json +++ b/star_lock/images/lan/lan_keys.json @@ -705,6 +705,8 @@ "请输入wifi名称": "请输入wifi名称", "厂商": "厂商", "型号": "型号", + "密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。": "密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。", + "密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。":"密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。", "相机": "相机", "相册": "相册", diff --git a/star_lock/images/lan/lan_zh.json b/star_lock/images/lan/lan_zh.json index b1159109..2ab7523f 100644 --- a/star_lock/images/lan/lan_zh.json +++ b/star_lock/images/lan/lan_zh.json @@ -707,6 +707,8 @@ "请输入wifi名称": "请输入wifi名称", "厂商": "厂商", "型号": "型号", + "密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。": "密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。", + "密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。":"密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。", "相机": "相机", "相册": "相册", diff --git a/star_lock/lib/blue/io_protocol/io_senderCustomPasswords.dart b/star_lock/lib/blue/io_protocol/io_senderCustomPasswords.dart index 476af520..29d23145 100644 --- a/star_lock/lib/blue/io_protocol/io_senderCustomPasswords.dart +++ b/star_lock/lib/blue/io_protocol/io_senderCustomPasswords.dart @@ -72,11 +72,13 @@ class SenderCustomPasswordsCommand extends SenderProtocol { // PwdNo subData.add(pwdNo!); + AppLog.log("pwdNo:$pwdNo"); // pwd 20 int pwdLength = utf8.encode(pwd!).length; subData.addAll(utf8.encode(pwd!)); subData = getFixedLengthList(subData, 20 - pwdLength); + AppLog.log("pwd:$pwd"); // UseCountLimit subData.add(useCountLimit!); @@ -84,6 +86,8 @@ class SenderCustomPasswordsCommand extends SenderProtocol { // token subData.addAll(token!); + AppLog.log("startTime:$startTime endTime:$endTime"); + // startTime 4 subData.add((startTime! & 0xff000000) >> 24); subData.add((startTime! & 0xff0000) >> 16); diff --git a/star_lock/lib/main/lockDetail/card/addICCard/addICCard_page.dart b/star_lock/lib/main/lockDetail/card/addICCard/addICCard_page.dart index 8845cddf..d8e1bb31 100644 --- a/star_lock/lib/main/lockDetail/card/addICCard/addICCard_page.dart +++ b/star_lock/lib/main/lockDetail/card/addICCard/addICCard_page.dart @@ -49,8 +49,8 @@ class _AddICCardPageState extends State with RouteAware { SizedBox(height: 120.h), Container( width: 1.sw, - height: 50.h, - // padding: EdgeInsets.only(left: 30.w, right: 30.w, top: 10.h, bottom: 10.h), + // height: 50.h, + padding: EdgeInsets.all(10.w), margin: EdgeInsets.only( left: 15.w, right: 15.w, top: 10.h, bottom: 10.h), // color: AppColors.blackColor, diff --git a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart index eb2f6030..2b6df480 100644 --- a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart +++ b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_logic.dart @@ -1,11 +1,8 @@ -import 'dart:async'; -import 'dart:convert'; -import 'package:flutter/services.dart'; +import 'dart:async'; + import 'package:flutter_blue_plus/flutter_blue_plus.dart'; -import 'package:flutter_easyloading/flutter_easyloading.dart'; -import 'package:star_lock/app_settings/app_settings.dart'; -// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; + import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_entity.dart'; import 'package:star_lock/main/lockDetail/doorLockLog/doorLockLog_state.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecord/keyOperationRecord_entity.dart'; @@ -64,13 +61,18 @@ class DoorLockLogLogic extends BaseGetXController { // 根据时间查解析数据 Future _replyReferEventRecordTime(Reply reply) async { + cancelBlueConnetctToastTimer(); int status = reply.data[2]; switch (status) { case 0x00: //成功 - if (reply.data[5] > 0) { + var dataLength = reply.data[5]; + if (dataLength > 0) { reply.data.removeRange(0, 6); // 把得到的数据按8位分割成数组 然后塞进一个新的数组里面 + if(reply.data.length < 8){ + return; + } var getList = splitList(reply.data, 8); // AppLog.log("getList:$getList"); var uploadList = []; @@ -94,11 +96,34 @@ class DoorLockLogLogic extends BaseGetXController { uploadList.add(indexMap); } lockRecordUploadData(uploadList); + + if(dataLength == 20){ + state.ifHaveNext = true; + } } break; case 0x06: //无权限 需要鉴权 - + // var privateKey = await Storage.getStringList(saveBluePrivateKey); + // List getPrivateKeyList = changeStringListToIntList(privateKey!); + // + // var token = await Storage.getStringList(saveBlueToken); + // List getTokenList = changeStringListToIntList(token!); + // + // var publicKey = await Storage.getStringList(saveBluePublicKey); + // List getPublicKeyList = changeStringListToIntList(publicKey!); + // + // IoSenderManage.senderReferEventRecordTimeCommand( + // keyID: BlueManage().connectDeviceName, + // userID: await Storage.getUid(), + // logsCount: int.parse(pageSize), + // // time:DateTime.now().millisecondsSinceEpoch~/1000, + // time: state.operateDate, + // token: getTokenList, + // needAuthor: 1, + // publicKey: getPublicKeyList, + // privateKey: getPrivateKeyList, + // ); break; default: //失败 @@ -134,7 +159,7 @@ class DoorLockLogLogic extends BaseGetXController { // } // 查询事件记录(时间查询) - Future senderReferEventRecordTime(int time) async { + Future senderReferEventRecordTime() async { showEasyLoading(); showBlueConnetctToastTimer(action: (){ @@ -151,13 +176,12 @@ class DoorLockLogLogic extends BaseGetXController { var publicKey = await Storage.getStringList(saveBluePublicKey); List getPublicKeyList = changeStringListToIntList(publicKey!); - EasyLoading.show(); IoSenderManage.senderReferEventRecordTimeCommand( keyID: BlueManage().connectDeviceName, userID: await Storage.getUid(), - logsCount: 20, + logsCount: int.parse(pageSize), // time:DateTime.now().millisecondsSinceEpoch~/1000, - time: time, + time: state.operateDate, token: getTokenList, needAuthor: 1, publicKey: getPublicKeyList, @@ -216,7 +240,8 @@ class DoorLockLogLogic extends BaseGetXController { .getLockRecordLastUploadDataTime( lockId: state.keyInfos.value.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { - senderReferEventRecordTime(entity.data!.operateDate! ~/ 1000); + state.operateDate = entity.data!.operateDate! ~/ 1000; + senderReferEventRecordTime(); } } @@ -226,7 +251,12 @@ class DoorLockLogLogic extends BaseGetXController { .lockRecordUploadData( lockId: state.keyInfos.value.lockId.toString(), records: list); if (entity.errorCode!.codeIsSuccessful) { - mockNetworkDataRequest(); + if(state.ifHaveNext == true){ + getLockRecordLastUploadDataTime(); + }else{ + pageNo = 1; + mockNetworkDataRequest(); + } } } @@ -264,6 +294,7 @@ class DoorLockLogLogic extends BaseGetXController { getLockRecordLastUploadDataTime(); // senderReferEventRecordTime(); // senderReferEventRecordNumber(); + _initReplySubscription(); } } diff --git a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart index 42b50557..8b560b73 100644 --- a/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart +++ b/star_lock/lib/main/lockDetail/doorLockLog/doorLockLog_state.dart @@ -47,6 +47,8 @@ class DoorLockLogState { ]; var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + var operateDate = 0; // 按日期查询消息记录的时间戳 + var ifHaveNext = false; // 页码 DoorLockLogState() { keyInfos.value = Get.arguments["keyInfo"]; diff --git a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart index f7c27b4c..2fa1e028 100644 --- a/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart +++ b/star_lock/lib/main/lockDetail/face/addFaceType/addFaceType_page.dart @@ -245,7 +245,7 @@ class _AddFaceTypePageState extends State with SingleTickerProv return Column( children: [ CommonItem( - leftTitel: "是否是管理员", + leftTitel: "是否是管理员".tr, rightTitle: "", isTipsImg: false, isHaveRightWidget: true, diff --git a/star_lock/lib/main/lockDetail/iris/addIrisType/addIrisType_page.dart b/star_lock/lib/main/lockDetail/iris/addIrisType/addIrisType_page.dart index 749a5939..e2a04b35 100644 --- a/star_lock/lib/main/lockDetail/iris/addIrisType/addIrisType_page.dart +++ b/star_lock/lib/main/lockDetail/iris/addIrisType/addIrisType_page.dart @@ -245,7 +245,7 @@ class _AddIrisTypePageState extends State { return Column( children: [ CommonItem( - leftTitel: "是否是管理员", + leftTitel: "是否是管理员".tr, rightTitle: "", isTipsImg: false, isHaveRightWidget: true, diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart index 4f307e2f..77d0ba76 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart @@ -108,7 +108,7 @@ class LockDetailLogic extends BaseGetXController { keyID: BlueManage().connectDeviceName, userID: await Storage.getUid(), openMode: state.openDoorModel, - openTime: state.netTime, + openTime: getNetTime(), onlineToken: state.lockNetToken, token: tokenData, needAuthor: 1, @@ -160,10 +160,16 @@ class LockDetailLogic extends BaseGetXController { switch (status) { case 0x00: //成功 - if (reply.data[5] > 0) { + var dataLength = reply.data[5]; + if (dataLength > 0) { reply.data.removeRange(0, 6); // 把得到的数据按8位分割成数组 然后塞进一个新的数组里面 var getList = splitList(reply.data, 8); + if(reply.data.length < 8){ + await BlueManage().disconnect(); + cancelBlueConnetctToastTimer(); + return; + } var uploadList = []; for (int i = 0; i < getList.length; i++) { var indexList = getList[i]; @@ -184,14 +190,22 @@ class LockDetailLogic extends BaseGetXController { uploadList.add(indexMap); } lockRecordUploadData(uploadList); - await BlueManage().disconnect(); + + if(dataLength == 20){ + senderReferEventRecordTime(); + }else{ + await BlueManage().disconnect(); + } } break; case 0x06: //无权限 - + BlueManage().disconnect(); + cancelBlueConnetctToastTimer(); break; default: + BlueManage().disconnect(); + cancelBlueConnetctToastTimer(); break; } } @@ -329,7 +343,7 @@ class LockDetailLogic extends BaseGetXController { keyID: BlueManage().connectDeviceName, userID: await Storage.getUid(), openMode: state.openDoorModel, - openTime: state.netTime, + openTime: getNetTime(), onlineToken: state.lockNetToken, token: getTokenList, needAuthor: 1, @@ -351,10 +365,12 @@ class LockDetailLogic extends BaseGetXController { // 查询事件记录(时间查询) - Future senderReferEventRecordTime(int time) async { - BlueManage().bludSendData(BlueManage().connectDeviceName, - (BluetoothConnectionState state) async { - if (state == BluetoothConnectionState.connected) { + Future senderReferEventRecordTime() async { + showBlueConnetctToastTimer(isShowBlueConnetctToast: false, action: () { + BlueManage().disconnect(); + }); + BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { + if (connectionState == BluetoothConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -369,7 +385,7 @@ class LockDetailLogic extends BaseGetXController { userID: await Storage.getUid(), logsCount: 20, // time:DateTime.now().millisecondsSinceEpoch~/1000, - time: time, + time: state.operateDate, token: getTokenList, needAuthor: 1, publicKey: getPublicKeyList, @@ -379,17 +395,21 @@ class LockDetailLogic extends BaseGetXController { }); } - // 从服务器获取锁的时间 开锁时传入 void getServerDatetime() async{ var entity = await ApiRepository.to.getServerDatetimeData( lockId: state.keyInfos.value.lockId.toString(), ); if(entity.errorCode!.codeIsSuccessful){ - state.netTime = entity.data!.date!.toString().length > 10 ? entity.data!.date!~/ 1000 : entity.data!.date!; + state.differentialTime = entity.data!.date! ~/ 1000 - DateTime.now().millisecondsSinceEpoch ~/ 1000; + // AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}"); } } + int getNetTime(){ + return DateTime.now().millisecondsSinceEpoch ~/ 1000 + state.differentialTime; + } + // 获取手机联网token,根据锁设置里面获取的开锁时是否联网来判断是否调用这个接口 void getLockNetToken() async { LockNetTokenEntity entity = await ApiRepository.to.getLockNetToken(lockId: state.keyInfos.value.lockId.toString()); @@ -430,7 +450,8 @@ class LockDetailLogic extends BaseGetXController { .getLockRecordLastUploadDataTime( lockId: state.keyInfos.value.lockId.toString()); if (entity.errorCode!.codeIsSuccessful) { - senderReferEventRecordTime(entity.data!.operateDate! ~/ 1000); + state.operateDate = entity.data!.operateDate! ~/ 1000; + senderReferEventRecordTime(); } } diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart index 9164f2f5..24315b49 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart @@ -78,7 +78,7 @@ class _LockDetailPageState extends State }); } - void loadData() { + Future loadData() async { state.keyInfos.value = widget.lockListInfoItemEntity; CommonDataManage().currentLockUserNo = state.keyInfos.value.lockUserNo!; CommonDataManage().currentKeyInfo = state.keyInfos.value; @@ -126,8 +126,11 @@ class _LockDetailPageState extends State var saveSignKeyList = changeIntListToStringList(signKeyData); Storage.setStringList(saveBlueSignKey, saveSignKeyList); - var saveTokenList = changeIntListToStringList([0, 0, 0, 0]); - Storage.setStringList(saveBlueToken, saveTokenList); + bool ifHaveKey = await Storage.ifHaveKey(saveBlueToken); + if(!ifHaveKey){ + var saveTokenList = changeIntListToStringList([0, 0, 0, 0]); + Storage.setStringList(saveBlueToken, saveTokenList); + } } @override diff --git a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart index bb10e0d9..78b6b4c5 100644 --- a/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart +++ b/star_lock/lib/main/lockDetail/lockDetail/lockDetail_state.dart @@ -14,7 +14,7 @@ class LockDetailState { StreamSubscription? lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent; String lockNetToken = ""; - int netTime = 0; + int differentialTime = 0; int lockUserNo = 0; var senderUserId = 0; var isOnlyOneData = false; @@ -46,6 +46,7 @@ class LockDetailState { final PageController pageController = PageController(); var currentPage = 0.obs; + var operateDate = 0; // 按日期查询消息记录的时间戳 // LockDetailState() { // Map map = Get.arguments; diff --git a/star_lock/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_logic.dart b/star_lock/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_logic.dart index 421b42a8..66f7e730 100644 --- a/star_lock/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_logic.dart +++ b/star_lock/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_logic.dart @@ -1,6 +1,8 @@ import 'dart:async'; +import 'package:star_lock/app_settings/app_settings.dart'; + import '../../../../../tools/baseGetXController.dart'; import '../../../../../tools/eventBusEventManage.dart'; import '../../lockSet/lockSet_logic.dart'; @@ -24,6 +26,7 @@ class BasicInformationLogic extends BaseGetXController{ // TODO: implement onReady super.onReady(); + AppLog.log("厂商 vendor:${state.lockBasicInfo.value.vendor} 型号 model:${state.lockBasicInfo.value.model}"); } @override diff --git a/star_lock/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart b/star_lock/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart index 199f51df..2b2c5ce8 100644 --- a/star_lock/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart +++ b/star_lock/lib/main/lockDetail/lockSet/basicInformation/basicInformation/basicInformation_page.dart @@ -53,16 +53,16 @@ class _BasicInformationPageState extends State { "${state.lockBasicInfo.value.mac??""}/${state.lockBasicInfo.value.lockId??""}", allHeight: 70.h, isHaveLine: true)), - Obx(() => CommonItem( - leftTitel: "厂商".tr, - rightTitle: state.lockBasicInfo.value.vendor ??"", - allHeight: 70.h, - isHaveLine: true)), - Obx(() => CommonItem( - leftTitel: "型号".tr, - rightTitle: state.lockBasicInfo.value.model ??"", - allHeight: 70.h, - isHaveLine: false)), + // Obx(() => CommonItem( + // leftTitel: "厂商".tr, + // rightTitle: state.lockBasicInfo.value.vendor ??"", + // allHeight: 70.h, + // isHaveLine: true)), + // Obx(() => CommonItem( + // leftTitel: "型号".tr, + // rightTitle: state.lockBasicInfo.value.model ??"", + // allHeight: 70.h, + // isHaveLine: false)), SizedBox( height: 10.h, ), diff --git a/star_lock/lib/main/lockDetail/palm/addPalmType/addPalmType_page.dart b/star_lock/lib/main/lockDetail/palm/addPalmType/addPalmType_page.dart index 6c6fe494..bd6bf110 100644 --- a/star_lock/lib/main/lockDetail/palm/addPalmType/addPalmType_page.dart +++ b/star_lock/lib/main/lockDetail/palm/addPalmType/addPalmType_page.dart @@ -245,7 +245,7 @@ class _AddPalmTypePageState extends State { return Column( children: [ CommonItem( - leftTitel: "是否是管理员", + leftTitel: "是否是管理员".tr, rightTitle: "", isTipsImg: false, isHaveRightWidget: true, diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_logic.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_logic.dart index 097129cd..08fbbbcb 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_logic.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_logic.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; +import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_state.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart'; import 'package:star_lock/network/api_repository.dart'; @@ -24,11 +25,8 @@ class PasswordKeyDetailLogic extends BaseGetXController { void _initReplySubscription() { _replySubscription = EventBusManager().eventBus!.on().listen((reply) async { // 设置自定义密码 + AppLog.log("ifCurrentScreen:${state.ifCurrentScreen.value}"); if ((reply is SenderCustomPasswordsReply) && (state.ifCurrentScreen.value == true)) { - var token = reply.data.sublist(5, 9); - var saveStrList = changeIntListToStringList(token); - Storage.setStringList(saveBlueToken, saveStrList); - int status = reply.data[2]; switch (status) { case 0x00: @@ -36,7 +34,11 @@ class PasswordKeyDetailLogic extends BaseGetXController { state.sureBtnState.value = 0; dismissEasyLoading(); cancelBlueConnetctToastTimer(); - deletePwdRequest(); + if(state.isDeletPasswordKey.value == true){ + deletePwdRequest(); + }else{ + updatePwdRequest(2); + } break; case 0x06: //无权限 @@ -46,14 +48,18 @@ class PasswordKeyDetailLogic extends BaseGetXController { var signKey = await Storage.getStringList(saveBlueSignKey); List signKeyDataList = changeStringListToIntList(signKey!); + var token = reply.data.sublist(5, 9); + var saveStrList = changeIntListToStringList(token); + Storage.setStringList(saveBlueToken, saveStrList); + IoSenderManage.senderCustomPasswordsCommand( - keyID:state.keyId.value.toString(), + keyID:state.itemData.value.keyboardPwdId!.toString(), userID:await Storage.getUid(), - pwdNo: state.keyboardUserNo.value, - pwd: "000000", - useCountLimit: 0, - startTime:0x11223344, - endTime:0x11223344, + pwdNo: state.itemData.value.pwdUserNo!, + pwd: state.isDeletPasswordKey.value == true ? "000000" : state.inputPwdController.text, + useCountLimit: state.isDeletPasswordKey.value == true ? 0 : 0xff, + startTime:state.itemData.value.startDate! ~/ 1000, + endTime:state.itemData.value.endDate! ~/ 1000, needAuthor: 1, isBeforeAddUser: false, signKey: signKeyDataList, @@ -77,6 +83,7 @@ class PasswordKeyDetailLogic extends BaseGetXController { deleteType:1); if (entity.errorCode!.codeIsSuccessful) { showToast("删除成功".tr, something: (){ + eventBus.fire(GetPasswordListRefreshUI()); Get.back(result: "deletScuess"); }); } @@ -111,7 +118,7 @@ class PasswordKeyDetailLogic extends BaseGetXController { } } - // 设置自定义密码 这里用作删除密码 + // 设置自定义密码 这里用作修改或者删除密码 Future senderCustomPasswords() async { showEasyLoading(); @@ -130,14 +137,27 @@ class PasswordKeyDetailLogic extends BaseGetXController { var token = await Storage.getStringList(saveBlueToken); List getTokenList = changeStringListToIntList(token!); + // IoSenderManage.senderCustomPasswordsCommand( + // keyID:state.keyId.value.toString(), + // userID:await Storage.getUid(), + // pwdNo: state.keyboardUserNo.value, + // pwd: "000000", + // useCountLimit: 0, + // startTime:0x11223344, + // endTime:0x11223344, + // needAuthor: 1, + // isBeforeAddUser: false, + // signKey: signKeyDataList, + // privateKey: getPrivateKeyList, + // token: getTokenList); IoSenderManage.senderCustomPasswordsCommand( - keyID:state.keyId.value.toString(), + keyID:state.itemData.value.keyboardPwdId!.toString(), userID:await Storage.getUid(), - pwdNo: state.keyboardUserNo.value, - pwd: "000000", - useCountLimit: 0, - startTime:0x11223344, - endTime:0x11223344, + pwdNo: state.itemData.value.pwdUserNo!, + pwd: state.isDeletPasswordKey.value == true ? "000000" : state.inputPwdController.text, + useCountLimit: state.isDeletPasswordKey.value == true ? 0 : 0xff, + startTime:state.itemData.value.startDate! ~/ 1000, + endTime:state.itemData.value.endDate! ~/ 1000, needAuthor: 1, isBeforeAddUser: false, signKey: signKeyDataList, diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart index 0cd61d56..acab5ab7 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart @@ -201,7 +201,15 @@ class _PasswordKeyDetailPageState extends State with Rout padding: EdgeInsets.only(top: 25.w, bottom: 25.w), onClick: () { ShowTipView().showIosTipWithContentDialog("确定要删除吗?".tr, (){ - logic.senderCustomPasswords(); + state.isDeletPasswordKey.value = true; + state.ifCurrentScreen.value = true; + if(state.itemData.value.isCustom! == 1){ + // 自定义密码 + logic.senderCustomPasswords(); + }else{ + // 非自定义密码 + logic.deletePwdRequest(); + } }); }), ], @@ -243,11 +251,18 @@ class _PasswordKeyDetailPageState extends State with Rout return; } } - - logic.updatePwdRequest(inputController == state.inputNameController ? 1 : 2); + state.isDeletPasswordKey.value = false; + if(inputController == state.inputNameController){ + // 修改密码名称 + logic.updatePwdRequest(1); + }else{ + // 修改密码 + state.ifCurrentScreen.value = true; + logic.senderCustomPasswords(); + } }, cancelClick: () { - Navigator.pop(context); + Get.back(); }, ); }, diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_state.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_state.dart index 3c12bb66..d848989e 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_state.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_state.dart @@ -17,6 +17,7 @@ class PasswordKeyDetailState { var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用) final passwordKeyNumber = "".obs;// 密码号 + var isDeletPasswordKey = true.obs;// 是否删除卡 PasswordKeyDetailState() { Map map = Get.arguments; diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_logic.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_logic.dart index 4ad6b6d5..d80f9f80 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_logic.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_logic.dart @@ -1,14 +1,74 @@ +import 'dart:async'; + +import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_state.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyEntity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import '../../../../blue/blue_manage.dart'; +import '../../../../blue/io_protocol/io_senderCustomPasswords.dart'; +import '../../../../blue/io_reply.dart'; +import '../../../../blue/io_tool/io_tool.dart'; +import '../../../../blue/io_tool/manager_event_bus.dart'; +import '../../../../blue/sender_manage.dart'; import '../../../../tools/eventBusEventManage.dart'; +import '../../../../tools/storage.dart'; class PasswordKeyDetailChangeDateLogic extends BaseGetXController { PasswordKeyDetailChangeDateState state = PasswordKeyDetailChangeDateState(); + // 监听设备返回的数据 + late StreamSubscription _replySubscription; + void _initReplySubscription() { + _replySubscription = EventBusManager().eventBus!.on().listen((reply) async { + // 设置自定义密码 + if ((reply is SenderCustomPasswordsReply) && (state.ifCurrentScreen.value == true)) { + int status = reply.data[2]; + switch (status) { + case 0x00: + //成功 + state.sureBtnState.value = 0; + dismissEasyLoading(); + cancelBlueConnetctToastTimer(); + updatePwdRequest(); + break; + case 0x06: + //无权限 + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var signKey = await Storage.getStringList(saveBlueSignKey); + List signKeyDataList = changeStringListToIntList(signKey!); + + var token = reply.data.sublist(5, 9); + var saveStrList = changeIntListToStringList(token); + Storage.setStringList(saveBlueToken, saveStrList); + + IoSenderManage.senderCustomPasswordsCommand( + keyID:state.itemData.value.keyboardPwdId!.toString(), + userID:await Storage.getUid(), + pwdNo: state.itemData.value.pwdUserNo!, + pwd: state.itemData.value.keyboardPwd!.toString(), + useCountLimit: 0xff, + startTime:state.itemData.value.startDate! ~/ 1000, + endTime:state.itemData.value.endDate! ~/ 1000, + needAuthor: 1, + isBeforeAddUser: false, + signKey: signKeyDataList, + privateKey: getPrivateKeyList, + token: token); + break; + default: + //失败 + cancelBlueConnetctToastTimer(); + break; + } + } + }); + } + //更新密码请求 Future updatePwdRequest() async { var beginTimeTimestamp = state.itemData.value.startDate! ~/ 1000; @@ -47,5 +107,67 @@ class PasswordKeyDetailChangeDateLogic extends BaseGetXController { } } +// 设置自定义密码 这里用作修改或者删除密码 + Future senderCustomPasswords() async { + showEasyLoading(); + showBlueConnetctToastTimer(action: (){ + dismissEasyLoading(); + state.sureBtnState.value = 0; + }); + BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState deviceConnectionState) async { + if (deviceConnectionState == BluetoothConnectionState.connected) { + var signKey = await Storage.getStringList(saveBlueSignKey); + List signKeyDataList = changeStringListToIntList(signKey!); + + var privateKey = await Storage.getStringList(saveBluePrivateKey); + List getPrivateKeyList = changeStringListToIntList(privateKey!); + + var token = await Storage.getStringList(saveBlueToken); + List getTokenList = changeStringListToIntList(token!); + + IoSenderManage.senderCustomPasswordsCommand( + keyID:state.itemData.value.keyboardPwdId!.toString(), + userID:await Storage.getUid(), + pwdNo: state.itemData.value.pwdUserNo!, + pwd: state.itemData.value.keyboardPwd!.toString(), + useCountLimit: 0xff, + startTime:state.itemData.value.startDate! ~/ 1000, + endTime:state.itemData.value.endDate! ~/ 1000, + needAuthor: 1, + isBeforeAddUser: false, + signKey: signKeyDataList, + privateKey: getPrivateKeyList, + token: getTokenList); + } else if (deviceConnectionState == BluetoothConnectionState.disconnected) { + dismissEasyLoading(); + cancelBlueConnetctToastTimer(); + state.sureBtnState.value = 0; + if(state.ifCurrentScreen.value == true){ + showBlueConnetctToast(); + } + } + }); + } + + @override + void onReady() { + // TODO: implement onReady + super.onReady(); + + _initReplySubscription(); + // getPasswordTypeUpdateIndexAction(); + } + + @override + void onInit() { + // TODO: implement onInit + super.onInit(); + } + + @override + void onClose() { + // TODO: implement onClose + _replySubscription.cancel(); + } } diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_page.dart index 77533088..dc9fda54 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_page.dart @@ -10,6 +10,8 @@ import '../../../../../app_settings/app_colors.dart'; import '../../../../../tools/commonItem.dart'; import '../../../../../tools/titleAppBar.dart'; import '../../../../../translations/trans_lib.dart'; +import '../../../../tools/appRouteObserver.dart'; +import '../../../../tools/dateTool.dart'; class PasswordKeyDetailChangeDatePage extends StatefulWidget { const PasswordKeyDetailChangeDatePage({Key? key}) : super(key: key); @@ -19,8 +21,7 @@ class PasswordKeyDetailChangeDatePage extends StatefulWidget { _PasswordKeyDetailChangeDatePage(); } -class _PasswordKeyDetailChangeDatePage - extends State { +class _PasswordKeyDetailChangeDatePage extends State with RouteAware { final logic = Get.put(PasswordKeyDetailChangeDateLogic()); final state = Get.find().state; @@ -41,7 +42,7 @@ class _PasswordKeyDetailChangeDatePage ), onPressed: () { // if (state.lockId.value != 0 && state.pwdId.value.isNotEmpty) { - logic.updatePwdRequest(); + logic.senderCustomPasswords(); // } }, ), @@ -91,12 +92,10 @@ class _PasswordKeyDetailChangeDatePage isHaveLine: true, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDH, - onConfirm: (p) { - state.selectEffectiveDate.value = - '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; + Pickers.showDatePicker(context, mode: DateMode.YMDH, onConfirm: (p) { + state.selectEffectiveDate.value = DateTool().getYMDHNDateString(p, 1); // state.effectiveDateTime = DateTime.parse(state.selectEffectiveDate.value); - state.itemData.value.startDate = DateTime.parse(state.selectEffectiveDate.value).millisecondsSinceEpoch; //更新开始时间 + state.itemData.value.startDate = DateTool().dateToTimestamp(state.selectEffectiveDate.value, 1); //更新开始时间 }); })), Obx(() => CommonItem( @@ -106,19 +105,63 @@ class _PasswordKeyDetailChangeDatePage : getEndDate, isHaveDirection: true, action: () { - Pickers.showDatePicker(context, mode: DateMode.YMDH, - onConfirm: (p) { - state.selectFailureDate.value = - '${p.year}-${intToStr(p.month!)}-${intToStr(p.day!)} ${intToStr(p.hour!)}:${intToStr(p.minute!)}'; - // state.failureDateTime = DateTime.parse(state.selectFailureDate.value); - state.itemData.value.endDate = DateTime.parse(state.selectFailureDate.value).millisecondsSinceEpoch; //更新结束时间 + Pickers.showDatePicker(context, mode: DateMode.YMDH, onConfirm: (p) { + state.selectFailureDate.value = DateTool().getYMDHNDateString(p, 1); + state.itemData.value.endDate = DateTool().dateToTimestamp(state.selectFailureDate.value, 1); //更新结束时间 }); })), ], ); } - String intToStr(int v) { - return (v < 10) ? "0$v" : "$v"; + @override + void didChangeDependencies() { + // TODO: implement didChangeDependencies + super.didChangeDependencies(); + + /// 路由订阅 + AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); + } + + @override + void dispose() { + // TODO: implement dispose + /// 取消路由订阅 + AppRouteObserver().routeObserver.unsubscribe(this); + super.dispose(); + } + + /// 从上级界面进入 当前界面即将出现 + @override + void didPush() { + super.didPush(); + state.ifCurrentScreen.value = true; + } + + /// 返回上一个界面 当前界面即将消失 + @override + void didPop() { + super.didPop(); + logic.cancelBlueConnetctToastTimer(); + logic.dismissEasyLoading(); + state.ifCurrentScreen.value = false; + state.sureBtnState.value = 0; + } + + /// 从下级返回 当前界面即将出现 + @override + void didPopNext() { + super.didPopNext(); + state.ifCurrentScreen.value = true; + } + + /// 进入下级界面 当前界面即将消失 + @override + void didPushNext() { + super.didPushNext(); + logic.cancelBlueConnetctToastTimer(); + logic.dismissEasyLoading(); + state.ifCurrentScreen.value = false; + state.sureBtnState.value = 0; } } diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_state.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_state.dart index 63bdad8a..d3695f16 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_state.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetailChangeDate/passwordKeyDetailChangeDate_state.dart @@ -4,36 +4,17 @@ import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKe class PasswordKeyDetailChangeDateState { final itemData = PasswordKeyListItem().obs; - // final TextEditingController inputPwdController = TextEditingController(); - // final TextEditingController inputNameController = TextEditingController(); - // final changeType = '1'.obs; //1-通过APP走蓝牙修改,不传默认1,必需先通过APP SDK蓝牙修改后调用该接口 2-通过网关或WiFi锁修改,如果是WiFi锁或有连接网关,则可以传2,直接调用该接口修改生效 - // final isCoerced = '1'.obs; //胁迫指纹:1;非胁迫指纹:2(胁迫指纹开锁触发报警) - // final hoursStart = 0.obs; - // final hoursEnd = 0.obs; - // final startDate = 0.obs; - // final endDate = 0.obs; - // final pwdId = ''.obs; - // final lockId = 0.obs; - // final fromType = ''.obs; + final selectEffectiveDate = ''.obs; //生效时间 final selectFailureDate = ''.obs; //失效时间 - // DateTime effectiveDateTime = DateTime.now(); - // DateTime failureDateTime = DateTime.now(); - // final endDay = ''.obs; - // final startDay = ''.obs; - // final weekDays = [].obs; + + var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + var sureBtnState = 0.obs;// 0普通状态(可用) 1连接中(不可用) PasswordKeyDetailChangeDateState() { Map map = Get.arguments; - // itemData.value = map["itemData"]; if ((map["itemData"] != null)) { itemData.value = map["itemData"]; } - // if ((map["pwdId"] != null)) { - // pwdId.value = map["pwdId"]; - // } - // if ((map["lockId"] != null)) { - // lockId.value = map["lockId"]; - // } } } diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart index 3d89f3e6..7ab748e8 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_logic.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; +import 'package:star_lock/app_settings/app_settings.dart'; import 'package:star_lock/blue/io_type.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_state.dart'; @@ -183,8 +184,9 @@ class PasswordKeyListLogic extends BaseGetXController { DateTime sendDateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!); DateTime startDateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!); DateTime endDateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!); - int starHour = startDateStr.hour; - int endHour = endDateStr.hour; + int starHour = indexEntity.hoursStart!; + int endHour = indexEntity.hoursEnd!; + // AppLog.log('indexEntity.keyboardPwdName:${indexEntity.keyboardPwdName} indexEntity.keyboardPwdStatus:${indexEntity.keyboardPwdStatus} indexEntity.startDate!${indexEntity.startDate!} indexEntity.endDate!${indexEntity.endDate!} starHour:$starHour endHour:$endHour'); switch (getPwdType) { case 1: diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_page.dart deleted file mode 100644 index d8df9501..00000000 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_page.dart +++ /dev/null @@ -1,45 +0,0 @@ - -import 'package:flutter/material.dart'; -import 'package:get/get.dart'; -import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_tabbar.dart'; - -import '../../../../../app_settings/app_colors.dart'; -import '../../../../../tools/titleAppBar.dart'; -import '../../../../../translations/trans_lib.dart'; -import '../../../../lockMian/entity/lockListInfo_entity.dart'; - -class PasswordKeyManagePage extends StatefulWidget { - const PasswordKeyManagePage({Key? key}) : super(key: key); - - @override - State createState() => _PasswordKeyManagePageState(); -} - -class _PasswordKeyManagePageState extends State { - var index = 0; - late LockListInfoItemEntity keyInfo; - - @override - Widget build(BuildContext context) { - dynamic obj = ModalRoute.of(context)?.settings.arguments; - if (obj != null && (obj["keyInfo"] != null)) { - keyInfo = obj["keyInfo"]; - } - - return Scaffold( - backgroundColor: AppColors.mainBackgroundColor, - appBar: TitleAppBar( - barTitle: TranslationLoader.lanKeys!.getPassword!.tr, - haveBack: true, - backgroundColor: AppColors.mainColor), - body: Column( - children: [ - PasswordKeyManageTabbarPage( - initialIndex: index, - keyInfo: keyInfo, - ), - ], - ), - ); - } -} diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_tabbar.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_tabbar.dart deleted file mode 100644 index 6e29e1a8..00000000 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKeyManage/passwordKeyManage_tabbar.dart +++ /dev/null @@ -1,128 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:get/get.dart'; -import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart'; - -import '../../../../../app_settings/app_colors.dart'; -import '../../../../../tools/CustomUnderlineTabIndicator.dart'; -import '../../../../../translations/trans_lib.dart'; -import '../passwordKey_perpetual_page.dart'; - -class PasswordKeyManageTabbarPage extends StatefulWidget { - var initialIndex = 1; - final LockListInfoItemEntity keyInfo; - - PasswordKeyManageTabbarPage( - {Key? key, required this.initialIndex, required this.keyInfo}) - : super(key: key); - @override - State createState() => - _PasswordKeyManageTabbarPageState(); -} - -class _PasswordKeyManageTabbarPageState extends State with SingleTickerProviderStateMixin { - late TabController _tabController; - - final List _itemTabs = [ - ItemView(title: TranslationLoader.lanKeys!.permanent!.tr, type: "0"), - ItemView(title: TranslationLoader.lanKeys!.timeLimit!.tr, type: "1"), - ItemView(title: TranslationLoader.lanKeys!.once!.tr, type: "2"), - ItemView(title: TranslationLoader.lanKeys!.custom!.tr, type: "3"), - ItemView(title: TranslationLoader.lanKeys!.circulation!.tr, type: "4"), - ItemView(title: TranslationLoader.lanKeys!.clearAll!.tr, type: "5"), - ]; - - @override - void initState() { - // TODO: implement initState - super.initState(); - _tabController = TabController( - vsync: this, - length: _itemTabs.length, - initialIndex: widget.initialIndex); - - _tabController.addListener(() { - if (_tabController.animation!.value==_tabController.index){ - FocusScope.of(context).requestFocus(FocusNode()); - } - }); - // _tabController.addListener(handleTabIndex); - } - - // int handleTabIndex() { - // // 获取当前选定的标签索引 - // int currentIndex = _tabController.index; - // // 根据索引可以得知用户点击了哪个 item - // eventBus.fire(GetPasswordTypeUpdateIndex(currentIndex)); - // return currentIndex; - // } - - @override - Widget build(BuildContext context) { - return Expanded( - child: Column( - children: [ - _tabBar(), - _pageWidget(), - ], - )); - } - - TabBar _tabBar() { - return TabBar( - controller: _tabController, - onTap: (index){ - FocusScope.of(context).requestFocus(FocusNode()); - }, - tabs: _itemTabs.map((ItemView item) => _tab(item)).toList(), - isScrollable: true, - indicatorColor: Colors.red, - unselectedLabelColor: Colors.black, - unselectedLabelStyle: TextStyle( - color: AppColors.mainColor, - fontSize: 24.sp, - ), - automaticIndicatorColorAdjustment: true, - labelColor: AppColors.mainColor, - labelStyle: TextStyle( - color: AppColors.mainColor, - fontSize: 24.sp, - fontWeight: FontWeight.w600), - indicator: CustomUnderlineTabIndicator( - borderSide: BorderSide(color: AppColors.mainColor, width: 4.w), - strokeCap: StrokeCap.round, - width: 30.w), - ); - } - - Tab _tab(ItemView item) { - return Tab( - // text: item.title, - child: Container( - // width: item.title.length > 2 ? 1.sw / 8 : 1.sw / 12, - // margin: EdgeInsets.all(10.w), - // color: Colors.red, - child: Text( - item.title, - textAlign: TextAlign.center, - ), - ), - ); - } - - Widget _pageWidget() { - return Expanded( - child: TabBarView( - controller: _tabController, - children: _itemTabs.map((ItemView item) => PasswordKeyPerpetualPage()).toList(), - ), - ); - } -} - -class ItemView { - const ItemView({required this.title, required this.type}); - - final String title; - final String type; -} diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart index e6513d08..b732cc68 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart @@ -4,7 +4,6 @@ import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:get/get.dart'; -import 'package:star_lock/blue/io_type.dart'; import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_state.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/eventBusEventManage.dart'; @@ -26,27 +25,14 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { /// 收到点击密码类型更新 /** - 单次 1 只能在开始时间后6小时内使用一次 - 永久 2 从开始时间开始永久有效,必需在开始时间24小时内使用一次,否则将失效 - 限期 3 在开始和结束时间内有效,必需在开始时间24小时内使用一次,否则将失效 - 删除 4 在锁上使用后会删除之前在锁上使用过的密码 - 周未循环 5 在周未开始和结束时间指定时间段内有效 - 每日循环 6 每天开始和结束时间指定时间段内有效 - 工作日循环 7 工作日开始和结束时间指定的时间段内有效 - 周一循环 8 每周一开始和结束时间指定时间段内有效 - 周二循环 9 每周二开始和结束时间指定时间段内有效 - 周三循环 10 每周三开始和结束时间指定时间段内有效 - 周四循环 11 每周四开始和结束时间指定时间段内有效 - 周五循环 12 每周五开始和结束时间指定时间段内有效 - 周六循环 13 每周六开始和结束时间指定时间段内有效 - 周天循环 14 每周日开始和结束时间指定时间段内有效 + * getKeyType 单次1 永久2 限期3 删除4 周未循环5 每日循环6 工作日循环7 周一循环8 周二循环9 周三循环10 周四循环11 周五循环12 周六循环13 周天循环14 */ //获取密码请求 Future getKeyboardPwdRequest() async { var startDate = DateTool().dateToTimestamp(state.beginTime.value, 1); var endDate = DateTool().dateToTimestamp(state.endTime.value, 1); String lockId = state.keyInfo.value.lockId.toString(); - String getKeyType = state.widgetType.value.toString(); + String getKeyType = "0"; if (state.nameController.text.isEmpty) { showToast("请输入姓名".tr); diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart index efad0ad3..894276a8 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_page.dart @@ -93,7 +93,7 @@ class _PasswordKeyPerpetualPageState extends State wit TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, state.nameController), - keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip1!.tr) + keyBottomWidget("密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。".tr) ], ), ); @@ -110,7 +110,7 @@ class _PasswordKeyPerpetualPageState extends State wit TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, state.nameController), - keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip2!.tr) + keyBottomWidget("密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。".tr) ], ), ); @@ -169,7 +169,7 @@ class _PasswordKeyPerpetualPageState extends State wit TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, state.nameController), - keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip2!.tr) + keyBottomWidget("密码生成后,请在当日23:59前使用一次进行激活,否则过0点后未激活则失效。密码激活后,有效期内不限次数使用。".tr) ], ), ); @@ -185,7 +185,7 @@ class _PasswordKeyPerpetualPageState extends State wit TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, state.nameController), - keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip6!.tr) + keyBottomWidget("密码生成后,请在当日23:59前使用,否则过0点后失效。清空码用于清空今天0点之前生成的所有密码。".tr) ], ), ); @@ -286,7 +286,7 @@ class _PasswordKeyPerpetualPageState extends State wit children: [ // SizedBox(height: 10.h), Obx(() => CommonItem( - leftTitel: "是否是管理员", + leftTitel: "是否是管理员".tr, rightTitle: "", isTipsImg: false, isHaveRightWidget: true, diff --git a/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart b/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart index e64a01fc..f931d809 100644 --- a/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart +++ b/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_logic.dart @@ -1,3 +1,4 @@ + import 'dart:async'; import 'package:flutter_blue_plus/flutter_blue_plus.dart'; @@ -22,7 +23,17 @@ class NearbyLockLogic extends BaseGetXController { // 点击连接设备 void connect(String deviceName) { - showEasyLoading(); + showTitleEasyLoading("获取锁信息 1/3"); + // if(state.sureBtnState.value == 1){ + // return; + // } + // state.sureBtnState.value = 1; + + // showEasyLoading(); + showBlueConnetctToastTimer(action: (){ + dismissEasyLoading(); + // state.sureBtnState.value = 0; + }); BlueManage().bludSendData(deviceName, (BluetoothConnectionState state) async { AppLog.log("点击要添加的设备了"); if (state == BluetoothConnectionState.connected) { @@ -37,8 +48,7 @@ class NearbyLockLogic extends BaseGetXController { // 获取解析后的数据 late StreamSubscription _replySubscription; void _initReplySubscription() { - _replySubscription = - EventBusManager().eventBus!.on().listen((reply) { + _replySubscription = EventBusManager().eventBus!.on().listen((reply) { if (reply is GetPublicKeyReply) { _replyGetPublicKey(reply); } @@ -55,6 +65,8 @@ class NearbyLockLogic extends BaseGetXController { } Future _replyGetPublicKey(Reply reply) async { + // dismissEasyLoading(); + // 获取公钥 switch (reply.status) { case 0x00: @@ -67,6 +79,7 @@ class NearbyLockLogic extends BaseGetXController { // 获取私钥 AppLog.log("开始获取私钥"); + showTitleEasyLoading("获取锁信息 2/3"); IoSenderManage.getPrivateKey( lockId: BlueManage().connectDeviceName, keyID: "1", @@ -76,6 +89,7 @@ class NearbyLockLogic extends BaseGetXController { needAuthor: 1); break; default: + // state.sureBtnState.value = 0; AppLog.log("获取公钥失败"); break; } @@ -105,9 +119,11 @@ class NearbyLockLogic extends BaseGetXController { (0xff & timestamp[2]) << 8 | (0xFF & timestamp[3])); + showTitleEasyLoading("获取锁信息 3/3"); _getStarLockStatus(); break; default: + // state.sureBtnState.value = 0; break; } } @@ -286,6 +302,7 @@ class NearbyLockLogic extends BaseGetXController { break; default: //失败 + // state.sureBtnState.value = 0; break; } } diff --git a/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_state.dart b/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_state.dart index 984ba280..5d143e3e 100644 --- a/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_state.dart +++ b/star_lock/lib/mine/addLock/nearbyLock/nearbyLock_state.dart @@ -9,6 +9,8 @@ class NearbyLockState { RxList devices = [].obs; var ifCurrentScreen = true.obs; // 是否是当前界面,用于判断是否需要针对当前界面进行展示 + // var sureBtnState = 0.obs;// 0可点击 1 不可点击 + var selectLockName = "".obs; var timestampValue = 0; diff --git a/star_lock/lib/network/response_interceptor_log.dart b/star_lock/lib/network/response_interceptor_log.dart index 94015681..cc5c5bb5 100644 --- a/star_lock/lib/network/response_interceptor_log.dart +++ b/star_lock/lib/network/response_interceptor_log.dart @@ -5,7 +5,7 @@ import 'package:get/get_connect/http/src/request/request.dart'; import 'package:star_lock/app_settings/app_settings.dart'; FutureOr responseLogInterceptor(Request request, Response response) { - AppLog.log('HTTP request:${request.url}\n RESPONSE => stataCode:${response.statusCode} ${response.bodyString} ${response.headers}'); + print('HTTP request:${request.url}\n RESPONSE => stataCode:${response.statusCode} ${response.bodyString} ${response.headers}'); EasyLoading.dismiss(animation: true); return response; } diff --git a/star_lock/lib/tools/baseGetXController.dart b/star_lock/lib/tools/baseGetXController.dart index 537ecf40..872672cc 100644 --- a/star_lock/lib/tools/baseGetXController.dart +++ b/star_lock/lib/tools/baseGetXController.dart @@ -57,6 +57,8 @@ class BaseGetXController extends GetxController { void dismissEasyLoading() => EasyLoading.dismiss(); + void showTitleEasyLoading(String showContent) => EasyLoading.show(status: showContent); + Timer? _timer; // CancelableOperation? _operation; void showBlueConnetctToastTimer({bool isShowBlueConnetctToast = true, Function? action}) {