动态绑定class值 ,多种判断
:class=”type === 8 ? ‘home–stye-2′ : type === 24 ? ‘home–stye-1′ : ‘home–stye-3′”
<div class="home-right-top">
<div class="home-right-top-video">
<el-row :gutter="20">
<el-col :span="type" v-for="(item, index) in typeList" :key="item.id"
:class="type === 8 ? 'home-stye-2' : type === 24 ? 'home-stye-1' : 'home-stye-3'">
<div class="videoEvent">
//ifram视频嵌套
<iframe id="iframe"
:src="liveNvrUrl + `/play.html?channel=` + item.channelNo + `&protocol=WEBRTC&stretch=no&iframe=yes&autoplay=no&controls=no`"
allowfullscreen class="video" @click="iframeClick(index)">
</iframe>
</div>
//摄像仪名称 点击摄像仪名称实现全屏
<div class="camera-name" @click="handleVideoClick(item.id, item.channelNo, item.voiceCall)">摄像仪名称 : {{
item.cameraName }}
</div>
</el-col>
</el-row>
</div>
<div class="home-right-top-text">
<span class="full-screen" @click="fullScreenClick">全屏</span>
<span>
//分屏下拉款选择
<el-select v-model="cameraValue" placeholder="分屏" style="width: 100px;" size="mini" @change="changeSize">
<el-option v-for="item in cameraOptions" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</span>
</div>
</div>
js部分定义变量及方法,主要查阅对象为分屏和全屏方法
data(){
return{
typeNewList: [], //获取后端返回数组
typeList: [], //展示页面数组
liveNvrUrl: '',
cameraValue: '', //select绑定值
type: 24,
cameraIndex: null,//截取数量
}
},
mounted() {
this.getCameraStatus()
this.getWebSocket() // 链接服务
this.getLiveNvr() //获取liveNvr地址
},
methods: {
//获取liveNvr地址
getLiveNvr() {
getConfigKey("liveNvr").then(res => {
this.liveNvrUrl = res.msg;
})
},
// 链接服务
getWebSocket() {
function debounce(func, delay) {
let timeoutId;
return function (...args) {
clearTimeout(timeoutId);
timeoutId = setTimeout(() => {
func.apply(this, args);
}, delay);
};
}
const wsuri = 'ws://192.168.10.6:8081/websocket/message'
let ws = new WebSocket(wsuri)
var _this = this
ws.onopen = function (event) {
}
const debouncedFunction = debounce(function (event) {
if (event.data !== '连接成功') {
let result = event.data
let data = JSON.parse(result)
_this.cameraOnlineList.unshift(data)
}
// 执行的代码
}, 200);
ws.onmessage = function (e) {
debouncedFunction(e)
}
ws.onclose = function (event) {
}
},
//初始化数据
getCameraStatus() {
getCameraStatus().then(res => {
this.allCamera = res.cameraStatus.number
this.offlineCamera = res.cameraStatus.offDrillingNumber
this.onlineCamera = res.cameraStatus.onDrillingNumber
})
// 摄像仪通道
listCameraBase().then(response => {
this.typeNewList = response.rows
this.handleVideoClick(this.typeNewList[0].id, this.typeNewList[0].channelNo, this.typeNewList[0].voiceCall);
this.changeSize(this.type)
});
},
// 监控视频事件
handleVideoClick(videoId, channelNo, voiceCall) {
this.currentChannel = channelNo;
this.currentVideoId = videoId;
this.currentVoiceCall = voiceCall;
this.drillInformation = []
this.value = '';
this.drillValue = '';
const videoIdInt = videoId
getTaskIdByCameraId(videoIdInt).then((response) => {
if (response.data === undefined) {
this.$modal.msgError("当前相机无在执行任务");
this.taskPlanList = [];
return false
}
this.taskPlanList = response.data; //任务信息数据
// 调用钻孔放法或接口数据,绑定对应的id来获取对应数据
if (
response.data.taskDetailInfoList &&
response.data.taskDetailInfoList.length > 0
) {
this.drillOptions = response.data.taskDetailInfoList; //钻孔数据
this.selectedHoleCode = response.data.taskDetailInfoList[0].holeCode; // 假设选择第一个钻孔编号
}
});
},
// 分屏 初始化方法中调用this.changeSize(this.type)
changeSize(value) {
let arr = this.typeNewList;
this.cameraIndex = 0;
this.type = value;
if (value === 24) {
this.cameraIndex = 1;
}
if (value === 8) {
this.cameraIndex = 6;
}
if (value === 6) {
this.cameraIndex = 12;
}
this.typeList = arr.slice(0, this.cameraIndex);
},
// 全屏
fullScreenClick() {
this.typeList = []
this.cameraValue = ''
this.type = 24;
this.typeList = this.typeNewList.filter(item => item.id === this.currentVideoId)
},
}
css分屏样式
.home-right-top-video {
width: 100%;
height: calc(100% - 40px);
.el-row {
height: 100%;
//2*3
.home-stye-2 {
border-radius: 4px;
height: calc(100% / 2 - 10px);
margin-bottom: 10px;
position: relative;
.bg-purple {
position: absolute;
top: 0;
height: 100%;
}
.videoEvent {
width: 100%;
height: 100%;
.video {
width: 100%;
height: 100%;
}
}
.camera-name {
position: absolute;
top: 5px;
left: 20px;
height: 100%;
color: #1ea0f7;
font-size: 16px;
cursor: pointer;
}
}
//1*1
.home-stye-1 {
border-radius: 4px;
height: calc(100% - 10px);
margin-bottom: 10px;
position: relative;
.videoEvent {
width: 100%;
height: 100%;
.video {
width: 100%;
height: 100%;
}
}
.camera-name {
position: absolute;
top: 5px;
left: 20px;
height: 100%;
color: #1ea0f7;
font-size: 16px;
cursor: pointer;
}
}
}
}
//3*4
.home-stye-3 {
border-radius: 4px;
height: calc(100% / 3 - 10px);
margin-bottom: 10px;
position: relative;
.videoEvent {
width: 100%;
height: 100%;
.video {
width: 100%;
height: 100%;
}
}
.camera-name {
position: absolute;
top: 5px;
left: 20px;
height: 100%;
color: #1ea0f7;
font-size: 14px;
cursor: pointer;
}
}
}
}
注释:分屏实现逻辑:后端返回数据定义一个数组中,判断据type的值定义cameraIndex的长度,将定义的数组typeNewList使用slice进行截取(此方法不会修改原始数组),截取后的值赋值给typeList展示页面上
原文地址:https://blog.csdn.net/xiaoming4965/article/details/134683317
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_44640.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。