a1300399510@qq.com 提交于 2023/04/06 -12:20:01

This commit is contained in:
XiaoMo 2023-04-06 12:20:11 +08:00
parent b130ba67d3
commit d7807870c5
2 changed files with 26 additions and 8 deletions

View File

@ -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}`)
},
},

View File

@ -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;
}
}
}