a1300399510@qq.com 提交于 2023/04/06 -12:20:01
This commit is contained in:
parent
b130ba67d3
commit
d7807870c5
@ -18,19 +18,18 @@
|
||||
<div class="search-close" @click="searchClose()">取消</div>
|
||||
</div>
|
||||
<!-- 历史搜索 -->
|
||||
<div class="search-content flexcolumn">
|
||||
<div class="search-content flexcolumn" v-if="historicalSearch.length != 0">
|
||||
<div class="search-text">历史搜索</div>
|
||||
<div class="search-label">
|
||||
<span>香港大学</span>
|
||||
<span>香港大学</span>
|
||||
<span>香港大学</span>
|
||||
<span v-for="(item, index) in historicalSearch" :key="index">香港大学</span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 热门搜索 -->
|
||||
<div class="search-content">
|
||||
<div class="search-text">热门搜索</div>
|
||||
<div class="search-label">
|
||||
<span v-for="(item, index) in hotSearchkeywords" :key="index" @click="toSearchResult(item)">{{ item }}</span>
|
||||
<span v-for="(item, index) in hotSearchkeywords" :key="index" @click="toSearchResult(item)">{{ item
|
||||
}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -45,10 +44,18 @@ export default {
|
||||
searchWinShow: false,//显示搜索弹窗
|
||||
searchText: '',
|
||||
showClear: false, //显示清除按钮
|
||||
historicalSearch: [], // 历史搜索
|
||||
}
|
||||
},
|
||||
props: ["issearch", "hotSearchkeywords"],
|
||||
|
||||
mounted() {
|
||||
let hotSearchkeywords = ["香港大学","香港大学"]
|
||||
var cachedData = localStorage.setItem('hotSearchkeywords',[]) || [];
|
||||
|
||||
// var cachedData = localStorage.getItem('hotSearchkeywords') || [];
|
||||
},
|
||||
|
||||
methods: {
|
||||
collapseClick() {
|
||||
if (this.collapseShow == true) this.collapseShow = false;
|
||||
@ -75,7 +82,7 @@ export default {
|
||||
},
|
||||
|
||||
// 跳转搜索结果
|
||||
toSearchResult(kw){
|
||||
toSearchResult(kw) {
|
||||
this.$router.push(`/searchResult?kw=${kw}`)
|
||||
},
|
||||
},
|
||||
|
@ -109,17 +109,24 @@ export default {
|
||||
getSearchResult() {
|
||||
if (this.searchResultState) return
|
||||
this.searchResultState = true
|
||||
let kw = this.kw
|
||||
this.$http.post("/api/search", {
|
||||
keyword: this.kw,
|
||||
keyword: kw,
|
||||
page: this.page,
|
||||
limit: this.limit
|
||||
}).then(res => {
|
||||
let data = res.data
|
||||
|
||||
console.log(data.data);
|
||||
// console.log(data.data);
|
||||
// console.log(kw);
|
||||
// data.data.forEach(el => {
|
||||
// console.log(el.subject);
|
||||
// })
|
||||
|
||||
this.list = data.data
|
||||
this.count = data.count
|
||||
this.limit = data.limit
|
||||
|
||||
document.documentElement.scrollTop = 0;
|
||||
document.body.scrollTop = 0;
|
||||
this.searchResultState = false
|
||||
@ -236,6 +243,10 @@ export default {
|
||||
font-size: 0.37333rem;
|
||||
line-height: 0.65rem;
|
||||
display: inline;
|
||||
|
||||
/deep/ em {
|
||||
color: #F95D5D;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user