fix:修复锁钥匙过期的动画和提示
This commit is contained in:
parent
7369247fb6
commit
a65891cfa6
@ -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"
|
||||
}
|
||||
|
||||
@ -867,5 +867,6 @@
|
||||
"固件版本": "固件版本",
|
||||
"手动升级": "手动升级",
|
||||
"设备连接中...": "设备连接中...",
|
||||
"升级过程中无法开锁,请先开锁后再升级": "升级过程中无法开锁,请先开锁后再升级"
|
||||
"升级过程中无法开锁,请先开锁后再升级": "升级过程中无法开锁,请先开锁后再升级",
|
||||
"钥匙无效": "钥匙无效"
|
||||
}
|
||||
|
||||
@ -837,5 +837,7 @@
|
||||
"固件版本": "固件版本",
|
||||
"手动升级": "手动升级",
|
||||
"设备连接中...": "设备连接中...",
|
||||
"升级过程中无法开锁,请先开锁后再升级": "升级过程中无法开锁,请先开锁后再升级"
|
||||
"升级过程中无法开锁,请先开锁后再升级": "升级过程中无法开锁,请先开锁后再升级",
|
||||
"钥匙无效": "钥匙无效"
|
||||
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user