<!--
 * @Description: 顶部轮播图
 * @Author: 空白格
 * @Date: 2022-08-22 09:14:32
 * @LastEditors: 空白格
 * @LastEditTime: 2022-08-22 14:38:38
 * @FilePath: \veterans_client_web\src\views\Home\components\HeaderBanner.vue
 * @Copyright: Copyright (c) 2016~2022 by 空白格, All Rights Reserved.
-->
<template>
  <div class="home-carousel">
    <el-carousel arrow="never" height="400px" direction="vertical" :autoplay="false">
      <el-carousel-item
        class="home-carousel-item"
        v-for="(item, index) in bannerList"
        :key="index"
      >
        <el-image class="image" :src="item.bannerUrl" fit="cover">
          <div slot="placeholder" class="image-slot">
            加载图片中<span class="dot">...</span>
          </div>
        </el-image>
        <el-image class="image-text" :src="item.bannerTxtUrl" fit="cover">
          <div slot="placeholder" class="image-slot">
            加载图片中<span class="dot">...</span>
          </div>
        </el-image>
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script>
import { getBannerList } from "@/api/Home";
export default {
  name: "HeaderBanner",
  data() {
    return {
      bannerList: [
        {
          bannerUrl: require("@/assets/images/banner-1.png"),
          bannerTxtUrl: require("@/assets/images/banner-1-text.png"),
        },
      ],
    };
  },
  created() {
    // this.getBanner();
  },
  methods: {
    /**
     * 获取轮播图
     * @date 2022-08-22
     * @returns {any}
     */
    getBanner() {
      getBannerList({ type: 0 }).then((res) => {
        this.bannerList = res.data;
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.home {
  &-carousel {
    &-item {
      position: relative;
      .image-text {
        width: 900px;
        height: 270px;
        position: absolute;
        left: 300px;
        top: 80px;
      }
    }
    .image {
      width: 100%;
      height: 100%;
    }
    .image-slot {
      line-height: 300px;
      text-align: center;
    }
    :deep(.el-carousel__arrow) {
      border: solid 1px rgba($color: #fff, $alpha: 0.7);
    }
    :deep(.el-carousel__button) {
      display: none;
      // 指示器按钮
      width: 10px;
      height: 10px;
      border: none;
      border-radius: 50%;
      background-color: #fff;
    }
    :deep(.is-active .el-carousel__button) {
      // 指示器激活按钮
      width: 18px;
      border-radius: 10px;
    }
  }
}
</style>
