Ver código fonte

add WenshuSearch.vue backend api

reghao 7 meses atrás
pai
commit
56dc832a4c
2 arquivos alterados com 32 adições e 9 exclusões
  1. 12 1
      src/api/search.js
  2. 20 8
      src/views/wenshu/WenshuSearch.vue

+ 12 - 1
src/api/search.js

@@ -3,7 +3,9 @@ import { get, post } from '@/utils/request'
 const searchApi = {
   keywordSuggestApi: '/api/search/suggest',
   videoSearchApi: '/api/search/query',
-  hotSearchApi: '/api/search/hot'
+  hotSearchApi: '/api/search/hot',
+  wenshuSearchApi: '/api/search1/wenshu/query',
+  wenshuDetailApi: '/api/search1/wenshu/detail'
 }
 
 // 关键词建议
@@ -20,3 +22,12 @@ export function videoQuery(keyword, pageNumber) {
 export function hotKeyword() {
   return get(searchApi.hotSearchApi)
 }
+
+// 搜索裁判文书
+export function wenshuQuery(keyword) {
+  return get(searchApi.wenshuSearchApi + '?search=' + keyword)
+}
+
+export function getWenshuDetail(id) {
+  return get(searchApi.wenshuDetailApi + '/' + id)
+}

+ 20 - 8
src/views/wenshu/WenshuSearch.vue

@@ -63,7 +63,7 @@
                   />
                 </el-col>
                 <el-col :md="20">
-<!--                  <el-button style="float: left; padding: 3px 0" type="text" @click="onGetDetail">
+                  <!--                  <el-button style="float: left; padding: 3px 0" type="text" @click="onGetDetail">
                     {{ item.title }}
                   </el-button>-->
                   <el-row>
@@ -145,6 +145,7 @@
 <script>
 import RandomUtil from '@/utils/random-util'
 import Store from '@/utils/store'
+import { getWenshuDetail, wenshuQuery } from '@/api/search'
 
 export default {
   data() {
@@ -183,12 +184,6 @@ export default {
       // 回到顶部
       scrollTo(0, 0)
     },
-    onGetDetail(val) {
-      this.$message.info('get wenshu -> ' + val)
-      this.wenshuDetail = {
-      }
-      this.wenshuDetailDialog = true
-    },
     focus() {
       this.isFocus = true
       this.historySearchList = Store.loadHistory() == null ? [] : Store.loadHistory()
@@ -204,7 +199,13 @@ export default {
       clearTimeout(this.searchBoxTimeout)
     },
     searchHandler() {
-      console.log('search data')
+      this.$message.info('search -> ' + this.search)
+      wenshuQuery(this.search).then(resp => {
+        if (resp.code === 0) {
+          console.log(resp.data)
+        }
+      })
+
       this.dataList.push(
         {
           contentId: 111,
@@ -255,6 +256,17 @@ export default {
     },
     removeAllHistory() {
       Store.removeAllHistory()
+    },
+    onGetDetail(val) {
+      getWenshuDetail(val).then(resp => {
+        if (resp.code === 0) {
+          console.log(resp.data)
+          this.$message.info('get wenshu -> ' + val)
+          this.wenshuDetail = {}
+        }
+      }).finally(() => {
+        this.wenshuDetailDialog = true
+      })
     }
   }
 }