1. 连接设备添加兜底,防止loading无法关闭

2. 修正人脸认证的判断时间
This commit is contained in:
范鹏 2024-09-12 13:52:23 +08:00
parent 3ab936b319
commit 46f537842f
3 changed files with 50 additions and 44 deletions

View File

@ -3,7 +3,7 @@
"appid" : "__UNI__933D519",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "11",
"versionCode" : "12",
"transformPx" : false,
/* */
"mp-weixin" : {

View File

@ -83,8 +83,7 @@ export default {
onlineToken: '0',
pending: false,
show: false,
type: '',
serverTime: 0
type: ''
}
},
computed: {
@ -134,13 +133,12 @@ export default {
async getServeTime() {
const { code, data } = await this.updateServerTimestamp()
if(code === 0) {
this.serverTime = data.date
this.time = parseInt((data.date - new Date().getTime()) / 1000)
}
},
async openDoorOperate(type) {
if(this.currentLockInfo.faceAuthentication === 1 &&
this.currentLockInfo.nextFaceValidateTime <= this.serverTime) {
this.currentLockInfo.nextFaceValidateTime <= new Date().getTime() + this.time * 1000) {
uni.showModal({
title: '提示',
content: '开门前需进行实名认证小程序暂不支持请使用APP认证开门',

View File

@ -66,51 +66,59 @@ export default {
name: device.name,
deviceId: device.deviceId
})
const result = await this.connectBluetoothDevice()
if(result) {
this.stopGetBluetoothDevices()
const { code: getPublicKeyCode } = await this.getPublicKey(this.currentLockInfo.name)
console.log('获取公钥返回', getPublicKeyCode, [...this.currentLockInfo.publicKey])
if(getPublicKeyCode !== 0) {
try {
const result = await this.connectBluetoothDevice()
if(result) {
this.stopGetBluetoothDevices()
const { code: getPublicKeyCode } = await this.getPublicKey(this.currentLockInfo.name)
console.log('获取公钥返回', getPublicKeyCode, [...this.currentLockInfo.publicKey])
if(getPublicKeyCode !== 0) {
uni.hideLoading()
uni.showToast({
title: '连接失败,请靠近设备并保持设备处于唤醒状态',
icon: 'none'
})
return
}
const { code: getCommKeyCode } = await this.getCommKey(this.currentLockInfo.name, this.keyId,
this.userInfo.uid.toString(), this.serverTimestamp)
console.log('获取私钥返回', getCommKeyCode)
if(getCommKeyCode !== 0) {
uni.hideLoading()
uni.showToast({
title: '连接失败,请靠近设备并保持设备处于唤醒状态',
icon: 'none'
})
return
}
const date = new Date()
const timestamp = parseInt(date.getTime() / 1000) - date.getTimezoneOffset() * 60
const { code } = await this.getLockStatus({
name: this.currentLockInfo.name,
uid: this.userInfo.uid,
nowTime: this.serverTimestamp,
localTime: timestamp
})
if (code !== 0) {
uni.hideLoading()
uni.showToast({
title: '连接失败,请靠近设备并保持设备处于唤醒状态',
icon: 'none'
})
return
}
this.routeJump({
type: 'redirectTo',
name: 'selectAddress'
})
} else {
uni.hideLoading()
uni.showToast({
title: '连接失败,请靠近设备并保持设备处于唤醒状态',
icon: 'none'
})
return
}
const { code: getCommKeyCode } = await this.getCommKey(this.currentLockInfo.name, this.keyId,
this.userInfo.uid.toString(), this.serverTimestamp)
console.log('获取私钥返回', getCommKeyCode)
if(getCommKeyCode !== 0) {
uni.hideLoading()
uni.showToast({
title: '连接失败,请靠近设备并保持设备处于唤醒状态',
icon: 'none'
})
return
}
const date = new Date()
const timestamp = parseInt(date.getTime() / 1000) - date.getTimezoneOffset() * 60
const { code } = await this.getLockStatus({
name: this.currentLockInfo.name,
uid: this.userInfo.uid,
nowTime: this.serverTimestamp,
localTime: timestamp
})
if (code !== 0) {
uni.hideLoading()
uni.showToast({
title: '连接失败,请靠近设备并保持设备处于唤醒状态',
icon: 'none'
})
return
}
this.routeJump({
type: 'redirectTo',
name: 'selectAddress'
})
} else {
} catch (res) {
uni.hideLoading()
uni.showToast({
title: '连接失败,请靠近设备并保持设备处于唤醒状态',