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",
"手动升级": "Manual upgrade",
"设备连接中...": "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() {
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) {
_replyOpenLock(reply);
@ -88,7 +89,7 @@ class LockDetailLogic extends BaseGetXController {
state.electricQuantity.value = power;
//
if(state.keyInfos.value.lockFeature!.isSupportBackupBattery == 1){
if (state.keyInfos.value.lockFeature!.isSupportBackupBattery == 1) {
int powerStandby = reply.data[9];
state.electricQuantityStandby.value = powerStandby;
}
@ -132,8 +133,19 @@ class LockDetailLogic extends BaseGetXController {
cancelBlueConnetctToastTimer();
});
break;
case 0x0d:
// ...
showToast('钥匙无效'.tr);
state.openLockBtnState.value = 0;
state.openDoorBtnisUneable.value = false;
state.animationController!.stop();
cancelBlueConnetctToastTimer();
break;
default:
//
state.openLockBtnState.value = 0;
state.openDoorBtnisUneable.value = false;
state.animationController!.stop();
cancelBlueConnetctToastTimer();
break;
}
@ -170,7 +182,7 @@ class LockDetailLogic extends BaseGetXController {
if (dataLength > 0) {
reply.data.removeRange(0, 7);
// 8
if(reply.data.length < 17){
if (reply.data.length < 17) {
return;
}
var getList = splitList(reply.data, 17);
@ -182,29 +194,29 @@ class LockDetailLogic extends BaseGetXController {
var indexMap = {};
indexMap["type"] = indexList[0].toString();
if(indexList[0] == 2){
if (indexList[0] == 2) {
var passwordData = reply.data.sublist(7, 17);
var password = utf8String(passwordData);
indexMap["user"] = password.toString();
}else{
int userNo = (indexList[1]*255) + indexList[2];
} else {
int userNo = (indexList[1] * 255) + indexList[2];
indexMap["user"] = userNo.toString();
}
indexMap["success"] = "1";
int time = ((0xff & indexList[(3)]) << 24 |
(0xff & indexList[4]) << 16 |
(0xff & indexList[5]) << 8 |
(0xFF & indexList[6]));
(0xff & indexList[4]) << 16 |
(0xff & indexList[5]) << 8 |
(0xFF & indexList[6]));
indexMap["date"] = "${time * 1000}";
uploadList.add(indexMap);
}
lockRecordUploadData(uploadList);
if(dataLength == state.logCountPage){
if (dataLength == state.logCountPage) {
senderReferEventRecordTime();
}else{
} else {
await BlueManage().disconnect();
}
}
@ -348,7 +360,9 @@ class LockDetailLogic extends BaseGetXController {
var token = await Storage.getStringList(saveBlueToken);
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) {
IoSenderManage.senderOpenLock(
keyID: BlueManage().connectDeviceName,
@ -374,13 +388,15 @@ class LockDetailLogic extends BaseGetXController {
});
}
// ()
Future<void> senderReferEventRecordTime() async {
showBlueConnetctToastTimer(isShowBlueConnetctToast: false, action: () {
BlueManage().disconnect();
});
BlueManage().bludSendData(BlueManage().connectDeviceName, (BluetoothConnectionState connectionState) async {
showBlueConnetctToastTimer(
isShowBlueConnetctToast: false,
action: () {
BlueManage().disconnect();
});
BlueManage().bludSendData(BlueManage().connectDeviceName,
(BluetoothConnectionState connectionState) async {
if (connectionState == BluetoothConnectionState.connected) {
var privateKey = await Storage.getStringList(saveBluePrivateKey);
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();
if(entity.errorCode!.codeIsSuccessful){
state.differentialTime = entity.data!.date! ~/ 1000 - DateTime.now().millisecondsSinceEpoch ~/ 1000;
if (entity.errorCode!.codeIsSuccessful) {
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}");
}
}
int getUTCNetTime(){
return DateTime.now().millisecondsSinceEpoch ~/ 1000 + state.differentialTime;
int getUTCNetTime() {
return DateTime.now().millisecondsSinceEpoch ~/ 1000 +
state.differentialTime;
}
// token
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) {
state.lockNetToken = entity.data!.token!.toString();
AppLog.log("从服务器获取联网token:${state.lockNetToken}");
openDoorAction();
}else{
showToast("网络访问失败,请检查网络是否正常".tr, something: (){
} else {
showToast("网络访问失败,请检查网络是否正常".tr, something: () {
state.openLockBtnState.value = 0;
state.animationController!.forward();
cancelBlueConnetctToastTimer();
@ -439,11 +458,12 @@ class LockDetailLogic extends BaseGetXController {
//
Future<void> uploadElectricQuantityRequest() async {
KeyOperationRecordEntity entity = await ApiRepository.to.uploadElectricQuantity(
electricQuantity:state.electricQuantity.value.toString(),
electricQuantityStandby: state.electricQuantityStandby.value.toString(),
lockId: state.keyInfos.value.lockId.toString()
);
KeyOperationRecordEntity entity = await ApiRepository.to
.uploadElectricQuantity(
electricQuantity: state.electricQuantity.value.toString(),
electricQuantityStandby:
state.electricQuantityStandby.value.toString(),
lockId: state.keyInfos.value.lockId.toString());
if (entity.errorCode!.codeIsSuccessful) {
SchedulerBinding.instance.addPostFrameCallback((_) {
eventBus.fire(RefreshLockListInfoDataEvent());
@ -488,8 +508,9 @@ class LockDetailLogic extends BaseGetXController {
lockId: state.keyInfos.value.lockId.toString(), records: list);
if (entity.errorCode!.codeIsSuccessful) {
// mockNetworkDataRequest();
AppLog.log("state.keyInfos.value.keyType:${state.keyInfos.value.keyType}");
if(state.keyInfos.value.keyType == XSConstantMacro.keyTypeOnce){
AppLog.log(
"state.keyInfos.value.keyType:${state.keyInfos.value.keyType}");
if (state.keyInfos.value.keyType == XSConstantMacro.keyTypeOnce) {
//
deletKeyData();
}
@ -499,9 +520,7 @@ class LockDetailLogic extends BaseGetXController {
//
void deletKeyData() async {
var entity = await ApiRepository.to.deleteElectronicKey(
keyId:state.keyInfos.value.keyId.toString(),
includeUnderlings: 0
);
keyId: state.keyInfos.value.keyId.toString(), includeUnderlings: 0);
if (entity.errorCode!.codeIsSuccessful) {
BlueManage().connectDeviceMacAddress = "";
SchedulerBinding.instance.addPostFrameCallback((_) {
@ -511,21 +530,24 @@ class LockDetailLogic extends BaseGetXController {
}
}
///
void initLockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceAction() {
// eventBus
state.lockSetOpenOrCloseCheckInRefreshLockDetailWithAttendanceEvent =
eventBus.on<LockSetChangeSetRefreshLockDetailWithType>().listen((event) {
eventBus
.on<LockSetChangeSetRefreshLockDetailWithType>()
.listen((event) {
if (event.type == 0) {
// 0
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) {
// 1
state.isOpenLockNeedOnline.value = int.parse(event.setResult);
state.keyInfos.value.lockSetting!.appUnlockOnline = int.parse(event.setResult);
state.lockNetToken = "";// token
state.keyInfos.value.lockSetting!.appUnlockOnline =
int.parse(event.setResult);
state.lockNetToken = ""; // token
} else if (event.type == 2) {
// 2
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.keyStatusDeleted ||
state.keyInfos.value.keyStatus == XSConstantMacro.keyStatusReset) {
text = "${"你的钥匙".tr}${XSConstantMacro.getKeyStatusStr(state.keyInfos.value.keyStatus!)}";
text =
"${"你的钥匙".tr}${XSConstantMacro.getKeyStatusStr(state.keyInfos.value.keyStatus!)}";
} else {
text = state.isOpenPassageMode.value == 1
? "常开模式启动!长按闭锁".tr
@ -582,5 +605,4 @@ class LockDetailLogic extends BaseGetXController {
await PermissionDialog.request(Permission.location);
await PermissionDialog.requestBluetooth();
}
}