feat: 修复引用bug+优化监控和授权时的UI及文案
This commit is contained in:
parent
28aac335f9
commit
5af784a18d
@ -103,7 +103,7 @@
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
import { createKeyRequest } from '@/api/key'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { transportType } from '@/utils/constants'
|
||||
import { transportType } from '@/constant/transportType'
|
||||
|
||||
const instance = getCurrentInstance().proxy
|
||||
const eventChannel = instance.getOpenerEventChannel()
|
||||
|
||||
@ -127,7 +127,7 @@
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { checkCardNameRequest } from '@/api/card'
|
||||
import { transportType } from '@/utils/constants'
|
||||
import { transportType } from '@/constant/transportType'
|
||||
|
||||
const instance = getCurrentInstance().proxy
|
||||
const eventChannel = instance.getOpenerEventChannel()
|
||||
|
||||
@ -104,7 +104,7 @@
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { checkFaceNameRequest } from '@/api/face'
|
||||
import { transportType } from '@/utils/constants'
|
||||
import { transportType } from '@/constant/transportType'
|
||||
|
||||
const instance = getCurrentInstance().proxy
|
||||
const eventChannel = instance.getOpenerEventChannel()
|
||||
|
||||
@ -127,7 +127,7 @@
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { checkFingerprintNameRequest } from '@/api/fingerprint'
|
||||
import { transportType } from '@/utils/constants'
|
||||
import { transportType } from '@/constant/transportType'
|
||||
|
||||
const instance = getCurrentInstance().proxy
|
||||
const eventChannel = instance.getOpenerEventChannel()
|
||||
|
||||
@ -128,7 +128,7 @@
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { checkPalmVeinNameRequest } from '@/api/palmVein'
|
||||
import { transportType } from '@/utils/constants'
|
||||
import { transportType } from '@/constant/transportType'
|
||||
|
||||
const instance = getCurrentInstance().proxy
|
||||
const eventChannel = instance.getOpenerEventChannel()
|
||||
|
||||
@ -83,7 +83,7 @@
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { checkRemoteNameRequest } from '@/api/remote'
|
||||
import { transportType } from '@/utils/constants'
|
||||
import { transportType } from '@/constant/transportType'
|
||||
|
||||
const instance = getCurrentInstance().proxy
|
||||
const eventChannel = instance.getOpenerEventChannel()
|
||||
|
||||
@ -1,19 +1,20 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="mt-10 text-center text-base font-bold text-[#999]">授权后,设备可呼叫该微信</view>
|
||||
<view class="flex flex-col justify-center items-center pt-[30vh]">
|
||||
<view v-if="requestFinish">
|
||||
<view
|
||||
v-if="!isAuthorized"
|
||||
class="bg-[#63b8af] text-white rounded-full text-center leading-88rpx h-88rpx w-686 mx-4 mt-10"
|
||||
class="bg-[#63b8af] text-white rounded-full text-center leading-88rpx h-88rpx w-686 mx-4"
|
||||
@click="handleAuthorize"
|
||||
>
|
||||
授权
|
||||
</view>
|
||||
<view v-else>
|
||||
<view v-if="!reject" class="text-center text-lg font-bold mt-4">您已授权</view>
|
||||
<view v-if="!reject" class="text-center text-2xl font-bold">您已授权</view>
|
||||
<view v-else>
|
||||
<view class="text-center text-lg font-bold mt-4"> 您已拒绝授权,请去设置中 </view>
|
||||
<view class="text-center text-lg font-bold mt-4"> 打开语音、视频通话提醒开关 </view>
|
||||
<view class="text-center text-lg font-bold mt-6"> 您已拒绝授权,请去设置中 </view>
|
||||
<view class="text-center text-lg font-bold mt-4">
|
||||
打开<text class="text-red">语音、视频通话提醒</text>开关
|
||||
</view>
|
||||
<view
|
||||
class="bg-[#63b8af] text-white rounded-full text-center leading-88rpx h-88rpx w-686 mx-4 mt-10"
|
||||
@click="openSetting"
|
||||
@ -23,6 +24,12 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="requestFinish" class="mt-10 text-center text-base font-bold text-[#999]">
|
||||
授权后,在设备上按下门铃按钮
|
||||
</view>
|
||||
<view v-if="requestFinish" class="mt-4 text-center text-base font-bold text-[#999]">
|
||||
微信会收到视频通话请求
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
|
||||
@ -54,9 +54,9 @@
|
||||
|
||||
<view
|
||||
v-if="isVideoLoaded"
|
||||
class="fixed bottom-[calc(32rpx+env(safe-area-inset-bottom))] bg-[rgba(0,0,0,0.3)] rounded-xl p-4 shadow-lg mx-4 w-622"
|
||||
class="fixed bottom-[calc(32rpx+env(safe-area-inset-bottom))] bg-[rgba(0,0,0,0.3)] rounded-xl p-4 shadow-lg left-1/2 -translate-x-1/2 w-622"
|
||||
>
|
||||
<view class="flex items-center justify-around mx-10">
|
||||
<view class="flex items-center justify-around mx-15">
|
||||
<image
|
||||
@click="isMute = !isMute"
|
||||
:src="
|
||||
@ -72,7 +72,7 @@
|
||||
class="w-48 h-48 p-2"
|
||||
></image>
|
||||
</view>
|
||||
<view class="flex items-center justify-around text-white mt-2">
|
||||
<view class="flex items-center justify-between text-white mt-2 px-10">
|
||||
<view class="flex flex-col items-center" @longpress="startVoice" @touchend="stopVoice">
|
||||
<view class="bg-white w-80 h-80 rounded-full flex items-center justify-center">
|
||||
<image
|
||||
@ -84,13 +84,13 @@
|
||||
class="w-55 h-55"
|
||||
></image>
|
||||
</view>
|
||||
<view class="mt-2">长按说话</view>
|
||||
<view class="mt-2 text-center whitespace-nowrap text-xs">长按说话</view>
|
||||
</view>
|
||||
<view class="flex flex-col items-center" @click="handleHangUp">
|
||||
<view class="bg-[#eb292b] w-80 h-80 rounded-full flex items-center justify-center">
|
||||
<image src="https://oss-lock.xhjcn.ltd/mp/icon_hang_up.png" class="w-60 h-60"></image>
|
||||
</view>
|
||||
<view class="mt-2">挂断</view>
|
||||
<view class="mt-2 text-center whitespace-nowrap text-xs">挂断</view>
|
||||
</view>
|
||||
<view class="flex flex-col items-center" @click="handleLock">
|
||||
<view class="bg-[#63b8af] w-80 h-80 rounded-full flex items-center justify-center">
|
||||
@ -99,7 +99,7 @@
|
||||
class="w-60 h-60"
|
||||
></image>
|
||||
</view>
|
||||
<view class="mt-2">开锁</view>
|
||||
<view class="mt-2 text-center whitespace-nowrap text-xs">开锁</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@ -123,13 +123,23 @@
|
||||
import { onUnload } from '@dcloudio/uni-app'
|
||||
import { useBluetoothStore } from '@/stores/bluetooth'
|
||||
import { useBasicStore } from '@/stores/basic'
|
||||
import { useUserStore } from '@/stores/user'
|
||||
import { passthrough } from '@/api/sdk'
|
||||
import { getLockNetTokenRequest } from '@/api/lock'
|
||||
|
||||
const $bluetooth = useBluetoothStore()
|
||||
const $basic = useBasicStore()
|
||||
|
||||
const $user = useUserStore()
|
||||
const buttonInfo = ref(null)
|
||||
|
||||
const onlineToken = ref('0')
|
||||
|
||||
const lockId = ref()
|
||||
|
||||
const time = ref(0)
|
||||
|
||||
const pending = ref(false)
|
||||
|
||||
const index = ref(1)
|
||||
const range = ref([
|
||||
{ name: '标清', value: 'standard' },
|
||||
@ -166,6 +176,8 @@
|
||||
} else {
|
||||
$basic.backAndToast(message)
|
||||
}
|
||||
|
||||
await getServeTime()
|
||||
})
|
||||
|
||||
onUnload(() => {
|
||||
@ -213,7 +225,110 @@
|
||||
}
|
||||
|
||||
const handleLock = () => {
|
||||
console.log('handleLock')
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '是否确认开锁?',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
openDoorOperate()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const getServeTime = async () => {
|
||||
const { code, data } = await $bluetooth.updateServerTimestamp()
|
||||
if (code === 0) {
|
||||
time.value = parseInt((data.date - new Date().getTime()) / 1000, 10)
|
||||
}
|
||||
}
|
||||
|
||||
const openDoorOperate = async () => {
|
||||
const timestamp = new Date().getTime()
|
||||
if (pending.value) {
|
||||
return
|
||||
}
|
||||
|
||||
const netWork = await $basic.getNetworkType()
|
||||
if (!netWork) {
|
||||
return
|
||||
}
|
||||
|
||||
if ($bluetooth.currentLockInfo.appUnlockOnline) {
|
||||
const result = await getNetToken()
|
||||
if (!result) {
|
||||
pending.value = false
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
uni.showLoading({
|
||||
title: '开锁中'
|
||||
})
|
||||
uni.vibrateLong()
|
||||
pending.value = true
|
||||
const openMode = $bluetooth.currentLockInfo.appUnlockOnline ? 1 : 0
|
||||
|
||||
const { code } = await $bluetooth.openDoor({
|
||||
name: $bluetooth.currentLockInfo.lockName,
|
||||
uid: $user.userInfo.uid.toString(),
|
||||
openMode,
|
||||
openTime: parseInt(new Date().getTime() / 1000, 10) + time.value,
|
||||
onlineToken: onlineToken.value
|
||||
})
|
||||
|
||||
$bluetooth
|
||||
.syncRecord({
|
||||
keyId: $bluetooth.keyId.toString(),
|
||||
uid: $user.userInfo.uid.toString()
|
||||
})
|
||||
.then(() => {
|
||||
$bluetooth.closeBluetoothConnection()
|
||||
})
|
||||
|
||||
uni.reportEvent('open_door', {
|
||||
result: code,
|
||||
duration: new Date().getTime() - timestamp
|
||||
})
|
||||
|
||||
if (code === 0) {
|
||||
uni.showToast({
|
||||
title: `开门成功`,
|
||||
icon: 'none'
|
||||
})
|
||||
} 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: `开锁失败`,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
uni.hideLoading()
|
||||
pending.value = false
|
||||
}
|
||||
|
||||
const getNetToken = async () => {
|
||||
const { code, data, message } = await getLockNetTokenRequest({
|
||||
lockId: lockId.value
|
||||
})
|
||||
if (code === 0) {
|
||||
onlineToken.value = data.token
|
||||
return true
|
||||
}
|
||||
uni.showToast({
|
||||
title: message,
|
||||
icon: 'none'
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
const startVoice = () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user