<template>
  <div class="news">
    <div v-for="(item,index) in list" :key="index" style="position:relative" @click="handleShow(item)">
      <div class="news-point"></div>
      <div class="news-content">
        <div class="news-name">{{item.title}}</div>
        <div class="news-createdtime">{{item.modifyTime | filterModifyTime}}</div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      list: [],
      modalVisable: false,
      currentContent: '',
    }
  },
  filters: {
    filterModifyTime(val) {
      return val.substr(0, 10)
    },
  },
  mounted() {
    this.getNewsList()
  },
  methods: {
    handleShow(val) {
      this.modalVisable = true
      this.currentContent = val.content
      let routeUrl = window.GMS.$hideContainer.$router.resolve({
        name: 'newsDetail',
        query: { title: val.title, description: val.description, content: val.content, time: val.modifyTime.substr(0, 10)}
      })
      window.open(routeUrl.href, '_blank')
    },
    async getNewsList() {
      const url = `/news/query`
      const param = {
        pageIndex: 0,
        isValid: true,
        isNotValid: true,
        isPublished: true,
        isNotPublished: true,
        isSendMsg: true,
        isNotSendMsg: true,
        functionGroupIs: 'publish-zone-news',
        pageSize: 10,
      }
      const res = await window.GMS.$http.post(url, param)
      this.list = res.data.data
      console.log({ res })
    },
  },
}
</script>
<style lang="less" scoped>
.news {
  &-point {
    float: left;
    width: 6px;
    height: 6px;
    opacity: 1;
    background: #b8b8b8;
    border-radius: 50%;
    position: relative;
    top: 20px;
  }
  &-content {
    text-align: left;
    // width: calc(100% - 70px);
    min-height: 60px;
    width: 100%;
    min-width: 60px;
    border-radius: 4px;
    padding: 10px;
    // margin-bottom: 10px;

    .news-name {
      font-size: 14px;
      font-weight: 400;
      font-family: PingFangSC-Regular, PingFang SC;
      color: #0f0f0f;
      height: 24px;
      line-height: 24px;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
    .news-createdtime {
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #7f7f7f;
      line-height: 17px;
      height: 20px;
      font-size: 12px;
      line-height: 20px;
    }
  }
  &-download {
    float: right;
    color: #b8b8b8;
    font-size: 16px;
    margin-top: 13px;
    cursor: pointer;
  }
}
</style>