Commit 0a5188f2 authored by sxl's avatar sxl 💬

fix:全局搜索 接口处理

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