轮播图

master
fanluyan 2 years ago
parent a28f44361c
commit 04af23d181

@ -1,91 +1,78 @@
<template> <template>
<div class="thumb-example"> <div class="thumb-example">
<!-- swiper1 --> <div class="picTop">
<swiper <viewer class="bigimg">
class="swiper gallery-top" <img :src="bigPicPath + '!1280x720'" />
:options="swiperOptionTop" <p class="mark">
ref="swiperTop" {{ bigPicPath }}
> <span>{{ this.activeSmall }}</span>
<!-- --> </p>
</viewer>
<div class="arrow leftArrow" v-if="this.bigNum != 0" @click="leftClick">
<i class="el-icon-arrow-left"></i>
</div>
<div
class="arrow rightArrow"
v-if="this.bigNum < this.terminalPhoto.length - 1"
@click="rightClick"
>
<i class="el-icon-arrow-right"></i>
</div>
</div>
<div class="picBottom">
<ul class="smallPicBox">
<li
v-for="(item, index) in fiveList"
@click="handleBigpic(item, index)"
:class="activeSmall === index ? 'borderActive' : ''"
>
<!-- <img src="../../assets/img/nopic.jpg" /> -->
<img :src="item.path + '!260x160'" />
<p class="timeInfo" v-if="item.path.indexOf('nopic') == -1">
<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.channelId }}</span>
</p>
</li>
</ul>
<div <div
class="swiper-button-next swiper-button-white" class="arrow leftArrow"
slot="button-next" v-if="this.page != 1"
></div> @click="smallLeftClick"
>
<i class="el-icon-arrow-left"></i>
</div>
<div <div
class="swiper-button-prev swiper-button-white" class="arrow rightArrow"
slot="button-prev" v-if="this.page < this.total"
></div> @click="smallRightClick"
</swiper>
<!-- swiper2 Thumbs -->
<swiper
class="swiper gallery-thumbs"
:options="swiperOptionThumbs"
ref="swiperThumbs"
>
<swiper-slide
class="slide"
v-for="(item, index) in terminalPhoto"
:key="item.id"
> >
<div class="bigimg" v-if="item.path.indexOf('nopic') == -1"> <i class="el-icon-arrow-right"></i>
<!-- <img :src="item.path + '!1280x720'" alt="" /> --> </div>
<img v-if="index == 0" :src="item.path + '!260x160'" /> </div>
<img
v-else
src="../../assets/img/loading.jpg"
:data-src="item.path + '!260x160'"
class="swiper-lazy"
/>
</div>
<div class="bigimg" v-else>
<img :src="item.path" alt="" />
</div>
<!-- <img v-if="index == 0" :src="item.path + '!1280x720'" />
<img
src="item.path + '!260x160'"
alt=""
:data-src="item.path + '!260x160'"
class="swiper-lazy"
v-else-if="item.path.indexOf('nopic') == -1"
/>
<img :src="item.path" alt="" v-else /> -->
<p class="timeInfo" v-if="item.path.indexOf('nopic') == -1">
<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.channelId }}</span>
</p>
</swiper-slide>
</swiper>
</div> </div>
</template> </template>
<script> <script>
import { Swiper, SwiperSlide } from "vue-awesome-swiper";
import "swiper/css/swiper.css";
export default { export default {
components: { components: {},
Swiper,
SwiperSlide,
},
props: { props: {
terminalPhoto: { terminalPhoto: {
type: Array, type: Array,
@ -94,61 +81,85 @@ export default {
}, },
data() { data() {
return { return {
swiperOptionTop: { isshowArrow: true, //
lazy: { bigPicPath: "", //
loadPrevNext: true, smallPicPath: "", //
loadPrevNextAmount: 1, bigNum: 0, //
loadOnTransitionStart: true, fiveList: [], //list
}, activeSmall: 0, //,
navigation: { page: 1, //
nextEl: ".swiper-button-next", pagesize: 5, //
prevEl: ".swiper-button-prev", total: 0, //
},
virtual: {
slides: [],
renderSlide: function (slide, index) {
console.log(index);
if (slide.path.indexOf("nopic") != -1) {
return ` <div class="swiper-slide" ><div class="bigimg"><img src="static/img/nopic.0e9cfc7c.jpg" alt="" /></div></div>`;
} else {
return `<div class="swiper-slide"><div class="bigimg"><img src=" ${
slide.path + "!1280x720"
} " /></div></div>`;
}
},
},
},
swiperOptionThumbs: {
spaceBetween: 10,
centeredSlides: true,
slidesPerView: "auto",
slideToClickedSlide: true,
lazy: {
loadPrevNext: true,
loadPrevNextAmount: 5,
loadOnTransitionStart: true,
},
},
}; };
}, },
mounted() { mounted() {
this.$nextTick(() => { console.log(this.terminalPhoto);
const swiperTop = this.$refs.swiperTop.$swiper; this.bigPicPath = this.terminalPhoto[0].path;
const swiperThumbs = this.$refs.swiperThumbs.$swiper; this.fiveList = this.terminalPhoto.slice(this.page - 1, this.pagesize);
swiperTop.controller.control = swiperThumbs; this.total = this.terminalPhoto.length / this.pagesize;
swiperThumbs.controller.control = swiperTop;
});
}, },
methods: {},
watch: { methods: {
terminalPhoto: function (newVal, oldVal) { getphotoList() {
this.swiperOptionTop.virtual.slides = newVal; this.fiveList = this.terminalPhoto.slice(
(this.page - 1) * this.pagesize,
this.page * this.pagesize
);
this.bigPicPath = this.fiveList[this.activeSmall].path;
},
//
leftClick() {
this.bigNum--; //
this.bigPicPath = this.terminalPhoto[this.bigNum].path;
this.activeSmall--;
console.log("activeSmall", this.activeSmall, "bigNum", this.bigNum);
console.log(this.page);
if (this.activeSmall < 0) {
this.activeSmall = 4;
this.smallLeftClick();
}
},
//
rightClick() {
this.bigNum++; //
this.bigPicPath = this.terminalPhoto[this.bigNum].path;
this.activeSmall++;
console.log("activeSmall", this.activeSmall, "bigNum", this.bigNum);
if (this.activeSmall > 4) {
this.activeSmall = 0;
console.log(this.activeSmall);
this.smallRightClick();
}
},
//
handleBigpic(row, index) {
console.log(row);
console.log();
this.activeSmall = index;
this.bigPicPath = row.path;
},
//
smallLeftClick() {
console.log("点击了左侧");
this.page--;
if (this.page < 1) {
this.isshowArrow = false;
} else {
this.getphotoList();
}
console.log(this.page);
console.log(this.fiveList);
},
//
smallRightClick() {
console.log("点击了右侧");
console.log(this.page);
this.page++;
this.getphotoList();
console.log(this.fiveList);
}, },
},
created() {
console.log(this.swiperOptionTop.virtual.slides);
this.swiperOptionTop.virtual.slides = this.terminalPhoto;
}, },
}; };
</script> </script>
@ -157,101 +168,141 @@ export default {
width: 100%; width: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
height: calc(100% - 26px); height: calc(100% - 24px);
box-sizing: border-box; box-sizing: border-box;
.gallery-top { .picTop {
//background: #fcc;
width: 100%; width: 100%;
height: 80%; height: 80%;
overflow: hidden; overflow: hidden;
margin-bottom: 4px; margin-bottom: 4px;
//border: 3px solid transparent; position: relative;
.swiper-slide { &:hover {
.arrow {
opacity: 1;
transition: all 0.5s ease-in;
}
}
.bigimg {
width: 100%; width: 100%;
overflow: hidden; height: 100%;
.bigimg { display: flex;
width: 100%; align-items: center;
height: 100%; justify-content: center;
display: flex; position: relative;
align-items: center; .mark {
justify-content: center; position: absolute;
bottom: 16px;
color: #fff;
background-color: rgba(0, 0, 0, 0.5);
left: 16px;
font-size: 14px;
line-height: 24px;
animation: move 1s;
} }
img { @keyframes move {
width: 100%; 0% {
height: 100%; bottom: -10px;
object-fit: fill; }
100% {
transform: 16px;
}
} }
} }
.swiper-button-prev.swiper-button-disabled, img {
.swiper-button-next.swiper-button-disabled { width: 100%;
opacity: 0.35; height: 100%;
cursor: auto; object-fit: fill;
pointer-events: none; cursor: pointer;
display: none !important; }
.arrow {
opacity: 0;
position: absolute;
cursor: pointer;
color: #fff;
font-size: 60px;
border-radius: 30px;
position: absolute;
top: 50%;
transform: translateY(-50%);
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
color: #fff;
text-align: center;
line-height: 60px;
&:hover {
color: #409eff;
}
}
.leftArrow {
left: 16px;
}
.rightArrow {
right: 16px;
} }
} }
.gallery-thumbs { .picBottom {
width: 100%; width: 100%;
height: 18%; height: 18%;
.slide { position: relative;
width: 20%; .smallPicBox {
border: 3px solid transparent; width: 100%;
overflow: hidden; height: 100%;
box-sizing: border-box;
display: flex; display: flex;
align-items: center; li {
justify-content: center; width: 20%;
border: 3px solid transparent;
.bigimg { overflow: hidden;
width: 100%; box-sizing: border-box;
height: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
position: relative;
img {
width: 100%;
height: 100%;
object-fit: fill;
cursor: pointer;
}
} }
img { .borderActive {
//width: 100%; border: 3px solid #409eff;
height: 100%; }
object-fit: fill; .timeInfo {
position: absolute;
bottom: 0px;
width: 100%;
background: #f0f0f0;
padding: 8px 0px;
font-size: 12px;
text-align: center;
color: #333;
} }
} }
.arrow {
.timeInfo {
position: absolute; position: absolute;
bottom: 0px; cursor: pointer;
width: 100%; color: #fff;
background: #f0f0f0; font-size: 30px;
padding: 8px 0px; border-radius: 30px;
font-size: 12px; position: absolute;
top: 45%;
transform: translateY(-50%);
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
color: #fff;
text-align: center; text-align: center;
color: #333; line-height: 60px;
}
.leftArrow {
left: 16px;
}
.rightArrow {
right: 16px;
} }
}
.swiper-button-next.swiper-button-white,
.swiper-container-rtl .swiper-button-prev.swiper-button-white,
.swiper-button-prev.swiper-button-white,
.swiper-container-rtl .swiper-button-next.swiper-button-white {
width: 40px;
height: 40px;
border-radius: 30px;
position: absolute;
top: 50%;
transform: translateY(-50%);
background-color: rgba(0, 0, 0, 0.5);
display: flex;
justify-content: center;
align-items: center;
font-size: 30px;
color: #fff;
text-align: center;
line-height: 60px;
}
.swiper-button-next:after,
.swiper-container-rtl .swiper-button-prev:after,
.swiper-button-prev:after,
.swiper-container-rtl .swiper-button-next:after {
transform: scale(0.5);
} }
} }
// https://v1.github.surmon.me/vue-awesome-swiper/ // https://v1.github.surmon.me/vue-awesome-swiper/

@ -1,30 +1,20 @@
<template> <template>
<div class="thumb-example"> <div class="thumb-example">
<!-- swiper1 --> <!-- swiper1 -->
<swiper <swiper
class="swiper gallery-top" class="swiper gallery-top"
:options="swiperOptionTop" :options="swiperOptionTop"
ref="swiperTop" ref="swiperTop"
> >
<swiper-slide <!-- -->
class="slide-1" <!-- <viewer class="swiper-slide">
v-for="(item, index) in terminalPhoto"
:key="item.id" </viewer> -->
> <!-- <viewer class="swiper-slide">
<viewer class="bigimg" v-if="item.path.indexOf('nopic') == -1">
<!-- <img :src="item.path + '!1280x720'" alt="" /> --> </viewer> -->
<img v-if="index == 0" :src="item.path + '!1280x720'" />
<img
v-else
src="../../assets/img/loading.jpg"
:data-src="item.path + '!1280x720'"
class="swiper-lazy"
/>
</viewer>
<div class="bigimg" v-else>
<img :src="item.path" alt="" />
</div>
</swiper-slide>
<div <div
class="swiper-button-next swiper-button-white" class="swiper-button-next swiper-button-white"
slot="button-next" slot="button-next"
@ -34,6 +24,7 @@
slot="button-prev" slot="button-prev"
></div> ></div>
</swiper> </swiper>
<!-- swiper2 Thumbs --> <!-- swiper2 Thumbs -->
<swiper <swiper
class="swiper gallery-thumbs" class="swiper gallery-thumbs"
@ -46,6 +37,7 @@
:key="item.id" :key="item.id"
> >
<div class="bigimg" v-if="item.path.indexOf('nopic') == -1"> <div class="bigimg" v-if="item.path.indexOf('nopic') == -1">
<!-- <img :src="item.path + '!1280x720'" alt="" /> -->
<img v-if="index == 0" :src="item.path + '!260x160'" /> <img v-if="index == 0" :src="item.path + '!260x160'" />
<img <img
v-else v-else
@ -109,48 +101,47 @@ export default {
}, },
}, },
data() { data() {
let a = "1111111111111";
return { return {
imgflag: false,
swiperOptionTop: { swiperOptionTop: {
spaceBetween: 10,
//loop: true,
freeMode: true,
// loopedSlides: 1,
lazy: { lazy: {
loadPrevNext: true, loadPrevNext: true,
loadPrevNextAmount: 1, loadPrevNextAmount: 1,
loadOnTransitionStart: true, loadOnTransitionStart: true,
}, },
// lazyLoading: true, //
navigation: { navigation: {
nextEl: ".swiper-button-next", nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev", prevEl: ".swiper-button-prev",
}, },
observer: true, //swiperswiper virtual: {
observeParents: true, //swiperswiper slides: [],
onSlideChangeEnd: function (swiper) { renderSlide: function (slide, index) {
swiper.update(); if (slide.path.indexOf("nopic") != -1) {
return `<div class="swiper-slide"><div class="bigimg"><img src="static/img/nopic.0e9cfc7c.jpg" alt="" /></div></div>`;
} else {
return (
`<view class="swiper-slide">` +
`<div class="bigimg" id="imgView" style="background:url(${
slide.path + "!80x720"
});background-size:100% 100%">` +
`<img id="imgid" src=" ${slide.path + "!1280x720"} " />
</view>`
);
}
},
}, },
}, },
swiperOptionThumbs: { swiperOptionThumbs: {
spaceBetween: 10, spaceBetween: 10,
centeredSlides: true, centeredSlides: true,
slidesPerView: "auto", slidesPerView: "auto",
touchRatio: 0.2,
lazyLoading: true, //
slideToClickedSlide: true, slideToClickedSlide: true,
lazy: { lazy: {
loadPrevNext: true, loadPrevNext: true,
loadPrevNextAmount: 5, loadPrevNextAmount: 5,
loadOnTransitionStart: true, loadOnTransitionStart: true,
//loadOnTransitionStart: true,
}, },
observer: true, //swiperswiper
observeParents: true, //swiperswiper
onSlideChangeEnd: function (swiper) {
swiper.update();
},
//loop: true,
//loopedSlides: 4,
}, },
}; };
}, },
@ -162,8 +153,16 @@ export default {
swiperThumbs.controller.control = swiperTop; swiperThumbs.controller.control = swiperTop;
}); });
}, },
methods: {}, methods: {},
watch: {
terminalPhoto: function (newVal, oldVal) {
this.swiperOptionTop.virtual.slides = newVal;
},
},
created() {
console.log(this.swiperOptionTop.virtual.slides);
this.swiperOptionTop.virtual.slides = this.terminalPhoto;
},
}; };
</script> </script>
<style lang="less"> <style lang="less">
@ -180,7 +179,7 @@ export default {
overflow: hidden; overflow: hidden;
margin-bottom: 4px; margin-bottom: 4px;
//border: 3px solid transparent; //border: 3px solid transparent;
.slide-1 { .swiper-slide {
width: 100%; width: 100%;
overflow: hidden; overflow: hidden;
.bigimg { .bigimg {
@ -267,6 +266,15 @@ export default {
.swiper-container-rtl .swiper-button-next:after { .swiper-container-rtl .swiper-button-next:after {
transform: scale(0.5); transform: scale(0.5);
} }
.pismask {
width: 100%;
height: 100%;
position: fixed;
background: rgba(0, 0, 0, 0.5);
z-index: 99999;
top: 0px;
left: 0px;
}
} }
// https://v1.github.surmon.me/vue-awesome-swiper/ // https://v1.github.surmon.me/vue-awesome-swiper/
</style> </style>

@ -488,9 +488,9 @@ export default {
<style lang="less"> <style lang="less">
.monitorBox { .monitorBox {
width: calc(100% - 32px); width: calc(100% - 0px);
height: calc(100% - 32px); height: calc(100% - 32px);
padding: 16px 16px; padding: 16px 0px 8px 0px;
background: #ffffff; background: #ffffff;
.monitor-container { .monitor-container {
display: flex; display: flex;
@ -546,13 +546,13 @@ export default {
} }
.totalPic { .totalPic {
width: 100%; width: 100%;
height: 24px; height: 16px;
margin-bottom: 8px; margin-bottom: 8px;
text-align: center; text-align: right;
font-size: 12px; font-size: 12px;
color: #2d8cf0; color: #2d8cf0;
font-weight: bold; font-weight: bold;
line-height: 24px; line-height: 16px;
} }
} }
.parameterArea { .parameterArea {

Loading…
Cancel
Save