bug修复
This commit is contained in:
parent
932654b706
commit
f2f27b256b
@ -46,3 +46,12 @@ export function lockUserListRequest(data) {
|
|||||||
data
|
data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取锁详情
|
||||||
|
export function getLockDetailRequest(data) {
|
||||||
|
return request({
|
||||||
|
url: '/lock/detail',
|
||||||
|
method: 'POST',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@ -26,26 +26,26 @@
|
|||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
export default {
|
import { ref } from 'vue'
|
||||||
name: 'SwitchLoading',
|
|
||||||
props: {
|
const show = ref(false)
|
||||||
size: Number
|
|
||||||
},
|
const open = () => {
|
||||||
data() {
|
show.value = true
|
||||||
return {
|
|
||||||
show: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
open() {
|
|
||||||
this.show = true
|
|
||||||
},
|
|
||||||
close() {
|
|
||||||
this.show = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
const close = () => {
|
||||||
|
show.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
size: {
|
||||||
|
type: Number,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
defineExpose({ open, close })
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@ -19,15 +19,21 @@
|
|||||||
import { timeFormat } from 'uview-plus'
|
import { timeFormat } from 'uview-plus'
|
||||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
|
import { useBasicStore } from '@/stores/basic'
|
||||||
|
|
||||||
const $bluetooth = useBluetoothStore()
|
const $bluetooth = useBluetoothStore()
|
||||||
const $user = useUserStore()
|
const $user = useUserStore()
|
||||||
|
const $basic = useBasicStore()
|
||||||
|
|
||||||
const pending = ref(false)
|
const pending = ref(false)
|
||||||
|
|
||||||
const show = ref(false)
|
const show = ref(false)
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
const netWork = await $basic.getNetworkType()
|
||||||
|
if (!netWork) {
|
||||||
|
return
|
||||||
|
}
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '加载中'
|
title: '加载中'
|
||||||
})
|
})
|
||||||
@ -45,6 +51,8 @@
|
|||||||
$bluetooth.closeBluetoothConnection()
|
$bluetooth.closeBluetoothConnection()
|
||||||
if (lockStatus === 0) {
|
if (lockStatus === 0) {
|
||||||
show.value = true
|
show.value = true
|
||||||
|
} else if (lockStatus === -21) {
|
||||||
|
/* empty */
|
||||||
} else {
|
} else {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '获取锁时间失败,请返回重试',
|
title: '获取锁时间失败,请返回重试',
|
||||||
@ -61,9 +69,13 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
const update = async () => {
|
const update = async () => {
|
||||||
if (pending.value && show.value) return
|
if (pending.value) return
|
||||||
|
const netWork = await $basic.getNetworkType()
|
||||||
|
if (!netWork) {
|
||||||
|
return
|
||||||
|
}
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '更新中'
|
title: '校准中'
|
||||||
})
|
})
|
||||||
pending.value = true
|
pending.value = true
|
||||||
const { code, message } = await $bluetooth.updateServerTimestamp()
|
const { code, message } = await $bluetooth.updateServerTimestamp()
|
||||||
@ -84,19 +96,22 @@
|
|||||||
indate: $bluetooth.serverTimestamp * 1000
|
indate: $bluetooth.serverTimestamp * 1000
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
show.value = true
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '更新成功',
|
title: '校准成功',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
|
} else if (lockStatus === -21) {
|
||||||
|
/* empty */
|
||||||
} else {
|
} else {
|
||||||
uni.hideLoading()
|
|
||||||
pending.value = false
|
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '更新失败',
|
title: '校准失败,请保持在锁附近',
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
uni.hideLoading()
|
||||||
|
pending.value = false
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: message,
|
title: message,
|
||||||
icon: 'none'
|
icon: 'none'
|
||||||
|
|||||||
@ -1,143 +1,191 @@
|
|||||||
<template>
|
<template>
|
||||||
<view>
|
<view>
|
||||||
<view class="days" v-if="currentLockInfo.days">钥匙将在{{ currentLockInfo.days }}天后失效</view>
|
<scroll-view
|
||||||
<view class="lock-name">{{ currentLockInfo.lockAlias }}</view>
|
v-if="deviceInfo"
|
||||||
<view class="top">
|
scroll-y="true"
|
||||||
<image
|
:style="{ height: deviceInfo.screenHeight - deviceInfo.safeArea.top + 'px' }"
|
||||||
class="top-background"
|
@refresherrefresh="refresher"
|
||||||
src="/static/images/background_main.jpg"
|
:refresher-enabled="true"
|
||||||
mode="aspectFill"
|
:refresher-triggered="refresherTriggered"
|
||||||
></image>
|
>
|
||||||
<view style="width: 100%; height: 50rpx">
|
<view class="days" v-if="$bluetooth.currentLockInfo.days"
|
||||||
<view class="power" @click="powerTip">
|
>钥匙将在{{ $bluetooth.currentLockInfo.days }}天后失效</view
|
||||||
<image
|
>
|
||||||
class="power-icon"
|
<view class="lock-name">{{ $bluetooth.currentLockInfo.lockAlias }}</view>
|
||||||
:src="getPowerIcon(currentLockInfo.electricQuantity)"
|
<view class="top">
|
||||||
mode="aspectFill"
|
<image
|
||||||
></image>
|
class="top-background"
|
||||||
<view class="power-text">{{ currentLockInfo.electricQuantity }}%</view>
|
src="/static/images/background_main.jpg"
|
||||||
<image class="power-tips" src="/static/images/icon_tips.png" mode="aspectFill"></image>
|
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>
|
</view>
|
||||||
<view class="switch" @click="openDoorOperate('open')" @longpress="openDoorOperate('close')">
|
<view class="menu">
|
||||||
<SwitchLoading :size="220" ref="loading"></SwitchLoading>
|
<view class="menu-title">
|
||||||
</view>
|
<image class="menu-image" src="/static/images/icon_menu.png"></image>
|
||||||
<view class="switch-text">点击开锁,长按闭锁</view>
|
<view>功能</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>
|
</view>
|
||||||
<view class="bottom-side">
|
<view class="menu-main">
|
||||||
<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
|
<view
|
||||||
:style="{ color: currentLockInfo.lockSetting.appUnlockOnline ? '#63b8af' : '#a3a3a3' }"
|
v-if="$bluetooth.currentLockInfo.keyRight === 1"
|
||||||
>手机需联网</view
|
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>
|
||||||
</view>
|
<view class="setting" @click="$basic.routeJump({ name: 'setting' })">
|
||||||
<view class="menu">
|
<image class="setting-image" src="/static/images/icon_setting.png"></image>
|
||||||
<view class="menu-title">
|
<view class="setting-text">设置</view>
|
||||||
<image class="menu-image" src="/static/images/icon_menu.png"></image>
|
<image class="setting-arrow" mode="aspectFill" src="/static/images/icon_arrow.png"></image>
|
||||||
<view>功能</view>
|
|
||||||
</view>
|
</view>
|
||||||
<view class="menu-main">
|
</scroll-view>
|
||||||
<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>
|
|
||||||
<up-popup
|
<up-popup
|
||||||
:show="show"
|
:show="show"
|
||||||
@close="closePopup"
|
@close="closePopup"
|
||||||
@ -149,14 +197,14 @@
|
|||||||
<image
|
<image
|
||||||
class="popup-background"
|
class="popup-background"
|
||||||
:src="
|
:src="
|
||||||
type === 'close'
|
typeValue === 'close'
|
||||||
? '/static/images/background_close_door.png'
|
? '/static/images/background_close_door.png'
|
||||||
: '/static/images/background_open_door.png'
|
: '/static/images/background_open_door.png'
|
||||||
"
|
"
|
||||||
mode="aspectFill"
|
mode="aspectFill"
|
||||||
/>
|
/>
|
||||||
<view>
|
<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 class="popup-time">{{ timeFormat('', 'mm/dd h:M') }}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@ -164,190 +212,202 @@
|
|||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script setup>
|
||||||
import { mapState, mapActions } from 'pinia'
|
|
||||||
import { timeFormat } from 'uview-plus'
|
import { timeFormat } from 'uview-plus'
|
||||||
|
import { onMounted, ref } from 'vue'
|
||||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||||
import { useBasicStore } from '@/stores/basic'
|
import { useBasicStore } from '@/stores/basic'
|
||||||
import SwitchLoading from '@/components/SwitchLoading/SwitchLoading.vue'
|
import SwitchLoading from '@/components/SwitchLoading/SwitchLoading.vue'
|
||||||
import { useLockStore } from '@/stores/lock'
|
import { useLockStore } from '@/stores/lock'
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
import { getLockNetTokenRequest } from '@/api/lock'
|
import { getLockDetailRequest, getLockNetTokenRequest } from '@/api/lock'
|
||||||
import { deleteKeyRequest } from '@/api/key'
|
import { deleteKeyRequest } from '@/api/key'
|
||||||
|
|
||||||
export default {
|
const $bluetooth = useBluetoothStore()
|
||||||
components: {
|
const $basic = useBasicStore()
|
||||||
SwitchLoading
|
const $lock = useLockStore()
|
||||||
},
|
const $user = useUserStore()
|
||||||
data() {
|
|
||||||
return {
|
const sLoading = ref(null)
|
||||||
time: 0,
|
|
||||||
onlineToken: '0',
|
const time = ref(0)
|
||||||
pending: false,
|
const onlineToken = ref('0')
|
||||||
show: false,
|
const pending = ref(false)
|
||||||
type: ''
|
const show = ref(false)
|
||||||
}
|
const typeValue = ref('')
|
||||||
},
|
const refresherTriggered = ref(false)
|
||||||
computed: {
|
|
||||||
...mapState(useBluetoothStore, ['currentLockInfo', 'keyId']),
|
const deviceInfo = ref(null)
|
||||||
...mapState(useUserStore, ['userInfo']),
|
|
||||||
...mapState(useLockStore, ['lockSearch'])
|
onMounted(async () => {
|
||||||
},
|
deviceInfo.value = await $basic.getDeviceInfo()
|
||||||
onLoad() {
|
await getServeTime()
|
||||||
this.getServeTime()
|
})
|
||||||
},
|
|
||||||
methods: {
|
const openDoorOperate = async type => {
|
||||||
timeFormat,
|
const timestamp = new Date().getTime()
|
||||||
...mapActions(useLockStore, ['getRole', 'updateLockSearch', 'getLockList', 'getPowerIcon']),
|
if (
|
||||||
...mapActions(useBluetoothStore, [
|
$bluetooth.currentLockInfo.faceAuthentication === 1 &&
|
||||||
'openDoor',
|
$bluetooth.currentLockInfo.nextFaceValidateTime <= new Date().getTime() + time.value * 1000 &&
|
||||||
'updateServerTimestamp',
|
$bluetooth.currentLockInfo.nextFaceValidateTime !== 0
|
||||||
'closeBluetoothConnection',
|
) {
|
||||||
'syncRecord'
|
uni.showModal({
|
||||||
]),
|
title: '提示',
|
||||||
...mapActions(useBasicStore, ['routeJump', 'backAndToast', 'getNetworkType']),
|
content: '开门前需进行实名认证,小程序暂不支持,请使用APP认证开门',
|
||||||
closePopup() {
|
showCancel: false
|
||||||
this.show = false
|
})
|
||||||
},
|
return
|
||||||
powerTip() {
|
}
|
||||||
const that = this
|
if (pending.value) {
|
||||||
const time = timeFormat(that.currentLockInfo.electricQuantityDate, 'yyyy-mm-dd h:M')
|
return
|
||||||
console.log('更新时间', that.currentLockInfo.electricQuantityDate, time)
|
}
|
||||||
uni.showModal({
|
if ($bluetooth.currentLockInfo.appUnlockOnline && type !== 'close') {
|
||||||
title: '锁电量更新时间',
|
const netWork = await $basic.getNetworkType()
|
||||||
content: time,
|
if (!netWork) {
|
||||||
showCancel: false
|
return
|
||||||
})
|
|
||||||
},
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -325,8 +325,38 @@
|
|||||||
})
|
})
|
||||||
let featureBit
|
let featureBit
|
||||||
if (key === 'unlockReminder') {
|
if (key === 'unlockReminder') {
|
||||||
featureBit = 47
|
const { code, message } = await updateLockSettingRequest({
|
||||||
} else if (key === 'appUnlockOnline') {
|
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
|
featureBit = 55
|
||||||
} else if (key === 'remoteUnlock') {
|
} else if (key === 'remoteUnlock') {
|
||||||
featureBit = 28
|
featureBit = 28
|
||||||
@ -373,6 +403,9 @@
|
|||||||
icon: 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
} else if (code === -21) {
|
||||||
|
pending.value = false
|
||||||
|
uni.hideLoading()
|
||||||
} else {
|
} else {
|
||||||
pending.value = false
|
pending.value = false
|
||||||
uni.hideLoading()
|
uni.hideLoading()
|
||||||
|
|||||||
@ -112,11 +112,10 @@
|
|||||||
const data = JSON.parse(options.info)
|
const data = JSON.parse(options.info)
|
||||||
if (data.startDate) {
|
if (data.startDate) {
|
||||||
startDate.value = 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
|
info.value = data
|
||||||
defaultStartDate.value = data.startDate
|
defaultStartDate.value = data.startDate
|
||||||
defaultEndDate.value =
|
defaultEndDate.value = data.endDate === 0 ? data.startDate : data.endDate
|
||||||
data.endDate === 0 ? data.startDate + 24 * 60 * 60 * 1000 : 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)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
return {
|
return {
|
||||||
code: -1
|
code: -21
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2920,7 +2920,7 @@ export const useBluetoothStore = defineStore('ble', {
|
|||||||
console.log('写入未执行', this.bluetoothStatus)
|
console.log('写入未执行', this.bluetoothStatus)
|
||||||
this.getBluetoothStatus()
|
this.getBluetoothStatus()
|
||||||
return {
|
return {
|
||||||
code: -1
|
code: -21
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user