| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- <template>
- <div class="carousel-container">
- <!-- 主轮播区 -->
- <div class="main-carousel-wrapper">
- <el-carousel
- ref="mainCarousel"
- :interval="2000"
- :autoplay="true"
- height="1.89rem"
- indicator-position="none"
- arrow="never"
- @change="handleMainChange"
- >
- <el-carousel-item v-for="(item, index) in items" :key="index">
- <div class="image-wrapper">
- <el-image
- :src="item.image"
- :preview-src-list="previewList"
- fit="cover"
- class="main-image"
- />
- <div class="fullscreen-btn" @click="openFullscreen(index)">
- <img src="@/assets/image/smart-early-warning/fullScreen.png" alt="">
- </div>
- </div>
- </el-carousel-item>
- </el-carousel>
- </div>
- <!-- 缩略图导航区 -->
- <div class="thumbnail-container">
- <div class="nav-btn prev-btn" @click="prevSlide">
- <img src="@/assets/image/smart-early-warning/leftBtn.png" alt="">
- </div>
- <div class="thumbnail-list">
- <div
- v-for="(item, index) in items"
- :key="index"
- :class="['thumbnail-item', { active: currentIndex === index }]"
- @click="switchToSlide(index)"
- >
- <img :src="item.thumbnail" class="thumbnail-image">
- </div>
- </div>
- <div class="nav-btn next-btn" @click="nextSlide">
- <img src="@/assets/image/smart-early-warning/rightBtn.png" alt="">
- </div>
- </div>
- </div>
- </template>
- <script>
- export default {
- props:{
- items:Array
- },
- data() {
- return {
- currentIndex: 0
- }
- },
- computed: {
- previewList() {
- return this.items.map(item => item.image);
- }
- },
- methods: {
- handleMainChange(index) {
- this.currentIndex = index;
- },
- switchToSlide(index) {
- this.currentIndex = index;
- this.$refs.mainCarousel.setActiveItem(index);
- },
- prevSlide() {
- this.$refs.mainCarousel.prev();
- },
- nextSlide() {
- this.$refs.mainCarousel.next();
- },
- openFullscreen(index) {
- console.info(index)
- console.info('vv')
- this.$refs.mainCarousel.setActiveItem(index);
- const img = this.$el.querySelectorAll('.main-image')[index].querySelector('img');
-
- console.info(img)
- img.click(); // 触发图片预览
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .carousel-container {
- width: 100%;
- margin: 0 auto;
- }
- .main-carousel-wrapper {
- position: relative;
- margin-bottom: px-to-rem(10);
- }
- .image-wrapper {
- position: relative;
- width: 100%;
- height: 100%;
- }
- .main-image {
- width: 100%;
- height: 100%;
- object-fit: cover;
- cursor: pointer;
- transition: transform 0.3s;
- }
- .main-image:hover {
- transform: scale(1.02);
- }
- .fullscreen-btn {
- position: absolute;
- bottom: px-to-rem(10);
- right: px-to-rem(10);
- width: px-to-rem(40);
- height: px-to-rem(40);
- display: flex;
- align-items: center;
- justify-content: center;
- cursor: pointer;
- z-index: 10;
- transition: all 0.3s;
- }
- .fullscreen-btn:hover {
- transform: scale(1.1);
- }
- .thumbnail-container {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: px-to-rem(5);
- padding-bottom: px-to-rem(10);
- border-bottom: px-to-rem(1) solid #59799F;
- margin-bottom: px-to-rem(10);
- }
- .thumbnail-list {
- display: flex;
- gap: px-to-rem(5);
- overflow-x: auto;
- scrollbar-width: none;
- }
- .thumbnail-list::-webkit-scrollbar {
- display: none;
- }
- .thumbnail-item {
- width: px-to-rem(60);
- height: px-to-rem(30);
- border: px-to-rem(1) solid transparent;
- border-radius: px-to-rem(4);
- overflow: hidden;
- cursor: pointer;
- transition: all 0.3s;
- flex-shrink: 0;
- }
- .thumbnail-item:hover {
- border-color: #4F9FFF;
- }
- .thumbnail-item.active {
- border-color: #4F9FFF;
- }
- .thumbnail-image {
- width: 100%;
- height: 100%;
- object-fit: cover;
- }
- .nav-btn {
- width: px-to-rem(12);
- height: px-to-rem(30);
- display: flex;
- align-items: center;
- justify-content: center;
- cursor: pointer;
- transition: all 0.3s;
- }
- .nav-btn:hover {
- background: #409EFF;
- color: white;
- }
- </style>
|