|
@@ -4,6 +4,9 @@ import {apiReportSearch} from '@/api/report'
|
|
|
import moment from 'moment'
|
|
|
import Search from "@/components/Search.vue"
|
|
|
import SelfList from '@/components/SelfList.vue'
|
|
|
+import { onBeforeRouteLeave, useRouter } from 'vue-router'
|
|
|
+
|
|
|
+const router=useRouter()
|
|
|
|
|
|
let listState=reactive({
|
|
|
list:[],
|
|
@@ -30,6 +33,10 @@ const getSearchList=async ()=>{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+const onLoad=()=>{
|
|
|
+ listState.page++
|
|
|
+ getSearchList()
|
|
|
+}
|
|
|
|
|
|
const handleSearch=(e)=>{
|
|
|
listState.page=1
|
|
@@ -40,10 +47,38 @@ const handleSearch=(e)=>{
|
|
|
getSearchList()
|
|
|
}
|
|
|
|
|
|
+const goDetail=(item)=>{
|
|
|
+ if(['晨报','周报'].includes(item.classify_name_first)){
|
|
|
+ router.push({
|
|
|
+ path:'/report/chapterdetail',
|
|
|
+ query:{
|
|
|
+ chapterId:item.report_chapter_id
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ router.push({
|
|
|
+ path:'/report/detail',
|
|
|
+ query:{
|
|
|
+ reportId:item.report_id
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
let isMounted = ref(false);
|
|
|
onMounted(() => {
|
|
|
isMounted.value = true;
|
|
|
});
|
|
|
+onBeforeRouteLeave((to,from)=>{
|
|
|
+ // 如果是返回到首页则重置搜索页
|
|
|
+ if(to.name=='ReportIndex'){
|
|
|
+ console.log(to.name);
|
|
|
+ listState.list=[]
|
|
|
+ listState.page=1
|
|
|
+ listState.finished=false
|
|
|
+ listState.keyword=''
|
|
|
+ }
|
|
|
+})
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
@@ -53,6 +88,7 @@ onMounted(() => {
|
|
|
<Search
|
|
|
style="margin-top: 10px;"
|
|
|
placeholder="请输入标题/关键词"
|
|
|
+ :defaultVal="listState.keyword"
|
|
|
:autoFocus="true"
|
|
|
@search="handleSearch"
|
|
|
@clean="handleSearch"
|
|
@@ -67,7 +103,12 @@ onMounted(() => {
|
|
|
@listOnload="onLoad"
|
|
|
>
|
|
|
<div class="search-list-wrap">
|
|
|
- <div class="item" v-for="item in listState.list" :key="item.report_id+item.report_chapter_id">
|
|
|
+ <div
|
|
|
+ class="item"
|
|
|
+ v-for="item in listState.list"
|
|
|
+ :key="item.report_id+item.report_chapter_id"
|
|
|
+ @click="goDetail(item)"
|
|
|
+ >
|
|
|
<div class="title" v-html="item.title"></div>
|
|
|
<div class="des" v-html="item.content_sub"></div>
|
|
|
<div class="tags">
|