<template>
  <div class="app-container home">
    <el-row :gutter="20">
      <el-col :xs="24" :sm="24" :md="12" :lg="8">
        <el-carousel direction="horizontal" 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%;" @click="handleSee(item.url2)"></el-image>
              <h3>{{item.title}}</h3>
            </el-carousel-item>
          </div>
        </el-carousel>
      </el-col>
      <el-col :xs="24" :sm="24" :md="12" :lg="8">
        <div class="title">
          <div class="logo">
            <img src="../assets/logo/logo.png" alt="logo" />
          </div>
          学习资料
        </div>
        <manage-chart />
      </el-col>
      <el-col :xs="24" :sm="24" :md="12" :lg="8">
        <div class="title">
          <div class="logo">
            <img src="../assets/logo/logo.png" alt="logo" />
          </div>常用下载
        </div>
        <template-chart />
      </el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :xs="24" :sm="24" :md="12" :lg="8">
        <div class="title">
          <div class="logo">
            <img src="../assets/logo/logo.png" alt="logo" />
          </div>
          公示公告、工作提醒
        </div>
        <notice-chart />
      </el-col>
      <el-col :xs="24" :sm="24" :md="12" :lg="8">
        <div class="title">
          <div class="logo">
            <img src="../assets/logo/logo.png" alt="logo" />
          </div>
          先进风采
        </div>
        <demeanor-chart />
      </el-col>
      <el-col :xs="24" :sm="24" :md="12" :lg="8">
        <div class="title">
          <div class="logo">
            <img src="../assets/logo/logo.png" alt="logo" />
          </div>
          政治生日
        </div>
        <brith-chart />
      </el-col>
    </el-row>
  </div>
</template>

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

export default {
  name: "Index",
  components: { BrithChart, NoticeChart, DemeanorChart, ManageChart, TemplateChart },
  data() {
    return {
      // 支部园地宣传图片
      publicizeUrls: [],
      // 版本号
      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,
          "url2": profiles[i].url2,
          "title": profiles[i].title
        });
      }
    });
  },
  methods: {
    handleSee(url) {
      window.open(process.env.VUE_APP_BASE_API + url);
    },
  }
};
</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: 14px;
  background-color: #F5222D;
  color: white;
  height: 32px;
  line-height: 32px;
  font-weight: bold;
  margin-bottom: 0px;
}

.logo{
  height: 18px;
  width: 18px;
  display: inline-block;
}

.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: 14px;
  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>

