修复清理用户产生的bug
This commit is contained in:
parent
fbff1e5cef
commit
b18c77bb2c
@ -347,7 +347,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
...that.currentLockInfo,
|
...that.currentLockInfo,
|
||||||
token: decrypted.slice(2,6)
|
token: decrypted.slice(2,6)
|
||||||
})
|
})
|
||||||
console.log('开门', decrypted[6], that.currentLockInfo.token)
|
console.log('开门', decrypted[6], that.currentLockInfo.token)
|
||||||
characteristicValueCallback({
|
characteristicValueCallback({
|
||||||
code: decrypted[6]
|
code: decrypted[6]
|
||||||
})
|
})
|
||||||
@ -376,6 +376,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
console.log('上报时区结果', res)
|
console.log('上报时区结果', res)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
break
|
||||||
default:
|
default:
|
||||||
that.updateCurrentLockInfo({
|
that.updateCurrentLockInfo({
|
||||||
...that.currentLockInfo,
|
...that.currentLockInfo,
|
||||||
@ -764,9 +765,9 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
// 检查是否已添加为用户
|
// 检查是否已添加为用户
|
||||||
async checkLockUser() {
|
async checkLockUser(flag = false) {
|
||||||
console.log('检查是否已添加为用户', this.currentLockInfo.lockUserNo)
|
console.log('检查是否已添加为用户', this.currentLockInfo.lockUserNo)
|
||||||
if(this.currentLockInfo.lockUserNo === 0) {
|
if(this.currentLockInfo.lockUserNo === 0 || flag) {
|
||||||
const timestamp = parseInt(new Date().getTime() / 1000)
|
const timestamp = parseInt(new Date().getTime() / 1000)
|
||||||
const password = (Math.floor(Math.random() * 900000) + 100000).toString()
|
const password = (Math.floor(Math.random() * 900000) + 100000).toString()
|
||||||
console.log('用户未添加,开始添加用户')
|
console.log('用户未添加,开始添加用户')
|
||||||
@ -1212,6 +1213,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
},
|
},
|
||||||
// 获取写入结果
|
// 获取写入结果
|
||||||
getWriteResult(request, params) {
|
getWriteResult(request, params) {
|
||||||
|
const that = this
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
const getWriteResultTimer = setTimeout(() => {
|
const getWriteResultTimer = setTimeout(() => {
|
||||||
resolve({ code: -1 })
|
resolve({ code: -1 })
|
||||||
@ -1219,9 +1221,15 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
characteristicValueCallback = async (data) => {
|
characteristicValueCallback = async (data) => {
|
||||||
// code 6 token过期,重新获取
|
// code 6 token过期,重新获取
|
||||||
if(data.code === 6) {
|
if(data.code === 6) {
|
||||||
console.log('token过期', request.toString())
|
|
||||||
console.log('token过期', params)
|
|
||||||
resolve(await request(params))
|
resolve(await request(params))
|
||||||
|
} else if(data.code === 4) {
|
||||||
|
const checkResult = await that.checkLockUser(true)
|
||||||
|
if(checkResult) {
|
||||||
|
resolve(await request(params))
|
||||||
|
} else {
|
||||||
|
clearTimeout(getWriteResultTimer)
|
||||||
|
resolve(data)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
clearTimeout(getWriteResultTimer)
|
clearTimeout(getWriteResultTimer)
|
||||||
resolve(data)
|
resolve(data)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user