<template>
  <div class="recommend-brand">
    <div class="brand-content">
      <div v-swiper:mySwiper="swiperOption" class="swiper-container" ref="Vswiper">
        <div class="swiper-wrapper">
          <div class="swiper-slide" v-for="banner in sliceBanners">
            <a :href="banner.detailsLink" target="_blank">
              <img :src="banner.pictureLink"/>
            </a>
          </div>
          <div v-show="sliceBanners.length > 1" class="swiper-button-prev"><i class="iconfont icon-swiper-left"></i></div>
          <div v-show="sliceBanners.length > 1" class="swiper-button-next"><i class="iconfont icon-swiper-right"></i></div>
        </div>
        <div v-show="sliceBanners.length > 1" class="swiper-pagination swiper-pagination-bullets"></div>
      </div>
    </div>
  </div>
</template>
<script>
  export default {
    data () {
      return {
        swiperOption: {
          autoplay: 6000,
          pagination: '.swiper-pagination',
          paginationClickable: true,
          // 解决点击分页器后图片就不能轮播的问题
          autoplayDisableOnInteraction: false,
          mousewheelControl: false,
          effect: 'fade',
          lazyLoading: true,
          observer: true,
          loop: true,
          prevButton: '.swiper-button-prev',
          nextButton: '.swiper-button-next',
          onTransitionStart: (swiper) => {
            if (this.banners.data && this.banners.data.length && (swiper.activeIndex > this.banners.data.length)) {
              swiper.activeIndex = 1
            }
            if (this.banners.data && this.banners.data.length && swiper.activeIndex <= 0) {
              swiper.activeIndex = this.banners.data.length
            }
          }
        }
      }
    },
    created () {
      this.$store.dispatch('loadBrandCarousel')
    },
    mounted() {
      this.$nextTick(() => {
      })
    },
    computed: {
      banners () {
        return this.$store.state.carousel.brandCarousel.data
      },
      sliceBanners () {
        return this.banners.data && this.banners.data.length ? this.banners.data.slice(0, 3) : []
      }
    }
  }
</script>
<style lang="scss" scoped>
  .recommend-brand {
    width: 1190px;
    margin: 0 auto;
    overflow: hidden;
    .brand-toggle {
      float: left;
      margin-right: 15px;
    }
    .brand-content{
      float: left;
    }
    .swiper-container {
      z-index: 2;
      float: left;
      width: 955px;
      height: 400px;
      .swiper-wrapper {
        width: 955px;
        height: 400px;
        margin: 0 auto;
        .swiper-slide {
          height: 400px;
          margin: 0 auto;
          display: flex;
          img {
            width: 955px;
            /*height: 400px;*/
            /*border: 1px solid #ccc;*/
            border-radius: 5px;
          }
        }
        .swiper-button-prev i, .swiper-button-next i {
          font-size: 26px;
        }
      }
      .swiper-pagination-bullets {
        .swiper-pagination-bullet {
          width: 10px!important;
          height: 10px!important;
        }
      }
    }
    .recommend-adv {
      margin: 0 auto;
      width: 1190px;
      height: 163px;
      display: block;
      border-radius: 3px;
    }
    .recommend-area {
      margin: 20px auto 0;
      width: 1190px;
      height: 263px;
      background:url("/images/brandCenter/recommend-bg1.png") no-repeat;
      .recommend-items {
        padding-top: 51px;
        padding-left: 3px;
        li {
          border-radius: 3px;
          width: 233px;
          height: 98px;
          background: #fff;
          display: inline-block;
          margin-right: 3px;
          margin-bottom: 8px;
          text-align: center;
          border: solid 1px #f4f4f4;
          &:nth-child(5n) {
            margin-right: 0;
          }
          a {
            padding-top: 22px;
            width: 233px;
            height: 98px;
            line-height: 60px;
            display: block;
            position: relative;
            top:-1px;
            left: -1px;
            img {
              max-width: 140px;
              max-height: 60px;
            }
            >div {
              display: none;
              position: absolute;
              border-radius: 3px;
              width: 233px;
              height: 98px;
              background-color: #3a78f4;
              opacity: 0.9;
              top: 0;
              text-align: left;
              padding: 13px 7px;
              p {
                font-size: 15px;
                color: #fff;
                font-weight: bold;
                height: 16px;
                line-height: 16px;
              }
              span {
                color: #fff;
                display: block;
                width: 228px;
                line-height: 18px;
                font-size: 12px;
                &.brand-application {
                  padding-right: 5px;
                  text-overflow: ellipsis;
                  white-space: nowrap;
                  overflow: hidden;
                }
                &.brand-introduce {
                  padding-right: 5px;
                  word-break: break-all;
                }
              }
            }
          }
          &:hover {
            /*position: relative;
            bottom: 5px;*/
            a {
              div {
                display: block;
              }
            }
          }
        }
      }
    }
  }
  .recommend-brand .brand-content .brand-index-tab .brand-index-group a.active{
    background-color: #2496f1;
    border-radius: 5px;
    color: #fff;
    /*width: 56px;*/
    /*padding-left: 3px;*/
  }
</style>
