添加新绑定设备15秒内不判断是否绑定逻辑
This commit is contained in:
parent
f39916214b
commit
f11a642592
@ -33,7 +33,7 @@ export default {
|
|||||||
console.log(this.name)
|
console.log(this.name)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(useBluetoothStore, ['addLockUser', 'closeBluetoothConnection']),
|
...mapActions(useBluetoothStore, ['addLockUser', 'closeBluetoothConnection', 'updateBindedDeviceName']),
|
||||||
...mapActions(useLockStore, ['getLockList', 'updateLockSearch']),
|
...mapActions(useLockStore, ['getLockList', 'updateLockSearch']),
|
||||||
...mapActions(useBasicStore, ['backAndToast']),
|
...mapActions(useBasicStore, ['backAndToast']),
|
||||||
uopdateName(data) {
|
uopdateName(data) {
|
||||||
@ -74,6 +74,7 @@ export default {
|
|||||||
})
|
})
|
||||||
if(addUserCode === 0) {
|
if(addUserCode === 0) {
|
||||||
this.closeBluetoothConnection()
|
this.closeBluetoothConnection()
|
||||||
|
this.updateBindedDeviceName(this.currentLockInfo.name)
|
||||||
} else if(addUserCode === -1) {
|
} else if(addUserCode === -1) {
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
this.backAndToast('添加失败,请重试')
|
this.backAndToast('添加失败,请重试')
|
||||||
|
|||||||
@ -71,10 +71,20 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
// 服务器时间
|
// 服务器时间
|
||||||
serverTimestamp: 0,
|
serverTimestamp: 0,
|
||||||
// 设备keyID
|
// 设备keyID
|
||||||
keyId: '0'
|
keyId: '0',
|
||||||
|
// 刚绑定的设备名称
|
||||||
|
bindedDeviceName: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
// 保存刚绑定的设备名称
|
||||||
|
updateBindedDeviceName(name) {
|
||||||
|
this.bindedDeviceName = name
|
||||||
|
setTimeout(() => {
|
||||||
|
this.bindedDeviceName = ''
|
||||||
|
console.log('清空设备名称')
|
||||||
|
}, 15000)
|
||||||
|
},
|
||||||
// 更新keyId
|
// 更新keyId
|
||||||
updateKeyId(keyId) {
|
updateKeyId(keyId) {
|
||||||
this.keyId = keyId
|
this.keyId = keyId
|
||||||
@ -733,7 +743,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
let timer2
|
let timer2
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
uni.startBluetoothDevicesDiscovery({
|
uni.startBluetoothDevicesDiscovery({
|
||||||
success: function (res) {
|
success: function () {
|
||||||
timer2 = setTimeout(() => {
|
timer2 = setTimeout(() => {
|
||||||
uni.stopBluetoothDevicesDiscovery()
|
uni.stopBluetoothDevicesDiscovery()
|
||||||
clearInterval(timer1)
|
clearInterval(timer1)
|
||||||
@ -747,7 +757,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
if(deviceList[i]?.name === that.currentLockInfo.name) {
|
if(deviceList[i]?.name === that.currentLockInfo.name) {
|
||||||
const uuid = deviceList[i]?.advertisServiceUUIDs[0]
|
const uuid = deviceList[i]?.advertisServiceUUIDs[0]
|
||||||
console.log('设备UUID', uuid, uuid.slice(2,8), uuid.slice(30,32))
|
console.log('设备UUID', uuid, uuid.slice(2,8), uuid.slice(30,32))
|
||||||
if(uuid && uuid.slice(2,8)==='758824' && uuid.slice(30,32)==='01') {
|
if(uuid && uuid.slice(2,8)==='758824' && (uuid.slice(30,32)==='01' || that.bindedDeviceName === that.currentLockInfo.name)) {
|
||||||
uni.stopBluetoothDevicesDiscovery()
|
uni.stopBluetoothDevicesDiscovery()
|
||||||
clearTimeout(timer2)
|
clearTimeout(timer2)
|
||||||
clearInterval(timer1)
|
clearInterval(timer1)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user