轮播图

master
fanluyan 2 years ago
parent a28f44361c
commit 04af23d181

@ -1,56 +1,33 @@
<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 <div class="arrow leftArrow" v-if="this.bigNum != 0" @click="leftClick">
class="swiper-button-next swiper-button-white" <i class="el-icon-arrow-left"></i>
slot="button-next" </div>
></div>
<div <div
class="swiper-button-prev swiper-button-white" class="arrow rightArrow"
slot="button-prev" v-if="this.bigNum < this.terminalPhoto.length - 1"
></div> @click="rightClick"
</swiper>
<!-- swiper2 Thumbs -->
<swiper
class="swiper gallery-thumbs"
:options="swiperOptionThumbs"
ref="swiperThumbs"
> >
<swiper-slide <i class="el-icon-arrow-right"></i>
class="slide"
v-for="(item, index) in terminalPhoto"
:key="item.id"
>
<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-else
src="../../assets/img/loading.jpg"
:data-src="item.path + '!260x160'"
class="swiper-lazy"
/>
</div> </div>
<div class="bigimg" v-else>
<img :src="item.path" alt="" />
</div> </div>
<!-- <img v-if="index == 0" :src="item.path + '!1280x720'" /> <div class="picBottom">
<ul class="smallPicBox">
<img <li
src="item.path + '!260x160'" v-for="(item, index) in fiveList"
alt="" @click="handleBigpic(item, index)"
:data-src="item.path + '!260x160'" :class="activeSmall === index ? 'borderActive' : ''"
class="swiper-lazy" >
v-else-if="item.path.indexOf('nopic') == -1" <!-- <img src="../../assets/img/nopic.jpg" /> -->
/> <img :src="item.path + '!260x160'" />
<img :src="item.path" alt="" v-else /> -->
<p class="timeInfo" v-if="item.path.indexOf('nopic') == -1"> <p class="timeInfo" v-if="item.path.indexOf('nopic') == -1">
<el-tooltip <el-tooltip
class="item" class="item"
@ -73,19 +50,29 @@
) )
<span>--通道{{ item.channelId }}</span> <span>--通道{{ item.channelId }}</span>
</p> </p>
</swiper-slide> </li>
</swiper> </ul>
<div
class="arrow leftArrow"
v-if="this.page != 1"
@click="smallLeftClick"
>
<i class="el-icon-arrow-left"></i>
</div>
<div
class="arrow rightArrow"
v-if="this.page < this.total"
@click="smallRightClick"
>
<i class="el-icon-arrow-right"></i>
</div>
</div>
</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, //,
page: 1, //
pagesize: 5, //
total: 0, //
};
}, },
navigation: { mounted() {
nextEl: ".swiper-button-next", console.log(this.terminalPhoto);
prevEl: ".swiper-button-prev", this.bigPicPath = this.terminalPhoto[0].path;
this.fiveList = this.terminalPhoto.slice(this.page - 1, this.pagesize);
this.total = this.terminalPhoto.length / this.pagesize;
}, },
virtual: { methods: {
slides: [], getphotoList() {
renderSlide: function (slide, index) { this.fiveList = this.terminalPhoto.slice(
console.log(index); (this.page - 1) * this.pagesize,
if (slide.path.indexOf("nopic") != -1) { this.page * this.pagesize
return ` <div class="swiper-slide" ><div class="bigimg"><img src="static/img/nopic.0e9cfc7c.jpg" alt="" /></div></div>`; );
} else { this.bigPicPath = this.fiveList[this.activeSmall].path;
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,
}, },
//
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();
}
}, },
mounted() { //
this.$nextTick(() => { handleBigpic(row, index) {
const swiperTop = this.$refs.swiperTop.$swiper; console.log(row);
const swiperThumbs = this.$refs.swiperThumbs.$swiper; console.log();
swiperTop.controller.control = swiperThumbs; this.activeSmall = index;
swiperThumbs.controller.control = swiperTop; this.bigPicPath = row.path;
});
}, },
methods: {}, //
watch: { smallLeftClick() {
terminalPhoto: function (newVal, oldVal) { console.log("点击了左侧");
this.swiperOptionTop.virtual.slides = newVal;
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,43 +168,89 @@ 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 {
width: 100%; .arrow {
overflow: hidden; opacity: 1;
transition: all 0.5s ease-in;
}
}
.bigimg { .bigimg {
width: 100%; width: 100%;
height: 100%; height: 100%;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
position: relative;
.mark {
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;
}
@keyframes move {
0% {
bottom: -10px;
}
100% {
transform: 16px;
}
}
} }
img { img {
width: 100%; width: 100%;
height: 100%; height: 100%;
object-fit: fill; object-fit: fill;
cursor: pointer;
}
.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;
} }
.swiper-button-prev.swiper-button-disabled, .rightArrow {
.swiper-button-next.swiper-button-disabled { right: 16px;
opacity: 0.35;
cursor: auto;
pointer-events: none;
display: none !important;
} }
} }
.gallery-thumbs { .picBottom {
width: 100%; width: 100%;
height: 18%; height: 18%;
.slide { position: relative;
.smallPicBox {
width: 100%;
height: 100%;
display: flex;
li {
width: 20%; width: 20%;
border: 3px solid transparent; border: 3px solid transparent;
overflow: hidden; overflow: hidden;
@ -201,21 +258,17 @@ export default {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
position: relative;
.bigimg {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
img { img {
//width: 100%; width: 100%;
height: 100%; height: 100%;
object-fit: fill; object-fit: fill;
cursor: pointer;
} }
} }
.borderActive {
border: 3px solid #409eff;
}
.timeInfo { .timeInfo {
position: absolute; position: absolute;
bottom: 0px; bottom: 0px;
@ -227,31 +280,29 @@ export default {
color: #333; color: #333;
} }
} }
.arrow {
.swiper-button-next.swiper-button-white, position: absolute;
.swiper-container-rtl .swiper-button-prev.swiper-button-white, cursor: pointer;
.swiper-button-prev.swiper-button-white, color: #fff;
.swiper-container-rtl .swiper-button-next.swiper-button-white { font-size: 30px;
width: 40px;
height: 40px;
border-radius: 30px; border-radius: 30px;
position: absolute; position: absolute;
top: 50%; top: 45%;
transform: translateY(-50%); transform: translateY(-50%);
background-color: rgba(0, 0, 0, 0.5); background-color: rgba(0, 0, 0, 0.5);
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
font-size: 30px;
color: #fff; color: #fff;
text-align: center; text-align: center;
line-height: 60px; line-height: 60px;
} }
.swiper-button-next:after, .leftArrow {
.swiper-container-rtl .swiper-button-prev:after, left: 16px;
.swiper-button-prev:after, }
.swiper-container-rtl .swiper-button-next:after { .rightArrow {
transform: scale(0.5); right: 16px;
}
} }
} }
// 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