<script src="../../../utils/sist.js"></script>
<template>
  <div class="news_center">
    <div class="headline">
      <div class="title">
        {{ $t("message.news_ceter") }}
        <span class="vertica_line"></span>
        <div class="news_center_english">
          <span class="">NEWS</span>
          <span class="">CENTER</span>
        </div>
      </div>
      <div class="more" @click="lookMore()">
        <span class="more_text">更多</span>
        <img src="../../../assets/index/news_center/gd_icon.png" alt="">
      </div>
    </div>

    <!--轮播图下的新闻-->
    <div class="news">
      <el-row>
        <el-col :span="6" v-for="(item,index) in newsData" :key="index" :class="'border_right-' + (index + 1)">
          <div class="news_context" @click="getArticle(item)">
            <div class="news_context_img">
              <img v-if="item.imgurl" :src="item.imgurl" alt="">
            </div>
            <div class="news_context_text" >
              <div class="news_context_text-title">{{ item.title }}</div>
              <div v-if="item.description" class="news_context_text-content">{{item.description}}</div>
              <div v-if="!item.description" class="news_context_text-content" v-html="item.content"></div>
              <div class="news_context_time">
                <div class="icon"><img src="../../../assets/index/news_center/shijian.png" alt=""></div>
                <span class="time">{{ getDateTime(item.publishTime) }}</span>
              </div>
            </div>
          </div>
        </el-col>
      </el-row>
    </div>

  </div>
</template>

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

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

<style>
.el-carousel__indicators {
  display: none;
}

.grid-content {
  height: 1px !important;
}
</style>

<style scoped lang="scss">
@media screen and (max-width: 1200px) {
  .news {
    width: 100rem !important;
  }
  .headline {
    width: 100rem !important;
  }
}

@media screen and (max-width: 1050px) {
  .news {
    width: 90rem !important;
  }
  .headline {
    width: 90rem !important;
  }
}

@media screen and (max-width: 960px) {
  .news {
    width: 80rem !important;
  }
  .headline {
    width: 80rem !important;
  }
}

@media screen and (max-width: 960px) {
  .news {
    width: 80rem !important;
  }
  .headline {
    width: 80rem !important;
  }
}

@media screen and (max-width: 768px) {
  .news {
    width: 70rem !important;
  }
  .headline {
    width: 70rem !important;
  }
  .news_context {
    padding-bottom: .5rem !important;
  }
}

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

  .headline {
    display: flex;
    //width: 100%;
    justify-content: space-between;
    width: 115.4rem;
    margin: 0 auto;

    .title {
      display: flex;
      width: 24rem;
      height: 5.9rem;
      line-height: 5.9rem;
      border-radius: 1.3rem 0 0 1.3rem;
      font-size: 3rem;
      font-weight: 500;
      letter-spacing: .1rem;
      color: #FFFFFF;
      text-align: left;
      background: linear-gradient(240deg, rgba(0, 75, 177, 0) 0%, rgba(6, 79, 175, 0.64) 44%, #0A51AE 100%);
      padding-left: 1.9rem;
      margin-top: 6.3rem;

      .vertica_line {
        width: .1rem;
        height: 2.5rem;
        border: .1rem solid #FFFFFF;
        margin: 1.7rem 1.4rem;
      }

      .news_center_english {
        width: 5.3rem;
        height: 2.8rem;
        font-size: 1.3rem;
        font-weight: 500;
        color: #FFFFFF;
        line-height: 1.4rem;
        margin-top: 1.6rem;

        span {
          float: left;
        }
      }
    }
  }

  .more {
    display: flex;
    height: 3.7rem;
    margin-top: 9.8rem;
    cursor: pointer;

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

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

.border_right-4{
  .news_context{
    .news_context_text{
      border-right: none!important;
    }
  }
}


.news {
  margin: 4rem auto 0 auto;
  width: 115.4rem;
  //height: 60.4%;
  background-color: #fff;
  //margin-top: 4rem;


  .news_context {
    cursor: pointer;
    //width: 28rem;
    width: 100%;
    //height: 35.1rem;
    padding-bottom: 2rem;

    //&:hover {
    //  box-shadow: 0 0 0.7rem 0 rgba(18, 69, 155, 0.59);
    //}

    .news_context_img {
      height: 42.8%;
      width: 100%;
      overflow: hidden;

      img {
        &:hover {
          transform: scale(1.3);
        }

        width: 100%;
        transition: all 1s;
      }
    }


    .news_context_text {
      margin: 2rem 0 2rem 2rem;
      padding-right: 2rem;
      border-right: 1px solid #CCCCCC;
      .news_context_text-title {
        &:hover {
          color: #0040A4;
        }

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

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

      .news_context_time {
        display: flex;

        .icon {
          margin-right: .4rem;

          img {
            width: 1.1rem;
            height: 1.1rem;
          }
        }

        .time {
          height: 1.4rem;
          font-size: 1rem;
          font-weight: 500;
          color: #0040A4;
          line-height: 1.4rem;
        }
      }

    }
  }
}


</style>
