<template>
  <div class="wrapper-tools">
    <div
      ref="mySwiper"
      v-swiper:mySwiper="swiperOption"
      class="swiper-container"
      @mouseenter="handleEnter" @mouseleave="handleLeave"
    >
      <div class="carousel-indicators">
        <span class="swiper-pagination-bullet swiper-pagination-bullet-active" tabindex="0" role="button" aria-label="Go to slide 1"></span>
        <span class="swiper-pagination-bullet" tabindex="0" role="button" aria-label="Go to slide 2"></span>
        <span class="swiper-pagination-bullet" tabindex="0" role="button" aria-label="Go to slide 3"></span>
        <span class="swiper-pagination-bullet" tabindex="0" role="button" aria-label="Go to slide 4"></span>
        <span class="swiper-pagination-bullet" tabindex="0" role="button" aria-label="Go to slide 5"></span>
      </div>
      <div ref="myWrapper" class="swiper-wrapper">
        <div v-for="(item, index) in lists" :key="index" class="swiper-slide">
          <div class="list">
            <div class="header">
              <img :src="item.src" alt="item.title">
              <div class="context">
                <div class="title">{{ item.title }}</div>
                <component :is='item.rate'></component>
              </div>
            </div>
            <div class="des">
              {{ item.des }}
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { directive } from 'vue-awesome-swiper'
import Array from '~/assets/images/PDFReaderPro/array.svg?inline'
import Rate from '~/assets/images/PDFReaderPro/rate.svg?inline'
import FiveRate from '~/assets/images/PDFReaderPro/fiveRate.svg?inline'

export default {
  directives: {
    swiper: directive
  },
  components: {
    Array,
    Rate,
    FiveRate
  },
  props: ['lists'],
  data() {
    return {
      swiperOption: {
        autoplay: {
          delay: 5000,
          disableOnInteraction: false,
        },
        centeredSlides: true,
        loop: true,
        slidesPerView: 1,
        pagination: {
          el: '.carousel-indicators',
          clickable: true
        },
      }
    }
  },
  methods: {
    handleEnter () {
      this.$refs.mySwiper.swiper.autoplay.stop()
    },
    handleLeave () {
      this.$refs.mySwiper.swiper.autoplay.start()
    }
  }
}
</script>

<style lang="scss" scoped>
::v-deep .swiper-container {
  position: relative;
  overflow: hidden;
  z-index: 1;
  .swiper-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: flex;
    transition-property: transform;
    box-sizing: content-box;
    .swiper-slide {
      flex-shrink: 0;
      width: 408px;
      height: 100%;
      position: relative;
      transition-property: transform;
      margin-bottom: 70px;
      justify-content: center;
      align-items: center;
      display: flex;
    }
  }
  .carousel-indicators {
    position: absolute;
    bottom: 24px;
    z-index: 2;
    width: 100%;
    font-size: 0;
    margin: 0;
    text-align: center;
    .swiper-pagination-bullet {
      display: inline-block;
      width: 8px;
      height: 8px;
      margin: 0;
      margin-right: 6px;
      background: #0000001f;
      border-radius:4px;
      transition: width 0.3s;
      &.swiper-pagination-bullet-active {
        background: #00000066;
      }
    }
  }
}
.swiper-container-free-mode .swiper-wrapper {
  /* 默认是ease-out */
  -webkit-transition-timing-function: linear;  
  -ms-transition-timing-function: linear;
  -moz-transition-timing-function: linear;
  -o-transition-timing-function: linear;
  transition-timing-function: linear;
}
div.wrapper-tools {
  .list {
    width: 100%;
    max-width: 400px;
    margin: 0 10px;
    height: 320px;
    margin-top: 40px;
    background: #F5F9FF;
    border-radius: 16px;
    padding: 40px;
    padding-bottom: 0;
    .header {
      display: flex;
      img {
        width: 64px;
        vertical-align: middle;
      }
      .context {
        margin-left: 16px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        .title {
          font-size: 18px;
          font-weight: 700;
          line-height: 24px;
          color: #192233;
          margin-bottom: 8px;
        }
      }
    }
    .des {
      margin-top: 32px;
      font-size: 16px;
      line-height: 32px;
      color: #404754;
    }
  }
}
</style>
