NewsDetail.vue
5.6 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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<template>
<div class="news_detail">
<Top :active="active"></Top>
<div class="news_det_wrap">
<div class="news_det_box">
<!-- 面包屑 -->
<div class="major_title layout align_left">
<el-breadcrumb separator="|">
<el-breadcrumb-item>首页</el-breadcrumb-item>
<el-breadcrumb-item>教育新闻</el-breadcrumb-item>
</el-breadcrumb>
</div>
<div class="clearfix">
<!-- 左侧 新闻列表 -->
<div class="news_list">
<!-- 上部标题 -->
<div class="news_l_top layout flex_diection justify_center">
<i class="news_content">NEWS</i>
<i>教育新闻</i>
</div>
<!-- 下层列表内容 -->
<div class="news_l_bottom">
<ul class="clearfix">
<li
class="news_list_li"
:class="{li_color:isNew == item.id}"
v-for="item in list"
:key="item.id"
@click="newsDet(item.id)"
>{{item.name}}</li>
</ul>
<!-- 翻页按钮 -->
<div class="news_btn clearfix" v-show="pageSum > 1">
<div class="prev_page" @click="prev">上一页</div>
<div class="next_page" @click="next">下一页</div>
</div>
</div>
</div>
<!-- 右侧 新闻详情 -->
<div class="news_single_det">
<div class="news_single_box">
<!-- 日期 -->
<div class="news_date">
<i class="date_time">{{detail.date}}</i>
/{{detail.year}}
</div>
<!-- 内容 -->
<div class="news_det_content">
<!-- 标题 -->
<div class="news_single_title">{{detail.name}}</div>
<!-- <div class="news_contents">{{detail.description}}</div> -->
<div class="news_contents" v-html="detail.content"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<bottom2></bottom2>
</div>
</template>
<script>
import Top from "../../common/Top";
import Bottom2 from "../../common/Bottom2";
import { post } from "@/api/http";
export default {
data() {
return {
active: 0,
// 所有数据
list: [],
detail: "",
id: "",
isNew: "",
// 当前页
currentPage: 1,
// 总页数
pageSum: ""
};
},
methods: {
// 教育新闻列表
getEducationNewsList() {
let url = "/api/index/getEducationNewsList/";
let params = {
page: this.currentPage
};
post(url, params).then(res => {
this.list = res.news_list.data;
if (this.currentPage > 1) {
this.id = res.news_list.data[0].id;
}else{
this.id = this.$route.query.id;
}
this.newsDet(this.id);
// 总页数
this.pageSum = res.total_page;
});
},
// 上一页
prev() {
if (this.currentPage == 1) {
return "";
} else {
this.currentPage--;
this.getEducationNewsList();
}
},
// 下一页
next() {
if (this.currentPage == this.pageSum) {
return "";
} else {
this.currentPage++;
this.getEducationNewsList();
}
},
// 教育新闻详情
newsDet(id) {
this.id = id;
this.isNew = id;
let url = "/api/index/getEducationNewsDetail/";
let params = {
id: this.id
};
post(url, params).then(res => {
this.detail = res;
});
}
},
components: {
Top,
Bottom2
},
mounted() {
this.getEducationNewsList();
this.isNew = this.$route.query.id;
},
watch: {
$route(to, from) {
this.id = this.$route.query.id;
this.getEducationNewsList();
}
}
};
</script>
<style scoped>
.news_det_wrap {
width: 100%;
background-color: #f2f5fa;
}
.news_det_box {
width: 1200px;
margin: 0 auto;
}
/* 左侧 */
.news_list {
float: left;
width: 180px;
}
.news_l_top {
width: 180px;
height: 140px;
/* background-color: #409eff; */
color: #fff;
font-size: 16px;
background-image: url("../../../assets/img/news.png");
background-position: 0 0;
background-size: cover;
background-repeat: no-repeat;
}
.news_content {
font-size: 30px;
}
.news_l_bottom {
width: 180px;
background-color: #fff;
margin-top: 20px;
}
.news_list_li {
color: #8c9198;
font-size: 14px;
width: 144px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
padding: 12px 18px;
}
.news_list_li:hover {
background-color: #eee;
}
.li_color {
color: #409eff;
}
/* 翻页按钮 */
.news_btn {
padding: 13px;
}
.prev_page,
.next_page {
width: 72px;
height: 30px;
border: 1px solid #409eff;
border-radius: 3px;
line-height: 30px;
text-align: center;
float: left;
font-size: 12px;
color: #409eff;
}
.next_page {
float: right;
background-color: #409eff;
color: #fff;
}
/* 右侧 */
.news_single_det {
float: right;
width: 996px;
background-color: #fff;
}
.news_single_box {
padding: 20px;
}
.news_date {
font-size: 14px;
color: #8c9198;
padding-bottom: 20px;
border-bottom: 1px solid #eee;
text-align: left;
}
.date_time {
font-weight: bold;
color: #34485e;
}
/* 标题 */
.news_single_title {
font-weight: bold;
color: #34485e;
font-size: 20px;
margin: 24px 0 20px 0;
}
.news_contents {
color: #8c9198;
font-size: 14px;
text-align: left;
}
.news_img {
width: 100%;
height: 148px;
margin: 20px 0;
}
.news_img img {
width: 100%;
height: 100%;
}
</style>