<template>
  <div class="info-card-container">
    <div class="news-title">
      {{ title }}
    </div>
    <div class="item-imgbox">
      <div
        class="news-img"
        :style="{ backgroundImage: 'url(' + backgroundImage + ')' }"
      ></div>
      <div v-if="img_count > 0" class="img-count">
        {{ img_count }}
      </div>
    </div>
    <div class="news-info">
      <div class="left media-mark">Amis · 低代码平台@Vue2.0组件</div>
      <div v-if="comment_count && comment_count != 0" class="cmt-num right">
        {{ agreeDataFormat(comment_count) }}评
      </div>
    </div>
  </div>
</template>
<script>
// 按需引入element-ui中的组件
import { Rate } from 'element-ui';

export default {
  data() {
    return {
      isAlive: true,
      isFirstVisit: true,
      img_count: 3,
      title:
        '全场景智能业务管理系统，助力企业构建数字化客户管理平台，推动业务持续增长。',
      backgroundImage: 'https://custom-widgets.bj.bcebos.com/amis-cmp-cli.jpg',
      comment_count: 2025,
      rateVal: 3,
    };
  },
  components: {
    Rate,
  },
  mounted() {
    this.isFirstVisit = false;
  },
  activated() {
    this.isAlive = true;
  },
  deactivated() {
    this.isAlive = false;
  },
  methods: {
    agreeDataFormat(agreeData) {
      if (agreeData && agreeData <= 9999) {
        return agreeData;
      } else if (agreeData && agreeData > 9999) {
        return `${Math.floor(agreeData / 1000) / 10}w`;
      }
    },
  },
};
</script>
<style lang="scss">
.info-card-container {
  position: relative;
  box-sizing: border-box;
  // border-bottom: 1px solid #ececec;
  margin: 6px 12px;
  padding: 6px 12px;
  background-color: #fff;

  .news-title {
    padding: 6px 0;
    font-family: PingFangSC-Regular;
    font-size: 16px;
    line-height: 22px;
    color: #5f5e5e;
  }

  .item-imgbox {
    position: relative;
    height: 395px;
    background: #f0f0f0;
    cursor: pointer;
    box-sizing: border-box;
    text-align: center;
    overflow: hidden;

    .news-img {
      width: 100%;
      height: 100%;
      box-sizing: border-box;
      background-size: contain;
    }

    .img-count {
      position: absolute;
      top: 0;
      right: 0;
      padding: 6px 8px;
      color: #fff;
      min-width: 60px;
      text-align: center;
      line-height: 1.2;
      background: rgba(0, 0, 0, 0.4);
      font-size: 25px;
      box-sizing: border-box;
      overflow: hidden;
    }
  }

  .news-info {
    font-family: PingFangSC-Light;
    height: 28px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .media-mark,
  .cmt-num {
    display: inline-block;
    height: 28px;
    line-height: 28px;
    font-family: PingFangSC-Light;
    font-size: 18px;
    color: #828282;
  }
}
</style>
