banner.vue 3.17 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;

    &:before {
      content: "";
      display: inline-block;
      width: 28px;
      height: 28px;
      background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAMAAADyHTlpAAAASFBMVEUAAAD////////////////////////////////////////////////////////////////////////////////////////////neHiwAAAAF3RSTlMAgC3B2mz485KHFeDetqWhj3xJHgYkVgWN1eoAAAELSURBVDjLpZXhkoMgDISXgFKUqrT28v5ver05HBSqgen3Y3/tjHGHbJBBYdLGWqOnQLiAFs87/HLmfs5cMD9RsrqeP9C7FRmD5hP0kE058ikjHZyWL7A77zDyJeOAyKpZQG//5ljExTz7YzxKuaiJ/j/fLHkDvDZNzHhDfOQOPKLuIQBLZr0BXdQ9CwCfWTvgFnWPL7/PD+AeNZsgcEL9MQDdpooTARMnUMCJCbrWqmGyAX4AivrmkLeVstqwsFJWyWqkrNIA+QN8ASbqEd0SVqi1BlCtlQBfl5UHsEhZpUdIdVlRXBg5q7lcQ6dUv2m2hg3L3VAZjUUk11t7acpV3Fzw8tn47hjJJ+4Xnidmo39mnugAAAAASUVORK5CYII=');
      background-size: 100% 100%;
      margin-right: 10px;
    }
  }

  .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>