bug修复
This commit is contained in:
parent
932654b706
commit
f2f27b256b
@ -46,3 +46,12 @@ export function lockUserListRequest(data) {
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 获取锁详情
|
||||
export function getLockDetailRequest(data) {
|
||||
return request({
|
||||
url: '/lock/detail',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
@ -26,26 +26,26 @@
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'SwitchLoading',
|
||||
props: {
|
||||
size: Number
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
show: false
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
open() {
|
||||
this.show = true
|
||||
},
|
||||
close() {
|
||||
this.show = false
|
||||
}
|
||||
}
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
const show = ref(false)
|
||||
|
||||
const open = () => {
|
||||
show.value = true
|
||||
}
|
||||
const close = () => {
|
||||
show.value = false
|
||||
}
|
||||
|
||||
defineProps({
|
||||
size: {
|
||||
type: Number,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
|
||||
defineExpose({ open, close })
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
@ -19,15 +19,21 @@
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
|
||||
const $bluetooth = useBluetoothStore()
|
||||
const $user = useUserStore()
|
||||
const $basic = useBasicStore()
|
||||
|
||||
const pending = ref(false)
|
||||
|
||||
const show = ref(false)
|
||||
|
||||
onMounted(async () => {
|
||||
const netWork = await $basic.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '加载中'
|
||||
})
|
||||
@ -45,6 +51,8 @@
|
||||
$bluetooth.closeBluetoothConnection()
|
||||
if (lockStatus === 0) {
|
||||
show.value = true
|
||||
} else if (lockStatus === -21) {
|
||||
/* empty */
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '获取锁时间失败,请返回重试',
|
||||
@ -61,9 +69,13 @@
|
||||
})
|
||||
|
||||
const update = async () => {
|
||||
if (pending.value && show.value) return
|
||||
if (pending.value) return
|
||||
const netWork = await $basic.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
uni.showLoading({
|
||||
title: '更新中'
|
||||
title: '校准中'
|
||||
})
|
||||
pending.value = true
|
||||
const { code, message } = await $bluetooth.updateServerTimestamp()
|
||||
@ -84,19 +96,22 @@
|
||||
indate: $bluetooth.serverTimestamp * 1000
|
||||
}
|
||||
})
|
||||
show.value = true
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
title: '校准成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (lockStatus === -21) {
|
||||
/* empty */
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
pending.value = false
|
||||
uni.showToast({
|
||||
title: '更新失败',
|
||||
title: '校准失败,请保持在锁附近',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
uni.hideLoading()
|
||||
pending.value = false
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
|
||||
@ -1,143 +1,191 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="days" v-if="currentLockInfo.days">钥匙将在{{ currentLockInfo.days }}天后失效</view>
|
||||
<view class="lock-name">{{ currentLockInfo.lockAlias }}</view>
|
||||
<view class="top">
|
||||
<image
|
||||
class="top-background"
|
||||
src="/static/images/background_main.jpg"
|
||||
mode="aspectFill"
|
||||
></image>
|
||||
<view style="width: 100%; height: 50rpx">
|
||||
<view class="power" @click="powerTip">
|
||||
<image
|
||||
class="power-icon"
|
||||
:src="getPowerIcon(currentLockInfo.electricQuantity)"
|
||||
mode="aspectFill"
|
||||
></image>
|
||||
<view class="power-text">{{ currentLockInfo.electricQuantity }}%</view>
|
||||
<image class="power-tips" src="/static/images/icon_tips.png" mode="aspectFill"></image>
|
||||
<scroll-view
|
||||
v-if="deviceInfo"
|
||||
scroll-y="true"
|
||||
:style="{ height: deviceInfo.screenHeight - deviceInfo.safeArea.top + 'px' }"
|
||||
@refresherrefresh="refresher"
|
||||
:refresher-enabled="true"
|
||||
:refresher-triggered="refresherTriggered"
|
||||
>
|
||||
<view class="days" v-if="$bluetooth.currentLockInfo.days"
|
||||
>钥匙将在{{ $bluetooth.currentLockInfo.days }}天后失效</view
|
||||
>
|
||||
<view class="lock-name">{{ $bluetooth.currentLockInfo.lockAlias }}</view>
|
||||
<view class="top">
|
||||
<image
|
||||
class="top-background"
|
||||
src="/static/images/background_main.jpg"
|
||||
mode="aspectFill"
|
||||
></image>
|
||||
<view style="width: 100%; height: 50rpx">
|
||||
<view class="power" @click="powerTip">
|
||||
<image
|
||||
class="power-icon"
|
||||
:src="$lock.getPowerIcon($bluetooth.currentLockInfo.electricQuantity)"
|
||||
mode="aspectFill"
|
||||
></image>
|
||||
<view class="power-text">{{ $bluetooth.currentLockInfo.electricQuantity }}%</view>
|
||||
<image class="power-tips" src="/static/images/icon_tips.png" mode="aspectFill"></image>
|
||||
</view>
|
||||
</view>
|
||||
<view class="switch" @click="openDoorOperate('open')" @longpress="openDoorOperate('close')">
|
||||
<SwitchLoading :size="220" ref="sLoading"></SwitchLoading>
|
||||
</view>
|
||||
<view class="switch-text">点击开锁,长按闭锁</view>
|
||||
<view class="bottom">
|
||||
<view class="bottom-side">
|
||||
<image class="bottom-icon" src="/static/images/icon_role.png" mode="aspectFill"></image>
|
||||
<view>{{
|
||||
$lock.getRole(
|
||||
$bluetooth.currentLockInfo.userType,
|
||||
$bluetooth.currentLockInfo.keyRight
|
||||
)
|
||||
}}</view>
|
||||
</view>
|
||||
<view class="bottom-side">
|
||||
<image
|
||||
class="bottom-icon"
|
||||
:src="
|
||||
$bluetooth.currentLockInfo.appUnlockOnline
|
||||
? '/static/images/icon_cloud_active.png'
|
||||
: '/static/images/icon_cloud.png'
|
||||
"
|
||||
mode="aspectFill"
|
||||
style="width: 40rpx; height: 40rpx"
|
||||
></image>
|
||||
<view
|
||||
:style="{
|
||||
color: $bluetooth.currentLockInfo.appUnlockOnline ? '#63b8af' : '#a3a3a3'
|
||||
}"
|
||||
>手机需联网</view
|
||||
>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="switch" @click="openDoorOperate('open')" @longpress="openDoorOperate('close')">
|
||||
<SwitchLoading :size="220" ref="loading"></SwitchLoading>
|
||||
</view>
|
||||
<view class="switch-text">点击开锁,长按闭锁</view>
|
||||
<view class="bottom">
|
||||
<view class="bottom-side">
|
||||
<image class="bottom-icon" src="/static/images/icon_role.png" mode="aspectFill"></image>
|
||||
<view>{{ getRole(currentLockInfo.userType, currentLockInfo.keyRight) }}</view>
|
||||
<view class="menu">
|
||||
<view class="menu-title">
|
||||
<image class="menu-image" src="/static/images/icon_menu.png"></image>
|
||||
<view>功能</view>
|
||||
</view>
|
||||
<view class="bottom-side">
|
||||
<image
|
||||
class="bottom-icon"
|
||||
:src="
|
||||
currentLockInfo.lockSetting.appUnlockOnline
|
||||
? '/static/images/icon_cloud_active.png'
|
||||
: '/static/images/icon_cloud.png'
|
||||
"
|
||||
mode="aspectFill"
|
||||
style="width: 40rpx; height: 40rpx"
|
||||
></image>
|
||||
<view class="menu-main">
|
||||
<view
|
||||
:style="{ color: currentLockInfo.lockSetting.appUnlockOnline ? '#63b8af' : '#a3a3a3' }"
|
||||
>手机需联网</view
|
||||
v-if="$bluetooth.currentLockInfo.keyRight === 1"
|
||||
class="menu-main-view"
|
||||
@click="$basic.routeJump({ name: 'keyList' })"
|
||||
>
|
||||
<image
|
||||
class="menu-main-image transform-scale-90"
|
||||
src="/static/images/icon_key.png"
|
||||
></image>
|
||||
<view>电子钥匙</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="
|
||||
$bluetooth.currentLockInfo.lockFeature.password &&
|
||||
$bluetooth.currentLockInfo.keyRight === 1
|
||||
"
|
||||
class="menu-main-view"
|
||||
@click="$basic.routeJump({ name: 'passwordList' })"
|
||||
>
|
||||
<image class="menu-main-image" src="/static/images/icon_password_green.png"></image>
|
||||
<view>密码</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="
|
||||
$bluetooth.currentLockInfo.lockFeature.icCard &&
|
||||
$bluetooth.currentLockInfo.keyRight === 1
|
||||
"
|
||||
class="menu-main-view"
|
||||
@click="$basic.routeJump({ name: 'cardList' })"
|
||||
>
|
||||
<image
|
||||
class="menu-main-image transform-scale-110"
|
||||
src="/static/images/icon_card.png"
|
||||
></image>
|
||||
<view>卡</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="
|
||||
$bluetooth.currentLockInfo.lockFeature.fingerprint &&
|
||||
$bluetooth.currentLockInfo.keyRight === 1
|
||||
"
|
||||
class="menu-main-view"
|
||||
@click="$basic.routeJump({ name: 'fingerprintList' })"
|
||||
>
|
||||
<image class="menu-main-image" src="/static/images/icon_fingerprint.png"></image>
|
||||
<view>指纹</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="
|
||||
$bluetooth.currentLockInfo.lockFeature.bluetoothRemoteControl &&
|
||||
$bluetooth.currentLockInfo.keyRight === 1
|
||||
"
|
||||
class="menu-main-view transform-scale-110"
|
||||
@click="$basic.routeJump({ name: 'remoteList' })"
|
||||
>
|
||||
<image class="menu-main-image" src="/static/images/icon_remote.png"></image>
|
||||
<view>遥控</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="
|
||||
$bluetooth.currentLockInfo.lockFeature.d3Face &&
|
||||
$bluetooth.currentLockInfo.keyRight === 1
|
||||
"
|
||||
class="menu-main-view"
|
||||
@click="$basic.routeJump({ name: 'faceList' })"
|
||||
>
|
||||
<image class="menu-main-image" src="/static/images/icon_face.png"></image>
|
||||
<view>人脸</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="
|
||||
$bluetooth.currentLockInfo.lockFeature.palmVein &&
|
||||
$bluetooth.currentLockInfo.keyRight === 1
|
||||
"
|
||||
class="menu-main-view"
|
||||
@click="$basic.routeJump({ name: 'palmVeinList' })"
|
||||
>
|
||||
<image class="menu-main-image" src="/static/images/icon_palm_vein.png"></image>
|
||||
<view>掌静脉</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="$bluetooth.currentLockInfo.userType === 110301"
|
||||
class="menu-main-view"
|
||||
@click="$basic.routeJump({ name: 'adminList' })"
|
||||
>
|
||||
<image
|
||||
class="menu-main-image transform-scale-140"
|
||||
src="/static/images/icon_admin_black.png"
|
||||
></image>
|
||||
<view>授权管理员</view>
|
||||
</view>
|
||||
<view
|
||||
class="menu-main-view transform-scale-105"
|
||||
@click="$basic.routeJump({ name: 'recordList' })"
|
||||
>
|
||||
<image class="menu-main-image" src="/static/images/icon_record.png"></image>
|
||||
<view>操作记录</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="$bluetooth.currentLockInfo.keyRight === 1"
|
||||
class="menu-main-view"
|
||||
@click="$basic.routeJump({ name: 'messageReminder' })"
|
||||
>
|
||||
<image
|
||||
class="menu-main-image transform-scale-110"
|
||||
src="/static/images/icon_remind.png"
|
||||
></image>
|
||||
<view>消息提醒</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="menu">
|
||||
<view class="menu-title">
|
||||
<image class="menu-image" src="/static/images/icon_menu.png"></image>
|
||||
<view>功能</view>
|
||||
<view class="setting" @click="$basic.routeJump({ name: 'setting' })">
|
||||
<image class="setting-image" src="/static/images/icon_setting.png"></image>
|
||||
<view class="setting-text">设置</view>
|
||||
<image class="setting-arrow" mode="aspectFill" src="/static/images/icon_arrow.png"></image>
|
||||
</view>
|
||||
<view class="menu-main">
|
||||
<view
|
||||
v-if="currentLockInfo.keyRight === 1"
|
||||
class="menu-main-view"
|
||||
@click="routeJump({ name: 'keyList' })"
|
||||
>
|
||||
<image
|
||||
class="menu-main-image transform-scale-90"
|
||||
src="/static/images/icon_key.png"
|
||||
></image>
|
||||
<view>电子钥匙</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="currentLockInfo.lockFeature.password && currentLockInfo.keyRight === 1"
|
||||
class="menu-main-view"
|
||||
@click="routeJump({ name: 'passwordList' })"
|
||||
>
|
||||
<image class="menu-main-image" src="/static/images/icon_password_green.png"></image>
|
||||
<view>密码</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="currentLockInfo.lockFeature.icCard && currentLockInfo.keyRight === 1"
|
||||
class="menu-main-view"
|
||||
@click="routeJump({ name: 'cardList' })"
|
||||
>
|
||||
<image
|
||||
class="menu-main-image transform-scale-110"
|
||||
src="/static/images/icon_card.png"
|
||||
></image>
|
||||
<view>卡</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="currentLockInfo.lockFeature.fingerprint && currentLockInfo.keyRight === 1"
|
||||
class="menu-main-view"
|
||||
@click="routeJump({ name: 'fingerprintList' })"
|
||||
>
|
||||
<image class="menu-main-image" src="/static/images/icon_fingerprint.png"></image>
|
||||
<view>指纹</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="
|
||||
currentLockInfo.lockFeature.bluetoothRemoteControl && currentLockInfo.keyRight === 1
|
||||
"
|
||||
class="menu-main-view transform-scale-110"
|
||||
@click="routeJump({ name: 'remoteList' })"
|
||||
>
|
||||
<image class="menu-main-image" src="/static/images/icon_remote.png"></image>
|
||||
<view>遥控</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="currentLockInfo.lockFeature.d3Face && currentLockInfo.keyRight === 1"
|
||||
class="menu-main-view"
|
||||
@click="routeJump({ name: 'faceList' })"
|
||||
>
|
||||
<image class="menu-main-image" src="/static/images/icon_face.png"></image>
|
||||
<view>人脸</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="currentLockInfo.lockFeature.palmVein && currentLockInfo.keyRight === 1"
|
||||
class="menu-main-view"
|
||||
@click="routeJump({ name: 'palmVeinList' })"
|
||||
>
|
||||
<image class="menu-main-image" src="/static/images/icon_palm_vein.png"></image>
|
||||
<view>掌静脉</view>
|
||||
</view>
|
||||
<view
|
||||
v-if="currentLockInfo.userType === 110301"
|
||||
class="menu-main-view"
|
||||
@click="routeJump({ name: 'adminList' })"
|
||||
>
|
||||
<image
|
||||
class="menu-main-image transform-scale-140"
|
||||
src="/static/images/icon_admin_black.png"
|
||||
></image>
|
||||
<view>授权管理员</view>
|
||||
</view>
|
||||
<view class="menu-main-view transform-scale-105" @click="routeJump({ name: 'recordList' })">
|
||||
<image class="menu-main-image" src="/static/images/icon_record.png"></image>
|
||||
<view>操作记录</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="setting" @click="routeJump({ name: 'setting' })">
|
||||
<image class="setting-image" src="/static/images/icon_setting.png"></image>
|
||||
<view class="setting-text">设置</view>
|
||||
<image class="setting-arrow" mode="aspectFill" src="/static/images/icon_arrow.png"></image>
|
||||
</view>
|
||||
</scroll-view>
|
||||
<up-popup
|
||||
:show="show"
|
||||
@close="closePopup"
|
||||
@ -149,14 +197,14 @@
|
||||
<image
|
||||
class="popup-background"
|
||||
:src="
|
||||
type === 'close'
|
||||
typeValue === 'close'
|
||||
? '/static/images/background_close_door.png'
|
||||
: '/static/images/background_open_door.png'
|
||||
"
|
||||
mode="aspectFill"
|
||||
/>
|
||||
<view>
|
||||
<view class="popup-name">{{ currentLockInfo.lockAlias }}</view>
|
||||
<view class="popup-name">{{ $bluetooth.currentLockInfo.lockAlias }}</view>
|
||||
<view class="popup-time">{{ timeFormat('', 'mm/dd h:M') }}</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -164,190 +212,202 @@
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapState, mapActions } from 'pinia'
|
||||
<script setup>
|
||||
import { timeFormat } from 'uview-plus'
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
import SwitchLoading from '@/components/SwitchLoading/SwitchLoading.vue'
|
||||
import { useLockStore } from '@/stores/lock'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { getLockNetTokenRequest } from '@/api/lock'
|
||||
import { getLockDetailRequest, getLockNetTokenRequest } from '@/api/lock'
|
||||
import { deleteKeyRequest } from '@/api/key'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
SwitchLoading
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
time: 0,
|
||||
onlineToken: '0',
|
||||
pending: false,
|
||||
show: false,
|
||||
type: ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']),
|
||||
...mapState(useUserStore, ['userInfo']),
|
||||
...mapState(useLockStore, ['lockSearch'])
|
||||
},
|
||||
onLoad() {
|
||||
this.getServeTime()
|
||||
},
|
||||
methods: {
|
||||
timeFormat,
|
||||
...mapActions(useLockStore, ['getRole', 'updateLockSearch', 'getLockList', 'getPowerIcon']),
|
||||
...mapActions(useBluetoothStore, [
|
||||
'openDoor',
|
||||
'updateServerTimestamp',
|
||||
'closeBluetoothConnection',
|
||||
'syncRecord'
|
||||
]),
|
||||
...mapActions(useBasicStore, ['routeJump', 'backAndToast', 'getNetworkType']),
|
||||
closePopup() {
|
||||
this.show = false
|
||||
},
|
||||
powerTip() {
|
||||
const that = this
|
||||
const time = timeFormat(that.currentLockInfo.electricQuantityDate, 'yyyy-mm-dd h:M')
|
||||
console.log('更新时间', that.currentLockInfo.electricQuantityDate, time)
|
||||
uni.showModal({
|
||||
title: '锁电量更新时间',
|
||||
content: time,
|
||||
showCancel: false
|
||||
})
|
||||
},
|
||||
async getNetToken() {
|
||||
const { code, data, message } = await getLockNetTokenRequest({
|
||||
lockId: this.currentLockInfo.lockId
|
||||
})
|
||||
if (code === 0) {
|
||||
this.onlineToken = data.token
|
||||
return true
|
||||
}
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
return false
|
||||
},
|
||||
async getServeTime() {
|
||||
const { code, data } = await this.updateServerTimestamp()
|
||||
if (code === 0) {
|
||||
this.time = parseInt((data.date - new Date().getTime()) / 1000, 10)
|
||||
}
|
||||
},
|
||||
async openDoorOperate(type) {
|
||||
const timestamp = new Date().getTime()
|
||||
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) {
|
||||
return
|
||||
}
|
||||
if (this.currentLockInfo.lockSetting.appUnlockOnline && type !== 'close') {
|
||||
const netWork = await this.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
}
|
||||
uni.vibrateLong()
|
||||
this.pending = true
|
||||
this.$refs.loading.open()
|
||||
if (type === 'close') {
|
||||
uni.showToast({
|
||||
title: `正在尝试闭锁……`,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
if (this.currentLockInfo.lockSetting.appUnlockOnline && type !== 'close') {
|
||||
const result = await this.getNetToken()
|
||||
if (!result) {
|
||||
this.$refs.loading.close()
|
||||
this.pending = false
|
||||
return
|
||||
}
|
||||
}
|
||||
let openMode
|
||||
if (type === 'close') {
|
||||
openMode = this.currentLockInfo.lockSetting.appUnlockOnline ? 33 : 32
|
||||
} else {
|
||||
openMode = this.currentLockInfo.lockSetting.appUnlockOnline ? 1 : 0
|
||||
}
|
||||
const { code } = await this.openDoor({
|
||||
name: this.currentLockInfo.name,
|
||||
uid: this.userInfo.uid.toString(),
|
||||
openMode,
|
||||
openTime: parseInt(new Date().getTime() / 1000, 10) + this.time,
|
||||
onlineToken: this.onlineToken
|
||||
})
|
||||
this.syncRecord({
|
||||
keyId: this.currentLockInfo.toString(),
|
||||
uid: this.userInfo.uid.toString()
|
||||
}).then(() => {
|
||||
this.closeBluetoothConnection()
|
||||
})
|
||||
if (type === 'open') {
|
||||
uni.reportEvent('open_door', {
|
||||
result: code,
|
||||
duration: new Date().getTime() - timestamp
|
||||
})
|
||||
} else if (type === 'close') {
|
||||
uni.reportEvent('close_door', {
|
||||
result: code,
|
||||
duration: new Date().getTime() - timestamp
|
||||
})
|
||||
}
|
||||
if (code === 0) {
|
||||
this.show = true
|
||||
this.type = type
|
||||
setTimeout(() => {
|
||||
this.show = false
|
||||
}, 3000)
|
||||
if (this.currentLockInfo.keyType === 3) {
|
||||
const { code: deleteKeyCode } = await deleteKeyRequest({
|
||||
keyId: this.keyId
|
||||
})
|
||||
if (deleteKeyCode === 0) {
|
||||
this.updateLockSearch({
|
||||
...this.lockSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
this.getLockList(this.lockSearch)
|
||||
this.backAndToast('单次钥匙已在被使用后删除', 1)
|
||||
}
|
||||
}
|
||||
} else if (code === 7) {
|
||||
uni.showToast({
|
||||
title: `钥匙过期`,
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (code === 13) {
|
||||
uni.showToast({
|
||||
title: `钥匙当前不可用`,
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (code === -1) {
|
||||
uni.showToast({
|
||||
title: `${type === 'close' ? '关' : '开'}锁失败,请保证在锁附近`,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
this.$refs.loading.close()
|
||||
this.pending = false
|
||||
const $bluetooth = useBluetoothStore()
|
||||
const $basic = useBasicStore()
|
||||
const $lock = useLockStore()
|
||||
const $user = useUserStore()
|
||||
|
||||
const sLoading = ref(null)
|
||||
|
||||
const time = ref(0)
|
||||
const onlineToken = ref('0')
|
||||
const pending = ref(false)
|
||||
const show = ref(false)
|
||||
const typeValue = ref('')
|
||||
const refresherTriggered = ref(false)
|
||||
|
||||
const deviceInfo = ref(null)
|
||||
|
||||
onMounted(async () => {
|
||||
deviceInfo.value = await $basic.getDeviceInfo()
|
||||
await getServeTime()
|
||||
})
|
||||
|
||||
const openDoorOperate = async type => {
|
||||
const timestamp = new Date().getTime()
|
||||
if (
|
||||
$bluetooth.currentLockInfo.faceAuthentication === 1 &&
|
||||
$bluetooth.currentLockInfo.nextFaceValidateTime <= new Date().getTime() + time.value * 1000 &&
|
||||
$bluetooth.currentLockInfo.nextFaceValidateTime !== 0
|
||||
) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '开门前需进行实名认证,小程序暂不支持,请使用APP认证开门',
|
||||
showCancel: false
|
||||
})
|
||||
return
|
||||
}
|
||||
if (pending.value) {
|
||||
return
|
||||
}
|
||||
if ($bluetooth.currentLockInfo.appUnlockOnline && type !== 'close') {
|
||||
const netWork = await $basic.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
}
|
||||
uni.vibrateLong()
|
||||
pending.value = true
|
||||
sLoading.value.open()
|
||||
if (type === 'close') {
|
||||
uni.showToast({
|
||||
title: `正在尝试闭锁……`,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
if ($bluetooth.currentLockInfo.appUnlockOnline && type !== 'close') {
|
||||
const result = await getNetToken()
|
||||
if (!result) {
|
||||
sLoading.value.close()
|
||||
pending.value = false
|
||||
return
|
||||
}
|
||||
}
|
||||
let openMode
|
||||
if (type === 'close') {
|
||||
openMode = $bluetooth.currentLockInfo.appUnlockOnline ? 33 : 32
|
||||
} else {
|
||||
openMode = $bluetooth.currentLockInfo.appUnlockOnline ? 1 : 0
|
||||
}
|
||||
const { code } = await $bluetooth.openDoor({
|
||||
name: $bluetooth.currentLockInfo.name,
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
openMode,
|
||||
openTime: parseInt(new Date().getTime() / 1000, 10) + time.value,
|
||||
onlineToken: onlineToken.value
|
||||
})
|
||||
$bluetooth
|
||||
.syncRecord({
|
||||
keyId: $bluetooth.currentLockInfo.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString()
|
||||
})
|
||||
.then(() => {
|
||||
$bluetooth.closeBluetoothConnection()
|
||||
})
|
||||
if (type === 'open') {
|
||||
uni.reportEvent('open_door', {
|
||||
result: code,
|
||||
duration: new Date().getTime() - timestamp
|
||||
})
|
||||
} else if (type === 'close') {
|
||||
uni.reportEvent('close_door', {
|
||||
result: code,
|
||||
duration: new Date().getTime() - timestamp
|
||||
})
|
||||
}
|
||||
if (code === 0) {
|
||||
show.value = true
|
||||
typeValue.value = type
|
||||
setTimeout(() => {
|
||||
show.value = false
|
||||
}, 3000)
|
||||
if ($bluetooth.currentLockInfo.keyType === 3) {
|
||||
const { code: deleteKeyCode } = await deleteKeyRequest({
|
||||
keyId: $bluetooth.keyId
|
||||
})
|
||||
if (deleteKeyCode === 0) {
|
||||
$lock.updateLockSearch({
|
||||
...$lock.lockSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
$lock.getLockList($lock.lockSearch)
|
||||
$basic.backAndToast('单次钥匙已在被使用后删除', 1)
|
||||
}
|
||||
}
|
||||
} else if (code === 7) {
|
||||
uni.showToast({
|
||||
title: `钥匙过期`,
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (code === 13) {
|
||||
uni.showToast({
|
||||
title: `钥匙当前不可用`,
|
||||
icon: 'none'
|
||||
})
|
||||
} else if (code === -1) {
|
||||
uni.showToast({
|
||||
title: `${type === 'close' ? '关' : '开'}锁失败,请保证在锁附近`,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
sLoading.value.close()
|
||||
pending.value = false
|
||||
}
|
||||
|
||||
const closePopup = () => {
|
||||
show.value = false
|
||||
}
|
||||
|
||||
const powerTip = () => {
|
||||
const time = timeFormat($bluetooth.currentLockInfo.electricQuantityDate, 'yyyy-mm-dd h:M')
|
||||
uni.showModal({
|
||||
title: '锁电量更新时间',
|
||||
content: time,
|
||||
showCancel: false
|
||||
})
|
||||
}
|
||||
|
||||
const getNetToken = async () => {
|
||||
const { code, data, message } = await getLockNetTokenRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId
|
||||
})
|
||||
if (code === 0) {
|
||||
onlineToken.value = data.token
|
||||
return true
|
||||
}
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
const getServeTime = async () => {
|
||||
const { code, data } = await $bluetooth.updateServerTimestamp()
|
||||
if (code === 0) {
|
||||
time.value = parseInt((data.date - new Date().getTime()) / 1000, 10)
|
||||
}
|
||||
}
|
||||
|
||||
const refresher = async () => {
|
||||
refresherTriggered.value = true
|
||||
const { code, data, message } = await getLockDetailRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId
|
||||
})
|
||||
if (code === 0) {
|
||||
$bluetooth.updateCurrentLockInfo({ ...$bluetooth.currentLockInfo, ...data })
|
||||
uni.showToast({
|
||||
title: '刷新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
refresherTriggered.value = false
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@ -325,8 +325,38 @@
|
||||
})
|
||||
let featureBit
|
||||
if (key === 'unlockReminder') {
|
||||
featureBit = 47
|
||||
} else if (key === 'appUnlockOnline') {
|
||||
const { code, message } = await updateLockSettingRequest({
|
||||
lockId: $bluetooth.currentLockInfo.lockId,
|
||||
[key]: $bluetooth.currentLockSetting.lockSettingInfo[key] === 1 ? 0 : 1
|
||||
})
|
||||
pending.value = false
|
||||
uni.hideLoading()
|
||||
if (code === 0) {
|
||||
$bluetooth.updateCurrentLockSetting({
|
||||
...$bluetooth.currentLockSetting,
|
||||
lockSettingInfo: {
|
||||
...$bluetooth.currentLockSetting.lockSettingInfo,
|
||||
[key]: $bluetooth.currentLockSetting.lockSettingInfo[key] === 1 ? 0 : 1
|
||||
}
|
||||
})
|
||||
$lock.updateLockSearch({
|
||||
...$lock.lockSearch,
|
||||
pageNo: 1
|
||||
})
|
||||
$lock.getLockList($lock.lockSearch)
|
||||
uni.showToast({
|
||||
title: '更新成功',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
if (key === 'appUnlockOnline') {
|
||||
featureBit = 55
|
||||
} else if (key === 'remoteUnlock') {
|
||||
featureBit = 28
|
||||
@ -373,6 +403,9 @@
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} else if (code === -21) {
|
||||
pending.value = false
|
||||
uni.hideLoading()
|
||||
} else {
|
||||
pending.value = false
|
||||
uni.hideLoading()
|
||||
|
||||
@ -112,11 +112,10 @@
|
||||
const data = JSON.parse(options.info)
|
||||
if (data.startDate) {
|
||||
startDate.value = data.startDate
|
||||
endDate.value = data.endDate === 0 ? data.startDate + 24 * 60 * 60 * 1000 : data.endDate
|
||||
endDate.value = data.endDate === 0 ? data.startDate : data.endDate
|
||||
info.value = data
|
||||
defaultStartDate.value = data.startDate
|
||||
defaultEndDate.value =
|
||||
data.endDate === 0 ? data.startDate + 24 * 60 * 60 * 1000 : data.endDate
|
||||
defaultEndDate.value = data.endDate === 0 ? data.startDate : data.endDate
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
BIN
static/images/icon_remind.png
Normal file
BIN
static/images/icon_remind.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.7 KiB |
@ -1476,7 +1476,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
console.log('写入未执行', this.bluetoothStatus)
|
||||
this.getBluetoothStatus()
|
||||
return {
|
||||
code: -1
|
||||
code: -21
|
||||
}
|
||||
}
|
||||
|
||||
@ -2920,7 +2920,7 @@ export const useBluetoothStore = defineStore('ble', {
|
||||
console.log('写入未执行', this.bluetoothStatus)
|
||||
this.getBluetoothStatus()
|
||||
return {
|
||||
code: -1
|
||||
code: -21
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user