<template>
  <div class="app-container home">
    <el-row :gutter="20">
      <el-col :xs="12" :sm="12" :md="12" :lg="12">
        <el-carousel direction="vertical" height="350px" style="margin-bottom: 20px;">
          <!-- 为了让走马灯在轮播图片的同时能够在上面附带文字，将走马灯组件单独放在一个 div 里
       		并且为这个 div 单独设计 css 样式 pic_item -->
          <div class="pic_item">
            <el-carousel-item v-for="(item, index) in publicizeUrls" :key="index">
              <el-image :src="item.url" style="width: 100%; height: 100%;"></el-image>
              <h3>{{item.title}}</h3>
            </el-carousel-item>
          </div>
        </el-carousel>
      </el-col>
      <el-col :xs="12" :sm="12" :md="12" :lg="12">
        <el-carousel direction="vertical" height="350px" style="margin-bottom: 20px;">
          <div class="pic_item">
            <el-carousel-item v-for="(item, index) in demeanorUrls" :key="index">
              <el-image :src="item.url" style="width: 100%; height: 100%;"></el-image>
              <h3>{{item.title}}</h3>
            </el-carousel-item>
          </div>
        </el-carousel>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :xs="24" :sm="24" :md="12" :lg="8">
        <el-card>
          <div slot="header">
            <span class="title">
              公示公告
            </span>
          </div>
          <div class="body">
            <div class="chart-wrapper">
              <notice-chart />
            </div>
          </div>
        </el-card>
      </el-col>
      <el-col :xs="24" :sm="24" :md="12" :lg="8">
        <el-card>
          <div slot="header">
            <span class="title">
              先进风采
            </span>
          </div>
          <div class="body">
            <div class="chart-wrapper">
              <demeanor-chart />
            </div>
          </div>
        </el-card>
      </el-col>
      <el-col :xs="24" :sm="24" :md="12" :lg="8">
        <el-card>
          <div slot="header">
            <span class="title">
              政治生日
            </span>
          </div>
          <div class="body">
            <div class="chart-wrapper">
              <brith-chart />
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import BrithChart from "./dashboard/BrithChart";
import DemeanorChart from "./dashboard/DemeanorChart";
import NoticeChart from "./dashboard/NoticeChart";
import { listPublicizeProfiles } from "@/api/branch/publicize";
import { listDemeanorProfiles } from "@/api/branch/demeanor";

export default {
  name: "Index",
  components: { BrithChart, NoticeChart, DemeanorChart },
  data() {
    return {
      // 支部园地宣传图片
      publicizeUrls: [],
      // 支部园地风采图片
      demeanorUrls: [],
      // 版本号
      version: "3.8.5",
    };
  },
  created() {
    /** 查询支部园地宣传图片 */
    listPublicizeProfiles().then(response => {
      let profiles = response.data;
      for (let i = 0; i < profiles.length; i++) {
        this.publicizeUrls.push({
          "url": process.env.VUE_APP_BASE_API + profiles[i].url,
          "title": profiles[i].title
        });
      }
    });
    /** 查询支部园地风采图片 */
    listDemeanorProfiles().then(response => {
      let profiles = response.data;
      for (let i = 0; i < profiles.length; i++) {
        this.demeanorUrls.push({
          "url": process.env.VUE_APP_BASE_API + profiles[i].url,
          "title": profiles[i].title
        });
      }
    });
  },
  methods: {
  }
};
</script>

<style scoped lang="scss">
.home {
  blockquote {
    padding: 10px 20px;
    margin: 0 0 20px;
    font-size: 17.5px;
    border-left: 5px solid #eee;
  }
  hr {
    margin-top: 20px;
    margin-bottom: 20px;
    border: 0;
    border-top: 1px solid #eee;
  }
  .col-item {
    margin-bottom: 20px;
  }

  ul {
    padding: 0;
    margin: 0;
  }

  /*font-family: "open sans", "Helvetica Neue", Helvetica, Arial, sans-serif;*/
  font-size: 13px;
  color: #676a6c;
  overflow-x: hidden;

  ul {
    list-style-type: none;
  }

  h4 {
    margin-top: 0px;
  }

  h2 {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 100;
  }

  p {
    margin-top: 10px;

    b {
      font-weight: 700;
    }
  }
}

.title{
  font-size: 18px;
}

.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.9;
  line-height: 150px;
  margin: 0;
  text-align: center;
}

img{
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
}

.dashboard-editor-container {
  padding: 32px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 32px;
  }
}

@media (max-width:1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}
.pic_item {
  position: relative;
  height: 100%;
}
.pic_item:hover{
  cursor: pointer;
}

// pic_item 这个整体 div 样式的时候，其中的 h3 的标签的样式
// 也就是显示在走马灯上的字体

.pic_item h3 {
  /* position: relative; */
  /* width: 864px;
  height: 168px; */
  position: absolute;
  left: 1rem;
  bottom: 1rem;
  color: white;
  /* text-decoration-line: underline; */
  font-weight: 900;
  /*font-family:Georgia, 'Times New Roman', Times, serif;*/
  font-size: 18px;
  line-height: 116%;
  display: flex;
  align-items: center;
  flex: none;
  order: 1;
  align-self: stretch;
}

.smallpic_item h3{
  position: absolute;
  left: 3rem;
  bottom: 5rem;
  font-family:Georgia, 'Times New Roman', Times, serif;
  font-style: normal;
  font-weight: 700;
  font-size: 24px;
  line-height: 132%;
  display: flex;
  align-items: center;
  letter-spacing: 0.02em;
  font-feature-settings: 'liga' off;

  /* White */

  color: #FFFFFF;
}
</style>

