Merge branch 'fanpeng' into 'master'

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

See merge request StarlockTeam/wx-starlock!8
This commit is contained in:
范鹏 2024-09-12 06:21:21 +00:00
commit b897c0937b
7 changed files with 67 additions and 43 deletions

View File

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

View File

@ -137,6 +137,16 @@ export default {
} }
}, },
async openDoorOperate(type) { async openDoorOperate(type) {
if(this.currentLockInfo.faceAuthentication === 1 &&
((this.currentLockInfo.nextFaceValidateTime <= new Date().getTime() + this.time * 1000) &&
this.currentLockInfo.nextFaceValidateTime !== 0)) {
uni.showModal({
title: '提示',
content: '开门前需进行实名认证小程序暂不支持请使用APP认证开门',
showCancel: false
})
return
}
if(this.pending) { if(this.pending) {
return return
} }

View File

@ -95,7 +95,8 @@ export default {
}, },
methods: { methods: {
...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo', 'getNetworkType']), ...mapActions(useBasicStore, ['routeJump', 'getDeviceInfo', 'getNetworkType']),
...mapActions(useLockStore, ['getPasswordList', 'updateCurrentPasswordInfo', 'updatePasswordSearch', 'getPasswordStatus']), ...mapActions(useLockStore, ['getPasswordList', 'updateCurrentPasswordInfo', 'updatePasswordSearch',
'getPasswordStatus', 'clearList']),
...mapActions(useBluetoothStore, ['resetLockPassword', 'setLockPassword', 'closeBluetoothConnection']), ...mapActions(useBluetoothStore, ['resetLockPassword', 'setLockPassword', 'closeBluetoothConnection']),
toPasswordDetail(password) { toPasswordDetail(password) {
this.updateCurrentPasswordInfo(password) this.updateCurrentPasswordInfo(password)

View File

@ -45,7 +45,11 @@ export default {
}) })
} }
}, },
updateAnswer() { async updateAnswer() {
const netWork = await this.getNetworkType()
if(!netWork) {
return
}
this.routeJump({ this.routeJump({
type: 'redirectTo', type: 'redirectTo',
name: 'updateSafeQuestion' name: 'updateSafeQuestion'

View File

@ -66,51 +66,59 @@ export default {
name: device.name, name: device.name,
deviceId: device.deviceId deviceId: device.deviceId
}) })
const result = await this.connectBluetoothDevice() try {
if(result) { const result = await this.connectBluetoothDevice()
this.stopGetBluetoothDevices() if(result) {
const { code: getPublicKeyCode } = await this.getPublicKey(this.currentLockInfo.name) this.stopGetBluetoothDevices()
console.log('获取公钥返回', getPublicKeyCode, [...this.currentLockInfo.publicKey]) const { code: getPublicKeyCode } = await this.getPublicKey(this.currentLockInfo.name)
if(getPublicKeyCode !== 0) { 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.hideLoading()
uni.showToast({ uni.showToast({
title: '连接失败,请靠近设备并保持设备处于唤醒状态', title: '连接失败,请靠近设备并保持设备处于唤醒状态',
icon: 'none' icon: 'none'
}) })
return
} }
const { code: getCommKeyCode } = await this.getCommKey(this.currentLockInfo.name, this.keyId, } catch (res) {
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.hideLoading()
uni.showToast({ uni.showToast({
title: '连接失败,请靠近设备并保持设备处于唤醒状态', title: '连接失败,请靠近设备并保持设备处于唤醒状态',

View File

@ -3,7 +3,7 @@
<view class="title">地理位置</view> <view class="title">地理位置</view>
<view v-if="show"> <view v-if="show">
<map class="map" :longitude="longitude" :latitude="latitude" :scale="16" :markers="markers" <map class="map" :longitude="longitude" :latitude="latitude" :scale="16" :markers="markers"
:enable-zoom="false" :enable-scroll="false"></map> :enable-zoom="true" :enable-scroll="true"></map>
</view> </view>
<view v-else class="map"></view> <view v-else class="map"></view>
<view class="explain">检查以确保以下地址是正确的</view> <view class="explain">检查以确保以下地址是正确的</view>

View File

@ -618,6 +618,7 @@ export const useBluetoothStore = defineStore('ble', {
} }
uni.createBLEConnection({ uni.createBLEConnection({
deviceId: that.currentLockInfo.deviceId, deviceId: that.currentLockInfo.deviceId,
timeout: 10000,
success(res) { success(res) {
console.log('连接成功', res) console.log('连接成功', res)
// 获取设备服务 // 获取设备服务