图片加载优化

menu1.0
fanluyan 9 months ago
parent 5f5fd289cf
commit 8c0c78f4b6

6
package-lock.json generated

@ -8373,9 +8373,9 @@
"dev": true "dev": true
}, },
"vue-lazyload": { "vue-lazyload": {
"version": "1.3.3", "version": "1.2.6",
"resolved": "https://registry.npmjs.org/vue-lazyload/-/vue-lazyload-1.3.3.tgz", "resolved": "https://registry.npmmirror.com/vue-lazyload/-/vue-lazyload-1.2.6.tgz",
"integrity": "sha512-uHnq0FTEeNmqnbBC2aRKlmtd9LofMZ6Q3mWvgfLa+i9vhxU8fDK+nGs9c1iVT85axSua/AUnMttIq3xPaU9G3A==" "integrity": "sha512-6a61+pzwcfowhLRQiPdmRuJ40n/4fL/sEynu8KQZoCf5RVA0NH0X68vplLY0+lUM8mKNScYomaepV+hdjgnZhg=="
}, },
"vue-loader": { "vue-loader": {
"version": "17.2.2", "version": "17.2.2",

@ -20,7 +20,7 @@
"vue": "^2.6.14", "vue": "^2.6.14",
"vue-awesome-swiper": "^5.0.1", "vue-awesome-swiper": "^5.0.1",
"vue-clipboard2": "^0.3.3", "vue-clipboard2": "^0.3.3",
"vue-lazyload": "^1.3.3", "vue-lazyload": "^1.2.6",
"vue-router": "^3.5.1", "vue-router": "^3.5.1",
"vue-touch": "^2.0.0-beta.4", "vue-touch": "^2.0.0-beta.4",
"vuex": "^3.6.2" "vuex": "^3.6.2"

@ -5,6 +5,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" /> <meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="<%= BASE_URL %>favicon.ico" /> <link rel="icon" href="<%= BASE_URL %>favicon.ico" />
<title>视频监控可视化平台</title> <title>视频监控可视化平台</title>
</head> </head>
<body> <body>

@ -9,6 +9,35 @@ import { mapActions } from "vuex";
export default { export default {
name: "App", name: "App",
mounted() {
let goUrl = this.isMobile();
if (goUrl === 1) {
this.$confirm(
"您正在使用手机访问本站,可能无法获得最佳浏览体验, 即将跳转到手机端...",
"提示",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
customClass: "phonemesBox",
}
)
.then(() => {
// this.$message({
// type: "success",
// message: "!",
// });
//
location = "http://61.169.135.146:40080/phone/#/login";
})
.catch(() => {
// this.$message({
// type: "info",
// message: "",
// });
});
}
},
methods: { methods: {
...mapActions("cache", ["addCache", "removeCache"]), ...mapActions("cache", ["addCache", "removeCache"]),
// //
@ -46,6 +75,15 @@ export default {
this.cmpNames[name] = file; this.cmpNames[name] = file;
} }
}, },
isMobile() {
let flag = navigator.userAgent.match(
/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
);
// localStorage.setItem('isiphone',flag)
localStorage.setItem("ismobile", flag ? 1 : 0);
let goUrl = flag ? 1 : 0;
return goUrl;
},
}, },
watch: { watch: {
"$route.path": { "$route.path": {
@ -58,4 +96,9 @@ export default {
}; };
</script> </script>
<style lang="less"></style> <style lang="less">
.phonemesBox {
width: 80% !important;
max-width: 450px;
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

@ -28,6 +28,11 @@ Vue.use(ElementUI, {
//引入插件 //引入插件
import VueLazyload from "vue-lazyload"; import VueLazyload from "vue-lazyload";
//注册插件 //注册插件
// 全局配置vue-lazyload
// Vue.use(VueLazyload, {
// listenEvents: ["scroll"], // 监听的事件类型
// });
Vue.use(VueLazyload, { Vue.use(VueLazyload, {
error: require("./assets/img/nodatapic2.jpg"), error: require("./assets/img/nodatapic2.jpg"),
listenEvents: [ listenEvents: [

File diff suppressed because it is too large Load Diff

@ -16,6 +16,7 @@
<span>{{ protocolInfo }}</span> <span>{{ protocolInfo }}</span>
<!-- <span>({{ terminalPhoto.length }})</span> --> <!-- <span>({{ terminalPhoto.length }})</span> -->
</div> </div>
<div class="topPic"> <div class="topPic">
<div <div
class="bigPic" class="bigPic"
@ -23,11 +24,7 @@
> >
<el-image :src="currentPicPath"></el-image> <el-image :src="currentPicPath"></el-image>
</div> </div>
<div <div class="bigPic" v-else-if="currentPicPath && mediaType == 0">
class="bigPic"
v-else-if="currentPicPath && mediaType == 0"
v-loading="picLoading"
>
<!-- :preview-src-list="srcList" @click="handleBigPicbox(currentPicPath)" --> <!-- :preview-src-list="srcList" @click="handleBigPicbox(currentPicPath)" -->
<el-image <el-image
:src="currentPicPath + '!1366x768'" :src="currentPicPath + '!1366x768'"
@ -74,6 +71,7 @@
</div> </div>
</div> </div>
<!-- --> <!-- -->
<div class="bottomPic"> <div class="bottomPic">
<div class="scrollPicContain"> <div class="scrollPicContain">
<div <div
@ -99,7 +97,7 @@
" "
> >
<!-- <el-image v-lazy="item.path + '!260x160'"></el-image> --> <!-- <el-image v-lazy="item.path + '!260x160'"></el-image> -->
<img v-lazy="item.path + '!260x160'" /> <img v-lazy="item.path + '!160x60'" />
<!-- <img :src="item.path + '!260x160'" />--> <!-- <img :src="item.path + '!260x160'" />-->
<!-- :class="{ alarmSpan: item.isAlarm === 1 }" --> <!-- :class="{ alarmSpan: item.isAlarm === 1 }" -->
<p class="timeInfo"> <p class="timeInfo">
@ -134,7 +132,7 @@
</div> </div>
<div class="picBox" v-else-if="item.mediaType == 1"> <div class="picBox" v-else-if="item.mediaType == 1">
<!-- <el-image :src="item.thumb + '!260x160'"></el-image> --> <!-- <el-image :src="item.thumb + '!260x160'"></el-image> -->
<img v-lazy="item.thumb + '!260x160'" /> <img v-lazy="item.thumb + '!160x60'" />
<p class="timeInfo"> <p class="timeInfo">
<i class="el-icon-video-camera"></i> <i class="el-icon-video-camera"></i>
<el-tooltip <el-tooltip
@ -256,16 +254,19 @@ export default {
// //
showBigpic: false, showBigpic: false,
picShowFlag: true,
}; };
}, },
mounted() { mounted() {
////console.log(this.terminalPhoto); console.log("我是图片列表", this.terminalPhoto);
this.changeBigPic(this.terminalPhoto[0], 0); this.changeBigPic(this.terminalPhoto[0], 0);
// console.log(this.terminalPhoto[0].path);
}, },
watch: { watch: {
terminalPhoto: { terminalPhoto: {
handler(newVal, oldVal) { handler(newVal, oldVal) {
this.terminalPhoto = newVal; this.terminalPhoto = newVal;
console.log("我是图片列表", this.terminalPhoto);
}, },
immediate: true, immediate: true,
deep: true, //deep false deep: true, //deep false
@ -403,6 +404,10 @@ export default {
// //
changeBigPic(data, i) { changeBigPic(data, i) {
// //console.log("222222222", this.currentPage, this.activeSmall); // //console.log("222222222", this.currentPage, this.activeSmall);
this.picShowFlag = true;
if (this.currentPicPath == "static/img/nopic.0e9cfc7c.jpg") {
this.picShowFlag = false;
}
this.picDataAlarm = data; this.picDataAlarm = data;
this.srcList = []; this.srcList = [];
this.localPoints = []; this.localPoints = [];
@ -458,10 +463,12 @@ export default {
console.log("loading"); console.log("loading");
this.picLoading = false; this.picLoading = false;
this.drawlineBig(this.picDataAlarm); this.drawlineBig(this.picDataAlarm);
this.picShowFlag = false;
}, },
setDefaultImage(e) { setDefaultImage(e) {
e.target.src = defaultImage; e.target.src = defaultImage;
this.picLoading = false; this.picLoading = false;
this.picShowFlag = false;
}, },
// //
handleScroll(e) { handleScroll(e) {
@ -699,6 +706,20 @@ export default {
color: #fff; color: #fff;
font-size: 14px; font-size: 14px;
} }
.skeletonBox {
width: 100%;
height: 80%;
margin-bottom: 4px;
.el-skeleton,
.elpicBox {
width: 100%;
height: 100%;
}
.el-skeleton__image svg {
width: 50%;
height: 50%;
}
}
.topPic { .topPic {
width: 100%; width: 100%;
height: 80%; height: 80%;
@ -708,9 +729,14 @@ export default {
width: 100%; width: 100%;
height: 100%; height: 100%;
cursor: pointer; cursor: pointer;
.el-image { .el-image {
width: 100%; width: 100%;
height: 100%; height: 100%;
.el-image__placeholder {
background: url(../../../assets/img/nopicbg.png) no-repeat center;
background-size: 100% 100%;
}
img { img {
width: 100%; width: 100%;
height: 100%; height: 100%;
@ -846,6 +872,27 @@ export default {
overflow-y: hidden; overflow-y: hidden;
scroll-behavior: smooth; scroll-behavior: smooth;
scrollbar-width: none; scrollbar-width: none;
//background-color: #4cdbc8;
.noppiclist {
width: 100%;
height: 100%;
display: flex;
// align-items: center;
justify-content: center;
li {
list-style: none;
width: 19.2%;
height: 100%;
border: 3px solid transparent;
box-sizing: border-box;
flex-shrink: 0;
white-space: nowrap;
position: relative;
cursor: pointer;
background: url(../../../assets/img/nopicbg.png) no-repeat;
background-size: 100% 100%;
}
}
.smallPic { .smallPic {
width: 19.2%; width: 19.2%;
border: 3px solid transparent; border: 3px solid transparent;
@ -857,8 +904,9 @@ export default {
.picBox { .picBox {
width: 100%; width: 100%;
height: 100%; height: 100%;
background: url(../../../assets/img/nopicbg.png) no-repeat;
background-size: 100% 100%;
} }
img { img {
width: 100%; width: 100%;
height: 100%; height: 100%;

@ -0,0 +1,999 @@
<template>
<div class="thumb-example">
<div class="radioBox" v-if="roleUser == 8 || roleUser == 0">
{{ radioPx }} <span v-if="fileSize">({{ fileSize }})</span>
<span v-if="protocolInfo == '65280'"> I1 </span>
<span v-if="protocolInfo == '65296'"> 西 </span>
<span v-if="protocolInfo == '65281'"> </span>
<span v-if="protocolInfo == '65282'"> </span>
<span v-if="protocolInfo == '65283'"> </span>
<span v-if="protocolInfo == '65284'"> </span>
<span v-if="protocolInfo == '65285'"> </span>
<span v-if="protocolInfo == '65286'"> </span>
<span v-if="protocolInfo == '65290'"> v2020 </span>
<span v-if="protocolInfo == '65298'"> </span>
<span v-if="protocolInfo == '2'"> </span>
<span>{{ protocolInfo }}</span>
<!-- <span>({{ terminalPhoto.length }})</span> -->
</div>
<div class="topPic">
<div
class="bigPic"
v-if="currentPicPath.indexOf('nopic') !== -1 && currentPicPath"
>
<el-image :src="currentPicPath"></el-image>
</div>
<div
class="bigPic"
v-else-if="currentPicPath && mediaType == 0"
v-loading="picLoading"
>
<!-- :preview-src-list="srcList" @click="handleBigPicbox(currentPicPath)" -->
<el-image
:src="currentPicPath + '!1366x768'"
@load="loadImage"
@error="setDefaultImage"
ref="picJpg"
id="alarmPic"
width="100%"
height="100%"
:preview-src-list="srcList"
>
<template slot="error">
<img src="../../../assets/img/nodatapic2.jpg" />
</template>
</el-image>
<canvas id="myCanvas" class="myCanvas" ref="myCanvas"></canvas>
<canvas id="alarmCanvas" class="alarmCanvas" ref="alarmCanvas"></canvas>
<!-- <img :src="currentPicPath + '!1366x768'" @load="loadImage" /> -->
</div>
<div class="bigPic" v-else-if="currentPicPath && mediaType == 1">
<video
width="100%"
height="100%"
:src="currentPicPath"
controls="controls"
autoplay
></video>
</div>
<div class="arrow leftArrow" @click="leftClick" v-if="activeSmall > 0">
<i class="el-icon-arrow-left"></i>
</div>
<el-button
v-if="mediaType !== 1"
class="downBtn"
@click.stop="downLoadPic(currentPicPath, currentPicPath)"
>下载图片</el-button
>
<div
class="arrow rightArrow"
@click="rightClick"
v-if="activeSmall !== terminalPhoto.length - 1"
>
<i class="el-icon-arrow-right"></i>
</div>
</div>
<!-- -->
<div class="bottomPic">
<div class="scrollPicContain">
<div
class="el-car-item"
ref="scrollBox"
v-on:wheel="handleScroll"
:class="terminalPhoto.length < photoNum ? 'littlePic' : ''"
>
<div
class="smallPic"
v-for="(item, index2) in terminalPhoto"
:key="index2"
@click="changeBigPic(item, index2)"
:class="`${activeSmall === index2 ? 'borderActive ' : ''}${
photoNum === 10 ? 'moreSmallPic' : ''
}`"
>
<div
class="picBox"
v-if="
item.path.indexOf('nopic') == -1 &&
item.path.indexOf('videos') == -1
"
>
<!-- <el-image v-lazy="item.path + '!260x160'"></el-image> -->
<img v-lazy="item.path + '!160x60'" />
<!-- <img :src="item.path + '!260x160'" />-->
<!-- :class="{ alarmSpan: item.isAlarm === 1 }" -->
<p class="timeInfo">
<el-tooltip
class="item"
effect="dark"
content="拍照时间"
placement="top-start"
>
<span>{{ $moment(item.photoTime).format("HH:mm:ss") }}</span>
</el-tooltip>
(
<el-tooltip
class="item"
effect="dark"
content="图片上传时间"
placement="top-start"
>
<span> {{ $moment(item.recvTime).format("HH:mm:ss") }}</span>
</el-tooltip>
)
<span
>--{{
item.alias !== null && item.alias !== ""
? item.alias
: item.channelName
}}</span
>
<span class="alarmSpan" v-if="item.isAlarm == 1">()</span>
</p>
</div>
<div class="picBox" v-else-if="item.mediaType == 1">
<!-- <el-image :src="item.thumb + '!260x160'"></el-image> -->
<img v-lazy="item.thumb + '!160x60'" />
<p class="timeInfo">
<i class="el-icon-video-camera"></i>
<el-tooltip
class="item"
effect="dark"
content="拍照时间"
placement="top-start"
>
<span>{{ $moment(item.photoTime).format("HH:mm:ss") }}</span>
</el-tooltip>
(
<el-tooltip
class="item"
effect="dark"
content="图片上传时间"
placement="top-start"
>
<span> {{ $moment(item.recvTime).format("HH:mm:ss") }}</span>
</el-tooltip>
)
<span
>--{{
item.alias !== null && item.alias !== ""
? item.alias
: item.channelName
}}</span
>
</p>
</div>
<div class="picBox" v-else>
<!-- <el-image :src="item.path"></el-image> -->
<img v-lazy="item.path" />
</div>
</div>
</div>
<div class="arrow leftArrow" @click.stop="smallLeftClick" ref="leftRef">
<i class="el-icon-arrow-left"></i>
</div>
<div class="arrow rightArrow" ref="rightRef">
<i class="el-icon-arrow-right" @click.stop="smallRightClick"></i>
</div>
</div>
</div>
<!-- 点击出现大图 -->
<!-- <div v-if="showBigpic" class="showPic" @click="closePic($event)">
<div class="picboxI">
<img
id="bigimg2"
ref="bigimgref"
class="maskPic img"
:src="bigImgPath"
width="100%"
height="100%"
/>
<canvas id="bigCanvas2" class="mybigCanvas" ref="myCanvasbig"></canvas>
</div>
<div class="viewClose" @click="closePic($event)">
<i class="el-icon-close"></i>
</div>
</div> -->
</div>
</template>
<script>
import defaultImage from "../../../assets/img/nodatapic2.jpg";
import { getCoordinate, updateMarkEnableStatus } from "@/utils/api/index";
export default {
components: {},
props: {
terminalPhoto: {
type: Array,
default: () => [],
},
photoNum: {
type: Number,
default: () => [],
},
protocolInfo: {
type: Number,
},
},
data() {
return {
items: [
"Item 1",
"Item 2",
"Item 3",
"Item 4",
"Item 5",
"Item 6",
"Item 7",
"Item 8",
"Item 9",
"Item 10",
],
picLoading: true,
currentPicPath: "", //
mediaType: "", //
activeSmall: 0, //,
currentPage: 0,
srcList: [],
radioPx: "",
fileSize: "",
roleUser: "",
localPoints: [], //线
flagLine: true, //线
canvas: null,
ctx: null,
imgpic: null,
color: "", //线
borderwidth: "", //线
markEnable: "", //
recArrs: [],
picDataAlarm: [],
labelMarkArrs: [],
//
showBigpic: false,
picShowFlag: true,
};
},
mounted() {
////console.log(this.terminalPhoto);
this.changeBigPic(this.terminalPhoto[0], 0);
// console.log(this.terminalPhoto[0].path);
},
watch: {
terminalPhoto: {
handler(newVal, oldVal) {
this.terminalPhoto = newVal;
},
immediate: true,
deep: true, //deep false
},
},
computed: {},
created() {
this.roleUser = localStorage.getItem("role");
////console.log(this.roleUser);
},
methods: {
//
async downLoadPic(path, name) {
const imgUrl = path;
const response = await fetch(imgUrl);
const blob = await response.blob();
//
const url = window.URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
console.log(name);
link.download = name.split("/").pop();
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
// Blob URL
window.URL.revokeObjectURL(url);
},
//线
getPointList(data) {
console.log("woshi 线缆绘制", data);
getCoordinate({
channelId: data.channelId,
needPic: "1",
termId: data.termId,
})
.then((res) => {
//console.log(res);
this.localPoints = res.data.list;
this.color = res.data.color;
this.borderwidth = res.data.boderWidth;
this.markEnable = res.data.markEnable;
if (this.markEnable === 1) {
this.drawline();
}
})
.catch((err) => {});
},
//线
openLine() {
this.flagLine = true;
//1
updateMarkEnableStatus({
status: 1,
}).then((res) => {
//console.log(res);
});
this.drawline();
},
//线
closeLine() {
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
this.flagLine = false;
//0
updateMarkEnableStatus({
status: 0,
}).then((res) => {
//console.log(res);
});
},
//线
drawline() {
this.canvas = this.$refs.myCanvas;
this.imgpic = this.$refs.picJpg;
this.canvas.width = this.imgpic.imageWidth; //
this.canvas.height = this.imgpic.imageHeight; //
this.ctx = this.canvas.getContext("2d");
if (this.flagLine == true) {
this.localPoints = this.localPoints;
} else {
this.localPoints = [];
}
this.ctx.beginPath();
//线
this.ctx.strokeStyle = this.color;
// 线
this.ctx.lineWidth = this.borderwidth;
if (this.localPoints == null) {
return;
} else {
for (var i = 0; i < this.localPoints.length; i++) {
this.ctx.moveTo(
this.localPoints[i].x1 * this.imgpic.imageWidth,
this.localPoints[i].y1 * this.imgpic.imageHeight
);
this.ctx.lineTo(
this.localPoints[i].x2 * this.imgpic.imageWidth,
this.localPoints[i].y2 * this.imgpic.imageHeight
);
}
this.ctx.closePath();
this.ctx.stroke();
}
// this.ctx.beginPath(); //
// this.ctx.moveTo(100, 100); //
// this.ctx.lineTo(300, 100); //
// this.ctx.lineTo(300, 300); //
// this.ctx.closePath(); //
// this.ctx.stroke(); //
},
//
leftClick() {
console.log(this.photoNum);
this.activeSmall--;
this.$refs.scrollBox.scrollLeft -=
this.$refs.scrollBox.offsetWidth / this.photoNum;
this.changeBigPic(this.terminalPhoto[this.activeSmall], this.activeSmall);
},
rightClick() {
console.log(this.photoNum);
this.activeSmall++;
this.$refs.scrollBox.scrollLeft +=
this.$refs.scrollBox.offsetWidth / this.photoNum;
this.changeBigPic(this.terminalPhoto[this.activeSmall], this.activeSmall);
},
//
changeBigPic(data, i) {
// //console.log("222222222", this.currentPage, this.activeSmall);
this.picShowFlag = true;
if (this.currentPicPath == "static/img/nopic.0e9cfc7c.jpg") {
this.picShowFlag = false;
}
this.picDataAlarm = data;
this.srcList = [];
this.localPoints = [];
this.activeSmall = i;
this.mediaType = data.mediaType;
this.currentPicPath = data.path;
this.srcList.push(data.path);
if (data.width != undefined) {
this.radioPx = data.width + "x" + data.height;
} else {
this.radioPx = "";
}
if (data.fileSize !== undefined) {
const sizeInBytes = data.fileSize;
const sizeInMB = sizeInBytes / (1024 * 1024);
const sizeInKB = sizeInBytes / 1024;
if (sizeInMB >= 1) {
this.fileSize = `${sizeInMB.toFixed(2)}M`; // 1MBMB
} else {
this.fileSize = `${sizeInKB.toFixed(0)}K`; // 1MBKB
}
} else {
this.fileSize = ""; // data.fileSize
}
// console.log(data.channelId);
if (data.channelId) {
this.getPointList(data);
}
const items = this.$refs.scrollBox.querySelectorAll(".smallPic");
const selectedItem = items[i];
const selectedItemLeft = selectedItem.offsetLeft;
const scrollContainer = this.$refs.scrollBox;
const scrollContainerWidth = scrollContainer.offsetWidth;
const selectedItemWidth = selectedItem.offsetWidth;
//
let scrollDistance =
selectedItemLeft - (scrollContainerWidth - selectedItemWidth) / 2;
if (scrollDistance < 0) {
scrollDistance = 0;
} else if (
scrollDistance + scrollContainerWidth >
scrollContainer.scrollWidth
) {
scrollDistance = scrollContainer.scrollWidth - scrollContainerWidth;
}
// scrollLeft
scrollContainer.scrollLeft = scrollDistance;
},
loadImage() {
console.log("loading");
this.picLoading = false;
this.drawlineBig(this.picDataAlarm);
this.picShowFlag = false;
},
setDefaultImage(e) {
e.target.src = defaultImage;
this.picLoading = false;
this.picShowFlag = false;
},
//
handleScroll(e) {
let direction = e.deltaY > 0 ? "down" : "up"; //deltaY
if (direction == "down") {
this.$refs.scrollBox.scrollLeft +=
(this.$refs.scrollBox.offsetWidth / this.photoNum) * 2;
}
if (direction == "up") {
this.$refs.scrollBox.scrollLeft -=
(this.$refs.scrollBox.offsetWidth / this.photoNum) * 2;
}
},
handleSwipeLeft() {
//
this.$refs.scrollBox.scrollLeft -=
(this.$refs.scrollBox.offsetWidth / this.photoNum) * 2;
},
handleSwipeRight() {
//
this.$refs.scrollBox.scrollLeft +=
(this.$refs.scrollBox.offsetWidth / this.photoNum) * 2;
},
//
smallLeftClick() {
this.$refs.scrollBox.scrollLeft -= this.$refs.scrollBox.offsetWidth;
this.$forceUpdate(); // Vue
},
smallRightClick() {
this.$refs.scrollBox.scrollLeft += this.$refs.scrollBox.offsetWidth;
this.$forceUpdate(); // Vue
},
//
//
drawlineBig(data) {
console.log(data);
this.canvas = document.getElementById("alarmCanvas");
this.imgpic = document.getElementById("alarmPic");
console.log(document.getElementById("alarmCanvas"));
console.log(document.getElementById("alarmPic"));
console.log(this.canvas);
console.log(this.imgpic);
this.textInfo = data.enname;
this.canvas.width = this.imgpic.offsetWidth; //
this.canvas.height = this.imgpic.offsetHeight; //
console.log(this.canvas.width, this.canvas.height);
this.ctx = this.canvas.getContext("2d");
this.ctx.beginPath();
//线
this.ctx.strokeStyle = "#ff0000";
// 线
this.ctx.lineWidth = 2;
this.labelMarkArrs = data.alarmlist;
this.recArrs = [];
for (var i = 0; i < this.labelMarkArrs.length; i++) {
console.log(this.labelMarkArrs[i]);
//
this.recArrs.push({
x:
this.labelMarkArrs[i].x * this.canvas.width -
(this.labelMarkArrs[i].width * this.canvas.width) / 2,
y:
this.labelMarkArrs[i].y * this.canvas.height -
(this.labelMarkArrs[i].height * this.canvas.height) / 2,
w: this.labelMarkArrs[i].width * this.canvas.width,
h: this.labelMarkArrs[i].height * this.canvas.height,
text: this.labelMarkArrs[i].enname + this.labelMarkArrs[i].prob + "%",
type: this.labelMarkArrs[i].label,
});
}
console.log(this.recArrs);
if (!this.recArrs.length) return;
for (var i = 0; i < this.recArrs.length; i++) {
// >2
if (this.recArrs[i].w > 2 && this.recArrs[i].h > 2) {
this.ctx.beginPath();
this.ctx.lineWidth = 2; // 线
this.ctx.strokeStyle = "rgb(255, 255, 0)"; // 线
//
// this.ctx.fillStyle = "rgba(22, 158, 140, 0.4)"; //
this.ctx.strokeRect(
this.recArrs[i].x,
this.recArrs[i].y,
this.recArrs[i].w,
this.recArrs[i].h
); //
// this.ctx.fillRect(
// this.recArrs[i].x,
// this.recArrs[i].y,
// this.recArrs[i].w,
// this.recArrs[i].h
// ); //
//
if (this.recArrs[i].text) {
this.ctx.font = "100 18px 微软雅黑";
this.ctx.lineWidth = 1;
this.ctx.strokeStyle = "rgb(255,255,0)";
this.ctx.strokeText(
this.recArrs[i].text,
this.recArrs[i].x +
this.recArrs[i].w / 2 -
(this.recArrs[i].text.length / 2) * 16,
this.recArrs[i].y - 20 < 0
? this.recArrs[i].y + this.recArrs[i].h + 20
: this.recArrs[i].y - 10
);
}
}
}
this.ctx.closePath();
this.ctx.stroke();
},
//
drawlineBig2(data) {
console.log(data);
this.canvas = document.getElementById("bigCanvas2");
this.imgpic = document.getElementById("bigimg2");
console.log(document.getElementById("alarmCanvas"));
console.log(document.getElementById("bigimg2"));
console.log(this.canvas);
console.log(this.imgpic);
this.textInfo = data.enname;
this.canvas.width = this.imgpic.offsetWidth; //
this.canvas.height = this.imgpic.offsetHeight; //
console.log(this.canvas.width, this.canvas.height);
this.ctx = this.canvas.getContext("2d");
this.ctx.beginPath();
//线
this.ctx.strokeStyle = "#ff0000";
// 线
this.ctx.lineWidth = 2;
this.labelMarkArrs = data.alarmlist;
this.recArrs = [];
for (var i = 0; i < this.labelMarkArrs.length; i++) {
console.log(this.labelMarkArrs[i]);
//
this.recArrs.push({
x:
this.labelMarkArrs[i].x * this.canvas.width -
(this.labelMarkArrs[i].width * this.canvas.width) / 2,
y:
this.labelMarkArrs[i].y * this.canvas.height -
(this.labelMarkArrs[i].height * this.canvas.height) / 2,
w: this.labelMarkArrs[i].width * this.canvas.width,
h: this.labelMarkArrs[i].height * this.canvas.height,
text: this.labelMarkArrs[i].enname + this.labelMarkArrs[i].prob + "%",
type: this.labelMarkArrs[i].label,
});
}
console.log(this.recArrs);
if (!this.recArrs.length) return;
for (var i = 0; i < this.recArrs.length; i++) {
// >2
if (this.recArrs[i].w > 2 && this.recArrs[i].h > 2) {
this.ctx.beginPath();
this.ctx.lineWidth = 2; // 线
this.ctx.strokeStyle = "rgb(255, 255, 0)"; // 线
//
// this.ctx.fillStyle = "rgba(22, 158, 140, 0.4)"; //
this.ctx.strokeRect(
this.recArrs[i].x,
this.recArrs[i].y,
this.recArrs[i].w,
this.recArrs[i].h
); //
// this.ctx.fillRect(
// this.recArrs[i].x,
// this.recArrs[i].y,
// this.recArrs[i].w,
// this.recArrs[i].h
// ); //
//
if (this.recArrs[i].text) {
this.ctx.font = "100 16px 微软雅黑";
this.ctx.lineWidth = 2;
this.ctx.strokeStyle = "rgb(255,255,0)";
this.ctx.strokeText(
this.recArrs[i].text,
this.recArrs[i].x +
this.recArrs[i].w / 2 -
(this.recArrs[i].text.length / 2) * 16,
this.recArrs[i].y - 20 < 0
? this.recArrs[i].y + this.recArrs[i].h + 20
: this.recArrs[i].y - 10
);
}
}
}
this.ctx.closePath();
this.ctx.stroke();
},
//
handleBigPicbox(val) {
console.log(val);
this.showBigpic = true;
this.bigImgPath = val;
setTimeout(() => {
this.$nextTick(() => {
this.drawlineBig2(this.picDataAlarm);
});
}, 100);
},
closePic(e) {
console.log(e);
var btn = this.$refs.bigimgref;
console.log(btn);
if (btn) {
if (!btn.contains(event.target)) {
//.app-download
this.zoomD = 1;
this.showBigpic = false;
}
}
//
// this.showBigpic = false;
},
},
};
</script>
<style lang="less">
.thumb-example {
width: 100%;
// display: flex;
// flex-direction: column;
height: calc(100% - 32px);
box-sizing: border-box;
.radioBox {
position: absolute;
top: 8px;
right: 24px;
color: #fff;
font-size: 14px;
}
.skeletonBox {
width: 100%;
height: 80%;
margin-bottom: 4px;
.el-skeleton,
.elpicBox {
width: 100%;
height: 100%;
}
.el-skeleton__image svg {
width: 50%;
height: 50%;
}
}
.topPic {
width: 100%;
height: 80%;
margin-bottom: 4px;
position: relative;
.bigPic {
width: 100%;
height: 100%;
cursor: pointer;
.el-image {
width: 100%;
height: 100%;
img {
width: 100%;
height: 100%;
}
}
}
.myCanvas {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
cursor: pointer;
z-index: 3;
pointer-events: none;
}
#alarmCanvas {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
margin: 0 auto;
cursor: pointer;
pointer-events: none;
}
&:hover {
.arrow {
opacity: 1;
transition: all 0.5s ease-in;
}
.downBtn {
opacity: 1;
transition: all 0.5s ease-in;
}
}
.arrow {
opacity: 0;
position: absolute;
cursor: pointer;
font-size: 16px;
border-radius: 30px;
position: absolute;
top: 50%;
transform: translateY(-50%);
color: #4cdbc8;
font-weight: bold;
background-color: rgba(31, 45, 61, 0.8);
display: flex;
justify-content: center;
align-items: center;
text-align: center;
line-height: 60px;
width: 40px;
height: 40px;
z-index: 4;
&:hover {
background-color: rgba(31, 45, 61, 1);
}
}
.leftArrow {
left: 16px;
}
.rightArrow {
right: 16px;
}
.downBtn {
position: absolute;
background: rgba(0, 0, 0, 0.5);
border: none;
right: 24px;
bottom: 24px;
color: #fff;
z-index: 5;
opacity: 0;
&:hover {
background: rgba(0, 0, 0, 0.9);
color: #169e8c;
}
}
}
.bottomPic {
width: 100%;
height: 20%;
margin-bottom: 6px;
.scrollPicContain {
// width: 1380px;
display: flex;
height: 100%;
position: relative;
.arrow {
opacity: 0;
position: absolute;
cursor: pointer;
font-size: 14px;
border-radius: 30px;
position: absolute;
top: 50%;
transform: translateY(-50%);
color: #4cdbc8;
font-weight: bold;
background-color: rgba(31, 45, 61, 0.8);
display: flex;
justify-content: center;
align-items: center;
text-align: center;
line-height: 60px;
width: 30px;
height: 30px;
z-index: 4;
&:hover {
background-color: rgba(31, 45, 61, 1);
}
}
.leftArrow {
left: 16px;
}
.rightArrow {
right: 16px;
}
&:hover {
.arrow {
opacity: 1;
transition: all 0.5s ease-in;
}
}
}
.el-car-item {
width: 100%;
height: 100%;
display: flex;
overflow-x: auto;
overflow-y: hidden;
scroll-behavior: smooth;
scrollbar-width: none;
.smallPic {
width: 19.2%;
border: 3px solid transparent;
box-sizing: border-box;
flex-shrink: 0;
white-space: nowrap;
position: relative;
cursor: pointer;
.picBox {
width: 100%;
height: 100%;
}
img {
width: 100%;
height: 100%;
}
.timeInfo {
position: absolute;
bottom: 0px;
width: 100%;
background: #f0f0f0;
padding: 6px 0;
font-size: 12px;
text-align: center;
color: #333;
.el-icon-video-camera {
font-size: 20px;
margin-right: 8px;
align-items: center;
vertical-align: sub;
color: #169e8c;
}
}
.alarmSpan {
color: #f00;
font-weight: bold;
}
}
.moreSmallPic {
width: 9.8%;
}
.borderActive {
.timeInfo {
color: #fff;
background: linear-gradient(180deg, #4cdbc8 10%, #128071);
}
.alarmSpan {
color: #f00;
font-weight: bold;
}
}
}
.littlePic {
justify-content: center;
}
}
.showPic {
position: fixed;
background-color: rgba(0, 0, 0, 50%);
bottom: 0;
left: 0;
overflow: hidden;
right: 0;
top: 0;
z-index: 9999;
width: 100%;
height: 100%;
display: flex;
cursor: pointer;
.picboxI {
position: relative;
width: 90%;
height: 90%;
margin: auto;
animation-name: scaleDraw;
/*关键帧名称*/
animation-timing-function: ease;
/*动画的速度曲线*/
animation-iteration-count: 1;
/*动画播放的次数*/
animation-duration: 0.65s;
display: flex;
align-items: center;
justify-content: center;
img {
max-width: 100%;
max-height: 100%;
margin: auto;
position: absolute;
cursor: grab;
}
.mybigCanvas {
position: absolute;
// top: 0;
// left: 0;
max-width: 100%;
max-height: 100%;
margin: 0 auto;
cursor: pointer;
pointer-events: none;
}
}
.viewClose {
-webkit-app-region: no-drag;
background-color: rgba(0, 0, 0, 0.5);
border-radius: 50%;
cursor: pointer;
height: 80px;
overflow: hidden;
position: absolute;
right: -40px;
top: -40px;
transition: background-color 0.15s;
width: 80px;
.el-icon-close {
bottom: 16px;
left: 16px;
position: absolute;
color: #fff;
font-size: 18px;
}
}
}
}
</style>

@ -20,6 +20,7 @@
</div> </div>
<div class="picmain" v-loading="picLoading"> <div class="picmain" v-loading="picLoading">
<carouselChart <carouselChart
:key="carouselKey"
ref="carouselpic" ref="carouselpic"
:terminalPhoto="terminalPhoto" :terminalPhoto="terminalPhoto"
:photoNum="photoNum" :photoNum="photoNum"
@ -47,6 +48,7 @@ export default {
nopicPath: require("@/assets/img/nopic.jpg"), nopicPath: require("@/assets/img/nopic.jpg"),
picLoading: false, picLoading: false,
photoNum: 10, photoNum: 10,
carouselKey: 0, // key
}; };
}, },
mounted() {}, mounted() {},
@ -83,6 +85,7 @@ export default {
} else { } else {
this.terminalPhoto = res.data.list; this.terminalPhoto = res.data.list;
} }
this.carouselKey++; // key
// let newDataList = []; // let newDataList = [];
// let current = 0; // let current = 0;
// if (this.terminalPhoto && this.terminalPhoto.length > 0) { // if (this.terminalPhoto && this.terminalPhoto.length > 0) {

@ -0,0 +1,298 @@
<template>
<div class="realTimeMonitor" v-loading="mainLoading">
<div class="monitor-container">
<div class="allSide">
<div class="typeList">
<el-radio-group v-model="typeRadio" size="mini" @input="getTypeRadio">
<el-radio-button :label="-1">全部</el-radio-button>
<el-radio-button
:label="1"
v-if="roleName === 'superadmin' || roleName === 'Matthew'"
>活动</el-radio-button
>
</el-radio-group>
</div>
<sideBar ref="sideTree" v-if="allTreeFlag"></sideBar>
<activeSiderBar ref="activesideTree" v-else></activeSiderBar>
</div>
<div class="picListBox">
<div class="previewBox" v-if="LineFlag">
<!-- 预览图页面 -->
<previewContain ref="previewRef"></previewContain>
</div>
<div class="previewBox" v-if="towerFlag">
<div class="swiperBox" v-loading="swiperLoading">
<div class="title">
<el-breadcrumb separator="/">
<el-breadcrumb-item> {{ towertitle }}</el-breadcrumb-item>
</el-breadcrumb>
</div>
<carouselChart
ref="carouselpic"
:terminalPhoto="terminalPhoto"
:photoNum="photoNum"
:protocolInfo="protocolInfo"
v-if="terminalPhoto.length !== 0"
></carouselChart>
</div>
<div class="parameterArea">
<parameterArea ref="areaRef"></parameterArea>
</div>
</div>
</div>
</div>
<morePicPreveiw ref="morePicPreveiw_ref"></morePicPreveiw>
</div>
</template>
<script>
import { getTerminalPhotoListJoggle } from "@/utils/api/index";
import sideBar from "./components/siderBar";
import activeSiderBar from "./components/activeSiderBar";
import previewContain from "./components/previewContain";
import carouselChart from "./components/carouselChart";
import parameterArea from "./components/parameterArea";
import morePicPreveiw from "./components/morePicPreveiw";
import { mapGetters, mapState } from "vuex";
import ActiveSiderBar from "./components/activeSiderBar.vue";
export default {
name: "realTimeMonitor",
data() {
return {
LineFlag: false, //线
towerFlag: false, //
mainLoading: false, //loading
page: 1, //
towertitle: "", //
lineLoading: false, //loading
swiperLoading: false,
terminalPhoto: [], //
photoNum: 5,
dateValue: "", //
protocolInfo: "",
nopicPath: require("@/assets/img/nopic.jpg"),
typeRadio: -1, //
allTreeFlag: true,
roleName: "",
};
},
watch: {
treeSelectData: {
handler(newVal, oldVal) {},
deep: true,
immediate: true,
},
},
components: {
sideBar,
activeSiderBar,
previewContain,
carouselChart,
parameterArea,
morePicPreveiw,
},
computed: {
treeSelectData() {
return this.$store.state.currentData;
},
},
created() {
this.roleName = localStorage.getItem("userName");
//this.treeSelectData = currentData;
//
},
mounted() {
this.mainLoading = true;
setTimeout(() => {
this.mainLoading = false;
}, 1000);
},
methods: {
getTypeRadio() {
console.log(this.typeRadio);
if (this.typeRadio == -1) {
this.allTreeFlag = true;
} else {
this.allTreeFlag = false;
}
},
getCurrentData(data) {
console.log("执行父组件", this.treeSelectData);
if (this.treeSelectData.dyValue) {
console.log("电压");
this.LineFlag = true;
this.towerFlag = false;
this.lineLoading = true;
this.type = 1;
this.$nextTick(() => {
this.$refs.previewRef.getPicList(
this.treeSelectData.id,
this.type,
this.page
);
});
} else if (this.treeSelectData.dyLevelId) {
console.log("线路");
this.LineFlag = true;
this.towerFlag = false;
this.type = 2;
console.log(this.treeSelectData);
this.$nextTick(() => {
this.$refs.previewRef.getPicList(
this.treeSelectData.id,
this.type,
this.page
);
});
} else {
console.log("杆塔");
this.LineFlag = false;
this.towerFlag = true;
this.terminalPhoto = [];
this.protocolInfo = this.treeSelectData.protocol;
console.log("asddddddddddddddddddddd", this.treeSelectData);
this.towertitle = this.treeSelectData.name;
this.$nextTick(() => {
this.$refs.areaRef.getChannelList();
this.$refs.areaRef.takepicFun();
});
}
},
getPhotoList(channelId, date, termId) {
console.log(channelId, date, termId);
this.swiperLoading = true;
console.log("zhanshi asdadadadadadsddadadadadad", this.terminalPhoto);
this.terminalPhoto = [];
getTerminalPhotoListJoggle({
channelid: channelId,
time: date,
terminalid: termId,
})
.then((res) => {
console.log(res);
if (res.data.list.length == 0) {
this.terminalPhoto = [
{
path: this.nopicPath,
termId: termId,
mediatype: 0,
},
];
} else {
this.terminalPhoto = res.data.list;
}
// let newDataList = [];
// let current = 0;
// if (this.terminalPhoto && this.terminalPhoto.length > 0) {
// for (let i = 0; i <= this.terminalPhoto.length - 1; i++) {
// if (i % this.photoNum !== 0 || i === 0) {
// if (!newDataList[current]) {
// newDataList.push([this.terminalPhoto[i]]);
// } else {
// newDataList[current].push(this.terminalPhoto[i]);
// }
// } else {
// current++;
// newDataList.push([this.terminalPhoto[i]]);
// }
// }
// }
// this.terminalPhoto = [...newDataList];
// this.$nextTick(() => {
// this.$refs.carouselpic.changeBigPic(this.terminalPhoto[0][0], 0);
// });
this.$nextTick(() => {
this.$refs.carouselpic.changeBigPic(this.terminalPhoto[0], 0);
});
this.swiperLoading = false;
})
.catch((err) => {
console.log(err); //
});
},
//
jumpTowerPic(data) {
console.log("我是从子组件过来的数据");
console.log(data);
this.$refs.morePicPreveiw_ref.display(data);
},
},
};
</script>
<style lang="less">
.realTimeMonitor {
width: calc(100% - 0px);
height: calc(100% - 12px);
padding: 12px 0px 0px 0px;
background: #ffffff;
.monitor-container {
display: flex;
height: 100%;
box-sizing: border-box;
background: #ffffff;
border: 1px solid #dddddd;
border-radius: 4px;
.allSide {
height: 100%;
.typeList {
width: 94%;
margin: 0 auto;
margin-top: 8px;
}
}
.picListBox {
display: flex;
width: 100%;
height: 100%;
flex: 1;
overflow: hidden;
border-left: 1px solid #dddddd;
.previewBox {
display: flex;
width: 100%;
height: 100%;
flex: 1;
}
.swiperBox {
-webkit-box-flex: 1;
-ms-flex: 1;
flex: 1;
width: auto;
overflow: hidden;
display: flex;
flex-direction: column;
position: relative;
.title {
height: 32px;
padding-left: 12px;
line-height: 32px;
color: #fff;
font-size: 12px;
//background-color: #169e8cb0;
background: linear-gradient(180deg, #4cdbc8 10%, #128071 100%);
.el-breadcrumb {
line-height: 32px;
color: #fff !important;
font-size: 14px;
height: 32px;
.el-breadcrumb__inner,
.el-breadcrumb__separator {
color: #fff !important;
}
}
}
}
.parameterArea {
width: 220px;
padding: 0px 8px;
border-left: 1px solid #dddddd;
position: relative;
overflow-y: auto;
}
}
}
}
</style>

@ -21,7 +21,7 @@
<!-- 预览图页面 --> <!-- 预览图页面 -->
<previewContain ref="previewRef"></previewContain> <previewContain ref="previewRef"></previewContain>
</div> </div>
<div class="previewBox" v-if="towerFlag"> <div class="previewBox" v-show="towerFlag">
<div class="swiperBox" v-loading="swiperLoading"> <div class="swiperBox" v-loading="swiperLoading">
<div class="title"> <div class="title">
<el-breadcrumb separator="/"> <el-breadcrumb separator="/">
@ -30,10 +30,10 @@
</div> </div>
<carouselChart <carouselChart
ref="carouselpic" ref="carouselpic"
:key="carouselKey"
:terminalPhoto="terminalPhoto" :terminalPhoto="terminalPhoto"
:photoNum="photoNum" :photoNum="photoNum"
:protocolInfo="protocolInfo" :protocolInfo="protocolInfo"
v-if="terminalPhoto.length !== 0"
></carouselChart> ></carouselChart>
</div> </div>
<div class="parameterArea"> <div class="parameterArea">
@ -66,15 +66,16 @@ export default {
page: 1, // page: 1, //
towertitle: "", // towertitle: "", //
lineLoading: false, //loading lineLoading: false, //loading
swiperLoading: false, swiperLoading: true,
terminalPhoto: [], // terminalPhoto: [], //
photoNum: 5, photoNum: 5,
dateValue: "", // dateValue: "", //
protocolInfo: "", protocolInfo: 0,
nopicPath: require("@/assets/img/nopic.jpg"), nopicPath: require("@/assets/img/nopic.jpg"),
typeRadio: -1, // typeRadio: -1, //
allTreeFlag: true, allTreeFlag: true,
roleName: "", roleName: "",
carouselKey: 0, // key
}; };
}, },
watch: { watch: {
@ -149,7 +150,7 @@ export default {
console.log("杆塔"); console.log("杆塔");
this.LineFlag = false; this.LineFlag = false;
this.towerFlag = true; this.towerFlag = true;
this.terminalPhoto = []; //this.terminalPhoto = [];
this.protocolInfo = this.treeSelectData.protocol; this.protocolInfo = this.treeSelectData.protocol;
console.log("asddddddddddddddddddddd", this.treeSelectData); console.log("asddddddddddddddddddddd", this.treeSelectData);
this.towertitle = this.treeSelectData.name; this.towertitle = this.treeSelectData.name;
@ -163,7 +164,7 @@ export default {
console.log(channelId, date, termId); console.log(channelId, date, termId);
this.swiperLoading = true; this.swiperLoading = true;
console.log("zhanshi asdadadadadadsddadadadadad", this.terminalPhoto); console.log("zhanshi asdadadadadadsddadadadadad", this.terminalPhoto);
this.terminalPhoto = []; //this.terminalPhoto = [];
getTerminalPhotoListJoggle({ getTerminalPhotoListJoggle({
channelid: channelId, channelid: channelId,
time: date, time: date,
@ -176,12 +177,13 @@ export default {
{ {
path: this.nopicPath, path: this.nopicPath,
termId: termId, termId: termId,
mediatype: 0, mediaType: 0,
}, },
]; ];
} else { } else {
this.terminalPhoto = res.data.list; this.terminalPhoto = res.data.list;
} }
this.carouselKey++; // key
// let newDataList = []; // let newDataList = [];
// let current = 0; // let current = 0;
// if (this.terminalPhoto && this.terminalPhoto.length > 0) { // if (this.terminalPhoto && this.terminalPhoto.length > 0) {
@ -284,6 +286,9 @@ export default {
} }
} }
} }
.el-loading-mask {
background-color: rgba(0, 0, 0, 0.3);
}
} }
.parameterArea { .parameterArea {
width: 220px; width: 220px;

@ -343,6 +343,7 @@ export default {
message: res.msg, message: res.msg,
type: "error", type: "error",
}); });
this.progressLoading = false;
this.reportData.title = ""; this.reportData.title = "";
this.$refs.upload.clearFiles(); this.$refs.upload.clearFiles();
} }

Loading…
Cancel
Save