<template>
  <div class="info">
    <div class="info-top">
      <div class="info-top__item" @click="linkTo('../AppMonitoringObject/AppMonitoringObject')" v-if="$permissions('app_apppreventionreturntopoverty_detail')">
        <image :src="$cdn + 'wdbf.png'"/>
        <h2>监测对象</h2>
      </div>
      <div class="info-top__item" @click="linkTo('../AppWarningMonitoring/AppWarningMonitoring')">
        <image :src="$cdn + 'yjjk.png'"/>
        <h2>预警监控</h2>
      </div>
      <div class="info-top__item" @click="linkTo('../AppServicePublic/AppServicePublic?moduleId=ac80f2857f2c4e4d8f0e266a703aed7a&listName=政策动态')">
        <image :src="$cdn + 'news.png'"/>
        <h2>政策动态</h2>
      </div>
    </div>
    <div class="news">
      <h2>最新动态</h2>
      <div class="news-list" v-if="list.length">
        <div class="news-item" v-for="(item, index) in list" :key="index"
          @click="linkTo(`../AppServicePublic/Detail?id=${item.id}&listName=政策动态`)">
          <div class="left">
            <h2>{{ item.title }}</h2>
            <div class="item-bottom">
              <span>{{ item.categoryName || '' }}</span>
              <span>{{ item.createTime }}</span>
            </div>
          </div>
          <image v-if="item.coverFile" :src="item.coverFile ? item.coverFile.url : ''"/>
        </div>
      </div>
      <AiEmpty description="暂无数据" v-else></AiEmpty>
    </div>
  </div>
</template>

<script>
export default {
  name: "AppPovertyHome",
  appName: "防返贫",
  data() {
    return {
      list: []
    }
  },
  onLoad() {
    this.$dict.load(['newsCenterPolicyType']).then(() => {
      this.getList()
    })

    console.log(this.$cdn + 'wdbf.png')
  },
  onShow() {
    document.title = "防返贫"
  },

  methods: {
    linkTo(url) {
      uni.navigateTo({url})
    },
    getList() {
      this.$http.post('/app/appcontentinfo/list', null, {
        params: {
          size: 20,
          current: 1,
          moduleId: 'ac80f2857f2c4e4d8f0e266a703aed7a',
        },
      })
      .then((res) => {
        if (res?.data) {
          this.list = res.data.records
        }
      })
      // this.$http.post(`/app/appnewscenterinfo/listForWx`, null, {
      //   params: {
      //     current: 1,
      //     size: 10,
      //     status: 1
      //   }
      // }).then(res => {
      //   if (res.code == 0) {
      //     this.list = res.data.records
      //   }
      // })
    }
  }
}
</script>

<style lang="scss">
.info {
  background: #f5f5f5;
  padding: 32px 30px;

  .info-top {
    display: flex;
    align-items: center;
    margin-bottom: 32px;
    background: #FFFFFF;
    border-radius: 16px;

    div {
      flex: 1;
      padding: 32px 0;
      text-align: center;

      image {
        width: 80px;
        height: 80px;
      }

      h2 {
        margin-top: 4px;
        color: #3D434A;
        font-size: 28px;
        font-weight: normal;
      }
    }
  }

  .news {
    & > h2 {
      margin-bottom: 32px;
      color: #333333;
      font-weight: 600;
      font-size: 32px;
    }

    .news-item {
      display: flex;
      align-items: center;
      margin-bottom: 20px;
      padding: 32px 24px;
      background: #fff;
      border-radius: 14px;

      &:active {
        background: #eee;
      }

      &:last-child {
        border-bottom: none;
      }

      .left {
        flex: 1;
        margin-right: 20px;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
      }

      & > image {
        width: 200px;
        height: 140px;
      }

      h2 {
        width: 100%;
        margin-bottom: 32px;
        color: #333333;
        font-size: 30px;
        font-weight: 600;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        overflow: hidden;
      }

      .item-bottom {
        display: flex;
        align-items: center;

        span {
          color: #999999;
          font-size: 24px;

          &:first-child {
            margin-right: 32px;
          }
        }
      }
    }
  }
}
</style>
