banner.vue
3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<template>
<div class="topic-head" :style="headStyle">
<div class="center">
<p class="desc">{{data.topicDesc}}</p>
<div v-if="showAttAmount" class="att-amount">
<label>{{data.attAmount}}人已关注</label>
</div>
<div v-if="+data.allowAttention" class="att-topic-btn" :class="attClass" @click="onClick">
<WidgetFollow v-if="!share" class="att-click-wrap" :topic-id="data.topicId" :follow="data.hasAttention" @on-follow="onFollow"></WidgetFollow>
<template v-if="data.hasAttention">
已关注
</template>
<template v-else>
<span class="iconfont icon-plus"></span>
关注话题
</template>
</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;
},
showAttAmount() {
return this.data && +this.data.showAttAmount > 0;
},
attClass() {
return {
active: this.data.hasAttention
};
}
},
methods: {
onClick() {
if (this.share) {
return this.$links.toDownloadApp();
}
},
onFollow(follow) {
this.$emit('on-follow', follow);
},
}
};
</script>
<style scoped>
.topic-head {
min-height: 360px;
background-size: 100%;
background-image: linear-gradient(140deg, #7A88FF, #7AFFAF);
box-sizing: border-box;
position: relative;
background-size: cover;
display: flex;
align-items: center;
&:before {
content: "";
height: 1px;
position: absolute;
top: -1px;
left: 0;
right: 0;
z-index: 1;
box-shadow: 0 0 140px 40px #000;
}
.center {
width: 100%;
position: relative;
z-index: 2;
text-align: center;
padding: 40px 100px;
box-sizing: border-box;
}
.desc {
font-size: 24px;
color: #fff;
line-height: 1.42;
word-break: break-all;
}
$attColor: #b0b0b0;
.att-amount {
margin-top: 20px;
color: $attColor;
display: flex;
justify-content: center;
label {
display: inline-block;
position: relative;
line-height: 1;
&:before,
&:after {
content: "";
width: 60px;
height: 2px;
background-color: $attColor;
display: block;
position: absolute;
top: 50%;
margin-top: -1px;
}
&:before {
right: calc(100% + 20px);
}
&:after {
left: calc(100% + 20px);
}
}
}
.att-topic-btn {
width: 200px;
height: 50px;
font-size: 26px;
border-radius: 28px;
line-height: 1;
display: flex;
align-items: center;
justify-content: center;
background-color: #d90025;
color: #fff;
margin: 36px auto 0;
position: relative;
.iconfont {
font-weight: bold;
margin-right: 10px;
}
&.active {
background-color: #e48a8a;
}
}
}
</style>