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);
@ -88,7 +89,7 @@ class LockDetailLogic extends BaseGetXController {
state.electricQuantity.value = power; state.electricQuantity.value = power;
// //
if(state.keyInfos.value.lockFeature!.isSupportBackupBattery == 1){ if (state.keyInfos.value.lockFeature!.isSupportBackupBattery == 1) {
int powerStandby = reply.data[9]; int powerStandby = reply.data[9];
state.electricQuantityStandby.value = powerStandby; state.electricQuantityStandby.value = powerStandby;
} }
@ -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;
} }
@ -170,7 +182,7 @@ class LockDetailLogic extends BaseGetXController {
if (dataLength > 0) { if (dataLength > 0) {
reply.data.removeRange(0, 7); reply.data.removeRange(0, 7);
// 8 // 8
if(reply.data.length < 17){ if (reply.data.length < 17) {
return; return;
} }
var getList = splitList(reply.data, 17); var getList = splitList(reply.data, 17);
@ -182,29 +194,29 @@ class LockDetailLogic extends BaseGetXController {
var indexMap = {}; var indexMap = {};
indexMap["type"] = indexList[0].toString(); indexMap["type"] = indexList[0].toString();
if(indexList[0] == 2){ if (indexList[0] == 2) {
var passwordData = reply.data.sublist(7, 17); var passwordData = reply.data.sublist(7, 17);
var password = utf8String(passwordData); var password = utf8String(passwordData);
indexMap["user"] = password.toString(); indexMap["user"] = password.toString();
}else{ } else {
int userNo = (indexList[1]*255) + indexList[2]; int userNo = (indexList[1] * 255) + indexList[2];
indexMap["user"] = userNo.toString(); indexMap["user"] = userNo.toString();
} }
indexMap["success"] = "1"; indexMap["success"] = "1";
int time = ((0xff & indexList[(3)]) << 24 | int time = ((0xff & indexList[(3)]) << 24 |
(0xff & indexList[4]) << 16 | (0xff & indexList[4]) << 16 |
(0xff & indexList[5]) << 8 | (0xff & indexList[5]) << 8 |
(0xFF & indexList[6])); (0xFF & indexList[6]));
indexMap["date"] = "${time * 1000}"; indexMap["date"] = "${time * 1000}";
uploadList.add(indexMap); uploadList.add(indexMap);
} }
lockRecordUploadData(uploadList); lockRecordUploadData(uploadList);
if(dataLength == state.logCountPage){ if (dataLength == state.logCountPage) {
senderReferEventRecordTime(); senderReferEventRecordTime();
}else{ } else {
await BlueManage().disconnect(); await BlueManage().disconnect();
} }
} }
@ -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(
BlueManage().disconnect(); isShowBlueConnetctToast: false,
}); action: () {
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async { BlueManage().disconnect();
});
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!);
@ -407,27 +423,30 @@ 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}");
openDoorAction(); openDoorAction();
}else{ } else {
showToast("网络访问失败,请检查网络是否正常".tr, something: (){ showToast("网络访问失败,请检查网络是否正常".tr, something: () {
state.openLockBtnState.value = 0; state.openLockBtnState.value = 0;
state.animationController!.forward(); state.animationController!.forward();
cancelBlueConnetctToastTimer(); cancelBlueConnetctToastTimer();
@ -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
electricQuantity:state.electricQuantity.value.toString(), .uploadElectricQuantity(
electricQuantityStandby: state.electricQuantityStandby.value.toString(), electricQuantity: state.electricQuantity.value.toString(),
lockId: state.keyInfos.value.lockId.toString() electricQuantityStandby:
); 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,8 +508,9 @@ 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(
if(state.keyInfos.value.keyType == XSConstantMacro.keyTypeOnce){ "state.keyInfos.value.keyType:${state.keyInfos.value.keyType}");
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,21 +530,24 @@ 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 =
state.lockNetToken = "";// token int.parse(event.setResult);
state.lockNetToken = ""; // token
} else if (event.type == 2) { } else if (event.type == 2) {
// 2 // 2
state.isOpenPassageMode.value = int.parse(event.setResult); state.isOpenPassageMode.value = int.parse(event.setResult);
@ -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();
} }
} }