Blame view

apps/pages/article/components/topic/banner.vue 3.6 KB
yyq authored
1
<template>
yyq authored
2 3 4 5 6
  <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">
yyq authored
7
        <label class="att-amount" :class="{invisible: !data.articleAmount}">{{data.articleAmount}}人参与讨论</label>
yyq authored
8
        <WidgetFollow v-if="+data.allowAttention" class="att-click-wrap" :topic-id="data.topicId" :follow="data.hasAttention" :share="share" @on-follow="onFollow"></WidgetFollow>
yyq authored
9 10 11 12 13 14
      </div>
    </div>
  </div>
</template>

<script>
yyq authored
15 16 17
import {mapState} from 'vuex';
import {get} from 'lodash';
yyq authored
18
export default {
yyq authored
19
  props: ['data', 'share'],
yyq authored
20
  computed: {
yyq authored
21
    ...mapState(['yoho']),
yyq authored
22
    headStyle() {
yyq authored
23 24 25 26 27 28
      let top = 0;

      if (this.yoho.window.statusBarStatus) {
        top = get(this.yoho, 'window.statusBarHeight', 0);
      }
yyq authored
29
      let style = {
yyq authored
30
        paddingTop: `${44 + top}px`
yyq authored
31 32 33
      };

      if (this.data.topicImageUrl) {
yyq authored
34 35 36
        let topicImageUrl = this.data.topicImageUrl.split('?')[0];

        style.backgroundImage = `url(//${topicImageUrl.split('//')[1]}?imageView2/2/w/750/h/300/format/jpg/interlace/1)`;
yyq authored
37 38
      }
yyq authored
39
      return style;
yyq authored
40 41 42 43 44 45 46 47 48 49
    }
  },
  methods: {
    onFollow(follow) {
      this.$emit('on-follow', follow);
    },
  }
};
</script>
陈峰 authored
50
<style scoped lang="scss">
yyq authored
51
.topic-banner {
yyq authored
52
  background-size: cover;
yyq authored
53 54
  background-repeat: no-repeat;
  background-color: #eee;
yyq authored
55
  background-position: center;
yyq authored
56 57
  color: #fff;
  position: relative;
yyq authored
58
yyq authored
59 60 61
  &:before {
    content: "";
    position: absolute;
yyq authored
62 63 64 65 66
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
yyq authored
67 68
  }
yyq authored
69 70
  .banner-main {
    height: 240px;
yyq authored
71 72
    position: relative;
    z-index: 2;
yyq authored
73
  }
yyq authored
74
yyq authored
75 76 77 78 79 80 81 82 83
  .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;
yyq authored
84 85 86 87 88 89

    &:before {
      content: "";
      display: inline-block;
      width: 28px;
      height: 28px;
陈峰 authored
90
      background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACoAAAAqCAMAAADyHTlpAAAASFBMVEUAAAD////////////////////////////////////////////////////////////////////////////////////////////neHiwAAAAF3RSTlMAgC3B2mz485KHFeDetqWhj3xJHgYkVgWN1eoAAAELSURBVDjLpZXhkoMgDISXgFKUqrT28v5ver05HBSqgen3Y3/tjHGHbJBBYdLGWqOnQLiAFs87/HLmfs5cMD9RsrqeP9C7FRmD5hP0kE058ikjHZyWL7A77zDyJeOAyKpZQG//5ljExTz7YzxKuaiJ/j/fLHkDvDZNzHhDfOQOPKLuIQBLZr0BXdQ9CwCfWTvgFnWPL7/PD+AeNZsgcEL9MQDdpooTARMnUMCJCbrWqmGyAX4AivrmkLeVstqwsFJWyWqkrNIA+QN8ASbqEd0SVqi1BlCtlQBfl5UHsEhZpUdIdVlRXBg5q7lcQ6dUv2m2hg3L3VAZjUUk11t7acpV3Fzw8tn47hjJJ+4Xnidmo39mnugAAAAASUVORK5CYII=");
yyq authored
91 92 93
      background-size: 100% 100%;
      margin-right: 10px;
    }
yyq authored
94 95
  }
yyq authored
96 97 98
  .topic-desc {
    padding: 0 30px;
    height: 60px;
yyq authored
99
    font-size: 24px;
yyq authored
100 101 102 103 104 105 106
    font-weight: 300;
    line-height: 30px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
yyq authored
107 108
  }
yyq authored
109 110 111 112
  .topic-extra {
    width: 100%;
    height: 36px;
    margin: 34px 0 40px;
yyq authored
113 114
    display: flex;
    align-items: center;
yyq authored
115
    justify-content: space-between;
yyq authored
116
yyq authored
117 118 119 120
    .att-amount {
      font-size: 26px;
      font-weight: 700px;
      margin-left: 30px;
yyq authored
121 122
    }
yyq authored
123 124 125 126 127 128 129 130 131 132 133
    .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;
yyq authored
134
      &.loading {
yyq authored
135
        padding: 0 36px 0 10px;
yyq authored
136 137
      }
yyq authored
138 139 140 141
      &.follow {
        background: none;
        border-color: #fff;
      }
yyq authored
142 143 144 145
    }
  }
}
</style>