<template>
  <div class="announcements">
    <div class="headline">
      <div class="line_left">
        <img src="../../../assets/index/announcements/gang1.png" alt="">
      </div>
      <div class="title">
        {{ $t("message.notice") }}
      </div>
      <div class="line_right">
        <img src="../../../assets/index/announcements/gang2.png" alt="">
      </div>
    </div>

    <el-row type="flex" justify="center">
      <el-col  :xs="23" :sm="20" :md="16" :lg="12" :xl="12">
        <el-row type="flex" justify="space-between">
          <el-col  :xs="7" :sm="7" :md="7" :lg="7" :xl="7" v-for="(item,index) in announcementsData" :key="index">
            <div class="announcements_text" @click="getArticle(item)">
              <div class="announcements_text_line_time">
                <div class="announcements_text_line_time_btime">{{getDayTime(item.publishTime)}}</div>
                <div class="announcements_text_line_time_stime">{{getDateTime(item.publishTime)}}</div>
              </div>
              <div class="announcements_text_line"></div>
              <div class="announcements_text_title">{{item.title}}</div>
              <div class="announcements_text_content" v-html="item.content">
              </div>
            </div>
          </el-col>
        </el-row>
      </el-col>
    </el-row>

    <div class="more" @click="lookMore">
      <span class="more_text">更多</span>
      <img src="../../../assets/index/news_center/gd_icon.png" alt="">
    </div>
  </div>
</template>

<script>
import {getArticleList} from "@/api";
import {toArticle} from "@/utils/sist";
import {lookMoreFixedComment} from "../../../utils/sist";

export default {
  name: "announcements",
  data() {
    return {
      announcementsData: [],
      width: document.documentElement.clientWidth > 992
    };
  },
  created() {
    this.getAnnouncementsList();
  },
  methods: {
    clickTo(link) {
      //console.log(link)
      window.location.href = link;//当前标签页
    },
    getArticle(news) {
      toArticle(news, this.width);
    },
    lookMore() {
      lookMoreFixedComment("Ag_9Jx2oC93JQcGt0VS0d4I", this.width);
    },
    getAnnouncementsList() {
      getArticleList({
        navId: "Ag_9Jx2oC93JQcGt0VS0d4I",
        pageNum: 1,
        pageSize: 3
      }).then(res => {
        this.announcementsData = res.rows;
      });
    },
    getDateTime(date) {
      let time = new Date(date);
      let year = time.getFullYear();
      let month = time.getMonth() + 1
      return year + "-" + month;
    },
    getDayTime(date) {
      let time = new Date(date);
      let day = time.getDate();
      return day;
    },
  },
};
</script>

<style scoped lang="scss">
/deep/ .el-col-1 {
  width: 6%;
}

.announcements {
  background-image: url("../../../assets/index/announcements/sy_bj3.png");
  background-size: cover;
  background-repeat: no-repeat;
  width: 100%;

  .headline {
    width: 100%;
    display: flex;
    justify-content: center;
    padding-top: 6.3rem;
    padding-bottom: 5.6rem;

    .line_left {
      line-height: 4.4rem;
    }

    .title {
      width: 12.9rem;
      height: 4.4rem;
      font-size: 3.1rem;
      font-weight: 500;
      color: #0049AE;
      letter-spacing: .1rem;
      margin: 0 1.3rem;
    }

    .line_right {
      line-height: 4.4rem;
    }
  }

  .announcements_text {
    cursor: pointer;
    &:hover {
      box-shadow: 0px 8px 11px 0px rgba(0, 73, 174, 0.5);
    }

    //width: 30.4%;
    //height: 26.3rem;
    background: #FFFFFF;
    border-radius: 1.3rem;
    padding: 3.9rem 3.3rem;

    &_line_time {
      display: flex;

      &_btime {
        height: 4.1rem;
        font-size: 3.1rem;
        font-weight: bold;
        color: #0049AE;
        letter-spacing: .1rem;
      }

      &_stime {
        font-size: 1.3rem;
        font-weight: 500;
        color: #0049AE;
        margin-top: 1.5em;
        line-height: 1.8rem;
      }
    }

    &_line {
      //width: 216px;
      width: 100%;
      height: .2rem;
      background: linear-gradient(240deg, rgba(0, 77, 175, 0) 0%, rgba(0, 77, 174, 0.67) 47%, #004DAE 100%);
      margin-bottom: 2.3rem;
    }

    &_title {
      &:hover {
        color: #0049AF;
      }

      width: 100%;
      height: 3.8rem;
      font-size: 1.4rem;
      font-weight: bold;
      color: #000000;
      line-height: 1.9rem;
      letter-spacing: .1rem;
      margin-bottom: .6rem;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box; //作为弹性伸缩盒子模型显示。
      -webkit-box-orient: vertical; //设置伸缩盒子的子元素排列方式--从上到下垂直排列
      -webkit-line-clamp: 2; //显示的行
    }

    &_content {
      width: 100%;
      height: 7rem;
      font-size: 1rem;
      font-weight: 500;
      color: #777777;
      line-height: 1.8rem;
      letter-spacing: .1rem;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box; //作为弹性伸缩盒子模型显示。
      -webkit-box-orient: vertical; //设置伸缩盒子的子元素排列方式--从上到下垂直排列
      -webkit-line-clamp: 4; //显示的行
    }
  }

  .more {
    width: 100%;
    display: flex;
    justify-content: center;
    height: 2.3rem;
    margin-top: 2.6rem;
    padding-bottom: 2.6rem;
    cursor: pointer;

    .more_text {
      font-size: 1.6rem;
      font-weight: 500;
      color: #8B8B8B;
      letter-spacing: .2rem;
    }

    img {
      width: 2.9rem;
      height: 1.4rem;
      margin-left: 0.8rem;
      margin-top: .5rem;
    }
  }
}

</style>
