indexSearch.vue
2.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
<template>
<el-dialog
v-model="show"
:close-on-click-modal="true"
:modal="false"
:show-close="true"
append-to-body
class="searchpp"
destroy-on-close
style="padding-top: 50px"
title="搜索"
top="80px"
width="80vw"
>
<div class="searchBody">
<div class="searchline">
<el-input v-model="query.name" placeholder="请输入关键词搜索" @change="search"/>
<el-button :icon="Search" @click="search">搜索</el-button>
</div>
<div class="hotword" hidden>
<span>跆拳道世界锦标赛</span>
<span>跆拳道</span>
<span>2024年奥运会</span>
</div>
<h2>近期热门</h2>
<el-row :gutter="20" class="newsimgcover">
<el-col v-for="(n,index) in hottest" v-show="index<4" :key="index" :span="6">
<div class="item shadow" @click="goDetail(n)">
<div class="imgbox"><img :src="fillImgUrl_webSite(n.picUrl)"></div>
<h3 class="esp">{{ n.name }}</h3>
</div>
</el-col>
</el-row>
</div>
</el-dialog>
</template>
<script setup>
import {onMounted, ref} from 'vue'
import {Search} from '@element-plus/icons-vue'
const router = useRouter()
import {getHottest} from '@/apiPc/webSite'
import {useRouter} from 'vue-router'
const show = ref(false)
const query = ref({})
const hottest = ref([])
const open = (params) => {
show.value = true
getHotList()
}
defineExpose({
open
})
function getHotList() {
getHottest().then(res => {
hottest.value = res.data
})
}
function search() {
show.value = false
router.push({
path: `/search`,
query: {
name: query.value.name
}
})
}
const goDetail = (n) => {
show.value = false
if (n.isOut == '1') {
window.open(n.jumpUrl)
} else {
router.push({
path: `/news/detail/${n.noteId}`
})
}
}
</script>
<style lang="scss" scoped>
h2 {
font-size: 24px;
margin: 30px 0 15px;
}
.hotword {
margin: 0;
font-size: 18px;
color: #7B7F83;
span {
margin-right: 20px;
cursor: pointer;
&:hover {
text-decoration: underline;
}
}
}
.searchBody {
padding: 0 0 60px
}
.searchline {
display: flex;
height: 60px;
margin: 30px 0;
background: #F8F8F8;
.el-input {
border: none;
background: transparent;
outline: none;
font-size: 18px;
}
.el-button {
width: 130px;
font-size: 20px;
border: none;
height: 60px;
color: #fff;
background: #000;;
border-radius: 0px 5px 5px 0px;
}
:deep(.el-input__wrapper) {
background-color: transparent;
box-shadow: none;
}
}
</style>