本帖最后由 恐别倾城 于 2024-1-6 21:56 编辑
抱歉,应该是
这个节点数据处理有点问题
双击修改为以下代码
const { name, data, did, created_at } = msg.payload?.payload || {};
const { lock_user, image_url } = data || {};
const actionMaps = {
REMOTE_UNLOCK:"门铃",
UNLOCKED:"开锁",
LOCK_FINGERPRINT_FRONZEN:"验证失败",
LOCKED:"上锁"
}
msg.payload = {
action: actionMaps[name] || name,
did,
image_url: image_url || "",
time: formatTime(created_at)
}
if (name == 'UNLOCKED'){
//开锁
const { type, id, alias } = lock_user;
const maps = {
0:'门内',
1:'指纹',
2:'密码',
5:'微信',
6:'人脸'
}
msg.payload.type = maps[type]
msg.payload.user = id
msg.payload.username = alias
} else if (name == 'LOCKED'){
//上锁
} else if (name == 'REMOTE_UNLOCK') {
//请求远程开锁(门铃)
} else if (name == 'LOCK_FINGERPRINT_FRONZEN') {
//开锁失败
}else{
msg.payload = {}
return msg
}
function formatTime(isoString) {
const date = new Date(isoString);
const year = date.getFullYear();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const day = date.getDate().toString().padStart(2, '0');
const hours = date.getHours().toString().padStart(2, '0');
const minutes = date.getMinutes().toString().padStart(2, '0');
const seconds = date.getSeconds().toString().padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
return msg;
如果还是不行,尝试直接从 实时情况 中获取数据
|