<template>
  <card title="校友故事">
    <p class="tips">You are What you together， 结识5000+ 同样优秀的人！</p>
    <swiper ref="mySwiper" :options="swiperOptions" class="my-swiper">
      <template v-for="(item, index) in list">
        <swiper-slide :key="index">
          <nuxt-link :to="`/alumnus/${item.id}`">
            <img :src="item.photo_uri" class="banner-img" />
            <p class="banner-title">{{ item.title }}</p>
          </nuxt-link>
        </swiper-slide>
      </template>
    </swiper>
  </card>
</template>

<script>
import Card from '@/components/Card'
export default {
  components: { Card },
  data() {
    return {
      swiperOptions: {
        autoplay: true,
        delay: 5000,
        loop: true,
        slidesPerView: 'auto',
        centeredSlides: true,
        spaceBetween: 10
      },
      list: []
    }
  },
  async fetch() {
    const params = { page: 1, per_page: 10, type: 71, project_id: 1013 }
    this.list = await this.$axios.$get('/api/zws/v1/cms/news', { params }).then(res => res)
  }
}
</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>
