fix:修复xhj删除锁的时候, 无法跳转页面

This commit is contained in:
anfe 2024-05-28 18:23:20 +08:00
parent 24b1b0c3e5
commit ca9011a598

View File

@ -4,6 +4,8 @@ import 'package:flutter/scheduler.dart';
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
import 'package:get/get.dart';
import 'package:star_lock/blue/io_type.dart';
import 'package:star_lock/login/login/entity/LoginEntity.dart';
import 'package:star_lock/main/lockMian/entity/lockListInfo_entity.dart';
import 'package:star_lock/tools/showTipView.dart';
import '../../../../blue/blue_manage.dart';
@ -13,6 +15,7 @@ import '../../../../blue/io_reply.dart';
import '../../../../blue/io_tool/io_tool.dart';
import '../../../../blue/io_tool/manager_event_bus.dart';
import '../../../../blue/sender_manage.dart';
import '../../../../flavors.dart';
import '../../../../network/api_repository.dart';
import '../../../../tools/baseGetXController.dart';
import '../../../../tools/commonDataManage.dart';
@ -31,9 +34,10 @@ class LockSetLogic extends BaseGetXController {
//
late StreamSubscription<Reply> _replySubscription;
void _initReplySubscription() {
_replySubscription =
EventBusManager().eventBus!.on<Reply>().listen((reply) async {
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
//
// if (reply is DeletUserReply) {
// _replyDeletUserKey(reply);
@ -100,8 +104,8 @@ class LockSetLogic extends BaseGetXController {
//
Future<void> _replyFactoryDataResetKey(Reply reply) async {
var token = reply.data.sublist(2, 6);
var saveStrList = changeIntListToStringList(token);
List<int> token = reply.data.sublist(2, 6);
List<String> saveStrList = changeIntListToStringList(token);
Storage.setStringList(saveBlueToken, saveStrList);
int status = reply.data[6];
@ -114,13 +118,15 @@ class LockSetLogic extends BaseGetXController {
break;
case 0x06:
//
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<String>? privateKey =
await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<String>? publicKey =
await Storage.getStringList(saveBluePublicKey);
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
var token = await Storage.getStringList(saveBlueToken);
List<String>? token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!);
IoSenderManage.senderFactoryDataReset(
@ -252,13 +258,15 @@ class LockSetLogic extends BaseGetXController {
BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<String>? privateKey =
await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<String>? publicKey =
await Storage.getStringList(saveBluePublicKey);
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
var token = await Storage.getStringList(saveBlueToken);
List<String>? token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!);
IoSenderManage.senderFactoryDataReset(
@ -314,18 +322,20 @@ class LockSetLogic extends BaseGetXController {
BlueManage().blueSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<String>? privateKey =
await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
var token = await Storage.getStringList(saveBlueToken);
List<String>? token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!);
var publicKey = await Storage.getStringList(saveBluePublicKey);
List<String>? publicKey =
await Storage.getStringList(saveBluePublicKey);
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
state.settingUpSupportFeatures = type;
var featureEnable = 0;
int featureEnable = 0;
if (type == 55) {
// APP开锁时是否需联网
featureEnable = state.isOpenLockNeedOnline.value == 1 ? 0 : 1;
@ -386,9 +396,9 @@ class LockSetLogic extends BaseGetXController {
}
//
void openCheckingInData(
Future<void> openCheckingInData(
BlockSetCheckInCallback blockSetCheckInCallback) async {
var entity = await ApiRepository.to.openCheckingInData(
CheckingInInfoDataEntity entity = await ApiRepository.to.openCheckingInData(
lockId: state.lockSetInfoData.value.lockId.toString(),
);
if (entity.errorCode!.codeIsSuccessful) {
@ -397,8 +407,8 @@ class LockSetLogic extends BaseGetXController {
}
//
void setLockSetGeneralSetting() async {
var entity = await ApiRepository.to.setCheckInData(
Future<void> setLockSetGeneralSetting() async {
LoginEntity entity = await ApiRepository.to.setCheckInData(
lockId: state.lockSetInfoData.value.lockId!,
attendance: state.isAttendance.value == 1 ? 0 : 1,
);
@ -415,7 +425,7 @@ class LockSetLogic extends BaseGetXController {
//
Future<void> setLockPickingReminder() async {
var entity = await ApiRepository.to.setLockPickingReminderData(
LoginEntity entity = await ApiRepository.to.setLockPickingReminderData(
lockId: state.lockSetInfoData.value.lockId!,
unlockReminder: state.isLockPickingReminder.value == 1 ? 0 : 1,
);
@ -431,8 +441,8 @@ class LockSetLogic extends BaseGetXController {
}
//
void setLockSetOpenLockNeedOnline() async {
var entity = await ApiRepository.to.setOpenLockNeedOnlineData(
Future<void> setLockSetOpenLockNeedOnline() async {
LoginEntity entity = await ApiRepository.to.setOpenLockNeedOnlineData(
lockId: state.lockSetInfoData.value.lockId!,
appUnlockOnline: state.isOpenLockNeedOnline.value == 1 ? 0 : 1,
);
@ -452,16 +462,18 @@ class LockSetLogic extends BaseGetXController {
//
StreamSubscription? _passCurrentLockInformationEvent;
void initLoadDataAction(BlockSetStateCallback blockSetStateCallback) {
// eventBus
_passCurrentLockInformationEvent =
eventBus.on<PassCurrentLockInformationEvent>().listen((event) {
_passCurrentLockInformationEvent = eventBus
.on<PassCurrentLockInformationEvent>()
.listen((PassCurrentLockInformationEvent event) {
getLockSettingInfoData();
});
}
void showDeletAlertTipDialog({String? showContent = ''}) {
var content = showContent!.isEmpty
String content = showContent!.isEmpty
? "${"删除设备失败,请确保在设备附近,设备未被连接,设备已打开".tr}${BlueManage().connectDeviceName!.contains("T9A") == true ? "。如果是全自动锁,请使屏幕变亮".tr : ""}"
: showContent;
ShowTipView().showSureAlertDialog(content);
@ -482,7 +494,7 @@ class LockSetLogic extends BaseGetXController {
} else if (state.lockBasicInfo.value.keyRight == 1) {
//
ShowTipView().showDeleteAdministratorIsHaveAllDataDialog(
'同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (a) {
'同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (bool a) {
//
state.deleteAdministratorIsHaveAllData.value = a;
deletKeyData();
@ -496,8 +508,8 @@ class LockSetLogic extends BaseGetXController {
}
//
void checkLoginPassword() async {
var entity = await ApiRepository.to.checkLoginPassword(
Future<void> checkLoginPassword() async {
LockListInfoEntity entity = await ApiRepository.to.checkLoginPassword(
password: state.passwordTF.text,
);
if (entity.errorCode!.codeIsSuccessful) {
@ -507,21 +519,21 @@ class LockSetLogic extends BaseGetXController {
}
//
void deletLockInfoData() async {
var entity = await ApiRepository.to.deletOwnerLockData(
Future<void> deletLockInfoData() async {
LockListInfoEntity entity = await ApiRepository.to.deletOwnerLockData(
lockId: state.lockSetInfoData.value.lockId!,
);
if (entity.errorCode!.codeIsSuccessful) {
BlueManage().connectDeviceMacAddress = "";
BlueManage().connectDeviceMacAddress = '';
SchedulerBinding.instance.addPostFrameCallback((_) {
eventBus.fire(RefreshLockListInfoDataEvent());
});
if(state.isOnlyOneData.value == true){
Future.delayed(const Duration(milliseconds: 200)).then((e) {
if (state.isOnlyOneData.value == true) {
Future<dynamic>.delayed(const Duration(milliseconds: 200)).then((e) {
Get.close(1);
});
}else{
Future.delayed(const Duration(milliseconds: 200)).then((e) {
} else {
Future<dynamic>.delayed(const Duration(milliseconds: 200)).then((e) {
Get.close(2);
});
}
@ -529,27 +541,27 @@ class LockSetLogic extends BaseGetXController {
}
//
void deletKeyData() async {
var entity = await ApiRepository.to.deletOwnerKeyData(
Future<void> deletKeyData() async {
final LockListInfoEntity entity = await ApiRepository.to.deletOwnerKeyData(
lockId: state.lockSetInfoData.value.lockId.toString(),
keyId: state.lockSetInfoData.value.lockBasicInfo!.keyId.toString(),
includeUnderlings: state.deleteAdministratorIsHaveAllData.value == true ? 1 : 0
);
includeUnderlings:
state.deleteAdministratorIsHaveAllData.value == true ? 1 : 0);
if (entity.errorCode!.codeIsSuccessful) {
BlueManage().connectDeviceMacAddress = "";
BlueManage().connectDeviceMacAddress = '';
SchedulerBinding.instance.addPostFrameCallback((_) {
eventBus.fire(RefreshLockListInfoDataEvent());
});
if(state.isOnlyOneData.value == true){
Future.delayed(const Duration(milliseconds: 200)).then((e) {
Get.close(1);
});
}else{
Future.delayed(const Duration(milliseconds: 200)).then((e) {
Get.close(2);
});
}
// Get.offAllNamed(Routers.starLockMain);
final bool isXHJ = F.isXHJ;
final bool isOnlyOneData = state.isOnlyOneData.value == true;
Future<dynamic>.delayed(const Duration(milliseconds: 200)).then((e) {
if (isXHJ) {
Get.close(3);
} else {
final int onlyOneDataInt = isOnlyOneData ? 1 : 2;
Get.close(onlyOneDataInt);
}
});
}
}