瀏覽代碼

feat:mobile新增文档搜索

yangfeng 1 年之前
父節點
當前提交
f9ea9c778c

+ 8 - 0
apps/mobile/src/router/modules/search.js

@@ -40,6 +40,14 @@ const MiddleSearch = {
       meta: {
         title: '供应搜索'
       }
+    },
+    {
+      path: 'docs',
+      name: 'search-middle-docs',
+      component: () => import('@/views/search/middle/docs/index.vue'),
+      meta: {
+        title: '文档搜索'
+      }
     }
   ]
 }

+ 5 - 1
apps/mobile/src/store/modules/search.js

@@ -20,7 +20,8 @@ export default {
         bidding: [],
         buyer: [],
         company: [],
-        supplier: []
+        supplier: [],
+        docs: []
       },
       { login: true }
     )
@@ -99,6 +100,9 @@ export default {
     },
     supplierSearchHistory(state) {
       return state.searchHistory.supplier
+    },
+    docsSearchHistory(state) {
+      return state.searchHistory.docs
     }
   }
 }

+ 3 - 0
apps/mobile/src/views/search/layout.vue

@@ -158,6 +158,9 @@ export default {
       if (name.indexOf('winner') !== -1) {
         this.topSearch.placeholder = '中标企业名称'
       }
+      if (name.indexOf('docs') !== -1) {
+        this.topSearch.placeholder = '在上亿级文档资料库里搜索文档'
+      }
     }
   }
 }

+ 77 - 0
apps/mobile/src/views/search/middle/docs/index.vue

@@ -0,0 +1,77 @@
+<template>
+  <div class="page-search-docs">
+    <history-list
+      v-show="type === 'history' && isLogin"
+      :list="docsSearchHistory"
+      @click="goPage"
+      @delete="deleteList"
+    ></history-list>
+  </div>
+</template>
+
+<script>
+import { HistoryList } from '@/ui'
+import { mapActions, mapGetters } from 'vuex'
+import { openLinkOfOther } from '@/utils'
+
+export default {
+  name: 'SearchMiddleDocs',
+  components: {
+    [HistoryList.name]: HistoryList
+  },
+  inject: {
+    topSearch: {
+      default: () => {}
+    }
+  },
+  data() {
+    return {
+      cacheSearch: '',
+      type: 'history',
+      list: []
+    }
+  },
+  computed: {
+    ...mapGetters('user', ['isLogin']),
+    ...mapGetters('search', ['docsSearchHistory']),
+    getKeys() {
+      return this.topSearch.input.split(' ').filter((v) => v.trim())
+    }
+  },
+  methods: {
+    ...mapActions('search', ['removeHistory', 'setHistory']),
+    clear() {
+      this.type = 'history'
+      this.cacheSearch = ''
+      this.list = []
+    },
+    deleteList() {
+      this.removeHistory({
+        type: 'docs'
+      })
+    },
+    submit() {
+      // 历史记录新增
+      this.setHistory({
+        type: 'docs',
+        item: {
+          label: this.topSearch.input
+        }
+      })
+      if (this.topSearch.input) {
+        return openLinkOfOther(`/page_docs_mobile/search?text=${this.topSearch.input}`)
+      } else {
+        return openLinkOfOther('/page_docs_mobile/home')
+      }
+    },
+    goPage(data) {
+      // 历史记录新增
+      this.setHistory({
+        type: 'docs',
+        item: data
+      })
+      openLinkOfOther(`/page_docs_mobile/search?text=${data.label}`)
+    }
+  }
+}
+</script>

+ 11 - 2
apps/mobile/src/views/search/middle/layout.vue

@@ -5,6 +5,7 @@
       v-model="searchType"
       @change="changeType"
       :before-change="beforeTypeChange"
+      :swipe-threshold="4"
     >
       <van-tab
         :title="value.title"
@@ -55,6 +56,9 @@ export default {
         'search-middle-buyer': {
           title: '采购单位搜索'
         },
+        'search-middle-docs': {
+          title: '文档搜索'
+        },
         'search-middle-supplier': {
           title: '供应搜索'
         }
@@ -159,12 +163,14 @@ export default {
 .page-search-tabs {
   ::v-deep {
     .van-tabs__nav {
-      padding: 0 16px;
-      justify-content: space-between;
+      padding: 0 6px;
+      overflow-x: scroll;
+      //justify-content: space-between;
     }
     .van-tab {
       color: $gray_7;
       flex: unset;
+      flex-shrink: 0;
       &.van-tab--active {
         color: $main;
       }
@@ -183,6 +189,9 @@ export default {
       background: linear-gradient(270.04deg, #25beee 0.03%, #2abed1 74.46%);
       border-radius: 1px;
     }
+    .van-tabs__wrap--scrollable .van-tab{
+      padding: 0 6px;
+    }
   }
 }
 .page-search-content {