banner.vue 2.37 KB
<template>
  <div class="topic-banner" :style="headStyle">
    <div class="banner-main">
      <div class="topic-name">{{data.topicName}}</div>
      <p class="topic-desc">{{data.topicDesc}}</p>
      <div class="topic-extra">
        <label class="att-amount">{{data.articleAmount}}人参与讨论</label>
        <WidgetFollow v-if="+data.allowAttention" class="att-click-wrap" :topic-id="data.topicId" :follow="data.hasAttention" :share="share" @on-follow="onFollow"></WidgetFollow>
      </div>
    </div>
  </div>
</template>

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

export default {
  props: ['data', 'share'],
  computed: {
    ...mapState(['yoho']),
    headStyle() {
      let top = 0;

      if (this.yoho.window.statusBarStatus) {
        top = get(this.yoho, 'window.statusBarHeight', 0);
      }

      let style = {
        paddingTop: `${44 + top}px`
      };

      if (this.data.topicImageUrl) {
        style.backgroundImage = `url(//${this.data.topicImageUrl.split('//')[1]})`;
      }

      return style;
    }
  },
  methods: {
    onFollow(follow) {
      this.$emit('on-follow', follow);
    },
  }
};
</script>

<style scoped>
.topic-banner {
  background-size: cover;
  background-repeat: no-repeat;
  background-color: #eee;
  color: #fff;
  position: relative;

  .banner-main {
    height: 240px;
  }

  .topic-name {
    height: 50px;
    padding: 0 30px;
    margin: 30px 0 18px;
    font-size: 36px;
    letter-spacing: 0.09PX;
    font-weight: 800;
    display: flex;
    align-items: center;
  }

  .topic-desc {
    padding: 0 30px;
    height: 60px;
    font-size: 24px;
    font-weight: 300;
    line-height: 30px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .topic-extra {
    width: 100%;
    height: 36px;
    margin: 34px 0 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;

    .att-amount {
      font-size: 26px;
      font-weight: 700px;
      margin-left: 30px;
    }

    .att-click-wrap {
      width: 190px;
      height: 60px;
      padding-right: 36px;
      margin-right: -32px;
      border-radius: 31px;
      border-color: #ff5660;
      background-color: #ff5660;
      color: #fff;
      font-size: 32px;

      &.follow {
        background: none;
        border-color: #fff;
      }
    }
  }
}
</style>