修改关于海威格式
|
Before Width: | Height: | Size: 967 KiB After Width: | Height: | Size: 937 KiB |
|
After Width: | Height: | Size: 967 KiB |
|
Before Width: | Height: | Size: 984 KiB After Width: | Height: | Size: 974 KiB |
|
After Width: | Height: | Size: 984 KiB |
|
After Width: | Height: | Size: 998 KiB |
@ -0,0 +1,340 @@
|
|||||||
|
<template>
|
||||||
|
<div class="newsListPage">
|
||||||
|
<Title title="新闻列表"/>
|
||||||
|
<div class="content">
|
||||||
|
<div class="filter">
|
||||||
|
<el-input
|
||||||
|
v-model="keywordText"
|
||||||
|
clearable
|
||||||
|
placeholder="请输入关键词,多个关键词用空格分隔"
|
||||||
|
prefix-icon="el-icon-search">
|
||||||
|
</el-input>
|
||||||
|
</div>
|
||||||
|
<div class="info-image-card" v-for="i in pageList" :key="i.newsCode || i.id">
|
||||||
|
<div class="info-image-card__side">
|
||||||
|
<div class="info-image-card__side-main">{{ i.day }}</div>
|
||||||
|
<div class="info-image-card__side-sub">{{ i.month }}/{{ i.year }}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="info-image-card__content">
|
||||||
|
<div class="info-image-card__title">
|
||||||
|
<span :style="tagStyle(i.type)">[{{ i.tag }}]</span>{{ i.title }}
|
||||||
|
</div>
|
||||||
|
<div class="info-image-card__desc">
|
||||||
|
{{ i.summary }}
|
||||||
|
</div>
|
||||||
|
<div class="info-image-card__link" @click="toDetail(i)">
|
||||||
|
<span>查看详情</span>
|
||||||
|
<span class="info-image-card__arrow"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<img
|
||||||
|
class="info-image-card__image"
|
||||||
|
:src="i.cover"
|
||||||
|
:alt="i.title"
|
||||||
|
draggable="false"
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
<div class="pagination">
|
||||||
|
<el-pagination
|
||||||
|
background
|
||||||
|
layout="prev, pager, next"
|
||||||
|
:current-page="currentPage"
|
||||||
|
:page-size="pageSize"
|
||||||
|
:total="filteredList.length"
|
||||||
|
@current-change="handlePageChange">
|
||||||
|
</el-pagination>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<ContactUs class="contactUs"/>
|
||||||
|
<Copyright class="copyright"/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {listNews} from "@/api/news";
|
||||||
|
import Title from "@/components/global/title.vue";
|
||||||
|
import ContactUs from "@/components/contactUs";
|
||||||
|
import Copyright from "@/components/copyright";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'NewsList',
|
||||||
|
components: {
|
||||||
|
Title,
|
||||||
|
ContactUs,
|
||||||
|
Copyright
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
list: [],
|
||||||
|
keywordText: '',
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
keywordText() {
|
||||||
|
this.currentPage = 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
keywords() {
|
||||||
|
return this.keywordText
|
||||||
|
.trim()
|
||||||
|
.split(/\s+/)
|
||||||
|
.filter(Boolean)
|
||||||
|
.map(item => item.toLowerCase())
|
||||||
|
},
|
||||||
|
filteredList() {
|
||||||
|
if (this.keywords.length === 0) {
|
||||||
|
return this.list
|
||||||
|
}
|
||||||
|
return this.list
|
||||||
|
.map(item => ({
|
||||||
|
...item,
|
||||||
|
matchCount: this.getMatchCount(item)
|
||||||
|
}))
|
||||||
|
.filter(item => item.matchCount > 0)
|
||||||
|
.sort((a, b) => b.matchCount - a.matchCount || this.getNewsTime(b) - this.getNewsTime(a))
|
||||||
|
},
|
||||||
|
pageList() {
|
||||||
|
const start = (this.currentPage - 1) * this.pageSize
|
||||||
|
return this.filteredList.slice(start, start + this.pageSize)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.getData()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getData() {
|
||||||
|
listNews().then(res => {
|
||||||
|
const rows = res.rows || res.data?.rows || []
|
||||||
|
this.list = rows
|
||||||
|
.map(item => this.parseNewsJson(item))
|
||||||
|
.filter(Boolean)
|
||||||
|
.sort((a, b) => this.getNewsTime(b) - this.getNewsTime(a))
|
||||||
|
})
|
||||||
|
},
|
||||||
|
parseNewsJson(item) {
|
||||||
|
try {
|
||||||
|
const newsJson = item.newsJson || '{}'
|
||||||
|
return {
|
||||||
|
id: item.id || item.newsId,
|
||||||
|
newsCode: item.newsCode,
|
||||||
|
newsJson,
|
||||||
|
...JSON.parse(newsJson)
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getMatchCount(item) {
|
||||||
|
const content = String(item.newsJson || '').toLowerCase()
|
||||||
|
return this.keywords.reduce((total, keyword) => {
|
||||||
|
return total + this.countKeyword(content, keyword)
|
||||||
|
}, 0)
|
||||||
|
},
|
||||||
|
countKeyword(content, keyword) {
|
||||||
|
let count = 0
|
||||||
|
let index = content.indexOf(keyword)
|
||||||
|
while (index !== -1) {
|
||||||
|
count += 1
|
||||||
|
index = content.indexOf(keyword, index + keyword.length)
|
||||||
|
}
|
||||||
|
return count
|
||||||
|
},
|
||||||
|
getNewsTime(item) {
|
||||||
|
return new Date(`${item.year || 0}/${item.month || 1}/${item.day || 1}`).getTime()
|
||||||
|
},
|
||||||
|
tagStyle(type) {
|
||||||
|
const colorMap = {
|
||||||
|
1: '#3372FE',
|
||||||
|
2: '#18A058',
|
||||||
|
3: '#D03050'
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
color: colorMap[type] || colorMap[1]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
toDetail(e) {
|
||||||
|
this.$router.push({
|
||||||
|
path: '/newsDetail',
|
||||||
|
query: {newsCode: e.newsCode}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handlePageChange(page) {
|
||||||
|
this.currentPage = page
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped>
|
||||||
|
@import "~@/style.less";
|
||||||
|
|
||||||
|
.newsListPage {
|
||||||
|
min-height: 100%;
|
||||||
|
padding-top: 2vw;
|
||||||
|
background-color: #f7fbff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
display: inline-block;
|
||||||
|
width: 85vw;
|
||||||
|
margin-top: 3.7vw;
|
||||||
|
margin-bottom: 5.2vw;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter {
|
||||||
|
width: 36vw;
|
||||||
|
margin: 0 auto 2vw;
|
||||||
|
|
||||||
|
/deep/ .el-input__inner {
|
||||||
|
height: 3vw;
|
||||||
|
line-height: 3vw;
|
||||||
|
border-radius: 0;
|
||||||
|
font-size: 1vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .el-input__icon {
|
||||||
|
line-height: 3vw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination {
|
||||||
|
margin-top: 2vw;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contactUs {
|
||||||
|
width: 100%;
|
||||||
|
background-color: #2e445c;
|
||||||
|
}
|
||||||
|
|
||||||
|
.copyright {
|
||||||
|
width: 100%;
|
||||||
|
background-color: #1d3348;
|
||||||
|
}
|
||||||
|
|
||||||
|
.info-image-card {
|
||||||
|
display: flex;
|
||||||
|
align-items: stretch;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
margin-bottom: 1vw;
|
||||||
|
overflow: hidden;
|
||||||
|
background-color: #fff;
|
||||||
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.02);
|
||||||
|
text-align: left;
|
||||||
|
|
||||||
|
&:hover &__side {
|
||||||
|
color: #fff;
|
||||||
|
background: #3372fe;
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
border-left-color: #3372fe;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__side {
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
display: flex;
|
||||||
|
width: 8vw;
|
||||||
|
flex: 0 0 8vw;
|
||||||
|
align-self: stretch;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: #000;
|
||||||
|
background: #fff;
|
||||||
|
transition: color 0.2s ease, background-color 0.2s ease;
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
right: calc(-1vw + 1px);
|
||||||
|
width: 0;
|
||||||
|
height: 0;
|
||||||
|
border-top: 1vw solid transparent;
|
||||||
|
border-bottom: 1vw solid transparent;
|
||||||
|
border-left: 1vw solid #fff;
|
||||||
|
content: '';
|
||||||
|
transform: translateY(-50%);
|
||||||
|
transition: border-left-color 0.2s ease;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__side-main {
|
||||||
|
font-size: 3vw;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__side-sub {
|
||||||
|
margin-top: 1vw;
|
||||||
|
font-size: 1vw;
|
||||||
|
line-height: 1.2;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__content {
|
||||||
|
display: flex;
|
||||||
|
min-width: 0;
|
||||||
|
flex: 1 1 auto;
|
||||||
|
flex-direction: column;
|
||||||
|
padding: 2vw 2vw 2vw 4vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__title {
|
||||||
|
overflow: hidden;
|
||||||
|
color: #000;
|
||||||
|
font-size: 1.3vw;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 1.6vw;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__desc {
|
||||||
|
display: -webkit-box;
|
||||||
|
height: calc(1.5vw * 3);
|
||||||
|
margin-top: 1vw;
|
||||||
|
overflow: hidden;
|
||||||
|
color: #555;
|
||||||
|
font-size: 0.9vw;
|
||||||
|
line-height: 1.5vw;
|
||||||
|
text-indent: 2em;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
-webkit-line-clamp: 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__link {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
margin-top: 2vw;
|
||||||
|
color: #3372fe;
|
||||||
|
font-size: 0.9vw;
|
||||||
|
line-height: 1.2vw;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__arrow {
|
||||||
|
width: 0.3vw;
|
||||||
|
height: 0.3vw;
|
||||||
|
margin-left: 0.1vw;
|
||||||
|
border-top: 0.12vw solid currentColor;
|
||||||
|
border-right: 0.12vw solid currentColor;
|
||||||
|
transform: rotate(45deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
&__image {
|
||||||
|
display: block;
|
||||||
|
width: 30%;
|
||||||
|
height: calc(1.6vw + 1vw + calc(1.5vw * 3) + 2vw + 1.2vw);
|
||||||
|
flex: 0 0 30%;
|
||||||
|
padding: 2vw 2vw 2vw 0;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||