<template>
  <CardBox :btnList="btnList" v-on="$listeners">
    <div class="browse-history-card" @click="$emit('handleToDetail')">
      <div class="header">
        <div class="user">
          <img class="avatar" :src="info.headimg" alt="" />
          <div class="name">{{ info.name }}</div>
        </div>
        <img class="vip" src="@/assets/icon/vip.png" v-if="info.level" />
      </div>
      <div class="title">
        <img class="icon" src="@/assets/icon/question.png" alt="" />
        <div class="content" v-html="formatRichText(info.content) || ''"></div>
      </div>

      <div class="tag">
        <div class="tag-item" v-for="tag in info.label_name">{{ tag }}</div>
      </div>
      <div class="footer">
        <img class="icon" src="@/assets/icon/answer.png" alt="" />
        <div class="answer-read">
          {{ info.reply_num }}人回答·{{ info.browse_num }}阅读量
        </div>
        <div class="report" @click.stop="$emit('handleReport')">
          <img class="report-icon" src="@/assets/icon/report.png" />
          <div class="report-text">举报</div>
        </div>
      </div>
    </div>
  </CardBox>
</template>

<script>
import { formatRichText } from "@/common/util";
import CardBox from "../card-module/card-box.vue";

export default {
  name: "BrowseHistoryCard",
  components: { CardBox },
  props: {
    info: {
      default: () => {
        return {};
      },
    },
  },
  computed: {
    btnList() {
      let arr = ["del"];
      return this.manageType ? [] : arr;
    },
  },
  methods: {
    formatRichText,
  },
};
</script>

<style lang="scss" scoped>
.browse-history-card {
  width: 100%;
  min-width: 750px;
  background-color: white;
  padding: 20px;
  box-sizing: border-box;
  cursor: default;
  .header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    .user {
      display: flex;
      align-items: center;
      .avatar {
        width: 30px;
        height: 30px;
        border-radius: 50%;
      }
      .name {
        font-size: 14px;
        color: #222222;
        margin-left: 10px;
      }
    }
    .vip {
      width: 38px;
      height: 20px;
      border-radius: 2px;
    }
  }
  .title {
    width: calc(100% - 40px);
    margin-top: 15px;
    font-size: 20px;
    font-weight: 500;
    color: #222222;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    .icon {
      width: 20px;
      height: 20px;
      margin-right: 10px;
    }
  }
  .content {
    width: calc(100% - 40px);
    font-size: 16px;
    font-weight: 400;
    color: #333333;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-box-orient: vertical;
  }
  .tag {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    height: 24px;
    overflow: hidden;
    margin-top: 15px;
    .tag-item {
      height: 24px;
      background: #f0f4ff;
      border-radius: 2px;
      margin-right: 10px;
      padding: 0 10px;
      font-size: 13px;
      font-weight: 400;
      color: #2a63f3;
      line-height: 24px;
    }
  }
  .footer {
    margin-top: 15px;
    display: flex;
    align-items: center;
    .icon {
      width: 20px;
      height: 20px;
      margin-right: 10px;
    }
    .answer-read {
      font-size: 14px;
      font-weight: 400;
      color: #666666;
      margin-right: 10px;
    }
    .report {
      display: flex;
      align-items: center;
      cursor: pointer;
      .report-icon {
        width: 16px;
        height: 16px;
        transform: translate(0, 1px);
      }
      .report-text {
        font-size: 14px;
        font-weight: 400;
        color: #666666;
        margin-left: 3px;
      }
    }
  }
}
</style>
