wszhyWx/pages/timeVideo/timeVideo.vue

297 lines
6.8 KiB
Vue

<template>
<view class="timeVideo">
<u-navbar :background="background" :is-back='true' back-icon-color='#FFFFFF' :border-bottom="false" title="实时视频"
title-color='#FFFFFF' :title-bold='true' title-size='32'></u-navbar>
<view class="content">
<view class="item" v-for="(item,index) in deviceList" :key="index">
<view class="nav">
<image src="../../static/video.png" mode=""></image>
<text>{{item.deviceTypeName}}-摄像机#2</text>
</view>
<view class="video" >
<video v-if="item.ezopen" style="width: 100%;height: 100%;border-radius: 8rpx;" :src="item.ezopen" :controls='false' :autoplay='false' :show-play-btn='false' :show-center-play-btn='false' object-fit='fill' :is-live='true'></video>
<image v-else src="../../static/video1.png" mode=""></image>
</view>
<view class="timer">
<view class="left">
<image src="../../static/timer.png" mode=""></image>
<text>{{ time }}</text>
</view>
<view class="right" @click="toVideoLive(item.cameraSerialNumber,item.cameraChannelNumber)">
<image src="../../static/play.png" mode=""></image>
<text>现场实况</text>
</view>
<!-- <view class="right" @click="toMiniProgram('AD6463273', 11)">
<image src="../../static/play.png" mode=""></image>
<text>现场实况</text>
</view> -->
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
// 头部导航背景
background: {
backgroundColor: '#24B383',
},
userid: '',
deviceList: [],
liveList: [],
accesstoken:'',
src: '',
time:'',
};
},
onLoad() {
this.userid = uni.getStorageSync('userid');
this.getEquipmentInfo(this.userid);
},
onPullDownRefresh() {
this.getEquipmentInfo(this.userid)
},
mounted() {
setInterval(() => {
this.time = this.getCurrentTime()
}, 1000);
},
methods: {
// 根据用户id查询对应的设备数据
getEquipmentInfo(userid) {
uni.showLoading({
title: '加载中...'
})
this.$http({
url: this.api.sel_eqbyid + userid,
method: 'GET'
}).then(res => {
if (res.code == 200) {
uni.hideLoading()
uni.stopPullDownRefresh();
this.deviceList = res.data;
this.deviceList = this.deviceList.map(el=>{
return {
...el,
ezopen:''
}
})
this.deviceList.forEach(el=>{
this.$http({
url: this.api.camera_getphonehls,
method: 'GET',
data: {
cameraid: el.cameraSerialNumber,
channelid: el.cameraChannelNumber,
}
}).then(res => {
if (res.code == 200) {
el.ezopen = res.data.ezopen
}
})
})
// console.log(this.deviceList,'0000');
} else {
this.$refs.uToast.show({
title: res.msg,
type: 'error',
})
}
})
},
// 获取摄像头得地址
// getVideoData(cameraid, channelid) {
// this.$http({
// url: this.api.camera_gethls,
// method: 'GET',
// data: {
// cameraid,
// channelid,
// }
// }).then(res => {
// if (res.code == 200) {
// this.accesstoken = res.data.accesstoken;
// this.src = res.data.ezopen;
// }
// })
// },
// toMiniProgram(cameraid,channelid){
// if(cameraid && channelid){
// this.$http({
// url: this.api.camera_gethls,
// method: 'GET',
// data: {
// cameraid,
// channelid
// }
// }).then(res => {
// if (res.code == 200) {
// this.accesstoken = res.data.accesstoken;
// this.src = res.data.ezopen;
// uni.navigateToMiniProgram({
// appId: 'wxf2b3a0262975d8c2',
// path: 'pages/live/live?accessToken=' + this.accesstoken + '&deviceSerial=' + cameraid + '&channelNo=' + channelid,
// success(res) {
// console.log(res);
// }
// })
// }
// })
// }else{
// uni.showToast({
// icon:'error',
// title: '暂无监控数据',
// duration: 2000
// });
// }
// },
toVideoLive(cameraSerialNumber,cameraChannelNumber) {
if(cameraSerialNumber && cameraChannelNumber){
uni.navigateTo({
url: '/pages/videoLive/videoLive?cameraSerialNumber=' + cameraSerialNumber + '&cameraChannelNumber=' + cameraChannelNumber
})
}else{
uni.showToast({
icon:'error',
title: '暂无监控数据',
duration: 2000
});
}
},
getCurrentTime() {
const now = new Date();
const year = now.getFullYear();
const month = (now.getMonth() + 1).toString().padStart(2, '0');
const day = now.getDate().toString().padStart(2, '0');
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
const seconds = now.getSeconds().toString().padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
}
}
</script>
<style lang="scss" scoped>
.timeVideo {
width: 100%;
min-height: 100vh;
background-color: #F5F6FA;
.content {
box-sizing: border-box;
padding: 30rpx;
.item {
width: 690rpx;
height: 577rpx;
background: #FFFFFF;
border-radius: 15rpx;
margin-bottom: 30rpx;
.nav {
height: 90rpx;
box-sizing: border-box;
padding: 20rpx;
display: flex;
align-items: center;
>image {
width: 50rpx;
height: 50rpx;
margin-right: 16rpx;
}
>text {
font-size: 30rpx;
font-family: PingFang SC;
font-weight: bold;
color: #333333;
}
}
.video {
width: 690rpx;
height: 380rpx;
background: #FFFFFF;
border-radius: 15rpx;
box-sizing: border-box;
padding: 0 20rpx;
>image {
width: 100%;
height: 100%;
}
}
.timer {
width: 100%;
height: 107rpx;
display: flex;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
padding: 0 20rpx;
.left {
display: flex;
align-items: center;
>image {
width: 30rpx;
height: 30rpx;
margin-right: 10rpx;
}
>text {
font-size: 24rpx;
font-family: PingFang SC;
font-weight: bold;
color: #666666;
}
}
.right {
width: 200rpx;
height: 66rpx;
background: linear-gradient(0deg, #7BD4B6 0%, #26B383 100%);
border-radius: 33rpx;
display: flex;
justify-content: center;
align-items: center;
>image {
width: 30rpx;
height: 30rpx;
margin-right: 10rpx;
}
>text {
font-size: 28rpx;
font-family: PingFang SC;
font-weight: bold;
color: #FFFFFF;
}
}
}
}
}
}
</style>