fix:修复锁钥匙过期的动画和提示

This commit is contained in:
anfe 2024-05-13 15:01:11 +08:00
parent 7369247fb6
commit a65891cfa6
4 changed files with 71 additions and 45 deletions

View File

@ -839,5 +839,6 @@
"固件版本": "Firmware version", "固件版本": "Firmware version",
"手动升级": "Manual upgrade", "手动升级": "Manual upgrade",
"设备连接中...": "Device Connecting...", "设备连接中...": "Device Connecting...",
"升级过程中无法开锁,请先开锁后再升级": "The lock cannot be unlocked during the upgrade, please unlock the lock before upgrading" "升级过程中无法开锁,请先开锁后再升级": "The lock cannot be unlocked during the upgrade, please unlock the lock before upgrading",
"钥匙无效": "The key is invalid"
} }

View File

@ -867,5 +867,6 @@
"固件版本": "固件版本", "固件版本": "固件版本",
"手动升级": "手动升级", "手动升级": "手动升级",
"设备连接中...": "设备连接中...", "设备连接中...": "设备连接中...",
"升级过程中无法开锁,请先开锁后再升级": "升级过程中无法开锁,请先开锁后再升级" "升级过程中无法开锁,请先开锁后再升级": "升级过程中无法开锁,请先开锁后再升级",
"钥匙无效": "钥匙无效"
} }

View File

@ -837,5 +837,7 @@
"固件版本": "固件版本", "固件版本": "固件版本",
"手动升级": "手动升级", "手动升级": "手动升级",
"设备连接中...": "设备连接中...", "设备连接中...": "设备连接中...",
"升级过程中无法开锁,请先开锁后再升级": "升级过程中无法开锁,请先开锁后再升级" "升级过程中无法开锁,请先开锁后再升级": "升级过程中无法开锁,请先开锁后再升级",
"钥匙无效": "钥匙无效"
} }

View File

