forked from mtianyan/vue-mooc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharticle.vue
144 lines (144 loc) · 3.43 KB
/
article.vue
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
<template>
<div class="user-article">
<dl>
<dt>
<span
v-for="(tab,index) in tabList"
:key="index"
:class="{active: currentTabIndex==index}"
@click="handleTabClick(tab,index)"
>{{ tab.title }}</span>
</dt>
<template v-if="filterList.length">
<dd v-for="(item,index) in filterList" :key="index" class="article-item">
<h3 class="title">
{{ item.title }}
</h3>
<div class="content-container">
<div v-if="item.img" class="img-box">
<img :src="item.img" alt="">
</div>
<div class="course-content">
<p class="desc">
{{ item.desc }}
</p>
</div>
</div>
<div class="other">
<span>{{ item.author }}</span>
<p class="fr">
<span>{{ item.view }}浏览</span>
<span>{{ item.like }}推荐</span>
<span>{{ item.comment }}评论</span>
</p>
</div>
</dd>
</template>
<empty v-else></empty>
</dl>
</div>
</template>
<script>
import Empty from 'components/empty/empty.vue'
export default {
props: {
list: {
type: Array,
default () {
return []
}
}
},
data () {
return {
currentTabIndex: 0,
tabList: []
}
},
created () {
// 初始化选项卡数据
this.tabList = [
{ title: '我的文章', type: 0 },
{ title: '我的收藏', type: 1 },
{ title: '我的推荐', type: 2 },
{ title: '我的评论', type: 3 }
]
},
methods: {
// 选项卡点击事件
handleTabClick (tab, index) {
this.currentTabIndex = index
}
},
computed: {
filterList () {
let currTab = this.tabList[this.currentTabIndex]
return this.list.filter(item => item.type === currTab.type)
}
},
components: {
Empty
}
}
</script>
<style lang="stylus" scoped>
.user-article
dt
border-bottom: 1px solid #d0d6d9;
& > span
margin-right: 48px;
display: inline-block;
vertical-align: middle;
height: 48px;
line-height: 48px;
box-sizing: border-box;
font-size: 14px;
color: #787d82
cursor: pointer;
&:last-child
margin-right: 0;
&.active
color: #f01414;
border-bottom: 2px solid #f01414;
.article-item
padding: 30px 0;
border-bottom: 1px solid #eff1f0;
&:last-child
border-bottom: none;
.title
padding-bottom: 20px;
font-size: 20px;
line-height: 32px;
font-weight: 700;
.content-container
display: flex;
align-items: flex-start;
.img-box
flex: 0 0 210px;
width: 210px;
height: 130px;
margin-right: 30px;
& > img
display: block;
width: 100%;
height: 100%;
.course-content
flex: 1;
.desc
font-size: 14px;
line-height: 28px;
color: #4d555d;
word-break: break-all;
.other
margin-top: 20px;
span
display: inline-block;
vertical-align: middle;
margin-right: 20px;
font-size: 14px;
color: #93999f;
&:last-child
margin-right: 0;
.fr
float: right;
</style>