修改了帮助中心搜索结果显示

This commit is contained in:
zhangyong 2024-06-11 16:10:21 +08:00
parent 15a9a227e7
commit b86f3ac7ee
51 changed files with 230 additions and 122 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 479 B

After

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 414 B

After

Width:  |  Height:  |  Size: 434 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 554 B

After

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 330 B

After

Width:  |  Height:  |  Size: 401 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 687 B

After

Width:  |  Height:  |  Size: 706 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 435 B

After

Width:  |  Height:  |  Size: 622 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 554 B

After

Width:  |  Height:  |  Size: 619 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 349 B

After

Width:  |  Height:  |  Size: 546 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 516 B

After

Width:  |  Height:  |  Size: 510 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 297 B

After

Width:  |  Height:  |  Size: 459 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 760 B

After

Width:  |  Height:  |  Size: 543 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 506 B

After

Width:  |  Height:  |  Size: 478 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 520 B

After

Width:  |  Height:  |  Size: 504 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 285 B

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 714 B

After

Width:  |  Height:  |  Size: 734 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 432 B

After

Width:  |  Height:  |  Size: 660 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 673 B

After

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 412 B

After

Width:  |  Height:  |  Size: 569 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 552 B

After

Width:  |  Height:  |  Size: 566 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 331 B

After

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 449 B

After

Width:  |  Height:  |  Size: 453 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 B

After

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 477 B

After

Width:  |  Height:  |  Size: 699 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 241 B

After

Width:  |  Height:  |  Size: 597 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 454 B

After

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 290 B

After

Width:  |  Height:  |  Size: 434 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 554 B

After

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 330 B

After

Width:  |  Height:  |  Size: 401 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 687 B

After

Width:  |  Height:  |  Size: 706 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 435 B

After

Width:  |  Height:  |  Size: 622 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 554 B

After

Width:  |  Height:  |  Size: 619 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 349 B

After

Width:  |  Height:  |  Size: 546 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 516 B

After

Width:  |  Height:  |  Size: 510 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 297 B

After

Width:  |  Height:  |  Size: 459 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 760 B

After

Width:  |  Height:  |  Size: 543 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 506 B

After

Width:  |  Height:  |  Size: 478 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 520 B

After

Width:  |  Height:  |  Size: 504 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 285 B

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 714 B

After

Width:  |  Height:  |  Size: 734 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 432 B

After

Width:  |  Height:  |  Size: 660 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 673 B

After

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 412 B

After

Width:  |  Height:  |  Size: 569 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 552 B

After

Width:  |  Height:  |  Size: 566 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 331 B

After

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 449 B

After

Width:  |  Height:  |  Size: 453 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 B

After

Width:  |  Height:  |  Size: 397 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 477 B

After

Width:  |  Height:  |  Size: 699 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 241 B

After

Width:  |  Height:  |  Size: 597 B

View File

