<template>
  <card :title="$t('home.alumni.title')">
    <p class="tips">{{ $t('home.alumni.des') }}</p>
    <swiper ref="mySwiper" :options="swiperOptions" class="my-swiper">
      <template v-for="(item, index) in list">
        <swiper-slide :key="index">
          <new-link :item="{ news: { data: item, path: '/about/news' } }">
            <img :src="item.web_img_uri" class="banner-img" />
            <p class="banner-title">{{ item.title }}</p>
          </new-link>
        </swiper-slide>
      </template>
    </swiper>
  </card>
</template>

<script>
import NewLink from '@/components/NewLink'
import Card from '@/components/Card'
export default {
  components: { Card, NewLink },
  data() {
    return {
      swiperOptions: {
        autoplay: true,
        delay: 5000,
        loop: true,
        slidesPerView: 'auto',
        centeredSlides: true,
        spaceBetween: 10
      },
      list: []
    }
  },
  async fetch() {
    const params = { project_id: process.env.projectId, type_tag: 'article_alumni' }
    this.list = await this.$axios.get('/api/cms/api/v1/articles', { params }).then(res => res.data.data)
  }
}
</script>

<style lang="scss" scoped>
.tips {
  font-size: 0.1rem;
  font-weight: 500;
  margin-bottom: 0.1rem;
}
.my-swiper {
  ::v-deep .swiper-wrapper {
    align-items: center;
  }
  .swiper-slide {
    position: relative;
    width: 2.1rem;
    height: 1.22rem;
  }
  .swiper-slide-active {
    width: 2.1rem;
    height: 1.34rem;
  }
}
.banner-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.banner-title {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0.24rem;
  padding: 0 0.1rem;
  font-size: 0.1rem;
  line-height: 0.24rem;
  color: #fff;
  background-color: rgba(0, 0, 0, 0.5);
}
</style>
