fix:修复xhj删除锁的时候, 无法跳转页面
This commit is contained in:
parent
24b1b0c3e5
commit
ca9011a598
@ -4,6 +4,8 @@ import 'package:flutter/scheduler.dart';
|
|||||||
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
import 'package:flutter_blue_plus/flutter_blue_plus.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:star_lock/blue/io_type.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 'package:star_lock/tools/showTipView.dart';
|
||||||
|
|
||||||
import '../../../../blue/blue_manage.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/io_tool.dart';
|
||||||
import '../../../../blue/io_tool/manager_event_bus.dart';
|
import '../../../../blue/io_tool/manager_event_bus.dart';
|
||||||
import '../../../../blue/sender_manage.dart';
|
import '../../../../blue/sender_manage.dart';
|
||||||
|
import '../../../../flavors.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/commonDataManage.dart';
|
||||||
@ -31,9 +34,10 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 监听蓝牙协议返回结果
|
// 监听蓝牙协议返回结果
|
||||||
late StreamSubscription<Reply> _replySubscription;
|
late StreamSubscription<Reply> _replySubscription;
|
||||||
|
|
||||||
void _initReplySubscription() {
|
void _initReplySubscription() {
|
||||||
_replySubscription =
|
_replySubscription =
|
||||||
EventBusManager().eventBus!.on<Reply>().listen((reply) async {
|
EventBusManager().eventBus!.on<Reply>().listen((Reply reply) async {
|
||||||
// 删除用户
|
// 删除用户
|
||||||
// if (reply is DeletUserReply) {
|
// if (reply is DeletUserReply) {
|
||||||
// _replyDeletUserKey(reply);
|
// _replyDeletUserKey(reply);
|
||||||
@ -100,8 +104,8 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 恢复出厂设置数据解析
|
// 恢复出厂设置数据解析
|
||||||
Future<void> _replyFactoryDataResetKey(Reply reply) async {
|
Future<void> _replyFactoryDataResetKey(Reply reply) async {
|
||||||
var token = reply.data.sublist(2, 6);
|
List<int> token = reply.data.sublist(2, 6);
|
||||||
var saveStrList = changeIntListToStringList(token);
|
List<String> saveStrList = changeIntListToStringList(token);
|
||||||
Storage.setStringList(saveBlueToken, saveStrList);
|
Storage.setStringList(saveBlueToken, saveStrList);
|
||||||
|
|
||||||
int status = reply.data[6];
|
int status = reply.data[6];
|
||||||
@ -114,13 +118,15 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
break;
|
break;
|
||||||
case 0x06:
|
case 0x06:
|
||||||
//无权限
|
//无权限
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
List<String>? privateKey =
|
||||||
|
await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
|
|
||||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
List<String>? publicKey =
|
||||||
|
await Storage.getStringList(saveBluePublicKey);
|
||||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||||
|
|
||||||
var token = await Storage.getStringList(saveBlueToken);
|
List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||||
List<int> getTokenList = changeStringListToIntList(token!);
|
List<int> getTokenList = changeStringListToIntList(token!);
|
||||||
|
|
||||||
IoSenderManage.senderFactoryDataReset(
|
IoSenderManage.senderFactoryDataReset(
|
||||||
@ -252,13 +258,15 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||||
(BluetoothConnectionState connectionState) async {
|
(BluetoothConnectionState connectionState) async {
|
||||||
if (connectionState == BluetoothConnectionState.connected) {
|
if (connectionState == BluetoothConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
List<String>? privateKey =
|
||||||
|
await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
|
|
||||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
List<String>? publicKey =
|
||||||
|
await Storage.getStringList(saveBluePublicKey);
|
||||||
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
List<int> publicKeyDataList = changeStringListToIntList(publicKey!);
|
||||||
|
|
||||||
var token = await Storage.getStringList(saveBlueToken);
|
List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||||
List<int> getTokenList = changeStringListToIntList(token!);
|
List<int> getTokenList = changeStringListToIntList(token!);
|
||||||
|
|
||||||
IoSenderManage.senderFactoryDataReset(
|
IoSenderManage.senderFactoryDataReset(
|
||||||
@ -314,18 +322,20 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
BlueManage().blueSendData(BlueManage().connectDeviceName,
|
||||||
(BluetoothConnectionState connectionState) async {
|
(BluetoothConnectionState connectionState) async {
|
||||||
if (connectionState == BluetoothConnectionState.connected) {
|
if (connectionState == BluetoothConnectionState.connected) {
|
||||||
var privateKey = await Storage.getStringList(saveBluePrivateKey);
|
List<String>? privateKey =
|
||||||
|
await Storage.getStringList(saveBluePrivateKey);
|
||||||
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
|
||||||
|
|
||||||
var token = await Storage.getStringList(saveBlueToken);
|
List<String>? token = await Storage.getStringList(saveBlueToken);
|
||||||
List<int> getTokenList = changeStringListToIntList(token!);
|
List<int> getTokenList = changeStringListToIntList(token!);
|
||||||
|
|
||||||
var publicKey = await Storage.getStringList(saveBluePublicKey);
|
List<String>? publicKey =
|
||||||
|
await Storage.getStringList(saveBluePublicKey);
|
||||||
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
List<int> getPublicKeyList = changeStringListToIntList(publicKey!);
|
||||||
|
|
||||||
state.settingUpSupportFeatures = type;
|
state.settingUpSupportFeatures = type;
|
||||||
|
|
||||||
var featureEnable = 0;
|
int featureEnable = 0;
|
||||||
if (type == 55) {
|
if (type == 55) {
|
||||||
// APP开锁时是否需联网
|
// APP开锁时是否需联网
|
||||||
featureEnable = state.isOpenLockNeedOnline.value == 1 ? 0 : 1;
|
featureEnable = state.isOpenLockNeedOnline.value == 1 ? 0 : 1;
|
||||||
@ -386,9 +396,9 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 开启考勤获取是否有公司
|
// 开启考勤获取是否有公司
|
||||||
void openCheckingInData(
|
Future<void> openCheckingInData(
|
||||||
BlockSetCheckInCallback blockSetCheckInCallback) async {
|
BlockSetCheckInCallback blockSetCheckInCallback) async {
|
||||||
var entity = await ApiRepository.to.openCheckingInData(
|
CheckingInInfoDataEntity entity = await ApiRepository.to.openCheckingInData(
|
||||||
lockId: state.lockSetInfoData.value.lockId.toString(),
|
lockId: state.lockSetInfoData.value.lockId.toString(),
|
||||||
);
|
);
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
@ -397,8 +407,8 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 设置是否打开考勤
|
// 设置是否打开考勤
|
||||||
void setLockSetGeneralSetting() async {
|
Future<void> setLockSetGeneralSetting() async {
|
||||||
var entity = await ApiRepository.to.setCheckInData(
|
LoginEntity entity = await ApiRepository.to.setCheckInData(
|
||||||
lockId: state.lockSetInfoData.value.lockId!,
|
lockId: state.lockSetInfoData.value.lockId!,
|
||||||
attendance: state.isAttendance.value == 1 ? 0 : 1,
|
attendance: state.isAttendance.value == 1 ? 0 : 1,
|
||||||
);
|
);
|
||||||
@ -415,7 +425,7 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 设置是否打开开锁提醒
|
// 设置是否打开开锁提醒
|
||||||
Future<void> setLockPickingReminder() async {
|
Future<void> setLockPickingReminder() async {
|
||||||
var entity = await ApiRepository.to.setLockPickingReminderData(
|
LoginEntity entity = await ApiRepository.to.setLockPickingReminderData(
|
||||||
lockId: state.lockSetInfoData.value.lockId!,
|
lockId: state.lockSetInfoData.value.lockId!,
|
||||||
unlockReminder: state.isLockPickingReminder.value == 1 ? 0 : 1,
|
unlockReminder: state.isLockPickingReminder.value == 1 ? 0 : 1,
|
||||||
);
|
);
|
||||||
@ -431,8 +441,8 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 设置是否打开开锁时是否需联网
|
// 设置是否打开开锁时是否需联网
|
||||||
void setLockSetOpenLockNeedOnline() async {
|
Future<void> setLockSetOpenLockNeedOnline() async {
|
||||||
var entity = await ApiRepository.to.setOpenLockNeedOnlineData(
|
LoginEntity entity = await ApiRepository.to.setOpenLockNeedOnlineData(
|
||||||
lockId: state.lockSetInfoData.value.lockId!,
|
lockId: state.lockSetInfoData.value.lockId!,
|
||||||
appUnlockOnline: state.isOpenLockNeedOnline.value == 1 ? 0 : 1,
|
appUnlockOnline: state.isOpenLockNeedOnline.value == 1 ? 0 : 1,
|
||||||
);
|
);
|
||||||
@ -452,16 +462,18 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
|
|
||||||
// 下级界面修改成功后传递数据
|
// 下级界面修改成功后传递数据
|
||||||
StreamSubscription? _passCurrentLockInformationEvent;
|
StreamSubscription? _passCurrentLockInformationEvent;
|
||||||
|
|
||||||
void initLoadDataAction(BlockSetStateCallback blockSetStateCallback) {
|
void initLoadDataAction(BlockSetStateCallback blockSetStateCallback) {
|
||||||
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
// 蓝牙协议通知传输跟蓝牙之外的数据传输类不一样 eventBus
|
||||||
_passCurrentLockInformationEvent =
|
_passCurrentLockInformationEvent = eventBus
|
||||||
eventBus.on<PassCurrentLockInformationEvent>().listen((event) {
|
.on<PassCurrentLockInformationEvent>()
|
||||||
|
.listen((PassCurrentLockInformationEvent event) {
|
||||||
getLockSettingInfoData();
|
getLockSettingInfoData();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void showDeletAlertTipDialog({String? showContent = ''}) {
|
void showDeletAlertTipDialog({String? showContent = ''}) {
|
||||||
var content = showContent!.isEmpty
|
String content = showContent!.isEmpty
|
||||||
? "${"删除设备失败,请确保在设备附近,设备未被连接,设备已打开".tr}${BlueManage().connectDeviceName!.contains("T9A") == true ? "。如果是全自动锁,请使屏幕变亮".tr : ""}"
|
? "${"删除设备失败,请确保在设备附近,设备未被连接,设备已打开".tr}${BlueManage().connectDeviceName!.contains("T9A") == true ? "。如果是全自动锁,请使屏幕变亮".tr : ""}"
|
||||||
: showContent;
|
: showContent;
|
||||||
ShowTipView().showSureAlertDialog(content);
|
ShowTipView().showSureAlertDialog(content);
|
||||||
@ -482,7 +494,7 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
} else if (state.lockBasicInfo.value.keyRight == 1) {
|
} else if (state.lockBasicInfo.value.keyRight == 1) {
|
||||||
// 授权管理员弹框提示
|
// 授权管理员弹框提示
|
||||||
ShowTipView().showDeleteAdministratorIsHaveAllDataDialog(
|
ShowTipView().showDeleteAdministratorIsHaveAllDataDialog(
|
||||||
'同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (a) {
|
'同时删除其发送的所有钥匙,钥匙删除后不能恢复'.tr, (bool a) {
|
||||||
// 授权管理员删除
|
// 授权管理员删除
|
||||||
state.deleteAdministratorIsHaveAllData.value = a;
|
state.deleteAdministratorIsHaveAllData.value = a;
|
||||||
deletKeyData();
|
deletKeyData();
|
||||||
@ -496,8 +508,8 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 查询账户密码
|
// 查询账户密码
|
||||||
void checkLoginPassword() async {
|
Future<void> checkLoginPassword() async {
|
||||||
var entity = await ApiRepository.to.checkLoginPassword(
|
LockListInfoEntity entity = await ApiRepository.to.checkLoginPassword(
|
||||||
password: state.passwordTF.text,
|
password: state.passwordTF.text,
|
||||||
);
|
);
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
@ -507,21 +519,21 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 当是锁拥有者的时候,删除锁
|
// 当是锁拥有者的时候,删除锁
|
||||||
void deletLockInfoData() async {
|
Future<void> deletLockInfoData() async {
|
||||||
var entity = await ApiRepository.to.deletOwnerLockData(
|
LockListInfoEntity entity = await ApiRepository.to.deletOwnerLockData(
|
||||||
lockId: state.lockSetInfoData.value.lockId!,
|
lockId: state.lockSetInfoData.value.lockId!,
|
||||||
);
|
);
|
||||||
if (entity.errorCode!.codeIsSuccessful) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
BlueManage().connectDeviceMacAddress = "";
|
BlueManage().connectDeviceMacAddress = '';
|
||||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||||
});
|
});
|
||||||
if(state.isOnlyOneData.value == true){
|
if (state.isOnlyOneData.value == true) {
|
||||||
Future.delayed(const Duration(milliseconds: 200)).then((e) {
|
Future<dynamic>.delayed(const Duration(milliseconds: 200)).then((e) {
|
||||||
Get.close(1);
|
Get.close(1);
|
||||||
});
|
});
|
||||||
}else{
|
} else {
|
||||||
Future.delayed(const Duration(milliseconds: 200)).then((e) {
|
Future<dynamic>.delayed(const Duration(milliseconds: 200)).then((e) {
|
||||||
Get.close(2);
|
Get.close(2);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -529,27 +541,27 @@ class LockSetLogic extends BaseGetXController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 普通用户或者授权管理员删除钥匙
|
// 普通用户或者授权管理员删除钥匙
|
||||||
void deletKeyData() async {
|
Future<void> deletKeyData() async {
|
||||||
var entity = await ApiRepository.to.deletOwnerKeyData(
|
final LockListInfoEntity entity = await ApiRepository.to.deletOwnerKeyData(
|
||||||
lockId: state.lockSetInfoData.value.lockId.toString(),
|
lockId: state.lockSetInfoData.value.lockId.toString(),
|
||||||
keyId: state.lockSetInfoData.value.lockBasicInfo!.keyId.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) {
|
if (entity.errorCode!.codeIsSuccessful) {
|
||||||
BlueManage().connectDeviceMacAddress = "";
|
BlueManage().connectDeviceMacAddress = '';
|
||||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||||
eventBus.fire(RefreshLockListInfoDataEvent());
|
eventBus.fire(RefreshLockListInfoDataEvent());
|
||||||
});
|
});
|
||||||
if(state.isOnlyOneData.value == true){
|
final bool isXHJ = F.isXHJ;
|
||||||
Future.delayed(const Duration(milliseconds: 200)).then((e) {
|
final bool isOnlyOneData = state.isOnlyOneData.value == true;
|
||||||
Get.close(1);
|
Future<dynamic>.delayed(const Duration(milliseconds: 200)).then((e) {
|
||||||
});
|
if (isXHJ) {
|
||||||
}else{
|
Get.close(3);
|
||||||
Future.delayed(const Duration(milliseconds: 200)).then((e) {
|
} else {
|
||||||
Get.close(2);
|
final int onlyOneDataInt = isOnlyOneData ? 1 : 2;
|
||||||
});
|
Get.close(onlyOneDataInt);
|
||||||
}
|
}
|
||||||
// Get.offAllNamed(Routers.starLockMain);
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user