@ -12,7 +12,7 @@
<h3>帮助中心</h3> <h3>帮助中心</h3>
<span> <span>
<input type="text" id="txtInput" placeholder="输入问题关键字" v-model="searchQuery"> <input type="text" id="txtInput" placeholder="输入问题关键字" v-model="searchQuery">
<button id="search" @click="search" @input="onInput">搜索</button> <button id="search" @click="search()">搜索</button>
<!-- <input id="search" name value="搜索" onclick="sendSearchRequest()"> --> <!-- <input id="search" name value="搜索" onclick="sendSearchRequest()"> -->
</span> </span>
</div> </div>
@ -37,9 +37,7 @@
<template #title> <template #title>
<el-icon><Expand /></el-icon> <el-icon><Expand /></el-icon>
<span>{{ item.name }}</span> <span>{{ item.name }}</span>
<!-- <i :class="{'el-sub-menu__icon-arrow': item.subList && item.subList.length > 0}"></i> --> <!-- <i v-if="item.subList && item.subList.length > 0" class="el-icon-arrow-down"></i> -->
<!-- <i v-if="item.subList && item.subList.length > 0" class="el-icon-arrow-down el-sub-menu__icon-arrow"></i> -->
<i v-if="item.subList && item.subList.length > 0" class="el-icon-arrow-down"></i>
</template> </template>
@ -65,32 +63,36 @@
</el-aside> </el-aside>
<el-main> <el-main>
<!-- <router-view :key="activeIndex"></router-view> --> <div class="contentBox" id="contentArea" v-show="xs1"></div>
<div class="contentBox" id="contentArea"> <div class="searchXS" v-show="xs2">
<div class="dataList"> <!-- <div class="searchXS" > -->
<div class="dataList" v-show="result1">
<ul class="data"> <ul class="data">
<!-- <li class="list" v-for="(data, index) in pagedData" :key=index> <li class="list" v-for="(data, index) in pagedData" :key=index>
<h4 class="dataTitle">{{ data.title }}</h4> <h4 class="dataTitle" :menuId="data.helpTypeId" @click="detailContent(data.helpTypeId)">{{ data.title }}</h4>
<p class="dataContent">{{ data.richContent }}</p> <p class="dataContent">{{ getPlainText(data.richContent) }}</p>
</li> --> </li>
</ul> </ul>
<div class="pagin"> <div class="pagin">
<!-- <el-pagination <el-pagination
@size-change="handleSizeChange"
@current-change="handlePageChange"
:page-size="pageSize" :page-size="pageSize"
:current-page="currentPage" :current-page="currentPage"
:total="pagedData.length" :total="totalData"
@current-change="handlePageChange" layout="total, prev, pager, next, jumper"
></el-pagination> --> ></el-pagination>
</div> </div>
</div> </div>
<div class="noData" v-show="result0">
很抱歉没有找到符合的记录请更换关键词重新搜索
</div>
</div> </div>
</el-main> </el-main>
</el-container> </el-container>
</div> </div>
<div class="boxFooter"> <!-- <div class="boxFooter"></div> -->
</div>
</div> </div>
</div> </div>
</div> </div>
@ -98,66 +100,73 @@
<script> <script>
import { ref, watch, onMounted } from 'vue' // import { ref, watch, onMounted } from 'vue'
import { useRoute, useRouter } from 'vue-router' // import { useRoute, useRouter } from 'vue-router'
// import { ref, reactive } from 'vue'
import axios from 'axios' import axios from 'axios'
// import $ from 'jquery' // import { useRoute } from 'vue-router';
// import func from 'vue-editor-bridge' // import jsdom from 'jsdom';
export default { export default {
// props: { props: {
// query: String searchQuery: String
// }, },
setup() {
const searchQuery = ref('') // setup() {
const result = ref('') // const searchQuery = ref('')
const route = useRoute() // const result = ref('')
// const route = useRoute()
onMounted(() => { // onMounted(() => {
if (route.query.q) { // if (route.query.q) {
searchQuery.value = route.query.q // searchQuery.value = route.query.q
search() // search()
// fetchSearchResults() // console.log(searchQuery.value);
} // // fetchSearchResults()
}) // }
// })
watch(() => route.query.q, (newQuery) => { // watch(() => route.query.q, (newQuery) => {
if(newQuery) { // if(newQuery) {
searchQuery.value = newQuery // searchQuery.value = newQuery
search() // search()
// fetchSearchResults() // console.log(searchQuery.value);
} // // fetchSearchResults()
}) // }
// })
const search = async () => { // const search = async () => {
try { // try {
const response = await axios.get(`https://www.aimzhu.com/operator/app/help-detail/listrelease?keywords=${searchQuery.value}`) // const response = await axios.get(`https://www.aimzhu.com/operator/app/help-detail/listpagerelease/10/1?keywords=${searchQuery.value}`)
// alert(11) // // alert(11)
// console.log(response.data); // // console.log(response.data);
let searchContent = response.data // this.xs1 = false
if (searchContent.length !== 0) { // this.xs2 = true
document.getElementById('contentArea').innerHTML = response.data[0].richContent // this.pagedData = response.data.rows
// alert(11) // this.totalData = response.data.total
} else { // if (this.totalData > 0) {
document.getElementById('contentArea').innerHTML = '很抱歉,没有找到符合的记录,请更换关键词重新搜索!' // this.result0 = false
} // this.result1 = true
// } else {
// this.result0 = true
// this.result1 = false
// }
// // console.log(this.searchQuery);
} catch (error) { // } catch (error) {
console.error(error) // console.error(error)
} // }
} // }
return { // return {
searchQuery, // searchQuery,
result, // result,
// search // // search
// onInput // // onInput
}; // };
}, // },
data() { data() {
return { return {
@ -168,9 +177,17 @@ export default {
defaultOpeneds: [], defaultOpeneds: [],
// //
// openedMenus: [], // openedMenus: [],
pagedData: [], totalData: null,
pagedData: '',
currentPage: 1, currentPage: 1,
pageSize: 10, pageSize: 10,
searchQuery: '',
xs1: true,
xs2: false,
res: false,
res0: false,
result0: false,
result1: false
} }
}, },
methods: { methods: {
@ -178,20 +195,17 @@ export default {
this.number = index this.number = index
}, },
menuIdContend (itemId0,itemHasDetail) { menuIdContend (itemId0,itemHasDetail) {
// console.log(itemId); document.querySelector('#txtInput').value = ''
this.xs1 = true
this.xs2 = false
var contendId = itemId0 var contendId = itemId0
var detail = itemHasDetail var detail = itemHasDetail
let contentBox = document.querySelector('.contentBox') let contentBox = document.querySelector('.contentBox')
// var url = 'https://www.aimzhu.com/operator/app/help-detail/listrelease?helpTypeId=' + contendId
// axios.get(url).then(response => {
// var content = response.data[0].richContent
// // console.log(content)
// contentBox.innerHTML = content
// })
if(detail === 1 ) { if(detail === 1 ) {
var url = 'https://www.aimzhu.com/operator/app/help-detail/listrelease?helpTypeId=' + contendId var url = 'https://www.aimzhu.com/operator/app/help-detail/listrelease?helpTypeId=' + contendId
axios.get(url).then(response => { axios.get(url).then(response => {
console.log(response.data)
var content = response.data[0].richContent var content = response.data[0].richContent
// console.log(content) // console.log(content)
contentBox.innerHTML = content contentBox.innerHTML = content
@ -203,32 +217,66 @@ export default {
}, },
search() { getData () {
var textInput = document.querySelector('#txtInput').value axios.get(`https://www.aimzhu.com/operator/app/help-detail/listpagerelease/${this.pageSize}/${this.currentPage}?keywords=${this.searchQuery}`)
// var pageSize = 10;
// var currentPage = 1;
axios.get(`https://www.aimzhu.com/operator/app/help-detail/listrelease?keywords=${textInput}`)
// axios.get(`https://www.aimzhu.com/operator/app/help-detail/listpagerelease/${pageSize}/${currentPage}?keywords=${textInput}`)
.then(response => { .then(response => {
// alert( response.data[0].richContent) // console.log(response.data);
// console.log(response); this.xs1 = false
console.log(response.data.rows); this.xs2 = true
this.pagedData = response.data.rows this.pagedData = response.data.rows
let searchContent = response.data this.totalData = response.data.total
if (searchContent.length !== 0) { if (this.totalData > 0) {
document.getElementById('contentArea').innerHTML = response.data[0].richContent this.result0 = false
} else { this.result1 = true
document.getElementById('contentArea').innerHTML = '很抱歉,没有找到符合的记录,请更换关键词重新搜索!' } else {
} this.result0 = true
document.getElementById('contentArea').innerHTML = response.data[0].richContent this.result1 = false
console.log(response.data); }
console.log(this.searchQuery);
}) })
.catch(function (error) { .catch(function (error) {
console.log(error) console.log(error)
}) })
},
search() {
this.currentPage = 1
this.getData()
// axios.get(`https://www.aimzhu.com/operator/app/help-detail/listrelease?keywords=${textInput}`)
}, },
// pagedData1() {
// const start = (this.currentPage - 1) * this.pageSize;
// const end = this.currentPage * this.pageSize;
// return this.pagedData.slice(start, end);
// },
updatePagination() {
this.pagedItems = this.pagedData.slice(
(this.currentPage - 1) * this.pageSize,
this.currentPage * this.pageSize
);
},
handlePageChange(page) {
this.currentPage = page;
// this.search();
this.getData()
// alert(this.currentPage)
},
handleSizeChange(newSize) {
this.pageSize = newSize;
this.currentPage = 1;
this.search();
},
getPlainText(richContent) {
// 使richContent
const regex = /<[^>]+>/gi; // richContent
const plainText = richContent.replace(regex, ''); // richContent
return plainText;
},
handleOpen(key, keyPath) { handleOpen(key, keyPath) {
// //
@ -247,16 +295,31 @@ export default {
// this.openedMenus.splice(index, 1) // this.openedMenus.splice(index, 1)
// } // }
}, },
detailContent(menId) {
this.xs1 = true
this.xs2 = false
var detailContentId = menId
let contentBox = document.querySelector('.contentBox')
var url = 'https://www.aimzhu.com/operator/app/help-detail/listrelease?helpTypeId=' + detailContentId
axios.get(url).then(response => {
// console.log(response.data[0].richContent);
contentBox.innerHTML = response.data[0].richContent
})
}
}, },
mounted() { mounted() {
document.querySelector('#txtInput').value = ''
this.xs1 = true
this.xs2 = false
axios.get('https://www.aimzhu.com/operator/app/help-type/helpAllListrelease').then(response => { axios.get('https://www.aimzhu.com/operator/app/help-type/helpAllListrelease').then(response => {
console.log(response.data) // console.log(response.data)
// this.items = response.data.name // this.items = response.data.name
this.items = response.data this.items = response.data
var textInput = document.querySelector('#txtInput').value // var textInput = document.querySelector('#txtInput').value
if(textInput === '') { // if(textInput === '') {
// //
let contendId0 = response.data[0].id let contendId0 = response.data[0].id
let url0 = 'https://www.aimzhu.com/operator/app/help-detail/listrelease?helpTypeId=' + contendId0 let url0 = 'https://www.aimzhu.com/operator/app/help-detail/listrelease?helpTypeId=' + contendId0
@ -266,9 +329,9 @@ export default {
let contentBox0 = document.querySelector('.contentBox') let contentBox0 = document.querySelector('.contentBox')
contentBox0.innerHTML = content0 contentBox0.innerHTML = content0
}) })
} else { // } else {
} // }
}) })
.catch(error => { .catch(error => {
@ -276,13 +339,6 @@ export default {
}); });
}, },
computed: {
pagedData() {
const start = (this.currentPage - 1) * this.pageSize;
const end = this.currentPage * this.pageSize;
return this.pagedData.slice(start, end);
},
},
} }
</script> </script>
@ -342,8 +398,6 @@ export default {
top: -200px; top: -200px;
bottom: 50px; bottom: 50px;
width: 1000px; width: 1000px;
/* height: 750px; */
/* padding: 25px; */
background-color: #FFF; background-color: #FFF;
-webkit-box-shadow: 0 0 10px rgba(0,0,0,.1); -webkit-box-shadow: 0 0 10px rgba(0,0,0,.1);
-moz-box-shadow: 0 0 10px rgba(0,0,0,.1); -moz-box-shadow: 0 0 10px rgba(0,0,0,.1);
@ -400,5 +454,45 @@ export default {
#contentArea { #contentArea {
line-height: 2.1; line-height: 2.1;
} }
.searchXS .dataList {
width: 100%;
height: 100%;
position: relative;
}
.searchXS .dataList li {
margin-bottom: 12px;
border-bottom: 1px solid #CCC;
}
.searchXS .dataList .list h4 {
/* margin-bottom: 6px; */
text-decoration: underline;
cursor: pointer;
color: #0095ff;
}
.searchXS .dataList .list h4:hover {
opacity: 0.7;
}
.searchXS .dataList .list p {
margin-bottom: 12px;
overflow: hidden;
text-overflow: ellipsis;
/* position: relative; */
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
}
.searchXS .noData {
width: 100%;
height: 40px;
border: 1px solid #CCC;
line-height: 40px;
font-size: 16px;
color: #474747;
padding-left: 10px;
}
.searchXS .dataList .pagin {
position: absolute;
right: 10px;
margin-top: 20px;
}
</style> </style>

View File

@ -12,6 +12,7 @@
<div class="kefu-sub"> <div class="kefu-sub">
<h4>客服中心</h4> <h4>客服中心</h4>
<div class="kefu-search"> <div class="kefu-search">
<!-- <input type="text" name="" id="txtInput" placeholder="请输入问题的关键字,如:排序题" v-model="searchQuery"> -->
<input type="text" name="" id="txtInput" placeholder="请输入问题的关键字,如:排序题" v-model="searchQuery"> <input type="text" name="" id="txtInput" placeholder="请输入问题的关键字,如:排序题" v-model="searchQuery">
<input type="submit" name value="搜索" id="search" @click="search"> <input type="submit" name value="搜索" id="search" @click="search">
</div> </div>
@ -93,24 +94,36 @@
</template> </template>
<script> <script>
import { ref } from 'vue'; // import { ref } from 'vue';
import { useRouter } from 'vue-router'; // import { useRouter } from 'vue-router';
export default { export default {
setup() { // setup() {
const searchQuery = ref('') // const searchQuery = ref('')
const router = useRouter() // const router = useRouter()
const search = () => { // const search = () => {
router.push({ // router.push({
name: 'HelpCenter', // name: 'HelpCenter',
query: { q: searchQuery.value} // query: { q: searchQuery.value}
}) // })
} // }
// return {
// searchQuery,
// search
// }
// }
data() {
return { return {
searchQuery, searchQuery: ''
search };
},
methods: {
search() {
this.$router.push({ name: 'HelpCenter', query: { q: this.searchQuery } });
} }
} }
} }
</script> </script>

View File

@ -39,6 +39,7 @@ app.use(router)
// app.use(ElementPlus) // app.use(ElementPlus)
app.use(VueScrollTo) app.use(VueScrollTo)
// app.use(VueAmazingUI) // app.use(VueAmazingUI)
app.mount('#app') app.mount('#app')
// createApp(App).mount('#app') // createApp(App).mount('#app')