订单管理修改 订单详情修改 监控室列表和播放功能

This commit is contained in:
2025-08-10 18:56:52 +08:00
parent f3b45139e4
commit cffe8b855b
12 changed files with 518 additions and 66 deletions

View File

@@ -0,0 +1,89 @@
<template>
<view>
<view v-if="node.children && node.children.length" class="tree-title" @click="toggle">
<text>{{ expanded ? '▼' : '▶' }} {{ node.title }}</text>
</view>
<view v-else class="list-card" @click="goToPlay(node)">
<view class="item-row">
<image src="/static/ic_monitor.webp" class="item-img" />
<view class="item-c">
<text>设备编号{{ node.code }}</text>
<text>设备描述{{ node.label }}</text>
</view>
</view>
</view>
<view v-show="expanded" class="children-box">
<TreeNode v-for="child in node.children" :key="child.code || child.id" :node="child" />
</view>
</view>
</template>
<script>
export default {
name: "TreeNode",
props: {
node: {
type: Object,
required: true
}
},
data() {
return {
expanded: false
};
},
methods: {
toggle() {
this.expanded = !this.expanded;
},
goToPlay(item) {
const detailItemStr = encodeURIComponent(JSON.stringify(item.data));
uni.navigateTo({
url: `/pages/sys/workbench/monitor/monitorplay?detailItem=${detailItemStr}`
});
}
},
components: {
TreeNode: () => import("./TreeNode.vue") // 递归组件自己导入自己
}
};
</script>
<style scoped>
.tree-title {
padding: 20rpx 30rpx;
background: #eaeaea;
border-radius: 8rpx;
margin: 10rpx 20rpx;
font-weight: bold;
user-select: none;
}
.children-box {
padding-left: 30rpx;
}
.list-card {
background: #fff;
border-radius: 12rpx;
margin: 25rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.03);
padding: 30rpx;
}
.item-row {
display: flex;
flex-direction: row;
align-items: center;
}
.item-c {
display: flex;
height: 80rpx;
flex-direction: column;
justify-content: space-between;
}
.item-img {
width: 80rpx;
height: 80rpx;
margin-right: 20rpx;
}
</style>

View File

@@ -0,0 +1,129 @@
<template>
<view class="monitor-page">
<!-- 视频播放区域 -->
<video
v-if="videoSrc"
id="monitorVideo"
class="monitor-video"
:src="playUrl"
autoplay
controls
show-center-play-btn
object-fit="contain"
@error="onVideoError"
></video>
<!-- 加载动画 -->
<u-loading-page
:loading="loading"
loading-text="视频加载中..."
></u-loading-page>
</view>
</template>
<script>
export default {
data() {
return {
detailItem:null,
videoSrc: '', // 原始视频地址
playUrl: '', // 实际播放地址
isPlaying: true,
loading: true
}
},
onLoad(options) {
// 接收传递的detailItem参数
if (options.detailItem) {
try {
this.detailItem = JSON.parse(decodeURIComponent(options.detailItem));
this.getPlay()
} catch (e) {
console.error('解析detailItem参数失败', e);
}
}
},
methods: {
async getPlay() {
let params = {
"videoIp": this.detailItem.deviceIp,
"factoryNo":this.detailItem.factoryNo,
"account":this.detailItem.deviceAccount,
"pwd":this.detailItem.devicePwd,
"channelId":this.detailItem.channelNo
}
let res = await this.$u.api.getPlay(params);
if (res.code == 200) {
this.videoSrc = res.data.hls
this.initPlayer()
}
},
async initPlayer() {
// #ifdef H5
if (this.videoSrc.endsWith('.m3u8')) {
const video = document.getElementById('monitorVideo')
const Hls = (await import('hls.js')).default
if (Hls.isSupported()) {
const hls = new Hls()
hls.loadSource(this.videoSrc)
hls.attachMedia(video)
hls.on(Hls.Events.MANIFEST_PARSED, () => {
this.loading = false
})
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = this.videoSrc
this.loading = false
}
} else {
this.playUrl = this.videoSrc
this.loading = false
}
// #endif
// #ifdef APP-PLUS
this.playUrl = this.videoSrc
this.loading = false
// #endif
},
togglePlay() {
const video = document.getElementById('monitorVideo')
if (!video) return
if (this.isPlaying) {
video.pause()
} else {
video.play()
}
this.isPlaying = !this.isPlaying
},
goFullScreen() {
const video = document.getElementById('monitorVideo')
if (video.requestFullscreen) {
video.requestFullscreen()
}
},
onVideoError(e) {
console.error('视频播放错误', e)
uni.showToast({ title: '视频加载失败', icon: 'none' })
this.loading = false
}
}
}
</script>
<style scoped>
.monitor-page {
display: flex;
flex-direction: column;
align-items: center;
background: #000;
height: 100vh;
position: relative;
}
.monitor-video {
width: 100%;
height: 70vh;
background: #000;
}
</style>

View File

@@ -0,0 +1,45 @@
<template>
<view class="list-box">
<TreeNode v-for="(node, idx) in monitors" :key="node.code || node.id || idx" :node="node" />
</view>
</template>
<script>
import TreeNode from "./TreeNode.vue";
export default {
components: {
TreeNode
},
data() {
return {
monitors: []
};
},
onLoad() {
this.getMonitors();
},
methods: {
async getMonitors() {
try {
const res = await this.$u.api.getMonitors();
if (res.code === 200) {
this.monitors = res.data || [];
} else {
this.monitors = [];
}
} catch (error) {
console.error("获取监控失败", error);
this.monitors = [];
}
}
}
};
</script>
<style>
.list-box {
background: #f7f7f7;
padding-top: 25rpx;
}
</style>