<template>
  <div>
    <!-- 新闻资讯 PC-->
    <div class="platform-news-information mta-hidden-xs">
      <!-- 新闻资讯 -->
      <div class="client-container">
        <h4 class="client-title-news">新闻资讯</h4>
        <ul>
          <li style="font-size: 16px" v-for="(item, index) in newsData" :key="index">
            <div>
              <img :src="item.pic" alt="新闻资讯"/>
              <h4 class="new_title" @click="checkInfo(item)">{{ item.title }}</h4>
              <span class="new_date">发布时间：{{ item.yyyy }}-{{ item.mmdd }}</span>
              <p class="new_des">{{ item.intro }}</p>
            </div>
          </li>
        </ul>
      </div>
    </div>

    <!-- 新闻资讯 手机-->
    <div class="client-container">
      <div class="client-newsInfo-phone mta-hidden-sm">
        <h4 class="client-title-news">新闻资讯</h4>
        <el-carousel :interval="5000" type="card" height="300px" indicator-position="none" arrow="never">
          <el-carousel-item v-for="(item,index) in newsData" @click="checkInfo(item)" :key="index" class="el-row">
            <img :src="item.pic" alt="新闻资讯"/>
            <div class="newsInfo-card-content">
              <a style="display: none" :href="`${baseUrl}/news/${item.code}`"></a>
              <h4>{{ item.title }}<i></i></h4>
              <span>{{ item.yyyy }}-{{ item.mmdd }}</span>
              <p>{{ item.intro }}</p>
            </div>
          </el-carousel-item>
        </el-carousel>
      </div>
    </div>
  </div>

</template>

<script>
import {mapGetters} from "vuex";

export default {
  name: "newsComp",
  props: {
    newsData: {
      type: Array,
      default: () => ([])
    }
  },
  data() {
    return {
      checkIsPc: false,
    }
  },
  computed: {
    baseUrl() {
      return this.getBaseUrl;
    },
    ...mapGetters(['getBaseUrl']),
  },
  methods: {
    isPC() {
      const browserWidth = document.documentElement.clientWidth;
      if (browserWidth <= 768) {
        return false;
      } else {
        return true;
      }
    },
    checkInfo(data) {
      const opt = {
        id: data.code,
      };
      this.$router.push({name: 'news-id', params: opt});
    }
  },
  mounted() {
    this.checkIsPc = this.isPC();
  }
}
</script>

<style lang="scss" scoped>
.platform-news-information {
  overflow: hidden;
  h4.client-title-news {
    font-size: 30px;
    font-weight: 800;
    text-align: center;
    color: #333;
    margin-top: 100px;
    margin-bottom: 80px;
  }

  ul {
    margin-bottom: 100px;
  }

  ul > li {
    .new_title {
      font-size: 18px;
      color: #333;
      text-align: left;
      font-weight: 800;


    }

    .new_date {
      font-size: 12px;
      font-weight: 500;
      color: #565656;
      position: relative;
      margin-bottom: 20px;

      &:after {
        content: '';
        position: absolute;
        bottom: -8px;
        left: 250px;
        width: 60px;
        height: 3px;
        background: #00B96B;
      }
    }

    .new_des {
      font-size: 14px;
      font-weight: 500;
      color: #565656;
    }
  }

  ul > li > div {
    border-bottom: none;
    margin-bottom: 66px;

    img {
      width: 226px;
      height: 152px;
    }
  }
}

</style>
