<template>
  <div class="msg-content">
    <div class="title-content">
      <div class="left-title">
        <div class="line"></div>
        <div class="text">{{ $t('home.msg.title') }}</div>
      </div>
      <div class="right-text" @click="$router.push({ path: '/about/message', query: { type: 'img_text_school' } })">
        {{ $t('viewMore') }}
      </div>
    </div>
    <div class="swiper-content">
      <div v-swiper:mySwiper="swiperOption" ref="mySwiper">
        <div class="swiper-wrapper">
          <div class="swiper-slide" v-for="(item, index) in listData" :key="index">
            <app-link :item="{ news: { data: item, path: '/about/message' } }">
              <img :src="item.web_img_uri" />
            </app-link>
          </div>
        </div>
        <div class="swiper-pagination swiper-pagination-bullets"></div>
      </div>
    </div>
    <text-swiper :listData="listData" @slideTo="handleSlideTo" v-if="listData.length" />
  </div>
</template>
<script>
import appLink from '@/components/Link'
import textSwiper from './textSwiper.vue'
export default {
  components: {
    appLink,
    textSwiper
  },
  data() {
    const that = this
    return {
      listData: [],
      swiperOption: {
        speed: 400,
        autoplay: false,
        delay: 3000,
        loop: false,
        // pagination: {
        //   el: '.swiper-pagination',
        //   clickable: true
        // },
        // direction: 'vertical',
        height: 500
        // autoHeight: true
      }
    }
  },
  async fetch() {
    const params = {
      project_id: process.env.projectId,
      type_tag: 'img_text_school'
    }
    this.listData = await this.$axios.get('/api/cms/api/v1/articles', { params }).then(res => {
      return res.data.data
    })
  },
  computed: {
    // swiper() {
    //   return this.$refs.mySwiper.swiper;
    // }
  },
  methods: {
    handleSlideTo(index) {
      this.$refs.mySwiper.swiper.slideTo(index)
    }
  }
}
</script>
<style lang="scss" scoped>
.msg-content {
  padding-top: 90px;
  width: 1200px;
  margin: 0 auto;
  .title-content {
    display: flex;
    .left-title {
      display: flex;
      .line {
        width: 6px;
        height: 34px;
        background: #aa1941;
      }
      .text {
        font-size: 34px;
        font-weight: bold;
        line-height: 34px;
        color: #424242;
        margin-left: 9px;
      }
    }
    .right-text {
      margin-left: auto;
      margin-top: 18px;
      font-size: 16px;
      font-weight: 300;
      line-height: 34px;
      color: #9b9b9b;
      cursor: pointer;
    }
  }
  .swiper-content {
    height: 500px;
    margin-top: 15px;
    overflow: hidden;
    img {
      width: 100%;
      height: 520px;
      display: block;
    }
    ::v-deep {
      .swiper-pagination-bullets {
        right: 34px !important;
      }
      .swiper-pagination-bullet {
        width: 6px;
        height: 6px;
        border-radius: 100%;
        border: 1px solid #fff;
        box-sizing: border-box;
        background: none;
        opacity: 1;
        margin: 10px 0;
      }
      .swiper-pagination-bullet-active {
        width: 6px;
        height: 31px;
        border-radius: 25px;
        background: #fff;
      }
    }
  }
}
</style>
