banner.vue
2.89 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
<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">
<WidgetFollow 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>
export default {
props: ['data'],
computed: {
headStyle() {
if (!this.data.topicImageUrl) {
return {};
}
return {
'background-image': `url(//${this.data.topicImageUrl.split('//')[1]})`
};
},
showAttAmount() {
return this.data && +this.data.showAttAmount > 0;
},
attClass() {
return {
active: this.data.hasAttention
};
}
},
methods: {
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);
padding-top: 44PX;
box-sizing: border-box;
position: relative;
background-size: cover;
display: flex;
align-items: center;
&:before {
content: "";
background: rgba(0, 0, 0, 0.5);
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: 1;
}
.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>