diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart index bc476fcf..01d2e090 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_logic.dart @@ -1,4 +1,3 @@ - import 'dart:async'; import 'package:flutter_reactive_ble/flutter_reactive_ble.dart'; @@ -21,9 +20,10 @@ class AuthorizedAdminLogic extends BaseGetXController { // 监听设备返回的数据 late StreamSubscription _replySubscription; void _initReplySubscription() { - _replySubscription = EventBusManager().eventBus!.on().listen((reply) async { + _replySubscription = + EventBusManager().eventBus!.on().listen((reply) async { // 开门 - if(reply is TransferPermissionsReply) { + if (reply is TransferPermissionsReply) { var token = reply.data.sublist(2, 6); var saveStrList = changeIntListToStringList(token); print("_replyFactoryDataResetKeyToken:$token"); @@ -32,17 +32,18 @@ class AuthorizedAdminLogic extends BaseGetXController { int status = reply.data[6]; print("status:$status"); - switch(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!); + List getPrivateKeyList = + changeStringListToIntList(privateKey!); var publicKey = await Storage.getStringList(saveBluePublicKey); List publicKeyDataList = changeStringListToIntList(publicKey!); @@ -51,27 +52,26 @@ class AuthorizedAdminLogic extends BaseGetXController { List getTokenList = changeStringListToIntList(token!); IoSenderManage.senderFactoryDataReset( - lockID:BlueManage().connectDeviceName, - userID:await Storage.getUid(), - keyID:"1", - needAuthor:1, - publicKey:publicKeyDataList, - privateKey:getPrivateKeyList, - token: getTokenList - ); + lockID: BlueManage().connectDeviceName, + userID: await Storage.getUid(), + keyID: "1", + needAuthor: 1, + publicKey: publicKeyDataList, + privateKey: getPrivateKeyList, + token: getTokenList); break; case 0x07: - //无权限 + //无权限 print("${reply.commandType!.typeValue} 用户无权限"); break; case 0x09: - // 权限校验错误 + // 权限校验错误 print("${reply.commandType!.typeValue} 权限校验错误"); break; default: - //失败 + //失败 print("${reply.commandType!.typeValue} 失败"); break; @@ -82,8 +82,10 @@ class AuthorizedAdminLogic extends BaseGetXController { // 转移权限 Future transferPermissionsAction() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async { - if (state == DeviceConnectionState.connected){ + BlueManage().judgeReconnect( + BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, + (DeviceConnectionState state) async { + if (state == DeviceConnectionState.connected) { var privateKey = await Storage.getStringList(saveBluePrivateKey); List getPrivateKeyList = changeStringListToIntList(privateKey!); @@ -95,16 +97,15 @@ class AuthorizedAdminLogic extends BaseGetXController { print("openDoorTokenPubToken:$getTokenList"); IoSenderManage.senderTransferPermissions( - lockID:BlueManage().connectDeviceName, - authUserID:await Storage.getUid(), - keyID:"1", - oldUserID:await Storage.getUid(), - newUserID:"100002", - needAuthor:1, - publicKey:publicKeyDataList, - privateKey:getPrivateKeyList, - token: getTokenList - ); + lockID: BlueManage().connectDeviceName, + authUserID: await Storage.getUid(), + keyID: "1", + oldUserID: await Storage.getUid(), + newUserID: "100002", + needAuthor: 1, + publicKey: publicKeyDataList, + privateKey: getPrivateKeyList, + token: getTokenList); } }); } @@ -121,7 +122,6 @@ class AuthorizedAdminLogic extends BaseGetXController { void onInit() { // TODO: implement onInit super.onInit(); - } @override @@ -129,5 +129,4 @@ class AuthorizedAdminLogic extends BaseGetXController { // TODO: implement onClose _replySubscription.cancel(); } - -} \ No newline at end of file +} diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart index 769bcd45..e523ae71 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart @@ -302,7 +302,7 @@ class _AuthorizedAdminPageState extends State { btnName: '完成', onClick: () { _isSendSuccess = false; - setState(() {}); + Navigator.pop(context, true); }), SizedBox( height: 10.h, diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart index bf9cb1c6..79024fb1 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart @@ -69,7 +69,12 @@ class _AuthorizedAdminListPageState extends State { arguments: { "lockMainEntity": lockMainEntity, "keyInfo": keyInfo - }); + }).then((val) { + if (val != null) { + mockNetworkDataRequest(); + setState(() {}); + } + }); }, ), SizedBox( diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart index 95dc8a1a..68c3cfa3 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart @@ -82,7 +82,12 @@ class _ElectronicKeyListPageState extends State { arguments: { "lockMainEntity": lockMainEntity, "keyInfo": keyInfo - }); + }).then((val) { + if (val != null) { + mockNetworkDataRequest(); + setState(() {}); + } + }); }, ), SizedBox( diff --git a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart index deb03563..73e397c0 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart @@ -80,67 +80,63 @@ class _SendElectronicKeyPageState extends State { } Widget indexChangeWidget() { - switch (int.parse(widget.type)) { - case 0: - { - // 限时 - return _isSendSuccess - ? sendElectronicKeySucceed() - : Column( - children: [ - keyInfoWidget(), - keyTimeWidget(), - remoteUnlockingWidget(), - keyRealNameWidget(), - keyBottomWidget() - ], - ); - } - case 1: - { - // 永久 - return _isSendSuccess - ? sendElectronicKeySucceed() - : Column( - children: [ - keyInfoWidget(), - remoteUnlockingWidget(), - keyRealNameWidget(), - keyBottomWidget() - ], - ); - } - case 2: - { - // 单次 - return _isSendSuccess - ? sendElectronicKeySucceed() - : Column( - children: [ - keyInfoWidget(), - remoteUnlockingWidget(), - keyRealNameWidget(), - keyBottomWidget() - ], - ); - } - case 3: - { - // 循环 - return _isSendSuccess - ? sendElectronicKeySucceed() - : Column( - children: [ - keyInfoWidget(), - keyPeriodValidityWidget(), - remoteUnlockingWidget(), - keyRealNameWidget(), - keyBottomWidget() - ], - ); - } - default: - return Container(); + if (_isSendSuccess) { + return sendElectronicKeySucceed(); + } else { + switch (int.parse(widget.type)) { + case 0: + { + // 限时 + return Column( + children: [ + keyInfoWidget(), + keyTimeWidget(), + remoteUnlockingWidget(), + keyRealNameWidget(), + keyBottomWidget() + ], + ); + } + case 1: + { + // 永久 + return Column( + children: [ + keyInfoWidget(), + remoteUnlockingWidget(), + keyRealNameWidget(), + keyBottomWidget() + ], + ); + } + case 2: + { + // 单次 + return Column( + children: [ + keyInfoWidget(), + remoteUnlockingWidget(), + keyRealNameWidget(), + keyBottomWidget() + ], + ); + } + case 3: + { + // 循环 + return Column( + children: [ + keyInfoWidget(), + keyPeriodValidityWidget(), + remoteUnlockingWidget(), + keyRealNameWidget(), + keyBottomWidget() + ], + ); + } + default: + return Container(); + } } } @@ -412,7 +408,7 @@ class _SendElectronicKeyPageState extends State { btnName: '完成', onClick: () { _isSendSuccess = false; - setState(() {}); + Navigator.pop(context, true); }), SizedBox( height: 10.h, diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart index 90d5c26d..cf0eb3ee 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart @@ -75,15 +75,20 @@ class _PasswordKeyListPageState extends State { height: 20.h, ), AddBottomWhiteBtn( - btnName: TranslationLoader.lanKeys!.getPassword!.tr, - onClick: () { - Navigator.pushNamed( - context, Routers.passwordKeyManagePage, arguments: { - "lockMainEntity": lockMainEntity, - "keyInfo": keyInfo - }); - }, - ), + btnName: TranslationLoader.lanKeys!.getPassword!.tr, + onClick: () { + Navigator.pushNamed( + context, Routers.passwordKeyManagePage, + arguments: { + "lockMainEntity": lockMainEntity, + "keyInfo": keyInfo + }).then((val) { + if (val != null) { + mockNetworkDataRequest(); + setState(() {}); + } + }); + }), SizedBox( height: 42.h, ) 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 95993fc1..5d57a1fc 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 @@ -14,13 +14,14 @@ import '../../../../tools/baseGetXController.dart'; import '../../../../tools/storage.dart'; class PasswordKeyPerpetualLogic extends BaseGetXController { - + late DateTime getStartDateTime; // 监听设备返回的数据 late StreamSubscription _replySubscription; void _initReplySubscription() { - _replySubscription = EventBusManager().eventBus!.on().listen((reply) async { + _replySubscription = + EventBusManager().eventBus!.on().listen((reply) async { // 设置自定义密码 - if(reply is SenderCustomPasswordsReply) { + if (reply is SenderCustomPasswordsReply) { var token = reply.data.sublist(2, 6); var saveStrList = changeIntListToStringList(token); print("_replyFactoryDataResetKeyToken:$token"); @@ -29,47 +30,49 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { int status = reply.data[6]; print("status:$status"); - switch(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!); + List getPrivateKeyList = + changeStringListToIntList(privateKey!); var publicKey = await Storage.getStringList(saveBluePublicKey); List publicKeyDataList = changeStringListToIntList(publicKey!); + print('得到的开始时间时间戳$getStartDate'); + IoSenderManage.senderCustomPasswordsCommand( - keyID:"1", - userID:await Storage.getUid(), - pwdNo:1, + keyID: "1", + userID: await Storage.getUid(), + pwdNo: 1, pwd: "123456", - useCountLimit:0xff, - startTime:0x11223344, - endTime:0x11223344, - needAuthor:1, - publicKey:publicKeyDataList, - privateKey:getPrivateKeyList, - token: token - ); + useCountLimit: 0xff, + startTime: 0x11223344, + endTime: 0x11223344, + 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; @@ -78,10 +81,16 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { }); } + void getStartDate(DateTime startDate) { + getStartDateTime = startDate; + } + // 设置自定义密码 Future senderCustomPasswords() async { - BlueManage().judgeReconnect(BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, (DeviceConnectionState state) async { - if (state == DeviceConnectionState.connected){ + BlueManage().judgeReconnect( + BlueManage().connectDeviceMacAddress, BlueManage().connectDeviceName, + (DeviceConnectionState state) async { + if (state == DeviceConnectionState.connected) { var publicKey = await Storage.getStringList(saveBluePublicKey); List publicKeyDataList = changeStringListToIntList(publicKey!); @@ -93,18 +102,17 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { print("openDoorTokenPubToken:$getTokenList"); IoSenderManage.senderCustomPasswordsCommand( - keyID:"1", - userID:await Storage.getUid(), - pwdNo:1, + keyID: "1", + userID: await Storage.getUid(), + pwdNo: 1, pwd: "123456", - useCountLimit:0xff, - startTime:0x11223344, - endTime:0x11223344, - needAuthor:1, - publicKey:publicKeyDataList, - privateKey:getPrivateKeyList, - token: getTokenList - ); + useCountLimit: 0xff, + startTime: 0x11223344, + endTime: 0x11223344, + needAuthor: 1, + publicKey: publicKeyDataList, + privateKey: getPrivateKeyList, + token: getTokenList); } }); } @@ -121,7 +129,6 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { void onInit() { // TODO: implement onInit super.onInit(); - } @override @@ -129,5 +136,4 @@ class PasswordKeyPerpetualLogic extends BaseGetXController { // TODO: implement onClose _replySubscription.cancel(); } - -} \ No newline at end of file +} 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 940fe685..b227de6d 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 @@ -6,6 +6,7 @@ import 'package:flutter_pickers/style/default_style.dart'; import 'package:flutter_pickers/time_picker/model/date_mode.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/passwordKey/passwordKey_perpetual/passwordKey_perpetual_logic.dart'; import 'package:star_lock/main/lockMian/entity/lockInfoEntity.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; @@ -33,7 +34,10 @@ class PasswordKeyPerpetualPage extends StatefulWidget { } class _PasswordKeyPerpetualPageState extends State { - final TextEditingController _controller = TextEditingController(); + final TextEditingController _nameController = TextEditingController(); + final TextEditingController _pwdController = TextEditingController(); + final logic = Get.put(PasswordKeyPerpetualLogic()); + late bool _isSendSuccess; //是否发送成功 late bool _isPermanent; //是否永久 late String _getPwdStr; @@ -47,7 +51,9 @@ class _PasswordKeyPerpetualPageState extends State { @override Widget build(BuildContext context) { - return indexChangeWidget(); + return SingleChildScrollView( + child: indexChangeWidget(), + ); } @override @@ -85,7 +91,7 @@ class _PasswordKeyPerpetualPageState extends State { perpetualKeyWidget( TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, - _controller), + _nameController), keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip1!.tr) ], ); @@ -99,7 +105,7 @@ class _PasswordKeyPerpetualPageState extends State { perpetualKeyWidget( TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, - _controller), + _nameController), keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip2!.tr) ], ); @@ -112,7 +118,7 @@ class _PasswordKeyPerpetualPageState extends State { perpetualKeyWidget( TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, - _controller), + _nameController), keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip3!.tr) ], ); @@ -127,9 +133,9 @@ class _PasswordKeyPerpetualPageState extends State { perpetualKeyWidget( TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, - _controller), + _nameController), perpetualKeyWidget(TranslationLoader.lanKeys!.password!.tr, - "请输入6-9位数字", _controller), + "请输入6-9位数字", _pwdController), keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip4!.tr) ], ); @@ -143,7 +149,7 @@ class _PasswordKeyPerpetualPageState extends State { perpetualKeyWidget( TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, - _controller), + _nameController), keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip5!.tr) ], ); @@ -156,7 +162,7 @@ class _PasswordKeyPerpetualPageState extends State { perpetualKeyWidget( TranslationLoader.lanKeys!.name!.tr, TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr, - _controller), + _nameController), keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip6!.tr) ], ); @@ -179,7 +185,7 @@ class _PasswordKeyPerpetualPageState extends State { leftTitel: titleStr, rightTitle: "", isHaveRightWidget: true, - rightWidget: getTFWidget(rightTitle)), + rightWidget: getTFWidget(rightTitle, controller)), ), SizedBox(height: 10.h), ], @@ -346,6 +352,7 @@ class _PasswordKeyPerpetualPageState extends State { SubmitBtn( btnName: TranslationLoader.lanKeys!.getPassword!.tr, onClick: () { + logic.getStartDate(_effectiveDateTime); getKeyboardPwdRequest(); }), ], @@ -403,7 +410,7 @@ class _PasswordKeyPerpetualPageState extends State { var entity = await ApiRepository.to.getPasswordKey( getFailureDateTime, '0', - _controller.text, + _nameController.text, getKeyType, '0', lockId, @@ -466,7 +473,8 @@ class _PasswordKeyPerpetualPageState extends State { SubmitBtn( btnName: '完成', onClick: () { - Navigator.pop(context); + _isSendSuccess = false; + Navigator.pop(context, true); }), SizedBox( height: 10.h, @@ -489,7 +497,7 @@ class _PasswordKeyPerpetualPageState extends State { } // 接受者信息输入框 - Widget getTFWidget(String tfStr) { + Widget getTFWidget(String tfStr, TextEditingController editController) { return SizedBox( height: 50.h, width: 300.w, @@ -499,7 +507,7 @@ class _PasswordKeyPerpetualPageState extends State { child: TextField( //输入框一行 maxLines: 1, - controller: _controller, + controller: editController, autofocus: false, textAlign: TextAlign.end, decoration: InputDecoration(