修复用户第一次进行蓝牙协议交互,添加用户问题

This commit is contained in:
魏少阳 2024-04-23 15:15:56 +08:00
parent 9e31a73a81
commit fc7b487f8a
11 changed files with 369 additions and 173 deletions

View File

@ -48,7 +48,7 @@ abstract class Reply{
case 0x06: case 0x06:
// //
Get.log("${commandType!.typeName}需要鉴权"); Get.log("${commandType!.typeName}需要鉴权");
showErrorMessage("需要鉴权"); // showErrorMessage("需要鉴权");
break; break;
case 0x07: case 0x07:
// //

View File

@ -0,0 +1,158 @@
import 'dart:async';
import 'package:get/get.dart';
import 'package:star_lock/blue/sender_manage.dart';
import 'package:star_lock/tools/baseGetXController.dart';
import 'package:star_lock/tools/eventBusEventManage.dart';
import '../main/lockDetail/lockDetail/lockNetToken_entity.dart';
import '../network/api_repository.dart';
import '../tools/commonDataManage.dart';
import '../tools/storage.dart';
import 'blue_manage.dart';
import 'io_protocol/io_addUser.dart';
import 'io_reply.dart';
import 'io_tool/io_tool.dart';
import 'io_tool/manager_event_bus.dart';
class SenderBeforeDataManage {
static SenderBeforeDataManage? _manager;
SenderBeforeDataManage._init();
static SenderBeforeDataManage? shareManager() {
_manager ??= SenderBeforeDataManage._init();
_manager!._init();
return _manager;
}
factory SenderBeforeDataManage() => shareManager()!;
SenderBeforeDataManage? get manager => shareManager();
void _init() {
_initReplySubscription();
}
//
StreamSubscription<Reply>? _replySubscription;
void _initReplySubscription() {
_replySubscription ??= EventBusManager().eventBus!.on<Reply>().listen((reply) async {
//
if ((reply is AddUserReply)) {
_replyAddUserKey(reply);
}
});
}
//
Future<void> _replyAddUserKey(Reply reply) async {
// var lockId = reply.data.sublist(2, 42);
// print("lockId:$lockId");
int status = reply.data[46];
// print("status:$status reply.data:${reply.data}");
print("status:$status");
switch (status) {
case 0x00:
//
CommonDataManage().currentLockUserNo = reply.data[47];
CommonDataManage().currentKeyInfo.lockUserNo = CommonDataManage().currentLockUserNo;
_updateLockUserNo();
break;
case 0x06:
//
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
var token = reply.data.sublist(42, 46);
List<String> strTokenList = changeIntListToStringList(token);
Storage.setStringList(saveBlueToken, strTokenList);
// print("token:$token");
// IoSenderManage.senderAddUser(
// lockID: BlueManage().connectDeviceName,
// authUserID: CommonDataManage().currentKeyInfo.senderUserId!.toString(),
// keyID: CommonDataManage().currentKeyInfo.keyId.toString(),
// userID: await Storage.getUid(),
// openMode: 1,
// keyType: 0,
// startDate: CommonDataManage().currentKeyInfo.startDate!~/10000,
// expireDate: CommonDataManage().currentKeyInfo.endDate!~/10000,
// role: CommonDataManage().currentKeyInfo.keyRight == 1 ? 1 : 0,
// password: "123456",
// needAuthor: 1,
// publicKey: publicKeyDataList,
// privateKey: getPrivateKeyList,
// token: token);
var addUserData = AddUserCommand(
lockID: BlueManage().connectDeviceName,
authUserID: CommonDataManage().currentKeyInfo.senderUserId!.toString(),
keyID: CommonDataManage().currentKeyInfo.keyId.toString(),
userID: await Storage.getUid(),
openMode: 1,
keyType: 0,
startDate: CommonDataManage().currentKeyInfo.startDate!~/10000,
expireDate: CommonDataManage().currentKeyInfo.endDate!~/10000,
role: CommonDataManage().currentKeyInfo.keyRight == 1 ? 1 : 0,
password: "123456",
needAuthor: 1,
publicKey: publicKeyDataList,
privateKey: getPrivateKeyList,
token: token);
eventBus.fire(LockAddUserSucceedEvent(addUserData.packageData(), 1));
break;
default:
//
break;
}
}
Future<List<int>> getAddUserKeyData() async {
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
var token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!);
var addUserData = AddUserCommand(
lockID: BlueManage().connectDeviceName,
authUserID: CommonDataManage().currentKeyInfo.senderUserId!.toString(),
keyID: CommonDataManage().currentKeyInfo.keyId.toString(),
userID: await Storage.getUid(),
openMode: 1,
keyType: 0,
startDate: CommonDataManage().currentKeyInfo.startDate!~/10000,
expireDate: CommonDataManage().currentKeyInfo.endDate!~/10000,
role: CommonDataManage().currentKeyInfo.keyRight == 1 ? 1 : 0,
password: "123456",
needAuthor: 1,
publicKey: publicKeyDataList,
privateKey: getPrivateKeyList,
token: getTokenList);
return addUserData.packageData();
}
// NO
void _updateLockUserNo() async {
LockNetTokenEntity entity = await ApiRepository.to.updateLockUserNo(
keyId: CommonDataManage().currentKeyInfo.keyId.toString(),
lockUserNo: CommonDataManage().currentKeyInfo.lockUserNo.toString()
);
if (entity.errorCode!.codeIsSuccessful) {
eventBus.fire(LockAddUserSucceedEvent([0], 0));
}
}
dispose() {
_replySubscription!.cancel();
}
}

