UniversitySearch.vue
6.2 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
<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="universityName" />
<div class="search_tips" @click="universitySearch()">搜索</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="university_search_result">
<!-- 结果标题 -->
<div class="university_result_title layout align_center flex_row">
<!-- 图标 -->
<div class="result_icon">
<img src="@/assets/img/23.png" alt />
</div>
<div class="result_tip">搜索结果</div>
<div>
共
<i class="university_num">{{totalNum}}</i>所院校
</div>
</div>
<!-- 搜索的院校 -->
<div
class="searched_university layout flex_diection"
v-show="resultList.length"
v-for="item in resultList"
:key="item.id"
>
<div class="layout flex_row justify">
<!-- 院校 -->
<div class="layout flex_row university_search_msg" @click="toUniversity(item)">
<!-- 院校logo -->
<div class="university_logo clearfix">
<img :src="item.images" alt />
</div>
<!-- 院校信息 -->
<div class="university_det_msg layout flex_diection justify align_left">
<div class="university_name layout align_center flex_row">
<i class="university_hover_color">{{item.name}}</i>
<i class="nine" v-show="item.is_985 == 1">985</i>
<i class="two" v-show="item.is_211 == 1">211</i>
</div>
<div>
中国校友会排名:
<img src="@/assets/img/54.png" alt v-show="item.rank==1" />
<img src="@/assets/img/55.png" alt v-show="item.rank==2" />
<img src="@/assets/img/53.png" alt v-show="item.rank==3" />
<i v-show="item.rank>3">{{item.rank}}</i>
<i v-show="item.rank==0">-</i>
</div>
<div>学校类别:{{item.type_name?item.type_name:'-'}}</div>
<div>隶属单位:{{item.belong?item.belong:'-'}}</div>
<div class="clearfix layout flex_row">
<div>专业优势:</div>
<div class="search_advantage">{{item.profession?item.profession:'-'}}</div>
</div>
</div>
</div>
<!-- 收藏 -->
<div
class="university_collection"
:class="{university_collectioned:item.is_favorite == 1 }"
@click="joinCollect(item)"
>{{item.is_favorite == 0?"收藏":"已收藏"}}</div>
</div>
<!-- 学校联系方式 -->
<div class="university_contact layout flex_row align_center">
<div>
<img src="@/assets/img/43.png" alt class="university_contact_icon" />
学校地址:{{item.address?item.address:'-'}}
</div>
<div class="university_phone">
<img src="@/assets/img/42.png" alt class="university_contact_icon" />
联系方式:{{item.phone?item.phone:'-'}}
</div>
<div>
<img src="@/assets/img/41.png" alt class="university_contact_icon" />
电子邮箱:{{item.email?item.email:'-'}}
</div>
</div>
</div>
<!-- 分页 -->
<el-pagination
background
layout="prev, pager, next"
:page-count="total"
@current-change="handleCurrentChange"
></el-pagination>
</div>
</div>
</div>
</template>
<script>
import { post } from "@/api/http";
export default {
data() {
return {
// 分页
total: 0,
totalNum: "",
resultList: [],
page: 1,
universityName: "",
// 热门院校
hotList: [],
// 关键字
keyword: ""
};
},
methods: {
// 收藏/取消收藏
joinCollect(item) {
let url = "/api/common/favorite";
let params = {
object_id: item.id,
type: 1
};
post(url, params).then(res => {
item.is_favorite = !item.is_favorite;
});
},
// 分页
handleCurrentChange(val) {
this.page = val;
this.getSchoolList();
document.body.scrollTop = 0;
document.documentElement.scrollTop = 0;
},
// 大学详情
toUniversity(item) {
this.$router.push({
path: "/UniversityIntroduc",
query: { id: item.id }
});
},
hotMajor(item){
this.$router.push({
path: "/UniversityIntroduc",
query: { id: item.id }
});
},
// 搜索
universitySearch() {
this.keyword = this.universityName;
this.getSchoolList();
},
// 大学院校列表
getSchoolList() {
let url = "/api/school/getSchoolList/";
let params = {
keyword: this.keyword,
page: this.page
};
post(url, params).then(res => {
this.resultList = res.school_list;
// 总页数
this.total = res.total_page;
// 总数
this.totalNum = res.school_count;
});
},
// 热门学校列表
getHotList() {
let url = "/api/school/getHotList/";
post(url).then(res => {
this.hotList = res.hot_list;
});
}
},
mounted() {
this.keyword = this.$route.query.keyWord;
this.universityName = this.$route.query.keyWord;
this.getHotList();
this.getSchoolList();
}
};
</script>
<style scoped>
@import "../../../../style/schoolFirstPage.css";
.major_search {
font-size: 14px;
color: #8c9198;
}
.hot_major {
margin-bottom: 32px;
}
.university_hover_color:hover {
color: #409eff;
}
</style>