forked from mtianyan/vue-mooc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquestion.vue
144 lines (144 loc) · 3.52 KB
/
question.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="course-question">
<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="course-item">
<div class="img-box">
<img src="https://img3.mukewang.com/5ab477e700015ea202400240.jpg" alt="">
</div>
<div class="course-content">
<p class="from">
来自 {{ item.from }}
</p>
<p class="title">
{{ item.title }}
</p>
<p v-if="item.isAnswer" class="answer-box">
<span class="title">我的回答</span>
<span class="answer">{{ item.answer }}</span>
</p>
<p class="other">
<span>{{ item.time }}</span>
<span v-if="item.isAnswer">{{ item.reply }}个回复</span>
<span v-else>{{ item.answer }}个回答</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 }
]
},
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>
.course-question
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;
.course-item
display: flex;
align-items: flex-start;
padding: 30px 0;
border-bottom: 1px solid #eff1f0;
&:last-child
border-bottom: none;
.img-box
flex: 0 0 40px;
width: 40px;
height: 40px;
& > img
display: block;
width: 100%;
height: 100%;
.course-content
flex: 1;
margin-left: 20px;
.from
font-size: 12px;
color: #787d82;
line-height: 20px;
.title
font-size: 18px;
font-weight: 700;
line-height: 30px;
.answer-box
margin-top: 10px;
.title
display: block;
font-size: 14px;
line-height: 24px;
.answer
line-height: 24px;
font-size: 14px;
.other
margin-top: 10px;
& > span
margin-right: 20px;
display: inline-block;
vertical-align: middle;
font-size: 14px;
color: #b5b9bc;
</style>