View File

@ -1,15 +1,19 @@
import 'dart:async';
import '../app_settings/app_settings.dart'; import '../app_settings/app_settings.dart';
import '../tools/commonDataManage.dart';
import '../tools/eventBusEventManage.dart';
import 'io_sender.dart'; import 'io_sender.dart';
import 'io_type.dart'; import 'io_type.dart';
import 'io_tool/io_model.dart'; import 'io_tool/io_model.dart';
import 'io_tool/manager_event_bus.dart'; import 'io_tool/manager_event_bus.dart';
import 'sender_beforeDataManage.dart';
typedef CommandSendCallBack = void Function(ErrorType errorType); typedef CommandSendCallBack = void Function(ErrorType errorType);
class CommandSenderManager { class CommandSenderManager {
static final CommandSenderManager _manager = CommandSenderManager static final CommandSenderManager _manager = CommandSenderManager._init();
._init();
factory CommandSenderManager()=>_manager; factory CommandSenderManager()=>_manager;
static CommandSenderManager getInstance()=>_manager; static CommandSenderManager getInstance()=>_manager;
CommandSenderManager._init(){ CommandSenderManager._init(){
@ -17,7 +21,21 @@ class CommandSenderManager {
} }
init(){ init(){
initLockAddUserSucceedEvent();
}
//
StreamSubscription? _passCurrentLockInformationEvent;
List<int> dataBeforeAddTheUser = [];
void initLockAddUserSucceedEvent() {
// eventBus
_passCurrentLockInformationEvent = eventBus.on<LockAddUserSucceedEvent>().listen((event) {
if(event.type == 0){
_sendNormalData(dataBeforeAddTheUser);
}else{
_sendNormalData(event.dataList);
}
});
} }
// CommandType lastCommandType = CommandType.readLockStatusInfo; // CommandType lastCommandType = CommandType.readLockStatusInfo;
@ -37,8 +55,17 @@ class CommandSenderManager {
} }
List<int> value = command.packageData(); List<int> value = command.packageData();
// print("sendData:${value}"); print("CommonDataManage().currentLockUserNo:${CommonDataManage().currentLockUserNo}");
_sendNormalData(value); if(CommonDataManage().currentLockUserNo == 0){
//
var entity = await SenderBeforeDataManage().getAddUserKeyData();
_sendNormalData(entity);
dataBeforeAddTheUser = value;
return;
}else{
print("继续发送数据了继续发送数据了继续发送数据了");
_sendNormalData(value);
}
} }
void _sendNormalData(List<int> data) async { void _sendNormalData(List<int> data) async {
@ -102,4 +129,7 @@ class CommandSenderManager {
// bufferList = []; // bufferList = [];
// } // }
dispose() {
_passCurrentLockInformationEvent?.cancel();
}
} }

View File

@ -57,9 +57,9 @@ class LockDetailLogic extends BaseGetXController {
} }
// //
if ((reply is AddUserReply) && (state.ifCurrentScreen.value == true)) { // if ((reply is AddUserReply) && (state.ifCurrentScreen.value == true)) {
_replyAddUserKey(reply); // _replyAddUserKey(reply);
} // }
}); });
} }
@ -297,126 +297,126 @@ class LockDetailLogic extends BaseGetXController {
} }
} }
// // //
Future<void> _replyAddUserKey(Reply reply) async { // Future<void> _replyAddUserKey(Reply reply) async {
var lockId = reply.data.sublist(2, 42); // var lockId = reply.data.sublist(2, 42);
// print("lockId:$lockId"); // // print("lockId:$lockId");
//
var token = reply.data.sublist(42, 46); // var token = reply.data.sublist(42, 46);
List<String> strTokenList = changeIntListToStringList(token); // List<String> strTokenList = changeIntListToStringList(token);
Storage.setStringList(saveBlueToken, strTokenList); // Storage.setStringList(saveBlueToken, strTokenList);
// print("token:$token"); // // print("token:$token");
//
int status = reply.data[46]; // int status = reply.data[46];
// print("status:$status reply.data:${reply.data}"); // // print("status:$status reply.data:${reply.data}");
//
print("status:$status"); // print("status:$status");
switch (status) { // switch (status) {
case 0x00: // case 0x00:
// // //
Get.log("添加用户数据解析成功"); // Get.log("添加用户数据解析成功");
cancelBlueConnetctToastTimer(); // cancelBlueConnetctToastTimer();
state.lockUserNo = reply.data[47]; // state.lockUserNo = reply.data[47];
_updateLockUserNo(); // _updateLockUserNo();
//
break; // break;
case 0x06: // case 0x06:
// // //
Get.log("需要鉴权"); // Get.log("需要鉴权");
var privateKey = await Storage.getStringList(saveBluePrivateKey); // var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); // List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
//
var publicKey = await Storage.getStringList(saveBluePublicKey); // var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> publicKeyDataList = changeStringListToIntList(publicKey!); // List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
//
IoSenderManage.senderAddUser( // IoSenderManage.senderAddUser(
lockID: BlueManage().connectDeviceName, // lockID: BlueManage().connectDeviceName,
authUserID: state.senderUserId.toString(), // authUserID: state.senderUserId.toString(),
keyID: state.keyInfos.value.keyId.toString(), // keyID: state.keyInfos.value.keyId.toString(),
userID: await Storage.getUid(), // userID: await Storage.getUid(),
openMode: 1, // openMode: 1,
keyType: 0, // keyType: 0,
startDate: state.keyInfos.value.startDate!~/10000, // startDate: state.keyInfos.value.startDate!~/10000,
expireDate: state.keyInfos.value.endDate!~/10000, // expireDate: state.keyInfos.value.endDate!~/10000,
role: state.keyInfos.value.keyRight == 1 ? 1 : 0, // role: state.keyInfos.value.keyRight == 1 ? 1 : 0,
password: "123456", // password: "123456",
needAuthor: 1, // needAuthor: 1,
publicKey: publicKeyDataList, // publicKey: publicKeyDataList,
privateKey: getPrivateKeyList, // privateKey: getPrivateKeyList,
token: token); // token: token);
break; // break;
default: // default:
// // //
Get.log("领锁失败"); // Get.log("领锁失败");
//
break; // break;
} // }
} // }
// () // ()
Future<void> addUserConnectBlue() async { // Future<void> addUserConnectBlue() async {
showBlueConnetctToastTimer(action: () { // showBlueConnetctToastTimer(action: () {
state.openLockBtnState.value = 0; // state.openLockBtnState.value = 0;
eventBus.fire(RefreshLockDetailInfoDataEvent()); // eventBus.fire(RefreshLockDetailInfoDataEvent());
}); // });
//
// var listData = AddUserCommand( // // var listData = AddUserCommand(
// lockID: BlueManage().connectDeviceName, // // lockID: BlueManage().connectDeviceName,
// authUserID: state.senderUserId.toString(), // // authUserID: state.senderUserId.toString(),
// keyID: state.keyInfos.value.keyId.toString(), // // keyID: state.keyInfos.value.keyId.toString(),
// userID: await Storage.getUid(), // // userID: await Storage.getUid(),
// openMode: 1, // // openMode: 1,
// keyType: 0, // // keyType: 0,
// startDate: state.keyInfos.value.startDate!~/10000, // // startDate: state.keyInfos.value.startDate!~/10000,
// expireDate: state.keyInfos.value.endDate!~/10000, // // expireDate: state.keyInfos.value.endDate!~/10000,
// role: state.keyInfos.value.keyRight == 1 ? 1 : 0, // // role: state.keyInfos.value.keyRight == 1 ? 1 : 0,
// password: "123456", // // password: "123456",
// needAuthor: 1, // // needAuthor: 1,
// publicKey: publicKeyDataList, // // publicKey: publicKeyDataList,
// privateKey: getPrivateKeyList, // // privateKey: getPrivateKeyList,
// token: getTokenList).packageData(); // // token: getTokenList).packageData();
BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (BluetoothConnectionState deviceConnectionState) async { // BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (BluetoothConnectionState deviceConnectionState) async {
if (deviceConnectionState == BluetoothConnectionState.connected) { // if (deviceConnectionState == BluetoothConnectionState.connected) {
// // //
var privateKey = await Storage.getStringList(saveBluePrivateKey); // var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); // List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
//
var publicKey = await Storage.getStringList(saveBluePublicKey); // var publicKey = await Storage.getStringList(saveBluePublicKey);
List<int> publicKeyDataList = changeStringListToIntList(publicKey!); // List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
//
var token = await Storage.getStringList(saveBlueToken); // var token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = [0, 0, 0, 0]; // List<int> getTokenList = [0, 0, 0, 0];
if (token != null) { // if (token != null) {
getTokenList = changeStringListToIntList(token); // getTokenList = changeStringListToIntList(token);
} // }
//
Get.log("BlueManage().connectDeviceName:${BlueManage().connectDeviceName} authUserID:${state.senderUserId.toString()} keyID:${state.keyInfos.value.keyId.toString()} userID:${await Storage.getUid()}"); // Get.log("BlueManage().connectDeviceName:${BlueManage().connectDeviceName} authUserID:${state.senderUserId.toString()} keyID:${state.keyInfos.value.keyId.toString()} userID:${await Storage.getUid()}");
IoSenderManage.senderAddUser( // IoSenderManage.senderAddUser(
lockID: BlueManage().connectDeviceName, // lockID: BlueManage().connectDeviceName,
authUserID: state.senderUserId.toString(), // authUserID: state.senderUserId.toString(),
keyID: state.keyInfos.value.keyId.toString(), // keyID: state.keyInfos.value.keyId.toString(),
userID: await Storage.getUid(), // userID: await Storage.getUid(),
openMode: 1, // openMode: 1,
keyType: 0, // keyType: 0,
startDate: state.keyInfos.value.startDate!~/10000, // startDate: state.keyInfos.value.startDate!~/10000,
expireDate: state.keyInfos.value.endDate!~/10000, // expireDate: state.keyInfos.value.endDate!~/10000,
role: state.keyInfos.value.keyRight == 1 ? 1 : 0, // role: state.keyInfos.value.keyRight == 1 ? 1 : 0,
password: "123456", // password: "123456",
needAuthor: 1, // needAuthor: 1,
publicKey: publicKeyDataList, // publicKey: publicKeyDataList,
privateKey: getPrivateKeyList, // privateKey: getPrivateKeyList,
token: getTokenList); // token: getTokenList);
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) { // } else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
cancelBlueConnetctToastTimer(); // cancelBlueConnetctToastTimer();
if (state.ifCurrentScreen.value == true) { // if (state.ifCurrentScreen.value == true) {
showBlueConnetctToast(); // showBlueConnetctToast();
} // }
//
state.openLockBtnState.value = 0; // state.openLockBtnState.value = 0;
eventBus.fire(RefreshLockDetailInfoDataEvent()); // eventBus.fire(RefreshLockDetailInfoDataEvent());
} // }
}); // });
} // }
// //
Future<void> openDoorAction() async { Future<void> openDoorAction() async {
@ -508,23 +508,23 @@ class LockDetailLogic extends BaseGetXController {
} }
// NO // NO
void _updateLockUserNo() async { // void _updateLockUserNo() async {
LockNetTokenEntity entity = await ApiRepository.to.updateLockUserNo( // LockNetTokenEntity entity = await ApiRepository.to.updateLockUserNo(
keyId: state.keyInfos.value.keyId.toString(), // keyId: state.keyInfos.value.keyId.toString(),
lockUserNo: state.lockUserNo.toString() // lockUserNo: state.lockUserNo.toString()
); // );
if (entity.errorCode!.codeIsSuccessful) { // if (entity.errorCode!.codeIsSuccessful) {
eventBus.fire(RefreshLockDetailInfoDataEvent()); // eventBus.fire(RefreshLockDetailInfoDataEvent());
SchedulerBinding.instance.addPostFrameCallback((_) { // SchedulerBinding.instance.addPostFrameCallback((_) {
eventBus.fire(RefreshLockListInfoDataEvent()); // eventBus.fire(RefreshLockListInfoDataEvent());
}); // });
if (state.isOpenLockNeedOnline.value == 0) { // if (state.isOpenLockNeedOnline.value == 0) {
openDoorAction(); // openDoorAction();
} else { // } else {
getLockNetToken(); // getLockNetToken();
} // }
} // }
} // }
// //
void getLockRecordLastUploadDataTime() async { void getLockRecordLastUploadDataTime() async {

View File

@ -17,6 +17,7 @@ import '../../../blue/blue_manage.dart';
import '../../../blue/io_tool/io_tool.dart'; import '../../../blue/io_tool/io_tool.dart';
import '../../../common/XSConstantMacro/XSConstantMacro.dart'; import '../../../common/XSConstantMacro/XSConstantMacro.dart';
import '../../../tools/appRouteObserver.dart'; import '../../../tools/appRouteObserver.dart';
import '../../../tools/commonDataManage.dart';
import '../../../tools/dateTool.dart'; import '../../../tools/dateTool.dart';
import '../../../tools/eventBusEventManage.dart'; import '../../../tools/eventBusEventManage.dart';
import '../../../tools/storage.dart'; import '../../../tools/storage.dart';
@ -48,7 +49,6 @@ class _LockDetailPageState extends State<LockDetailPage>
void initState() { void initState() {
// TODO: implement initState // TODO: implement initState
super.initState(); super.initState();
Get.log("LockDetailPage initState1111");
// logic.startScanAction(); // logic.startScanAction();
@ -66,7 +66,6 @@ class _LockDetailPageState extends State<LockDetailPage>
@override @override
void didChangeDependencies() { void didChangeDependencies() {
super.didChangeDependencies(); super.didChangeDependencies();
Get.log("LockDetailPage didChangeDependencies2222");
/// ///
AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!); AppRouteObserver().routeObserver.subscribe(this, ModalRoute.of(context)!);
@ -84,12 +83,15 @@ class _LockDetailPageState extends State<LockDetailPage>
void loadData() { void loadData() {
state.keyInfos.value = widget.lockListInfoItemEntity; state.keyInfos.value = widget.lockListInfoItemEntity;
CommonDataManage().currentLockUserNo = state.keyInfos.value.lockUserNo!;
CommonDataManage().currentKeyInfo = state.keyInfos.value;
state.lockUserNo = state.keyInfos.value.lockUserNo!; state.lockUserNo = state.keyInfos.value.lockUserNo!;
if (state.lockUserNo == 0) { // if (state.lockUserNo == 0) {
state.bottomBtnisEable.value = false; // state.bottomBtnisEable.value = false;
} else { // } else {
state.bottomBtnisEable.value = true; // state.bottomBtnisEable.value = true;
} // }
// print("state.keyInfos.value.keyStatus:${state.keyInfos.value.keyStatus}"); // print("state.keyInfos.value.keyStatus:${state.keyInfos.value.keyStatus}");
if (state.keyInfos.value.keyStatus == if (state.keyInfos.value.keyStatus ==
XSConstantMacro.keyStatusWaitIneffective || XSConstantMacro.keyStatusWaitIneffective ||
@ -989,10 +991,10 @@ class _LockDetailPageState extends State<LockDetailPage>
state.openLockBtnState.value = 1; state.openLockBtnState.value = 1;
// state.animationController!.forward(); // state.animationController!.forward();
if (state.lockUserNo == 0) { // if (state.lockUserNo == 0) {
// lockUserNo为0 // // lockUserNo为0
logic.addUserConnectBlue(); // logic.addUserConnectBlue();
} else { // } else {
// print("state.isOpenLockNeedOnline.value:${state.isOpenLockNeedOnline.value}"); // print("state.isOpenLockNeedOnline.value:${state.isOpenLockNeedOnline.value}");
if (state.isOpenLockNeedOnline.value == 0) { if (state.isOpenLockNeedOnline.value == 0) {
// //
@ -1002,7 +1004,7 @@ class _LockDetailPageState extends State<LockDetailPage>
// //
logic.getLockNetToken(); logic.getLockNetToken();
} }
} // }
// }); // });
} }
@ -1015,13 +1017,13 @@ class _LockDetailPageState extends State<LockDetailPage>
state.openLockBtnState.value = 1; state.openLockBtnState.value = 1;
state.animationController!.forward(); state.animationController!.forward();
if (state.lockUserNo == 0) { // if (state.lockUserNo == 0) {
// lockUserNo为0 // // lockUserNo为0
logic.addUserConnectBlue(); // logic.addUserConnectBlue();
} else { // } else {
state.openDoorModel = 32; state.openDoorModel = 32;
logic.openDoorAction(); logic.openDoorAction();
} // }
} }
@override @override
@ -1029,7 +1031,6 @@ class _LockDetailPageState extends State<LockDetailPage>
// TODO: implement dispose // TODO: implement dispose
/// ///
Get.log("LockDetailPage===dispose");
AppRouteObserver().routeObserver.unsubscribe(this); AppRouteObserver().routeObserver.unsubscribe(this);
state.closedUnlockSuccessfulTimer?.cancel(); state.closedUnlockSuccessfulTimer?.cancel();
_lockRefreshLockDetailInfoDataEvent?.cancel(); _lockRefreshLockDetailInfoDataEvent?.cancel();
@ -1048,7 +1049,6 @@ class _LockDetailPageState extends State<LockDetailPage>
@override @override
void didPush() { void didPush() {
super.didPush(); super.didPush();
Get.log("LockDetailPage===didPush");
state.ifCurrentScreen.value = true; state.ifCurrentScreen.value = true;
} }
@ -1056,7 +1056,6 @@ class _LockDetailPageState extends State<LockDetailPage>
@override @override
void didPop() { void didPop() {
super.didPop(); super.didPop();
Get.log("LockDetailPage===didPop");
state.ifCurrentScreen.value = false; state.ifCurrentScreen.value = false;
logic.cancelBlueConnetctToastTimer(); logic.cancelBlueConnetctToastTimer();
BlueManage().stopScan(); BlueManage().stopScan();
@ -1069,14 +1068,12 @@ class _LockDetailPageState extends State<LockDetailPage>
void didPopNext() { void didPopNext() {
super.didPopNext(); super.didPopNext();
state.ifCurrentScreen.value = true; state.ifCurrentScreen.value = true;
Get.log("LockDetailPage===didPopNext");
} }
/// ///
@override @override
void didPushNext() { void didPushNext() {
super.didPushNext(); super.didPushNext();
Get.log("LockDetailPage===didPushNext");
state.ifCurrentScreen.value = false; state.ifCurrentScreen.value = false;
logic.cancelBlueConnetctToastTimer(); logic.cancelBlueConnetctToastTimer();
BlueManage().stopScan(); BlueManage().stopScan();

View File

@ -16,6 +16,7 @@ import '../../../../blue/io_tool/manager_event_bus.dart';
import '../../../../blue/sender_manage.dart'; import '../../../../blue/sender_manage.dart';
import '../../../../network/api_repository.dart'; import '../../../../network/api_repository.dart';
import '../../../../tools/baseGetXController.dart'; import '../../../../tools/baseGetXController.dart';
import '../../../../tools/commonDataManage.dart';
import '../../../../tools/eventBusEventManage.dart'; import '../../../../tools/eventBusEventManage.dart';
import '../../../../tools/storage.dart'; import '../../../../tools/storage.dart';
import 'checkingInInfoData_entity.dart'; import 'checkingInInfoData_entity.dart';
@ -406,6 +407,8 @@ class LockSetLogic extends BaseGetXController {
); );
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.lockSetInfoData.value = entity.data!; state.lockSetInfoData.value = entity.data!;
CommonDataManage().currentLockSetInfoData = entity.data!;
state.lockSettingInfo.value = state.lockSetInfoData.value.lockSettingInfo!; state.lockSettingInfo.value = state.lockSetInfoData.value.lockSettingInfo!;
state.lockFeature.value = state.lockSetInfoData.value.lockFeature!; state.lockFeature.value = state.lockSetInfoData.value.lockFeature!;
state.lockStatus.value = state.lockSetInfoData.value.lockStatus!; state.lockStatus.value = state.lockSetInfoData.value.lockStatus!;

View File

@ -1,15 +1,10 @@
import 'dart:convert';
import 'dart:typed_data';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_blue_plus/flutter_blue_plus.dart'; import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart';
// import 'package:flutter_reactive_ble/flutter_reactive_ble.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import '../../../appRouters.dart';
import '../../../app_settings/app_colors.dart'; import '../../../app_settings/app_colors.dart';
import '../../../blue/blue_manage.dart'; import '../../../blue/blue_manage.dart';
import '../../../tools/appRouteObserver.dart'; import '../../../tools/appRouteObserver.dart';

View File

@ -30,7 +30,7 @@ class SaveLockLogic extends BaseGetXController {
late StreamSubscription<Reply> _replySubscription; late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() { void _initReplySubscription() {
_replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) { _replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) {
if (reply is AddUserReply) { if (reply is AddUserReply && state.ifCurrentScreen.value == true) {
_replyAddUserKey(reply); _replyAddUserKey(reply);
} }

View File

@ -2,6 +2,9 @@
// CommonDataManage的单例使 // CommonDataManage的单例使
import 'package:get/get.dart'; import 'package:get/get.dart';
import '../main/lockDetail/lockSet/lockSet/lockSetInfo_entity.dart';
import '../main/lockMian/entity/lockListInfo_entity.dart';
class CommonDataManage { class CommonDataManage {
static CommonDataManage? _manager; static CommonDataManage? _manager;
CommonDataManage._init(); CommonDataManage._init();
@ -20,12 +23,15 @@ class CommonDataManage {
set setMainLockCount(int v) => _mainLockCount.value = v; set setMainLockCount(int v) => _mainLockCount.value = v;
get getMainLockCount => _mainLockCount; get getMainLockCount => _mainLockCount;
//
LockListInfoItemEntity currentKeyInfo = LockListInfoItemEntity();
// //
int currentLockUserNo = 0; int currentLockUserNo = 0;
// set setCurrentLockUserNo(int v) => _currentLockUserNo = v; // set setCurrentLockUserNo(int v) => _currentLockUserNo = v;
// get getCurrentLockUserNo => _currentLockUserNo; // get getCurrentLockUserNo => _currentLockUserNo;
LockSetInfoData currentLockSetInfoData = LockSetInfoData();
} }

View File

@ -10,6 +10,13 @@ class RefreshLockListInfoDataEvent {
RefreshLockListInfoDataEvent(); RefreshLockListInfoDataEvent();
} }
///
class LockAddUserSucceedEvent {
int type; // 0 1token失效
List<int> dataList;
LockAddUserSucceedEvent(this.dataList, this.type);
}
/// ///
class RefreshLockDetailInfoDataEvent { class RefreshLockDetailInfoDataEvent {
RefreshLockDetailInfoDataEvent(); RefreshLockDetailInfoDataEvent();

View File

@ -207,7 +207,7 @@ class Storage {
if (data != null && data.isNotEmpty) { if (data != null && data.isNotEmpty) {
lockListInfoGroupEntity = LockListInfoGroupEntity.fromJson(jsonDecode(data)); lockListInfoGroupEntity = LockListInfoGroupEntity.fromJson(jsonDecode(data));
} }
print("lockListInfoEntity:$lockListInfoGroupEntity");
return lockListInfoGroupEntity; return lockListInfoGroupEntity;
} }
} }