feat: 添加监控相关功能

This commit is contained in:
fanpeng 2025-06-17 16:49:04 +08:00
parent d7c5ad4102
commit 88b512aa7f
8 changed files with 340 additions and 304 deletions

View File

@ -2,9 +2,7 @@
"compilerOptions": { "compilerOptions": {
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {
"@/*": [ "@/*": ["./*"]
"./*"
]
}, },
"target": "es2020", "target": "es2020",
"module": "esnext", "module": "esnext",
@ -15,14 +13,6 @@
"strict": true, "strict": true,
"skipLibCheck": true "skipLibCheck": true
}, },
"include": [ "include": ["**/*.js", "**/*.jsx", "**/*.vue", "pages/p2p/p2pPlayer.nvue"],
"**/*.js", "exclude": ["node_modules", "unpackage", "dist"]
"**/*.jsx",
"**/*.vue"
],
"exclude": [
"node_modules",
"unpackage",
"dist"
]
} }

View File

@ -1,75 +1,74 @@
{ {
"name" : "星星锁Lite", "name": "星星锁Lite",
"appid" : "__UNI__933D519", "appid": "__UNI__933D519",
"description" : "", "description": "",
"versionName" : "1.3.0", "versionName": "1.3.0",
"versionCode" : "37", "versionCode": "37",
"mp-weixin" : { "mp-weixin": {
"appid" : "wx9829a39e65550757", "appid": "wx9829a39e65550757",
"setting" : { "setting": {
"urlCheck" : true, "urlCheck": true,
"minified" : true "minified": true
}, },
"permission" : { "permission": {
"scope.bluetooth" : { "scope.bluetooth": {
"desc" : "蓝牙将用于控制和管理您的智能门锁" "desc": "蓝牙将用于控制和管理您的智能门锁"
} }
}, },
"requiredPrivateInfos" : [ "getLocation" ], "usingComponents": true,
"usingComponents" : true, "lazyCodeLoading": "requiredComponents",
"lazyCodeLoading" : "requiredComponents", "optimization": {
"optimization" : { "subPackages": true
"subPackages" : true
}, },
"plugins" : { "plugins": {
"wmpf-voip" : { "wmpf-voip": {
"version" : "latest", "version": "latest",
"provider" : "wxf830863afde621eb", "provider": "wxf830863afde621eb",
"genericsImplementation" : { "genericsImplementation": {
"call-page-plugin" : { "call-page-plugin": {
"custombox" : "pages/main/customBox" "custombox": "pages/main/customBox"
} }
} }
} }
} }
}, },
"vueVersion" : "3", "vueVersion": "3",
"app-plus" : { "app-plus": {
"distribute" : { "distribute": {
"icons" : { "icons": {
"android" : { "android": {
"hdpi" : "unpackage/res/icons/72x72.png", "hdpi": "unpackage/res/icons/72x72.png",
"xhdpi" : "unpackage/res/icons/96x96.png", "xhdpi": "unpackage/res/icons/96x96.png",
"xxhdpi" : "unpackage/res/icons/144x144.png", "xxhdpi": "unpackage/res/icons/144x144.png",
"xxxhdpi" : "unpackage/res/icons/192x192.png" "xxxhdpi": "unpackage/res/icons/192x192.png"
}, },
"ios" : { "ios": {
"appstore" : "unpackage/res/icons/1024x1024.png", "appstore": "unpackage/res/icons/1024x1024.png",
"ipad" : { "ipad": {
"app" : "unpackage/res/icons/76x76.png", "app": "unpackage/res/icons/76x76.png",
"app@2x" : "unpackage/res/icons/152x152.png", "app@2x": "unpackage/res/icons/152x152.png",
"notification" : "unpackage/res/icons/20x20.png", "notification": "unpackage/res/icons/20x20.png",
"notification@2x" : "unpackage/res/icons/40x40.png", "notification@2x": "unpackage/res/icons/40x40.png",
"proapp@2x" : "unpackage/res/icons/167x167.png", "proapp@2x": "unpackage/res/icons/167x167.png",
"settings" : "unpackage/res/icons/29x29.png", "settings": "unpackage/res/icons/29x29.png",
"settings@2x" : "unpackage/res/icons/58x58.png", "settings@2x": "unpackage/res/icons/58x58.png",
"spotlight" : "unpackage/res/icons/40x40.png", "spotlight": "unpackage/res/icons/40x40.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png" "spotlight@2x": "unpackage/res/icons/80x80.png"
}, },
"iphone" : { "iphone": {
"app@2x" : "unpackage/res/icons/120x120.png", "app@2x": "unpackage/res/icons/120x120.png",
"app@3x" : "unpackage/res/icons/180x180.png", "app@3x": "unpackage/res/icons/180x180.png",
"notification@2x" : "unpackage/res/icons/40x40.png", "notification@2x": "unpackage/res/icons/40x40.png",
"notification@3x" : "unpackage/res/icons/60x60.png", "notification@3x": "unpackage/res/icons/60x60.png",
"settings@2x" : "unpackage/res/icons/58x58.png", "settings@2x": "unpackage/res/icons/58x58.png",
"settings@3x" : "unpackage/res/icons/87x87.png", "settings@3x": "unpackage/res/icons/87x87.png",
"spotlight@2x" : "unpackage/res/icons/80x80.png", "spotlight@2x": "unpackage/res/icons/80x80.png",
"spotlight@3x" : "unpackage/res/icons/120x120.png" "spotlight@3x": "unpackage/res/icons/120x120.png"
} }
} }
}, },
"android" : { "android": {
"permissions" : [ "permissions": [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>", "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>", "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>", "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
@ -93,19 +92,19 @@
"<uses-permission android:name=\"android.permission.BLUETOOTH_CONNECT\" />" "<uses-permission android:name=\"android.permission.BLUETOOTH_CONNECT\" />"
] ]
}, },
"ios" : { "ios": {
"dSYMs" : false "dSYMs": false
} }
}, },
"modules" : { "modules": {
"Bluetooth" : {}, "Bluetooth": {},
"VideoPlayer" : {}, "VideoPlayer": {},
"LivePusher" : {}, "LivePusher": {},
"Camera" : {}, "Camera": {},
"Record" : {} "Record": {}
}, },
"splashscreen" : { "splashscreen": {
"waiting" : false "waiting": false
} }
} }
} }

