follow-topic-item.vue 1.9 KB
<template>
  <div class="topic-item">
    <div class="topic-cover" @click="toTopic">
      <ImageFormat v-if="data.topicImageUrl" :src="data.topicImageUrl" :mode="1" :width="240" :height="240"></ImageFormat>
    </div>
    <div class="topic-info" @click="toTopic">
      <div class="topic-name">
        <span>#{{data.topicName}}</span>
      </div>
      <p class="topic-desc">{{data.topicDesc}}</p>
    </div>
    <WidgetFollow class="option-btn" :topic-id="data.topicId" :follow="data.hasAttention === 'Y'"></WidgetFollow>
  </div>
</template>

<script>
import {get} from 'lodash';

export default {
  data() {
    return {}
  },
  props: [
    'data'
  ],
  methods: {
    toTopic() {
      this.$router.push({
        name: 'topic',
        params: {
          topicId: this.data.topicId,
          topicName: this.data.topicName
        }
      });
    }
  }
};
</script>

<style scoped>
.topic-item {
  height: 178px;
  display: flex;
  align-items: center;

  .topic-cover {
    width: 120px;
    height: 120px;
    background-color: #ccc;
    margin-right: 20px;
    flex-shrink: 0;

    img {
      width: 100%;
      height: 100%;
      display: block;
    }
  }

  .topic-info {
    height: 120px;
    flex-grow: 1;
  }

  .topic-name {
    font-size: 32px;
    line-height: 1.6;
    color: #222;
    letter-spacing: 0.08PX;
    font-weight: 500;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;

    span {
      display: inline-block;
      max-width: 400px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }

  .topic-desc {
    max-width: 400px;
    font-size: 24px;
    line-height: 1.3;
    color: #b0b0b0;
    letter-spacing: 0.06PX;
    overflow:hidden;
    word-break: break-all;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .option-btn {
    margin: 0 30px;
  }
}
</style>