ソースを参照

feat: pc搜索结果页面接口调用

cuiyalong 4 年 前
コミット
8ae98b3ae7

+ 11 - 7
jydocs-pc/src/App.vue

@@ -1,8 +1,7 @@
 <template>
-    <div class="home">
-        <router-link class="link-item" v-for="item in links" :key="item.to" :to="item.to">{{item.text}}</router-link>
-        <router-view></router-view>
-    </div>
+  <div class="docs-app">
+    <router-view></router-view>
+  </div>
 </template>
 
 <script>
@@ -10,6 +9,7 @@ export default {
   components: {},
   data () {
     return {
+      cashViews: [],
       links: [
         {
           to: '/',
@@ -37,7 +37,11 @@ export default {
 }
 </script>
 <style lang="scss">
-    .link-item {
-        margin: 0 10px;
-    }
+@import '~@/assets/style/reset-ele.scss';
+
+.page--docs--index.bg-white {
+  .page-container {
+    background-color: #fff;
+  }
+}
 </style>

+ 3 - 1
jydocs-pc/src/api/modules/search.js

@@ -1,5 +1,6 @@
 import httpRequest from '@/api'
 import mockRequest from '@/api/mock'
+import qs from 'qs'
 
 let request = httpRequest
 if (process.env.NODE_ENV === 'development' && process.env.VUE_APP_MOCK === 'true') {
@@ -7,7 +8,8 @@ if (process.env.NODE_ENV === 'development' && process.env.VUE_APP_MOCK === 'true
   request = mockRequest
 }
 
-export function ajaxGetSearch (data) {
+export function getSearch (data) {
+  data = qs.stringify(data)
   return request({
     url: '/search',
     method: 'post',

+ 15 - 0
jydocs-pc/src/assets/style/reset-ele.scss

@@ -0,0 +1,15 @@
+@import './_mixin';
+@import './_variables';
+
+.docs-app .el-pagination.is-background .el-pager {
+  li {
+    background-color: #fff;
+    border: 1px solid rgba($color: #000, $alpha: 0.05);
+  }
+
+  li:not(.disabled).active,
+  li:not(.disabled):hover {
+    color: #fff;
+    background-color: $color-text--highlight;
+  }
+}

+ 1 - 0
jydocs-pc/src/components/NoData.vue

@@ -20,6 +20,7 @@ export default {
 <style lang="scss" scoped>
 .no-data {
   margin: 0 auto;
+  margin-top: 150px;
   text-align: center;
   .el-image {
     width: 220px;

+ 5 - 5
jydocs-pc/src/components/Search.vue

@@ -29,22 +29,22 @@ export default {
   data () {
     return {
       input: '',
-      type: 'all1',
+      type: 'all',
       tabs: [
         {
-          type: 'all1',
+          type: 'all',
           label: '全部'
         },
         {
-          type: 'all2',
+          type: '招标',
           label: '招标'
         },
         {
-          type: 'all3',
+          type: '法律法规',
           label: '法律法规'
         },
         {
-          type: 'all4',
+          type: '行业报告',
           label: '行业报告'
         }
       ]

+ 5 - 4
jydocs-pc/src/components/doc-item-card/Card.vue

@@ -35,7 +35,7 @@
             >{{ item }}</span>
           </div>
           <div class="card-info-item price">
-            <Price :price="price" />
+            <slot name="price"><Price :price="price" /></slot>
           </div>
         </div>
       </div>
@@ -58,7 +58,7 @@
           >{{ item }}</span>
         </div>
         <div class="c-f-right flex-r-c">
-          <Price :price="price" />
+          <slot name="price"><Price :price="price" /></slot>
         </div>
       </div>
     </div>
@@ -68,7 +68,7 @@
 <script>
 import { Image } from 'element-ui'
 import Price from '@/components/doc-item-card/Price'
-import { replaceKeyword } from '@/utils/'
+import { replaceKeyword, docTypeConvert } from '@/utils/'
 
 export default {
   name: 'docs-card',
@@ -121,7 +121,8 @@ export default {
   },
   computed: {
     docTypeIcon () {
-      return `el-icon-jy-${this.docType}`
+      const t = docTypeConvert(this.docType)
+      return `el-icon-jy-${t}`
     },
     hightLightTitle () {
       return replaceKeyword(this.title, this.highlightKey, [

+ 15 - 0
jydocs-pc/src/utils/globalFunctions.js

@@ -236,6 +236,21 @@ export function formatSize (size, pointLength, units) {
   }
   return (unit === 'B' ? size : size.toFixed(pointLength === undefined ? 2 : pointLength)) + (unit || '')
 }
+
+// 文件类型转换
+export function docTypeConvert (docType = 'pdf') {
+  const typeMap = {
+    doc: 'word',
+    docx: 'word',
+    xls: 'excel',
+    xlsx: 'excel',
+    ppt: 'ppt',
+    pdf: 'pdf'
+  }
+  const type = typeMap[docType]
+  return type ? type : docType  // map中不存在的,则返回原始类型
+}
+
 /**
  * 通用关键字高亮替换
  * @param {String} value 要高亮的字符串

+ 8 - 0
jydocs-pc/src/utils/mixins.js

@@ -0,0 +1,8 @@
+export const mixinBackground = {
+  beforeCreate () {
+    $('body').addClass('bg-white')
+  },
+  beforeDestroy () {
+    $('body').removeClass('bg-white')
+  }
+}

+ 4 - 3
jydocs-pc/vue.config.js

@@ -8,11 +8,12 @@ module.exports = {
     port: '8080',
     disableHostCheck: true,
     proxy: {
-      '^/api-docs': {
-        target: 'http://xxx.com/api-docs',
+      '^/jydocs': {
+        target: 'http://192.168.20.180:821',
         changeOrigin: true,
+        logLevel: 'debug',
         pathRewrite: {
-          '^/api-docs': ''
+          '^/jydocs': '/jydocs'
         }
       }
     }