Merge branch 'starLock_wsy'
# Conflicts: # star_lock/lib/main/lockDetail/lockDetail/lockDetail_logic.dart # star_lock/lib/main/lockDetail/lockDetail/lockDetail_page.dart
This commit is contained in:
commit
0245540779
@ -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:
|
||||||
// 无权限
|
// 无权限
|
||||||
|
|||||||
158
star_lock/lib/blue/sender_beforeDataManage.dart
Normal file
158
star_lock/lib/blue/sender_beforeDataManage.dart
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -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,111 +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());
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (BluetoothConnectionState deviceConnectionState) async {
|
// // var listData = AddUserCommand(
|
||||||
if (deviceConnectionState == BluetoothConnectionState.connected) {
|
// // lockID: BlueManage().connectDeviceName,
|
||||||
// 私钥
|
// // authUserID: state.senderUserId.toString(),
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
// // keyID: state.keyInfos.value.keyId.toString(),
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
// // userID: await Storage.getUid(),
|
||||||
|
// // openMode: 1,
|
||||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
// // keyType: 0,
|
||||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
// // startDate: state.keyInfos.value.startDate!~/10000,
|
||||||
|
// // expireDate: state.keyInfos.value.endDate!~/10000,
|
||||||
var token = await Storage.getStringList(saveBlueToken);
|
// // role: state.keyInfos.value.keyRight == 1 ? 1 : 0,
|
||||||
List<int> getTokenList = [0, 0, 0, 0];
|
// // password: "123456",
|
||||||
if (token != null) {
|
// // needAuthor: 1,
|
||||||
getTokenList = changeStringListToIntList(token);
|
// // publicKey: publicKeyDataList,
|
||||||
}
|
// // privateKey: getPrivateKeyList,
|
||||||
|
// // token: getTokenList).packageData();
|
||||||
Get.log("BlueManage().connectDeviceName:${BlueManage().connectDeviceName} authUserID:${state.senderUserId.toString()} keyID:${state.keyInfos.value.keyId.toString()} userID:${await Storage.getUid()}");
|
// BlueManage().bludSendData(state.keyInfos.value.bluetooth!.bluetoothDeviceName!, (BluetoothConnectionState deviceConnectionState) async {
|
||||||
IoSenderManage.senderAddUser(
|
// if (deviceConnectionState == BluetoothConnectionState.connected) {
|
||||||
lockID: BlueManage().connectDeviceName,
|
// // 私钥
|
||||||
authUserID: state.senderUserId.toString(),
|
// var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
||||||
keyID: state.keyInfos.value.keyId.toString(),
|
// List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
userID: await Storage.getUid(),
|
//
|
||||||
openMode: 1,
|
// var publicKey = await Storage.getStringList(saveBluePublicKey);
|
||||||
keyType: 0,
|
// List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||||
startDate: state.keyInfos.value.startDate!~/10000,
|
//
|
||||||
expireDate: state.keyInfos.value.endDate!~/10000,
|
// var token = await Storage.getStringList(saveBlueToken);
|
||||||
role: state.keyInfos.value.keyRight == 1 ? 1 : 0,
|
// List<int> getTokenList = [0, 0, 0, 0];
|
||||||
password: "123456",
|
// if (token != null) {
|
||||||
needAuthor: 1,
|
// getTokenList = changeStringListToIntList(token);
|
||||||
publicKey: publicKeyDataList,
|
// }
|
||||||
privateKey: getPrivateKeyList,
|
//
|
||||||
token: getTokenList);
|
// Get.log("BlueManage().connectDeviceName:${BlueManage().connectDeviceName} authUserID:${state.senderUserId.toString()} keyID:${state.keyInfos.value.keyId.toString()} userID:${await Storage.getUid()}");
|
||||||
} else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
// IoSenderManage.senderAddUser(
|
||||||
cancelBlueConnetctToastTimer();
|
// lockID: BlueManage().connectDeviceName,
|
||||||
if (state.ifCurrentScreen.value == true) {
|
// authUserID: state.senderUserId.toString(),
|
||||||
showBlueConnetctToast();
|
// keyID: state.keyInfos.value.keyId.toString(),
|
||||||
}
|
// userID: await Storage.getUid(),
|
||||||
|
// openMode: 1,
|
||||||
state.openLockBtnState.value = 0;
|
// keyType: 0,
|
||||||
eventBus.fire(RefreshLockDetailInfoDataEvent());
|
// startDate: state.keyInfos.value.startDate!~/10000,
|
||||||
}
|
// expireDate: state.keyInfos.value.endDate!~/10000,
|
||||||
});
|
// role: state.keyInfos.value.keyRight == 1 ? 1 : 0,
|
||||||
}
|
// password: "123456",
|
||||||
|
// needAuthor: 1,
|
||||||
|
// publicKey: publicKeyDataList,
|
||||||
|
// privateKey: getPrivateKeyList,
|
||||||
|
// token: getTokenList);
|
||||||
|
// } else if (deviceConnectionState == BluetoothConnectionState.disconnected) {
|
||||||
|
// cancelBlueConnetctToastTimer();
|
||||||
|
// if (state.ifCurrentScreen.value == true) {
|
||||||
|
// showBlueConnetctToast();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// state.openLockBtnState.value = 0;
|
||||||
|
// eventBus.fire(RefreshLockDetailInfoDataEvent());
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
// 点击开门事件
|
// 点击开门事件
|
||||||
Future<void> openDoorAction() async {
|
Future<void> openDoorAction() async {
|
||||||
@ -493,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 {
|
||||||
|
|||||||
@ -49,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();
|
||||||
|
|
||||||
@ -67,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)!);
|
||||||
@ -85,14 +83,17 @@ class _LockDetailPageState extends State<LockDetailPage>
|
|||||||
|
|
||||||
void loadData() {
|
void loadData() {
|
||||||
state.keyInfos.value = widget.lockListInfoItemEntity;
|
state.keyInfos.value = widget.lockListInfoItemEntity;
|
||||||
state.lockUserNo = state.keyInfos.value.lockUserNo!;
|
CommonDataManage().currentLockUserNo = state.keyInfos.value.lockUserNo!;
|
||||||
CommonDataManage().currentLockUserNo = state.keyInfos.value.lockUserNo!;;
|
CommonDataManage().currentKeyInfo = state.keyInfos.value;
|
||||||
|
|
||||||
|
state.lockUserNo = state.keyInfos.value.lockUserNo!;
|
||||||
|
|
||||||
|
// if (state.lockUserNo == 0) {
|
||||||
|
// state.bottomBtnisEable.value = false;
|
||||||
|
// } else {
|
||||||
|
// state.bottomBtnisEable.value = true;
|
||||||
|
// }
|
||||||
|
|
||||||
if (state.lockUserNo == 0) {
|
|
||||||
state.bottomBtnisEable.value = false;
|
|
||||||
} else {
|
|
||||||
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 ||
|
||||||
@ -1222,11 +1223,10 @@ class _LockDetailPageState extends State<LockDetailPage>
|
|||||||
state.openLockBtnState.value = 1;
|
state.openLockBtnState.value = 1;
|
||||||
// state.animationController!.forward();
|
// state.animationController!.forward();
|
||||||
|
|
||||||
state.openDoorModel = 1;
|
// 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) {
|
||||||
// 不需要联网
|
// 不需要联网
|
||||||
@ -1235,7 +1235,7 @@ class _LockDetailPageState extends State<LockDetailPage>
|
|||||||
// 需要联网
|
// 需要联网
|
||||||
logic.getLockNetToken();
|
logic.getLockNetToken();
|
||||||
}
|
}
|
||||||
}
|
// }
|
||||||
// });
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1249,18 +1249,18 @@ class _LockDetailPageState extends State<LockDetailPage>
|
|||||||
state.animationController!.forward();
|
state.animationController!.forward();
|
||||||
state.openDoorModel = 32;
|
state.openDoorModel = 32;
|
||||||
|
|
||||||
if (state.lockUserNo == 0) {
|
// if (state.lockUserNo == 0) {
|
||||||
// 电子钥匙lockUserNo为0 要先添加用户
|
// // 电子钥匙lockUserNo为0 要先添加用户
|
||||||
logic.addUserConnectBlue();
|
// logic.addUserConnectBlue();
|
||||||
} else {
|
// } else {
|
||||||
|
state.openDoorModel = 32;
|
||||||
logic.openDoorAction();
|
logic.openDoorAction();
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
/// 取消路由订阅
|
/// 取消路由订阅
|
||||||
Get.log("LockDetailPage===dispose");
|
|
||||||
AppRouteObserver().routeObserver.unsubscribe(this);
|
AppRouteObserver().routeObserver.unsubscribe(this);
|
||||||
state.closedUnlockSuccessfulTimer?.cancel();
|
state.closedUnlockSuccessfulTimer?.cancel();
|
||||||
_lockRefreshLockDetailInfoDataEvent?.cancel();
|
_lockRefreshLockDetailInfoDataEvent?.cancel();
|
||||||
@ -1278,7 +1278,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1286,7 +1285,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().disconnect();
|
BlueManage().disconnect();
|
||||||
@ -1298,14 +1296,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();
|
||||||
state.openLockBtnState.value = 0;
|
state.openLockBtnState.value = 0;
|
||||||
|
|||||||
@ -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!;
|
||||||
|
|||||||
@ -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';
|
||||||
|
|||||||
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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();
|
||||||
|
|||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user