Commit 0a5188f2 authored by sxl's avatar sxl 💬

fix:全局搜索 接口处理

parent 937afddc
......@@ -14,26 +14,17 @@
</div>
<div class="inner">
<div class="search-input">
<el-input
v-model="query.searchCon"
placeholder="请输入内容"
@keyup.enter.native="tabList(query.searchCon)"
></el-input>
<span class="search-btn" @click="tabList(query.searchCon)"
>搜索</span
>
<el-input v-model="query.searchCon" placeholder="请输入内容"
@keyup.enter.native="tabList(query.searchCon)"></el-input>
<span class="search-btn" @click="tabList(query.searchCon)">搜索</span>
</div>
</div>
<div class="con-tab">
<div class="inner">
<ul v-if="conListData">
<li
v-for="(con, index) in conListData"
:key="index"
@click="setActive(index, con.type)"
:class="{ 'con-active': index === activeIndex }"
>
<li v-for="(con, index) in conListData" :key="index" @click="setActive(index, con.type)"
:class="{ 'con-active': index === activeIndex }">
{{ con.type }}
</li>
</ul>
......@@ -41,18 +32,12 @@
</div>
<div class="inner">
<p class="srarch-result">
为您找到相关结果约为<span>{{ total }}</span
>
为您找到相关结果约为<span>{{ total }}</span>
</p>
</div>
<div class="inner list">
<div class="con-list">
<div
class="con-list-con"
v-for="con in listcon"
:key="con.id"
@click="gotoDet(con)"
>
<div class="con-list-con" v-for="con in listcon" :key="con.id" @click="gotoDet(con)">
<h2>{{ con.title }}</h2>
<p v-html="con.details"></p>
</div>
......@@ -61,14 +46,8 @@
<div class="mt20"></div>
<div class="inner">
<div class="block">
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:page-size="10"
layout="prev, pager, next, jumper"
:total="total"
v-if="total > 10"
>
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :page-size="10"
layout="prev, pager, next, jumper" :total="total" v-if="total > 10">
</el-pagination>
</div>
</div>
......@@ -207,7 +186,7 @@ export default {
async tabList(searchCon) {
try {
const listMohu = await sendRequest(
"/business//homePage/listMohu",
"/business/homePage/listMohu",
"get",
{ infor: searchCon }
);
......@@ -227,9 +206,11 @@ export default {
width: 100%;
height: 60px;
background: #f7f7f7;
ul {
display: flex;
justify-content: start;
li {
line-height: 60px;
font-size: 22px;
......@@ -238,8 +219,10 @@ export default {
cursor: pointer;
position: relative;
transition: all 0.5s linear;
&:hover {
color: #000;
&::after {
content: "";
width: 100%;
......@@ -251,8 +234,10 @@ export default {
}
}
}
li.con-active {
color: #000;
&::after {
content: "";
width: 100%;
......@@ -265,29 +250,35 @@ export default {
}
}
}
.list {
min-height: 40vh;
}
.con-list {
width: 100%;
border: 1px solid #e1e1e1;
box-shadow: 0px 3px 4px 0px rgba(0, 0, 0, 0.2);
.con-list-con {
width: 90%;
margin: 20px auto;
border-bottom: 3px dashed #999;
cursor: pointer;
&:last-child {
border-bottom: none;
}
h2 {
font-size: 23px;
font-weight: 500;
color: #333333;
line-height: 46px;
}
> p {
>p {
font-size: 19px;
font-family: Source Han Sans CN;
font-weight: 400;
......@@ -302,6 +293,7 @@ export default {
}
}
}
.search-input {
width: 70%;
margin: 0 auto;
......@@ -309,6 +301,7 @@ export default {
display: flex;
justify-content: center;
align-items: center;
.search-btn {
width: 80px;
background: #2f6fb9;
......@@ -320,11 +313,13 @@ export default {
color: #fff;
}
}
.srarch-result {
font-size: 22px;
font-weight: 400;
color: #666666;
line-height: 80px;
span {
color: rgba(47, 111, 185, 1);
}
......
<template>
<div class="news cfkqbg">
<BackToTopButton />
<Header :show="false" :activeIndex="12"/>
<Header :show="false" :activeIndex="12" />
<div class="m2zrCon m2pubCon background-attachment">
<div class="container">
<div class="inner">
......@@ -14,26 +14,17 @@
</div>
<div class="inner">
<div class="search-input">
<el-input
v-model="query.searchCon"
placeholder="请输入内容"
@keyup.enter.native="handleSearch(query.searchCon)"
></el-input>
<span class="search-btn" @click="handleSearch(query.searchCon)"
>搜索</span
>
<el-input v-model="query.searchCon" placeholder="请输入内容"
@keyup.enter.native="handleSearch(query.searchCon)"></el-input>
<span class="search-btn" @click="handleSearch(query.searchCon)">搜索</span>
</div>
</div>
<div class="con-tab">
<div class="inner">
<ul v-if="conListData">
<li
v-for="(con, index) in conListData"
:key="index"
@click="setActive(index, con.type)"
:class="{ 'con-active': index === activeIndex }"
>
<li v-for="(con, index) in conListData" :key="index" @click="setActive(index, con.type)"
:class="{ 'con-active': index === activeIndex }">
{{ con.type }}
</li>
</ul>
......@@ -41,18 +32,12 @@
</div>
<div class="inner">
<p class="srarch-result">
为您找到相关结果约为<span>{{ total }}</span
>
为您找到相关结果约为<span>{{ total }}</span>
</p>
</div>
<div class="inner list">
<div class="con-list">
<div
class="con-list-con"
v-for="con in listcon"
:key="con.id"
@click="gotoDet(con)"
>
<div class="con-list-con" v-for="con in listcon" :key="con.id" @click="gotoDet(con)">
<h2>{{ con.title }}</h2>
<p v-show="con.details">{{ removeTagsAndSpaces(con.details) }}</p>
</div>
......@@ -127,13 +112,13 @@ export default {
},
mounted() {
// this.fetchData();
this.tabList(this.query.searchCon);
},
methods: {
removeTagsAndSpaces(input) {
if(input){
if (input) {
// 使用;正则表达式替换
var output = input.replace(/<\/?[^>]+(>|$)/g, ''); // 去除所有的<>标签
output = output.replace(/[\t\n\r]/g, ''); // 去除制表符、换行符、回车符
......@@ -142,37 +127,37 @@ export default {
return output;
}
},
handleSearch(){
this.activeIndex=0;
this.listcon=[];
this.total=0;
if(this.query.searchCon){
handleSearch() {
this.activeIndex = 0;
this.listcon = [];
this.total = 0;
if (this.query.searchCon) {
this.$router.push({
path: `/Search?search=${this.query.searchCon}`,
});
this.tabList(this.query.searchCon);
}else{
} else {
this.$message({
message: "请输入查询内容",
type: "error",
});
return
}
},
gotoDet(row) {
console.log(row, this.nowType);
if (this.nowType === "新闻资讯") {
this.$router.push({ path: `/News/det?id=${row.id}` });
}else if (this.nowType === "金融服务") {
} else if (this.nowType === "金融服务") {
this.$router.push({ path: `/Company?id=${row.id}` });
// } else if (this.nowType === "矿业权管理") {
// this.$router.push({
// path: `/TechnicalDocking/mmqManagement?id=${row.id}`,
// });
} else if(this.nowType === "矿权交易"){
// } else if (this.nowType === "矿业权管理") {
// this.$router.push({
// path: `/TechnicalDocking/mmqManagement?id=${row.id}`,
// });
} else if (this.nowType === "矿权交易") {
this.$router.push({ path: `/Transaction/minDet?id=${row.id}` });
}
},
......@@ -192,12 +177,12 @@ export default {
// this.scrollToTop();
},
setActive(index, type) {
this.listcon=[];
this.total=0;
this.listcon = [];
this.total = 0;
this.activeIndex = index;
if(this.query.searchCon){
if (this.query.searchCon) {
this.dataList(type);
}else{
} else {
this.$message({
message: "请输入查询内容",
type: "error",
......@@ -206,7 +191,7 @@ export default {
}
},
async dataList(type) {
this.nowType = type;
if (type === "新闻资讯") {
try {
......@@ -238,20 +223,20 @@ export default {
this.listcon = [];
this.total = 0;
}
// }else if (type === "矿业权管理") {
// const list = await sendRequest(
// "/business/mmqManagement/queryByStr",
// "get",
// { infor: this.query.searchCon }
// );
// if (list.code === 200 && list.rows) {
// this.listcon = list.rows;
// this.total = list.total;
// } else {
// this.listcon = [];
// this.total = 0;
// }
} else if(type === "矿权交易"){
// }else if (type === "矿业权管理") {
// const list = await sendRequest(
// "/business/mmqManagement/queryByStr",
// "get",
// { infor: this.query.searchCon }
// );
// if (list.code === 200 && list.rows) {
// this.listcon = list.rows;
// this.total = list.total;
// } else {
// this.listcon = [];
// this.total = 0;
// }
} else if (type === "矿权交易") {
const list = await sendRequest(
"/business/templateData/queryByStr",
"get",
......@@ -267,10 +252,10 @@ export default {
}
},
async tabList(searchCon) {
try {
const listMohu = await sendRequest(
"/business//homePage/listMohu",
"/business/homePage/listMohu",
"get",
{ infor: searchCon }
);
......@@ -290,9 +275,11 @@ export default {
width: 100%;
height: 60px;
background: #f7f7f7;
ul {
display: flex;
justify-content: start;
li {
line-height: 60px;
font-size: 16px;
......@@ -301,8 +288,10 @@ export default {
cursor: pointer;
position: relative;
transition: all 0.5s linear;
&:hover {
color: #000;
&::after {
content: "";
width: 100%;
......@@ -314,8 +303,10 @@ export default {
}
}
}
li.con-active {
color: #000;
&::after {
content: "";
width: 100%;
......@@ -328,29 +319,35 @@ export default {
}
}
}
.list {
min-height: 40vh;
}
.con-list {
width: 100%;
border: 1px solid #e1e1e1;
box-shadow: 0px 3px 4px 0px rgba(0, 0, 0, 0.2);
.con-list-con {
width: 90%;
margin: 20px auto;
border-bottom: 3px dashed #999;
cursor: pointer;
&:last-child {
border-bottom: none;
}
h2 {
font-size: 16px;
font-weight: 500;
color: #333333;
line-height: 32px;
}
> p {
>p {
font-size: 14px;
font-family: Source Han Sans CN;
font-weight: 400;
......@@ -365,6 +362,7 @@ export default {
}
}
}
.search-input {
width: 70%;
margin: 0 auto;
......@@ -372,6 +370,7 @@ export default {
display: flex;
justify-content: center;
align-items: center;
.search-btn {
width: 80px;
background: #2f6fb9;
......@@ -383,20 +382,24 @@ export default {
color: #fff;
}
}
.srarch-result {
font-size: 16px;
font-weight: 400;
color: #666666;
line-height: 40px;
span {
color: rgba(47, 111, 185, 1);
}
}
@media (min-width: 1200px) {
.inner {
width: 1170px;
}
}
@media (min-width: 1499px) {
.inner {
width: 1250px;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment