全局添加锁被重置的toast提示

This commit is contained in:
范鹏 2024-09-04 09:27:18 +08:00
parent ab960f8edd
commit 0ef64ecd61
6 changed files with 77 additions and 64 deletions

View File

@ -72,10 +72,14 @@ export default {
role: 0xff,
password
})
if(addUserCode !== 0) {
if(addUserCode === 0) {
} else if(addUserCode === -1) {
uni.hideLoading()
this.backAndToast('添加失败,请重试')
return
} else {
uni.hideLoading()
return
}
const params = {
lockAlias: this.name,

View File

@ -173,7 +173,7 @@ export default {
title: `只能在循环时间内操作门锁`,
icon: 'none'
})
} else {
} else if(code === -1) {
uni.showToast({
title: `${type === 'close' ? '关' : '开'}锁失败,请保证在锁附近`,
icon: 'none'

View File

@ -99,12 +99,14 @@ export default {
icon: 'none'
})
}
} else {
} else if(code === -1) {
uni.hideLoading()
uni.showToast({
title: '删除失败,请保持在锁附近',
icon: 'none'
})
} else {
uni.hideLoading()
}
}
}

View File

@ -144,12 +144,14 @@ export default {
icon: 'none'
})
}
} else {
} else if(code === -1) {
uni.hideLoading()
uni.showToast({
title: '删除失败,请保持在锁附近',
icon: 'none'
})
} else {
uni.hideLoading()
}
}
}
@ -188,7 +190,7 @@ export default {
icon: 'none'
})
}
} else {
} else if(code === -1) {
uni.showToast({
title: '重置密码失败,请保持在锁附近',
icon: 'none'

View File

@ -219,12 +219,14 @@ export default {
icon: 'none'
})
}
} else {
} else if(code === -1) {
uni.hideLoading()
uni.showToast({
title: '删除失败,请保持在锁附近',
icon: 'none'
})
} else {
uni.hideLoading()
}
} else {
const { code } = await deleteKeyRequest({

View File

@ -737,7 +737,7 @@ export const useBluetoothStore = defineStore('ble', {
timer2 = setTimeout(() => {
uni.stopBluetoothDevicesDiscovery()
clearInterval(timer1)
resolve(false)
resolve({ code: -1 })
}, 10500)
timer1 = setInterval(() => {
uni.getBluetoothDevices({
@ -750,7 +750,24 @@ export const useBluetoothStore = defineStore('ble', {
uni.stopBluetoothDevicesDiscovery()
clearTimeout(timer2)
clearInterval(timer1)
resolve(deviceList[i].deviceId)
resolve({
code: 0,
data: {
deviceId: deviceList[i].deviceId
}
})
break
} else if(uuid && uuid.slice(2,8)==='758824' && uuid.slice(30,32)==='00') {
uni.stopBluetoothDevicesDiscovery()
clearTimeout(timer2)
clearInterval(timer1)
uni.showToast({
title: '锁已被重置,请重新绑定',
icon: 'none'
})
resolve({
code: -2
})
break
}
}
@ -787,9 +804,13 @@ export const useBluetoothStore = defineStore('ble', {
}
}
})
resolve(false)
resolve({
code: -1
})
} else {
resolve(false)
resolve({
code: -1
})
}
}
})
@ -963,16 +984,14 @@ export const useBluetoothStore = defineStore('ble', {
// 确认设备连接正常
if(!this.currentLockInfo.connected) {
const srerchResult = await this.searchAndConnectDevice()
if(srerchResult.code !== 0) {
return srerchResult
}
this.updateCurrentLockInfo({
...this.currentLockInfo,
deviceId: srerchResult
deviceId: srerchResult.data.deviceId
})
console.log('设备ID', this.currentLockInfo.deviceId)
if(!srerchResult) {
return {
code: -1
}
}
const result = await this.connectBluetoothDevice()
console.log('连接结果', result)
if(!result) {
@ -1011,16 +1030,14 @@ export const useBluetoothStore = defineStore('ble', {
// 确认设备连接正常
if(!this.currentLockInfo.connected) {
const srerchResult = await this.searchAndConnectDevice()
if(srerchResult.code !== 0) {
return srerchResult
}
this.updateCurrentLockInfo({
...this.currentLockInfo,
deviceId: srerchResult
deviceId: srerchResult.data.deviceId
})
console.log('设备ID', this.currentLockInfo.deviceId)
if(!srerchResult) {
return {
code: -1
}
}
const result = await this.connectBluetoothDevice()
console.log('连接结果', result)
if(!result) {
@ -1093,16 +1110,14 @@ export const useBluetoothStore = defineStore('ble', {
// 确认设备连接正常
if(!this.currentLockInfo.connected) {
const srerchResult = await this.searchAndConnectDevice()
if(srerchResult.code !== 0) {
return srerchResult
}
this.updateCurrentLockInfo({
...this.currentLockInfo,
deviceId: srerchResult
deviceId: srerchResult.data.deviceId
})
console.log('设备ID', this.currentLockInfo.deviceId)
if(!srerchResult) {
return {
code: -1
}
}
const result = await this.connectBluetoothDevice()
console.log('连接结果', result)
if(!result) {
@ -1164,16 +1179,14 @@ export const useBluetoothStore = defineStore('ble', {
// 确认设备连接正常
if(!this.currentLockInfo.connected) {
const srerchResult = await this.searchAndConnectDevice()
if(srerchResult.code !== 0) {
return srerchResult
}
this.updateCurrentLockInfo({
...this.currentLockInfo,
deviceId: srerchResult
deviceId: srerchResult.data.deviceId
})
console.log('设备ID', this.currentLockInfo.deviceId)
if(!srerchResult) {
return {
code: -1
}
}
const result = await this.connectBluetoothDevice()
console.log('连接结果', result)
if(!result) {
@ -1283,16 +1296,14 @@ export const useBluetoothStore = defineStore('ble', {
// 确认设备连接正常
if(!this.currentLockInfo.connected) {
const srerchResult = await this.searchAndConnectDevice()
if(srerchResult.code !== 0) {
return srerchResult
}
this.updateCurrentLockInfo({
...this.currentLockInfo,
deviceId: srerchResult
deviceId: srerchResult.data.deviceId
})
console.log('设备ID', this.currentLockInfo.deviceId)
if(!srerchResult) {
return {
code: -1
}
}
const result = await this.connectBluetoothDevice()
console.log('连接结果', result)
if(!result) {
@ -1366,16 +1377,14 @@ export const useBluetoothStore = defineStore('ble', {
// 确认设备连接正常
if(!this.currentLockInfo.connected) {
const srerchResult = await this.searchAndConnectDevice()
if(srerchResult.code !== 0) {
return srerchResult
}
this.updateCurrentLockInfo({
...this.currentLockInfo,
deviceId: srerchResult
deviceId: srerchResult.data.deviceId
})
console.log('设备ID', this.currentLockInfo.deviceId)
if(!srerchResult) {
return {
code: -1
}
}
const result = await this.connectBluetoothDevice()
console.log('连接结果', result)
if(!result) {
@ -1447,16 +1456,14 @@ export const useBluetoothStore = defineStore('ble', {
// 确认设备连接正常
if(!this.currentLockInfo.connected) {
const srerchResult = await this.searchAndConnectDevice()
if(srerchResult.code !== 0) {
return srerchResult
}
this.updateCurrentLockInfo({
...this.currentLockInfo,
deviceId: srerchResult
deviceId: srerchResult.data.deviceId
})
console.log('设备ID', this.currentLockInfo.deviceId)
if(!srerchResult) {
return {
code: -1
}
}
const result = await this.connectBluetoothDevice()
console.log('连接结果', result)
if(!result) {
@ -1517,16 +1524,14 @@ export const useBluetoothStore = defineStore('ble', {
// 确认设备连接正常
if(!this.currentLockInfo.connected) {
const srerchResult = await this.searchAndConnectDevice()
if(srerchResult.code !== 0) {
return srerchResult
}
this.updateCurrentLockInfo({
...this.currentLockInfo,
deviceId: srerchResult
deviceId: srerchResult.data.deviceId
})
console.log('设备ID', this.currentLockInfo.deviceId)
if(!srerchResult) {
return {
code: -1
}
}
const result = await this.connectBluetoothDevice()
console.log('连接结果', result)
if(!result) {
@ -1595,16 +1600,14 @@ export const useBluetoothStore = defineStore('ble', {
// 确认设备连接正常
if(!this.currentLockInfo.connected) {
const srerchResult = await this.searchAndConnectDevice()
if(srerchResult.code !== 0) {
return srerchResult
}
this.updateCurrentLockInfo({
...this.currentLockInfo,
deviceId: srerchResult
deviceId: srerchResult.data.deviceId
})
console.log('设备ID', this.currentLockInfo.deviceId)
if(!srerchResult) {
return {
code: -1
}
}
const result = await this.connectBluetoothDevice()
console.log('连接结果', result)
if(!result) {