@ -32,7 +32,8 @@ class LockDetailLogic extends BaseGetXController {
// //
void initReplySubscription() { void initReplySubscription() {
state.replySubscription = EventBusManager().eventBus!.on<Reply>().listen((reply) async { state.replySubscription =
EventBusManager().eventBus!.on<Reply>().listen((reply) async {
// //
if (reply is OpenDoorReply && state.ifCurrentScreen.value == true) { if (reply is OpenDoorReply && state.ifCurrentScreen.value == true) {
_replyOpenLock(reply); _replyOpenLock(reply);
@ -132,8 +133,19 @@ class LockDetailLogic extends BaseGetXController {
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
}); });
break; break;
case 0x0d:
// ...
showToast('钥匙无效'.tr);
state.openLockBtnState.value = 0;
state.openDoorBtnisUneable.value = false;
state.animationController!.stop();
cancelBlueConnetctToastTimer();
break;
default: default:
// //
state.openLockBtnState.value = 0;
state.openDoorBtnisUneable.value = false;
state.animationController!.stop();
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
break; break;
} }
@ -348,7 +360,9 @@ class LockDetailLogic extends BaseGetXController {
var token = await Storage.getStringList(saveBlueToken); var token = await Storage.getStringList(saveBlueToken);
List<int> getTokenList = changeStringListToIntList(token!); List<int> getTokenList = changeStringListToIntList(token!);
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) {
IoSenderManage.senderOpenLock( IoSenderManage.senderOpenLock(
keyID: BlueManage().connectDeviceName, keyID: BlueManage().connectDeviceName,
@ -374,13 +388,15 @@ class LockDetailLogic extends BaseGetXController {
}); });
} }
// () // ()
Future<void> senderReferEventRecordTime() async { Future<void> senderReferEventRecordTime() async {
showBlueConnetctToastTimer(isShowBlueConnetctToast: false, action: () { showBlueConnetctToastTimer(
isShowBlueConnetctToast: false,
action: () {
BlueManage().disconnect(); BlueManage().disconnect();
}); });
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { BlueManage().bludSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) { if (connectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey); var privateKey = await Storage.getStringList(saveBluePrivateKey);
List<int> getPrivateKeyList = changeStringListToIntList(privateKey!); List<int> getPrivateKeyList = changeStringListToIntList(privateKey!);
@ -410,18 +426,21 @@ class LockDetailLogic extends BaseGetXController {
void getServerDatetime() async { void getServerDatetime() async {
var entity = await ApiRepository.to.getServerDatetimeData(); var entity = await ApiRepository.to.getServerDatetimeData();
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.differentialTime = entity.data!.date! ~/ 1000 - DateTime.now().millisecondsSinceEpoch ~/ 1000; state.differentialTime = entity.data!.date! ~/ 1000 -
DateTime.now().millisecondsSinceEpoch ~/ 1000;
// AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}"); // AppLog.log("entity.data!.date! ~/ 1000:${entity.data!.date! ~/ 1000} DateTime.now().millisecondsSinceEpoch ~/ 1000:${DateTime.now().millisecondsSinceEpoch ~/ 1000} 服务器时间差:${state.differentialTime}");
} }
} }
int getUTCNetTime() { int getUTCNetTime() {
return DateTime.now().millisecondsSinceEpoch ~/ 1000 + state.differentialTime; return DateTime.now().millisecondsSinceEpoch ~/ 1000 +
state.differentialTime;
} }
// token // token
void getLockNetToken() async { void getLockNetToken() async {
LockNetTokenEntity entity = await ApiRepository.to.getLockNetToken(lockId: state.keyInfos.value.lockId.toString()); LockNetTokenEntity entity = await ApiRepository.to
.getLockNetToken(lockId: state.keyInfos.value.lockId.toString());
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
state.lockNetToken = entity.data!.token!.toString(); state.lockNetToken = entity.data!.token!.toString();
AppLog.log("从服务器获取联网token:${state.lockNetToken}"); AppLog.log("从服务器获取联网token:${state.lockNetToken}");
@ -439,11 +458,12 @@ class LockDetailLogic extends BaseGetXController {
// //
Future<void> uploadElectricQuantityRequest() async { Future<void> uploadElectricQuantityRequest() async {
KeyOperationRecordEntity entity = await ApiRepository.to.uploadElectricQuantity( KeyOperationRecordEntity entity = await ApiRepository.to
.uploadElectricQuantity(
electricQuantity: state.electricQuantity.value.toString(), electricQuantity: state.electricQuantity.value.toString(),
electricQuantityStandby: state.electricQuantityStandby.value.toString(), electricQuantityStandby:
lockId: state.keyInfos.value.lockId.toString() state.electricQuantityStandby.value.toString(),
); lockId: state.keyInfos.value.lockId.toString());
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
SchedulerBinding.instance.addPostFrameCallback((_) { SchedulerBinding.instance.addPostFrameCallback((_) {
eventBus.fire(RefreshLockListInfoDataEvent()); eventBus.fire(RefreshLockListInfoDataEvent());
@ -488,7 +508,8 @@ class LockDetailLogic extends BaseGetXController {
lockId: state.keyInfos.value.lockId.toString(), records: list); lockId: state.keyInfos.value.lockId.toString(), records: list);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
// mockNetworkDataRequest(); // mockNetworkDataRequest();
AppLog.log("state.keyInfos.value.keyType:${state.keyInfos.value.keyType}"); AppLog.log(
"state.keyInfos.value.keyType:${state.keyInfos.value.keyType}");
if (state.keyInfos.value.keyType == XSConstantMacro.keyTypeOnce) { if (state.keyInfos.value.keyType == XSConstantMacro.keyTypeOnce) {
// //
deletKeyData(); deletKeyData();
@ -499,9 +520,7 @@ class LockDetailLogic extends BaseGetXController {
// //
void deletKeyData() async { void deletKeyData() async {
var entity = await ApiRepository.to.deleteElectronicKey( var entity = await ApiRepository.to.deleteElectronicKey(
keyId:state.keyInfos.value.keyId.toString(), keyId: state.keyInfos.value.keyId.toString(), includeUnderlings: 0);
includeUnderlings: 0
);
if (entity.errorCode!.codeIsSuccessful) { if (entity.errorCode!.codeIsSuccessful) {
BlueManage().connectDeviceMacAddress = ""; BlueManage().connectDeviceMacAddress = "";
SchedulerBinding.instance.addPostFrameCallback((_) { SchedulerBinding.instance.addPostFrameCallback((_) {
@ -511,20 +530,23 @@ class LockDetailLogic extends BaseGetXController {
} }
} }
/// ///
void initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction() { void initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction() {
// eventBus // eventBus
state.lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent = state.lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent =
eventBus.on<LockSetChangeSetRefreshLockDetailWithType>().listen((event) { eventBus
.on<LockSetChangeSetRefreshLockDetailWithType>()
.listen((event) {
if (event.type == 0) { if (event.type == 0) {
// 0 // 0
state.isAttendance.value = int.parse(event.setResult); state.isAttendance.value = int.parse(event.setResult);
state.keyInfos.value.lockSetting!.attendance = int.parse(event.setResult); state.keyInfos.value.lockSetting!.attendance =
int.parse(event.setResult);
} else if (event.type == 1) { } else if (event.type == 1) {
// 1 // 1
state.isOpenLockNeedOnline.value = int.parse(event.setResult); state.isOpenLockNeedOnline.value = int.parse(event.setResult);
state.keyInfos.value.lockSetting!.appUnlockOnline = int.parse(event.setResult); state.keyInfos.value.lockSetting!.appUnlockOnline =
int.parse(event.setResult);
state.lockNetToken = ""; // token state.lockNetToken = ""; // token
} else if (event.type == 2) { } else if (event.type == 2) {
// 2 // 2
@ -557,7 +579,8 @@ class LockDetailLogic extends BaseGetXController {
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusExpired || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusExpired ||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusDeleted || state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusDeleted ||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusReset) { state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusReset) {
text = "${"你的钥匙".tr}${XSConstantMacro.getKeyStatusStr(state.keyInfos.value.keyStatus!)}"; text =
"${"你的钥匙".tr}${XSConstantMacro.getKeyStatusStr(state.keyInfos.value.keyStatus!)}";
} else { } else {
text = state.isOpenPassageMode.value == 1 text = state.isOpenPassageMode.value == 1
? "常开模式启动!长按闭锁".tr ? "常开模式启动!长按闭锁".tr
@ -582,5 +605,4 @@ class LockDetailLogic extends BaseGetXController {
await PermissionDialog.request(Permission.location); await PermissionDialog.request(Permission.location);
await PermissionDialog.requestBluetooth(); await PermissionDialog.requestBluetooth();
} }
} }