<template>
  <div class="app-container home">
    <el-row :gutter="20">
      <el-col :xs="12" :sm="12" :md="12" :lg="12">
        <el-carousel height="350px" style="margin-bottom: 20px;">
          <el-carousel-item v-for="item in publicizeUrls" :key="item">
            <el-image :src="item" style="width: 100%; height: 100%;"></el-image>
          </el-carousel-item>
        </el-carousel>
      </el-col>
      <el-col :xs="12" :sm="12" :md="12" :lg="12">
        <el-carousel height="350px" style="margin-bottom: 20px;">
          <el-carousel-item v-for="item in demeanorUrls" :key="item">
            <el-image :src="item" style="width: 100%; height: 100%;"></el-image>
          </el-carousel-item>
        </el-carousel>
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :xs="24" :sm="24" :md="12" :lg="8">
        <el-card class="update-log">
          <div slot="header" class="clearfix">
            <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 class="update-log">
          <div slot="header" class="clearfix">
            <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 class="update-log">
          <div slot="header" class="clearfix">
            <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(process.env.VUE_APP_BASE_API + profiles[i].url);
      }
    });
    /** 查询支部园地风采图片 */
    listDemeanorProfiles().then(response => {
      let profiles = response.data;
      for (let i = 0; i < profiles.length; i++) {
        this.demeanorUrls.push(process.env.VUE_APP_BASE_API + profiles[i].url);
      }
    });
  },
  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;
    }
  }

  .update-log {
    ol {
      display: block;
      list-style-type: decimal;
      margin-block-start: 1em;
      margin-block-end: 1em;
      margin-inline-start: 0;
      margin-inline-end: 0;
      padding-inline-start: 40px;
    }
  }
}

.link:hover{
  color: red;
}

.date{
  float: right;
}

.title{
  font-size: 18px;
}

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

/*.el-carousel__item:nth-child(2n) {*/
  /*background-color: #99a9bf;*/
/*}*/

/*.el-carousel__item:nth-child(2n+1) {*/
  /*background-color: #d3dce6;*/
/*}*/

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;
  }
}
</style>

