You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
frontend/src/views/components/carouselChart.vue

166 lines
3.8 KiB
Vue

2 years ago
<template>
<div class="thumb-example">
<!-- swiper1 -->
<swiper
class="swiper gallery-top"
:options="swiperOptionTop"
ref="swiperTop"
>
<swiper-slide
class="slide-1"
v-for="item in terminalPhoto"
:key="item.id"
>
<img :src="item.path" style="width: 100%" alt="" />
</swiper-slide>
<div
class="swiper-button-next swiper-button-white"
slot="button-next"
></div>
<div
class="swiper-button-prev swiper-button-white"
slot="button-prev"
></div>
</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"
>
<img style="width: 100%" :src="item.path" alt="" />
2 years ago
<p class="timeInfo">
{{ $moment(item.photoTime).format("YYYY-MM-DD HH:mm:ss") }}
</p>
</swiper-slide>
2 years ago
<div
class="swiper-button-next swiper-button-white"
slot="button-next"
></div>
<div
class="swiper-button-prev swiper-button-white"
slot="button-prev"
2 years ago
></div>
</swiper>
</div>
2 years ago
</template>
<script>
export default {
props: {
terminalPhoto: {
type: Array,
default: () => [],
},
},
mounted() {
// 实现swiper双向控制
this.$nextTick(() => {
const swiperTop = this.$refs.swiperTop.swiper;
const swiperThumbs = this.$refs.swiperThumbs.swiper;
swiperTop.controller.control = swiperThumbs;
swiperThumbs.controller.control = swiperTop;
});
},
data() {
return {
swiperOptionTop: {
2 years ago
//zoom: true,//缩放功能
loop: true,
loopedSlides: 5, // looped slides should be the same
2 years ago
//spaceBetween: 10,
//observer: true, //修改swiper自己或子元素时自动初始化swiper
//observeParents: true, //修改swiper的父元素时自动初始化swiper
2 years ago
// autoplay: {
// //自动轮播
// delay: 2000,
2 years ago
// disableOnInteraction: false,
// },
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
},
swiperOptionThumbs: {
loop: true,
loopedSlides: 5, // looped slides should be the same
spaceBetween: 10,
centeredSlides: true,
slidesPerView: "auto",
2 years ago
// touchRatio: 0.2,
slideToClickedSlide: true,
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
},
};
},
2 years ago
methods: {},
2 years ago
};
</script>
<style lang="less">
2 years ago
.thumb-example {
width: 100%;
display: flex;
flex-direction: column;
height: 100%;
2 years ago
.slide {
width: 20%;
}
.gallery-top {
// height: 80% !important;
height: 80% !important;
2 years ago
width: 100%;
}
.gallery-thumbs {
height: 20% !important;
box-sizing: border-box;
padding: 10px 0px;
width: 100%;
margin-left: 2px;
background-color: #f0f0f8;
2 years ago
.swiper-button-next {
right: 0px;
2 years ago
}
.swiper-button-prev {
left: 0px;
2 years ago
}
.timeInfo {
position: absolute;
bottom: 0;
width: 100%;
background: #f0f0f0;
padding: 4px 0px;
font-size: 14px;
text-align: center;
color: @color-text-primary;
}
}
.swiper-slide {
background-size: cover;
background-position: center;
2 years ago
//border: 3px solid transparent;
}
2 years ago
.gallery-thumbs .swiper-slide {
// width: 20%;
// height: 80px;
// opacity: 0.4;
}
2 years ago
.slide {
border: 3px solid transparent;
}
.gallery-thumbs .swiper-slide-active {
border: 3px solid @color-primary;
}
2 years ago
}
</style>