1,发送钥匙成功后返回列表刷新

This commit is contained in:
Daisy 2023-08-31 18:50:28 +08:00
parent 7f44198536
commit d6570450cf
8 changed files with 182 additions and 158 deletions

View File

@ -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<Reply> _replySubscription;
void _initReplySubscription() {
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async {
_replySubscription =
EventBusManager().eventBus!.on<Reply>().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<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
List<int> getPrivateKeyList =
changeStringListToIntList(privateKey!);
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
@ -51,27 +52,26 @@ class AuthorizedAdminLogic extends BaseGetXController {
List<int> 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<void> 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<int> 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();
}
}
}

View File

@ -302,7 +302,7 @@ class _AuthorizedAdminPageState extends State<AuthorizedAdminPage> {
btnName: '完成',
onClick: () {
_isSendSuccess = false;
setState(() {});
Navigator.pop(context, true);
}),
SizedBox(
height: 10.h,

View File

@ -69,7 +69,12 @@ class _AuthorizedAdminListPageState extends State<AuthorizedAdminListPage> {
arguments: {
"lockMainEntity": lockMainEntity,
"keyInfo": keyInfo
});
}).then((val) {
if (val != null) {
mockNetworkDataRequest();
setState(() {});
}
});
},
),
SizedBox(

View File

@ -82,7 +82,12 @@ class _ElectronicKeyListPageState extends State<ElectronicKeyListPage> {
arguments: {
"lockMainEntity": lockMainEntity,
"keyInfo": keyInfo
});
}).then((val) {
if (val != null) {
mockNetworkDataRequest();
setState(() {});
}
});
},
),
SizedBox(

View File

@ -80,67 +80,63 @@ class _SendElectronicKeyPageState extends State<SendElectronicKeyPage> {
}
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<SendElectronicKeyPage> {
btnName: '完成',
onClick: () {
_isSendSuccess = false;
setState(() {});
Navigator.pop(context, true);
}),
SizedBox(
height: 10.h,

View File

@ -75,15 +75,20 @@ class _PasswordKeyListPageState extends State<PasswordKeyListPage> {
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,
)

View File

@ -14,13 +14,14 @@ import '../../../../tools/baseGetXController.dart';
import '../../../../tools/storage.dart';
class PasswordKeyPerpetualLogic extends BaseGetXController {
late DateTime getStartDateTime;
//
late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() {
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async {
_replySubscription =
EventBusManager().eventBus!.on<Reply>().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<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
List<int> getPrivateKeyList =
changeStringListToIntList(privateKey!);
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> 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<void> 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<int> 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();
}
}
}

View File

@ -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<PasswordKeyPerpetualPage> {
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<PasswordKeyPerpetualPage> {
@override
Widget build(BuildContext context) {
return indexChangeWidget();
return SingleChildScrollView(
child: indexChangeWidget(),
);
}
@override
@ -85,7 +91,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
_controller),
_nameController),
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip1!.tr)
],
);
@ -99,7 +105,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
_controller),
_nameController),
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip2!.tr)
],
);
@ -112,7 +118,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
_controller),
_nameController),
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip3!.tr)
],
);
@ -127,9 +133,9 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
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<PasswordKeyPerpetualPage> {
perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
_controller),
_nameController),
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip5!.tr)
],
);
@ -156,7 +162,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
perpetualKeyWidget(
TranslationLoader.lanKeys!.name!.tr,
TranslationLoader.lanKeys!.pleaseNameYourPassword!.tr,
_controller),
_nameController),
keyBottomWidget(TranslationLoader.lanKeys!.getPasswordTip6!.tr)
],
);
@ -179,7 +185,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
leftTitel: titleStr,
rightTitle: "",
isHaveRightWidget: true,
rightWidget: getTFWidget(rightTitle)),
rightWidget: getTFWidget(rightTitle, controller)),
),
SizedBox(height: 10.h),
],
@ -346,6 +352,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
SubmitBtn(
btnName: TranslationLoader.lanKeys!.getPassword!.tr,
onClick: () {
logic.getStartDate(_effectiveDateTime);
getKeyboardPwdRequest();
}),
],
@ -403,7 +410,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
var entity = await ApiRepository.to.getPasswordKey(
getFailureDateTime,
'0',
_controller.text,
_nameController.text,
getKeyType,
'0',
lockId,
@ -466,7 +473,8 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
SubmitBtn(
btnName: '完成',
onClick: () {
Navigator.pop(context);
_isSendSuccess = false;
Navigator.pop(context, true);
}),
SizedBox(
height: 10.h,
@ -489,7 +497,7 @@ class _PasswordKeyPerpetualPageState extends State<PasswordKeyPerpetualPage> {
}
//
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<PasswordKeyPerpetualPage> {
child: TextField(
//
maxLines: 1,
controller: _controller,
controller: editController,
autofocus: false,
textAlign: TextAlign.end,
decoration: InputDecoration(