Major.vue
5.9 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<template>
<!-- 专业查询 -->
<div class="major_search clearfix">
<div class="major_box clearfix">
<!-- 搜索框 -->
<div class="search_input clearfix layout flex_row align_center">
<input type="text" placeholder="专业查询" v-model="major_name" @keyup.enter="search()"/>
<div class="search_tips" @click="search()">搜索</div>
</div>
<!-- 热门专业 -->
<div class="hot_major clearfix ">
<div class="hot_major_title">热门专业:</div>
<!-- 专业名称 -->
<div
class="hot_major_name"
v-for="item in hotList"
:key="item.id"
@click="hotMajor(item)"
>{{item.name}}</div>
</div>
<!-- 专业分类 -->
<div class="major_category clearfix">
<div
class="cate_name"
:class="{choice_color:isChoice == index}"
@click="choiced(index)"
v-for="(item,index) in cateList"
:key="index"
>{{item}}</div>
</div>
<!-- 本科专业 -->
<div class="undergraduate_major clearfix" v-show="isUnder">
<div class="under_major_box">
<div
class="under_major_det layout flex_row align_center"
v-for="item in underList"
:key="item.id"
>
<!-- 左侧 -->
<div class="major_det_l clearfix layout flex_row align_left">
<!-- 图标 -->
<div class="major_icon" style="margin-left:30px">
<img :src="item.icon" alt />
</div>
<!-- 类名 -->
<div class="major_l_name" @click="majorDetail(item.id)">{{item.name}}</div>
</div>
<!-- 右侧 -->
<div class="major_det_r clearfix">
<div
class="major_det_name"
v-for="secondItem in item.child"
:key="secondItem.id"
@click="secondMajorDetail(secondItem.id)"
>{{secondItem.name}}</div>
</div>
</div>
</div>
</div>
<!-- 专科专业 -->
<div class="undergraduate_major clearfix" v-show="!isUnder">
<div class="under_major_box">
<div
class="under_major_det layout flex_row align_center"
v-for="item in specialtyList"
:key="item.id"
>
<!-- 左侧 -->
<div class="major_det_l clearfix layout flex_row align_left">
<!-- 图标 -->
<div class="major_icon">
<img :src="item.icon" alt />
</div>
<!-- 类名 -->
<div class="major_l_name" @click="majorDetail(item.id)">{{item.name}}</div>
</div>
<!-- 右侧 -->
<div class="major_det_r clearfix">
<div
class="major_det_name"
v-for="secondItem in item.child"
:key="secondItem.id"
@click="secondMajorDetail(secondItem.id)"
>{{secondItem.name}}</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import { post } from "@/api/http";
export default {
data() {
return {
major_name: "",
cateList: ["本科专业", "专科专业"],
isChoice: 0,
isUnder: true,
// 本科列表
underList: [],
// 专科列表
specialtyList: [],
// 热门专业列表
hotList: []
};
},
methods: {
// 热门专业
hotMajor(item) {
this.$router.push({ path: "/HotMajor", query: { id: item.id } });
},
// 搜索
search() {
this.$router.push({
path: "/MajorSearch",
query: { keyWord: this.major_name }
});
},
// 本/专科专业
choiced(index) {
this.isChoice = index;
if (index == 0) {
this.isUnder = true;
} else {
this.isUnder = false;
}
},
// 专业列表
getMajorList() {
let url = "/api/major/getMajorList/";
post(url).then(res => {
// 本科
this.underList = res.b_list;
// 专科
this.specialtyList = res.z_list;
});
},
// 热门专业
getHotList() {
let url = "/api/major/getHotList/";
post(url).then(res => {
this.hotList = res.hot_list;
});
},
// 一级专业详情
majorDetail(id) {
this.$router.push({ path: "/MajorDetail", query: { id: id } });
},
// 二级专业详情
secondMajorDetail(secondId) {
this.$router.push({
path: "/SecondMajorDetail",
query: { secondId: secondId }
});
}
},
mounted() {
this.getMajorList();
this.getHotList();
}
};
</script>
<style scoped>
@import '../../../../style/schoolFirstPage.css';
/* 专业类别 */
.major_category {
width: 228px;
height: 44px;
background: #fff;
border-radius: 3px;
margin: 48px auto 24px;
}
.cate_name {
width: 50%;
height: 44px;
font-size: 18px;
color: #5b5e63;
line-height: 44px;
float: left;
border-radius: 3px;
}
.choice_color {
background-color: #409eff;
color: #fff;
}
/* 本科专业 */
.undergraduate_major {
width: 1200px;
background-color: #fff;
}
.under_major_box {
padding: 0 24px;
}
/* 具体分类 */
.under_major_det {
padding: 22px 0;
border-bottom: 1px solid #eee;
}
/* 左侧 */
.major_det_l {
width: 180px;
}
/* 图标 */
.major_icon {
width: 43px;
height: 43px;
margin-right: 18px;
}
.major_icon img {
width: 100%;
height: 100%;
display: block;
}
/* 类名 */
.major_l_name {
color: #34485e;
font-size: 16px;
line-height: 43px;
}
.major_l_name:hover{
color: #409eff;
}
/* 右侧 */
.major_det_r {
padding: 12px 12px 12px 0;
border-left: 1px solid #eee;
width: 972px;
}
/* 具体专业 */
.major_det_name {
font-size: 14px;
color: #8c9198;
margin-left: 24px;
float: left;
}
.major_det_name:hover {
color: #409eff;
}
</style>