update
This commit is contained in:
@@ -15,14 +15,12 @@
|
||||
<span class="title">热搜榜</span>
|
||||
<!-- <span class="clear" @click="clearHistory" v-show="isShowClearHistory"><i class="el-icon-circle-close"></i>清空</span>-->
|
||||
</div>
|
||||
<div v-if="hotSearchKeyWords.length===0" v-show="isShowClearHistory">
|
||||
<div v-if="hotSearchKeyWords.length!==0" v-show="isShowClearHistory">
|
||||
<el-tag
|
||||
:v-if="hotSearchKeyWords.length!==0"
|
||||
v-for="(tag,index) in hotSearchKeyWords"
|
||||
:key="index"
|
||||
size="small"
|
||||
closable
|
||||
@close="handleClose(tag)"
|
||||
style="margin-right: 10px; margin-top: 10px; cursor: pointer"
|
||||
@click="handleSearch(tag)"
|
||||
>
|
||||
@@ -41,9 +39,9 @@
|
||||
<div class="search-his">
|
||||
<div>
|
||||
<span class="title">搜索历史</span>
|
||||
<span class="clear" @click="clearHistory" v-show="isShowClearHistory"><i class="el-icon-circle-close"></i>清空</span>
|
||||
<!-- <span class="clear" v-show="isShowClearHistory"><i class="el-icon-circle-close"></i>清空</span>-->
|
||||
</div>
|
||||
<div v-if="historySearch.length===0" v-show="isShowClearHistory">
|
||||
<div v-if="historySearch.length!==0" v-show="isShowClearHistory">
|
||||
<el-tag
|
||||
:v-if="historySearch.length!==0"
|
||||
v-for="(tag,index) in historySearch"
|
||||
@@ -138,40 +136,27 @@ export default {
|
||||
clearSearchResults(){
|
||||
this.searchResults=[];
|
||||
},
|
||||
clearHistory() {
|
||||
// var that=this;
|
||||
// axios({
|
||||
// method: 'post',
|
||||
// // 请求的地址
|
||||
// url: 'http://localhost:8082/helloGithub_war_exploded/deleteAllLabel',
|
||||
// // URL 中的查询参数
|
||||
// params: {
|
||||
// }
|
||||
// }).then((res)=>{
|
||||
// if (res.data.code === 200) {
|
||||
// Vue.prototype.$notify({
|
||||
// title: '成功',
|
||||
// message: ('i', {style: 'color: teal'}, res.data.msg),
|
||||
// type: 'success',
|
||||
// offset: 50
|
||||
// });
|
||||
// setTimeout(()=>{
|
||||
// that.gethistorySearch();
|
||||
// })
|
||||
// } else {
|
||||
// Vue.prototype.$notify.error({
|
||||
// title: '错误',
|
||||
// message: res.data.msg,
|
||||
// offset: 50
|
||||
// });
|
||||
// }
|
||||
// }).catch((error)=>{
|
||||
// Vue.prototype.$notify.error({
|
||||
// title: '错误',
|
||||
// message: error,
|
||||
// offset: 50
|
||||
// });
|
||||
// })
|
||||
getHotSearchKeyWords() {
|
||||
var that=this;
|
||||
axios({
|
||||
method: 'post',
|
||||
// 请求的地址
|
||||
url: '/api/Search/getHotList',
|
||||
// URL 中的查询参数
|
||||
params: {
|
||||
searchKey:this.search,
|
||||
}
|
||||
}).then((res)=>{
|
||||
if (res.data.code === 200) {
|
||||
|
||||
that.hotSearchKeyWords=res.data.data;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}).catch((error)=>{
|
||||
|
||||
})
|
||||
},
|
||||
// searchRequest() {
|
||||
// const params = {
|
||||
@@ -182,60 +167,78 @@ export default {
|
||||
// window.open(url, '_blank');
|
||||
// },
|
||||
gethistorySearch(){
|
||||
// var that=this;
|
||||
// axios({
|
||||
// method: 'post',
|
||||
// // 请求的地址
|
||||
// url: 'http://localhost:8082/helloGithub_war_exploded/selectUserLabel',
|
||||
// // URL 中的查询参数
|
||||
// params: {
|
||||
// }
|
||||
// }).then((res)=>{
|
||||
// that.historySearch=res.data;
|
||||
//
|
||||
// }).catch((error)=>{
|
||||
// Vue.prototype.$notify.error({
|
||||
// title: '错误',
|
||||
// message: error,
|
||||
// offset: 50
|
||||
// });
|
||||
// })
|
||||
var that=this;
|
||||
if(localStorage.getItem('userId')&& localStorage.getItem('Authorization') ){
|
||||
axios({
|
||||
method: 'post',
|
||||
// 请求的地址
|
||||
url: '/api/Search/getSearchHistoryByUserId',
|
||||
// URL 中的查询参数
|
||||
params: {
|
||||
userId:localStorage.getItem('userId')
|
||||
}
|
||||
}).then((res)=>{
|
||||
if(res.data.code===200){
|
||||
that.historySearch=res.data.data;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}).catch((error)=>{
|
||||
|
||||
})
|
||||
}else{
|
||||
Vue.prototype.$notify.info({
|
||||
title: '提示',
|
||||
message: ('i', {style: 'color: teal'}, "登录状态失效,请重新登录!"),
|
||||
offset: 50
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
handleClose(tag){
|
||||
// var that=this;
|
||||
// axios({
|
||||
// method: 'post',
|
||||
// // 请求的地址
|
||||
// url: 'http://localhost:8082/helloGithub_war_exploded/deletelabel',
|
||||
// // URL 中的查询参数
|
||||
// params: {
|
||||
// tag:tag
|
||||
// }
|
||||
// }).then((res)=>{
|
||||
// if(res.data.code===200){
|
||||
// Vue.prototype.$notify({
|
||||
// title: '成功',
|
||||
// message: ('i', {style: 'color: teal'}, res.data.msg),
|
||||
// type: 'success',
|
||||
// offset: 50
|
||||
// });
|
||||
// setTimeout(()=>{
|
||||
// that.gethistorySearch();
|
||||
// })
|
||||
// }else{
|
||||
// Vue.prototype.$notify.error({
|
||||
// title: '错误',
|
||||
// message: res.data.msg,
|
||||
// offset: 50
|
||||
// });
|
||||
// }
|
||||
// }).catch((error)=>{
|
||||
// Vue.prototype.$notify.error({
|
||||
// title: '错误',
|
||||
// message: error,
|
||||
// offset: 50
|
||||
// });
|
||||
// })
|
||||
var that=this;
|
||||
if(localStorage.getItem('userId')&& localStorage.getItem('Authorization') ){
|
||||
axios({
|
||||
method: 'post',
|
||||
// 请求的地址
|
||||
url: '/api/Search/delSearchHistoryByUserId',
|
||||
// URL 中的查询参数
|
||||
params: {
|
||||
searchKey:tag,
|
||||
userId:localStorage.getItem('userId')
|
||||
}
|
||||
}).then((res)=>{
|
||||
if(res.data.code===200){
|
||||
// Vue.prototype.$notify({
|
||||
// title: '成功',
|
||||
// message: ('i', {style: 'color: teal'}, "删除成功!"),
|
||||
// type: 'success',
|
||||
// offset: 50
|
||||
// });
|
||||
|
||||
that.gethistorySearch();
|
||||
|
||||
}else{
|
||||
Vue.prototype.$notify.error({
|
||||
title: '错误',
|
||||
message: "删除失败!",
|
||||
offset: 50
|
||||
});
|
||||
}
|
||||
}).catch((error)=>{
|
||||
|
||||
})
|
||||
}else{
|
||||
Vue.prototype.$notify.info({
|
||||
title: '提示',
|
||||
message: ('i', {style: 'color: teal'}, "登录状态失效,请重新登录!"),
|
||||
offset: 50
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
searchByInput(){
|
||||
var that=this;
|
||||
@@ -265,6 +268,7 @@ export default {
|
||||
type:"success",
|
||||
offset: 50
|
||||
});
|
||||
that.getHotSearchKeyWords();
|
||||
that.searchResults=res.data.data;
|
||||
setTimeout(() => {
|
||||
that.visible = true;
|
||||
|
Reference in New Issue
Block a user