View File

@ -38,13 +38,6 @@
"navigationBarTitleText": "门锁记录", "navigationBarTitleText": "门锁记录",
"disableScroll": true "disableScroll": true
} }
},
{
"path": "appPlayer",
"style": {
"navigationBarTitleText": "监控",
"disableScroll": true
}
} }
], ],
"plugins": { "plugins": {

View File

@ -310,12 +310,7 @@
}) })
const jumpToPlayer = () => { const jumpToPlayer = () => {
// #ifdef MP
$basic.routeJump({ name: 'p2pPlayer' }) $basic.routeJump({ name: 'p2pPlayer' })
// #endif
// #ifdef APP-PLUS
$basic.routeJump({ name: 'appPlayer' })
// #endif
} }
const openDoorOperate = async type => { const openDoorOperate = async type => {

View File

@ -1,67 +0,0 @@
<template>
<view>
<video v-if="url" autoplay :src="url" :is-live="true" :controls="false" class="w-full" />
</view>
</template>
<script setup>
// #ifdef APP-PLUS
import { onMounted, ref } from 'vue'
import { passthrough } from '@/api/sdk'
import { useBluetoothStore } from '@/stores/bluetooth'
import { useBasicStore } from '@/stores/basic'
import { startService, getLiveUrl } from '@/uni_modules/xhj-tencent-xp2p'
const $bluetooth = useBluetoothStore()
const $basic = useBasicStore()
const deviceInfo = ref()
const url = ref()
onMounted(async () => {
// const callback = new XP2PCallback1()
// setCallback(callback)
const { code, data, message } = await passthrough({
request_method: 'GET',
request_uri: '/api/v1/tencentYun/getDeviceDetailData',
post_args: {
lockId: $bluetooth.currentLockInfo.lockId
}
})
if (code === 0) {
deviceInfo.value = data
console.log(1)
const result = await startService({
appKey: 'aanuJXFtISXFYVVsd',
appSecret: 'SsnOMHJUcazCvpULSVWY',
productId: deviceInfo.value.productId,
deviceName: deviceInfo.value.deviceName,
xp2pInfo: deviceInfo.value.xp2pInfo
})
if (result.code === 0) {
setTimeout(async () => {
const urlResult = await getLiveUrl({
id: `${deviceInfo.value.productId}/${deviceInfo.value.deviceName}`
})
console.log(12, urlResult)
if (urlResult.code === 0) {
uni.request({
url: urlResult.data.url,
method: 'GET',
success: res => {
console.log(13, res)
}
})
url.value = urlResult.data.url
}
}, 200)
}
} else {
$basic.backAndToast(message)
}
})
// #endif
</script>

View File

@ -1,5 +1,7 @@
<template> <template>
<view> <view>
<view>
<!-- #ifdef MP-WEIXIN -->
<iot-p2p-player-with-mjpg <iot-p2p-player-with-mjpg
v-if="deviceInfo" v-if="deviceInfo"
id="playerRef" id="playerRef"
@ -19,30 +21,47 @@
@playsuccess="handlePlaySuccess" @playsuccess="handlePlaySuccess"
> >
</iot-p2p-player-with-mjpg> </iot-p2p-player-with-mjpg>
<view <!-- #endif -->
v-if="buttonInfo"
:style="{ <!-- #ifdef APP-PLUS -->
top: buttonInfo.bottom + 15 + 'px' <video
}" autoplay
class="bg-[rgba(0,0,0,0.35)] rounded-full px-2 py-1.5 fixed right-32" id="playerRef"
> v-if="url"
<picker :value="index" mode="selector" :range="range" range-key="name" @change="changeEvent"> :muted="isMute"
<up-icon :src="urlPrefix"
:label="range[index].name" object-fit="cover"
color="#ffffff" class="w-[100vw] h-[100vh]"
label-color="#ffffff" :is-live="true"
labelPos="left" :play-strategy="2"
name="arrow-down-fill" :controls="false"
size="32rpx" :show-progress="false"
space="16rpx" :show-fullscreen-btn="false"
></up-icon> :show-play-btn="false"
</picker> :enable-progress-gesture="false"
:vslide-gesture="true"
/>
<!-- #endif -->
</view> </view>
<image <image
v-if="!isVideoLoaded" v-if="!isVideoLoaded"
src="https://oss-lock.xhjcn.ltd/mp/background_monitor.png" src="https://oss-lock.xhjcn.ltd/mp/background_monitor.png"
class="w-full h-full absolute top-0 left-0" class="w-full h-full absolute top-0 left-0"
></image> ></image>
<cover-view
v-if="isApp || buttonInfo"
:style="{
top: isApp ? '60px' : buttonInfo.bottom + 15 + 'px'
}"
class="bg-[rgba(0,0,0,0.35)] rounded-full px-4 py-1.5 fixed right-32"
>
<cover-view class="text-white text-xs" @click="showQualitySelector">
{{ range[index].name }}
</cover-view>
</cover-view>
<!-- #ifdef MP-WEIXIN -->
<iot-p2p-voice <iot-p2p-voice
v-if="deviceInfo" v-if="deviceInfo"
id="voiceComponent" id="voiceComponent"
@ -51,58 +70,94 @@
voiceType="Pusher" voiceType="Pusher"
> >
</iot-p2p-voice> </iot-p2p-voice>
<!-- #endif -->
<view <cover-view
v-if="isVideoLoaded" 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 left-1/2 -translate-x-1/2 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-15"> <cover-view class="flex items-center justify-around mx-15">
<image <cover-view class="relative">
@click="isMute = !isMute" <cover-image
:src=" v-show="isMute"
isMute src="https://oss-lock.xhjcn.ltd/mp/icon_mute.png"
? 'https://oss-lock.xhjcn.ltd/mp/icon_mute.png' :class="isApp ? 'size-48' : 'size-48 p-2'"
: 'https://oss-lock.xhjcn.ltd/mp/icon_not_mute.png' ></cover-image>
" <cover-image
class="w-48 h-48 p-2" v-show="!isMute"
></image> src="https://oss-lock.xhjcn.ltd/mp/icon_not_mute.png"
<image :class="isApp ? 'size-48' : 'size-48 p-2'"
@click="handleScreenshot" ></cover-image>
<cover-view
@click="toggleMute"
class="absolute top-0 left-0 w-full h-full size-48 p-2"
></cover-view>
</cover-view>
<cover-view class="relative">
<cover-image
src="https://oss-lock.xhjcn.ltd/mp/icon_screenshot.png" src="https://oss-lock.xhjcn.ltd/mp/icon_screenshot.png"
class="w-48 h-48 p-2" :class="isApp ? 'size-48' : 'size-48 p-2'"
></image> ></cover-image>
</view> <cover-view
<view class="flex items-center justify-between text-white mt-2 px-10"> @click="handleScreenshot"
<view class="flex flex-col items-center" @longpress="startVoice" @touchend="stopVoice"> class="absolute top-0 left-0 w-full h-full"
<view class="bg-white w-80 h-80 rounded-full flex items-center justify-center"> ></cover-view>
<image </cover-view>
</cover-view>
<cover-view class="flex items-center justify-between text-white mt-2 px-10">
<cover-view class="flex flex-col items-center">
<cover-view
class="bg-white w-80 h-80 rounded-full flex items-center justify-center relative"
>
<cover-image
:src=" :src="
isVoice isVoice
? 'https://oss-lock.xhjcn.ltd/mp/icon_microphone.png' ? 'https://oss-lock.xhjcn.ltd/mp/icon_microphone.png'
: 'https://oss-lock.xhjcn.ltd/mp/icon_no_microphone.png' : 'https://oss-lock.xhjcn.ltd/mp/icon_no_microphone.png'
" "
class="w-55 h-55" class="w-55 h-55"
></image> ></cover-image>
</view> <cover-view
<view class="mt-2 text-center whitespace-nowrap text-xs">长按说话</view> @click="toggleVoice"
</view> class="absolute top-0 left-0 w-full h-full"
<view class="flex flex-col items-center" @click="handleHangUp"> ></cover-view>
<view class="bg-[#eb292b] w-80 h-80 rounded-full flex items-center justify-center"> </cover-view>
<image src="https://oss-lock.xhjcn.ltd/mp/icon_hang_up.png" class="w-60 h-60"></image> <cover-view class="mt-2 text-center whitespace-nowrap text-xs">{{
</view> isVoice ? '点击停止' : '点击说话'
<view class="mt-2 text-center whitespace-nowrap text-xs">挂断</view> }}</cover-view>
</view> </cover-view>
<view class="flex flex-col items-center" @click="handleLock"> <cover-view class="flex flex-col items-center">
<view class="bg-[#63b8af] w-80 h-80 rounded-full flex items-center justify-center"> <cover-view
<image class="bg-[#eb292b] w-80 h-80 rounded-full flex items-center justify-center relative"
>
<cover-image
src="https://oss-lock.xhjcn.ltd/mp/icon_hang_up.png"
class="w-60 h-60"
></cover-image>
<cover-view
@click="handleHangUp"
class="absolute top-0 left-0 w-full h-full"
></cover-view>
</cover-view>
<cover-view class="mt-2 text-center whitespace-nowrap text-xs">挂断</cover-view>
</cover-view>
<cover-view class="flex flex-col items-center">
<cover-view
class="bg-[#63b8af] w-80 h-80 rounded-full flex items-center justify-center relative"
>
<cover-image
src="https://oss-lock.xhjcn.ltd/mp/icon_lock_white.png" src="https://oss-lock.xhjcn.ltd/mp/icon_lock_white.png"
class="w-60 h-60" class="w-60 h-60"
></image> ></cover-image>
</view> <cover-view
<view class="mt-2 text-center whitespace-nowrap text-xs">开锁</view> @click="handleLock"
</view> class="absolute top-0 left-0 w-full h-full"
</view> ></cover-view>
</view> </cover-view>
<cover-view class="mt-2 text-center whitespace-nowrap text-xs">开锁</cover-view>
</cover-view>
</cover-view>
</cover-view>
<view <view
v-if="!isVideoLoaded" v-if="!isVideoLoaded"
class="fixed bottom-[calc(48rpx+env(safe-area-inset-bottom))] w-full flex justify-center" class="fixed bottom-[calc(48rpx+env(safe-area-inset-bottom))] w-full flex justify-center"
@ -119,7 +174,7 @@
</template> </template>
<script setup> <script setup>
import { onMounted, ref } from 'vue' import { onMounted, ref, computed } from 'vue'
import { onUnload } from '@dcloudio/uni-app' import { onUnload } from '@dcloudio/uni-app'
import { useBluetoothStore } from '@/stores/bluetooth' import { useBluetoothStore } from '@/stores/bluetooth'
import { useBasicStore } from '@/stores/basic' import { useBasicStore } from '@/stores/basic'
@ -131,17 +186,20 @@
import * as B from './exportForPlayerPlugin' import * as B from './exportForPlayerPlugin'
// #endif // #endif
// #ifdef APP-PLUS
import { startService, getLiveUrl, stopService } from '@/uni_modules/xhj-tencent-xp2p'
// #endif
const $bluetooth = useBluetoothStore() const $bluetooth = useBluetoothStore()
const $basic = useBasicStore() const $basic = useBasicStore()
const $user = useUserStore() const $user = useUserStore()
const buttonInfo = ref(null) const buttonInfo = ref(null)
const isApp = ref(false)
const onlineToken = ref('0') const onlineToken = ref('0')
const lockId = ref() const lockId = ref()
const time = ref(0) const time = ref(0)
const pending = ref(false) const pending = ref(false)
const index = ref(1) const index = ref(1)
@ -153,13 +211,20 @@
const deviceInfo = ref() const deviceInfo = ref()
const xp2pInfo = ref() const xp2pInfo = ref()
const url = ref()
const isVoice = ref(false) const isVoice = ref(false)
const isMute = ref(false) const isMute = ref(false)
const isVideoLoaded = ref(false) const isVideoLoaded = ref(false)
const urlPrefix = computed(() => {
return url.value + `ipc.flv?action=live&channel=0&quality=${range.value[index.value].value}`
})
onMounted(async () => { onMounted(async () => {
// #ifdef APP-PLUS
isApp.value = true
// #endif
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
console.log(A, B) console.log(A, B)
// #endif // #endif
@ -173,6 +238,7 @@
} }
}) })
// #ifdef MP-WEIXIN
if (code === 0) { if (code === 0) {
deviceInfo.value = { deviceInfo.value = {
deviceId: `${data.productId}/${data.deviceName}`, deviceId: `${data.productId}/${data.deviceName}`,
@ -183,23 +249,65 @@
} else { } else {
$basic.backAndToast(message) $basic.backAndToast(message)
} }
await getServeTime() await getServeTime()
// #endif
// #ifdef APP-PLUS
if (code === 0) {
deviceInfo.value = data
const result = await startService({
appKey: 'aanuJXFtISXFYVVsd',
appSecret: 'SsnOMHJUcazCvpULSVWY',
productId: deviceInfo.value.productId,
deviceName: deviceInfo.value.deviceName,
xp2pInfo: deviceInfo.value.xp2pInfo
})
if (result.code === 0) {
setTimeout(async () => {
const urlResult = await getLiveUrl({
id: `${deviceInfo.value.productId}/${deviceInfo.value.deviceName}`
})
if (urlResult.code === 0) {
url.value = urlResult.data.url
handlePlaySuccess()
} else {
$basic.backAndToast(message)
}
}, 200)
} else {
$basic.backAndToast(message)
}
} else {
$basic.backAndToast(message)
}
// #endif
}) })
onUnload(() => { onUnload(() => {
// #ifdef APP-PLUS
stopService({
id: `${deviceInfo.value.productId}/${deviceInfo.value.deviceName}`
})
// #endif
// #ifdef MP-WEIXIN
const page = getCurrentPages().pop() const page = getCurrentPages().pop()
const player = page.selectComponent('#playerRef') const player = page.selectComponent('#playerRef')
if (player.stopAll) { if (player.stopAll) {
player.stopAll() player.stopAll()
} }
// #endif
}) })
const changeEvent = e => { const showQualitySelector = () => {
index.value = e.detail.value uni.showActionSheet({
itemList: range.value.map(item => item.name),
success: res => {
index.value = res.tapIndex
}
})
} }
const handleScreenshot = () => { const handleScreenshot = () => {
// #ifdef MP-WEIXIN
const page = getCurrentPages().pop() const page = getCurrentPages().pop()
const player = page.selectComponent('#playerRef') const player = page.selectComponent('#playerRef')
@ -220,14 +328,26 @@
} }
}) })
}) })
// #endif
// #ifdef APP-PLUS
uni.showModal({
title: '提示',
content:
'由于技术限制APP端无法直接截取视频画面。请使用手机系统截图功能\n\niOS同时按下电源键+音量上键\nAndroid同时按下电源键+音量下键',
confirmText: '我知道了',
showCancel: false
})
// #endif
} }
const handleHangUp = () => { const handleHangUp = () => {
// #ifdef MP-WEIXIN
const page = getCurrentPages().pop() const page = getCurrentPages().pop()
const player = page.selectComponent('#playerRef') const player = page.selectComponent('#playerRef')
if (player.stopAll) { if (player.stopAll) {
player.stopAll() player.stopAll()
} }
// #endif
uni.navigateBack() uni.navigateBack()
} }
@ -340,24 +460,35 @@
return false return false
} }
const startVoice = () => { const toggleVoice = () => {
// #ifdef MP-WEIXIN
if (isVoice.value) {
isVoice.value = false
const page = getCurrentPages().pop()
const voice = page.selectComponent('#voiceComponent')
if (voice) {
voice.stopVoice()
}
} else {
uni.vibrateLong() uni.vibrateLong()
isVoice.value = true isVoice.value = true
const page = getCurrentPages().pop() const page = getCurrentPages().pop()
const voice = page.selectComponent('#voiceComponent') const voice = page.selectComponent('#voiceComponent')
if (voice) {
voice.startVoice() voice.startVoice()
} }
}
const stopVoice = () => { // #endif
isVoice.value = false console.log(1111)
const page = getCurrentPages().pop()
const voice = page.selectComponent('#voiceComponent')
voice.stopVoice()
} }
const handlePlaySuccess = () => { const handlePlaySuccess = () => {
isVideoLoaded.value = true isVideoLoaded.value = true
} }
const toggleMute = () => {
isMute.value = !isMute.value
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -431,11 +431,6 @@ const pages = [
name: 'safeVerify', name: 'safeVerify',
path: '/pages/user/safeVerify', path: '/pages/user/safeVerify',
tabBar: false tabBar: false
},
{
name: 'appPlayer',
path: '/pages/p2p/appPlayer',
tabBar: false
} }
] ]

View File

@ -11,6 +11,6 @@
"esModuleInterop": true, "esModuleInterop": true,
"moduleResolution": "bundler" "moduleResolution": "bundler"
}, },
"include": ["**/*.ts", "**/*.tsx", "**/*.uts", "**/*.vue"], "include": ["**/*.vue", "**/*.js", "**/*.uts", "uni_modules/**/*.uts"],
"exclude": ["node_modules", "unpackage", "dist"] "exclude": ["node_modules", "unpackage", "dist"]
} }