<!-- -->
<template>
  <div class="home-cr">
    <div class="title wow animate__animated animate__fadeInUp">
      <div class="ch">每日推送</div>
      <div class="en">Daily Exhibition Push</div>
    </div>
    <div class="text wow animate__animated animate__fadeInUp">文物</div>
    <div class="list wow animate__animated animate__zoomIn">
      <!-- 1231
      <el-carousel>
        <el-carousel-item v-for="(item,index) in length" :key="index">
         {{item}}
        </el-carousel-item>
      </el-carousel> -->
      <el-carousel indicator-position="outside" :autoplay="false" arrow="never">
        <el-carousel-item v-for="(item, index) in list" :key="index">
          <el-row :gutter="14">
            <el-col :span="6" v-for="i in item" :key="i.crId" class="container" >
              <img
                  v-if="i.faceImagePressUrl"
                  :src="i.faceImagePressUrl"
                  alt=""
                />
                <img v-else :src="index.faceImageUrl" alt="" />
              <div class="info" v-show='i.faceImageUrl'>
                <div class="name">{{ i.name }}</div>
                <div class="sourceWay">{{ i.sourceWay }}</div>
              </div>
            </el-col>
          </el-row>
        </el-carousel-item>
      </el-carousel>
    </div>

    <!-- <el-row v-if="list.length < 9 && list.length > 0" :gutter="14">
      <el-col
        :span="24 / list.length"
        class="container"
        v-for="item in list"
        :key="item.crId"
      >

        <el-image :src="item.faceImageUrl" style="width: 100%; height: 100%" />
      </el-col>
    </el-row>  -->
  </div>
</template>

<script>
import { getRecommendCr } from "@/api/culturalRelic";
export default {
  name:'CulturalRelic',
  data() {
    return {
      list: [],
      length: "",
    };
  },
  created() {
    this.loadList();
  },
  // watch: {
  //   list: {
  //     handler: function (value) {
  //       console.log(value);
  //       this.list = value;
  //     },
  //     immediate: true,
  //     deep: true,
  //   },
  // },
  methods: {
    async loadList() {
      let res = await getRecommendCr();
      if (res.data.length > 8) {
        this.length =
          res.data.length % 8 == 0
            ? res.data.length / 8
            : Math.floor(res.data.length / 8) + 1;
        for (let i = 0; i < this.length; i++) {
          let data = [];
          if (i == length - 1) {
            data = res.data.slice(8 * i, res.data.length);
          } else {
            data = res.data.slice(8 * i, (i + 1) * 8);
          }
          this.$set(this.list, i, data);
        }
        this.$set(this, "list", this.list);
      } else {
        this.list = res.data;
      }
    },
  },
};
</script>

<style lang="scss" scoped>
.home-cr {
  background-image: url("@/assets/imgs/home/display-bg.png");
  background-size: cover;
  display: flex;
  flex-direction: column;
  align-items: center;
  .title {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 60px 0 0 0;
    font-family: "Alibaba PuHuiTi";
    .ch {
      font-size: 30px;
      font-weight: bold;
      color: #fff;
      margin-bottom: 12px;
    }
    .en {
      font-size: 14px;
      color: #fff;
      margin-bottom: 80px;
    }
  }
  .text {
    color: #fff;
    margin-bottom: 36px;
    font-family: "Alibaba PuHuiTi";
  }
  .list {
    width: 100%;
    padding: 0 13%;
    height: 492px;
  }

  .container {
    // width: 339px;
    height: 20%;
    margin-bottom: 40px;
    cursor: pointer;
    position: relative;
    img {
      width: 100%;
      height: 100%;
    }
    .info{
      position: absolute;
      right: 20px;
      bottom: 10px;
      font-family: Lisu;
      color: #fff;
    }
  }
}
::v-deep .el-carousel__container {
  height: 492px;
}
.el-carousel--horizontal {
  overflow: hidden;
}
</style>
