Browse Source

Merge branch 'dev/v1.0.53_tsz' of jianyu/web into feature/v1.0.53

汤世哲 1 year ago
parent
commit
f8fc06da5d

+ 19 - 3
apps/mobile/src/utils/format/modules/filter-history-formatter.js

@@ -756,9 +756,6 @@ export class FilterHistoryViewModel2AjaxModel {
 
     for (const key in val) {
       if (Array.isArray(val[key])) {
-        if (val[key].includes('其他')) {
-          val[key].push('其它')
-        }
         val[key].forEach((item) => {
           industryArr.push(`${key}_${item}`)
         })
@@ -770,6 +767,25 @@ export class FilterHistoryViewModel2AjaxModel {
     return industry
   }
 
+  /**
+ * 处理筛选条件二级类(行业)其他, 查询参数有其他时,提交时需要再增加一个‘其它’
+ * '建筑工程,水利水电_其他,信息技术_其他,机械设备_其他设备'
+ */
+static formatFilterApiOther(str) {
+  if (!str) return
+  const arr = str.split(',')
+  const newArr = arr.map(item => {
+    if(item.indexOf('_其他') > -1) {
+      const value = item.split('_')[1]
+      if (value ==='其他') {
+        item = `${item},${item.replace('其他', '其它')}`
+      }
+    }
+    return item
+  })
+  return newArr.toString()
+}
+
   /**
    * 地区整理
    * @param String area

+ 9 - 7
apps/mobile/src/views/collection/index.vue

@@ -311,7 +311,7 @@ import {
   calcNotExactTime,
   openLinkOfOther,
   InfoTypeTransform,
-  FilterHistoryViewModel2AjaxModel,
+  FilterHistoryViewModel2AjaxModel
 } from '@/utils'
 import {
   getCollectList,
@@ -953,6 +953,9 @@ export default {
         }
       }
       this.filters.keyWords = additionalWords
+      const rexIndustry = FilterHistoryViewModel2AjaxModel.formatIndustry(
+        industry
+      )
 
       const params = {
         pageNum: this.listState.pageNum,
@@ -975,9 +978,7 @@ export default {
         ),
         label: label.join(','), // 个人标签
         price: FilterHistoryViewModel2AjaxModel.formatPrice(price),
-        industry: FilterHistoryViewModel2AjaxModel.formatIndustry(
-          industry
-        ), // 行业
+        industry: FilterHistoryViewModel2AjaxModel.formatFilterApiOther(rexIndustry), // 行业
         buyerClass: buyerClass.join(','),
         winnerTel: winnerConcat.join(','),
         buyerTel: buyerConcat.join(','),
@@ -1439,6 +1440,9 @@ export default {
           additionalWords = moreKeywordsMode.tags.join(',')
         }
       }
+      const rexIndustry = FilterHistoryViewModel2AjaxModel.formatIndustry(
+        this.filters.industry
+      )
 
       const params = {
         searchvalue: this.filters.additionalWords,
@@ -1447,9 +1451,7 @@ export default {
         area, // 地区省份(保存筛选接口用到)
         city,
         district,
-        industry: FilterHistoryViewModel2AjaxModel.formatIndustry(
-          this.filters.industry
-        ), // 行业
+        industry: FilterHistoryViewModel2AjaxModel.formatFilterApiOther(rexIndustry), // 行业
         minprice: this.filters.price.start,
         maxprice: this.filters.price.end,
         publishtime: FilterHistoryViewModel2AjaxModel.formatTime(

+ 58 - 15
apps/mobile/src/views/search/middle/buyer/index.vue

@@ -15,6 +15,7 @@
     <div class="divide-line" v-if="showBrowseList && showHistoryList"></div>
     <history-list
       v-if="showBrowseList"
+      class="browse-history"
       title="历史浏览"
       :list="buyerBrowseHistory"
       @click="goBrowseClick"
@@ -64,10 +65,18 @@ export default {
       return this.topSearch.input.split(' ').filter((v) => v.trim())
     },
     showHistoryList() {
-      return this.type === 'history' && this.buyerSearchHistory.length && this.isLogin
+      return (
+        this.type === 'history' &&
+        this.buyerSearchHistory.length &&
+        this.isLogin
+      )
     },
     showBrowseList() {
-      return this.type === 'history' && this.buyerBrowseHistory.length && this.isLogin
+      return (
+        this.type === 'history' &&
+        this.buyerBrowseHistory.length &&
+        this.isLogin
+      )
     }
   },
   created() {
@@ -82,13 +91,33 @@ export default {
   methods: {
     ...mapActions('search', ['removeHistory', 'setHistory']),
     // 历史搜索、历史浏览
-    getHistoryInfo() {
-      getHistoryQuery({ type: '4,5' }).then((res) => {
-        if (res.success === true) {
-          this.buyerSearchHistory = res?.search || []
-          res?.browse.forEach((s) => {
-            this.buyerBrowseHistory.push(s.name)
-          })
+    async getHistoryInfo() {
+      try {
+        if (!this.isLogin) return
+        const res = await getHistoryQuery({ type: '4,5' })
+        if (res.success) {
+          this.processSearchHistory(res.search)
+          this.processBrowseHistory(res.browse)
+        } else {
+          // 处理success为false的情况,例如记录日志、提示用户等
+          console.log('获取历史信息失败')
+        }
+      } catch (error) {
+        // 错误处理,例如记录日志、提示用户等
+        console.error('获取历史信息时发生错误:', error)
+      }
+    },
+    processSearchHistory(searchHistory) {
+      if (!searchHistory || !Array.isArray(searchHistory)) return
+      this.buyerSearchHistory = searchHistory.map((s) =>
+        s.length > 20 ? s.slice(0, 20) : s
+      )
+    },
+    processBrowseHistory(browseHistory) {
+      if (!browseHistory || !Array.isArray(browseHistory)) return
+      browseHistory.forEach((item) => {
+        if (item.name) {
+          this.buyerBrowseHistory.push(item.name)
         }
       })
     },
@@ -142,12 +171,14 @@ export default {
     },
     goPage(data) {
       // 历史记录新增
-      saveViewHistoryQuery({
-        type: 'buyer',
-        name: data?.label,
-      }).then((res) => {
-        console.log(res, 'res')
-      })
+      if (this.isLogin) {
+        saveViewHistoryQuery({
+          type: 'buyer',
+          name: data?.label,
+        }).then((res) => {
+          console.log(res, 'res')
+        })
+      }
       // 缓存定位值用于产品落地页
       sessionStorage.setItem(
         'landinfo',
@@ -249,5 +280,17 @@ export default {
     height: 12px;
     background: #F7F9FA;
   }
+  .browse-history{
+    ::v-deep {
+      .hover-css--slide{
+        max-width: 100%;
+      }
+      .content-text {
+        white-space: nowrap;
+        overflow: hidden;
+        text-overflow: ellipsis;
+      }
+    }
+  }
 }
 </style>

+ 49 - 15
apps/mobile/src/views/search/middle/company/index.vue

@@ -7,7 +7,8 @@
       @click="goPage"
     ></association-list>
     <history-list
-      class="content-module"
+      ref="searchHistoryRef"
+      class="search-history"
       v-if="showHistoryList"
       :list="companySearchHistory"
       @click="goSearch"
@@ -15,6 +16,7 @@
     ></history-list>
     <div class="divide-line" v-show="showBrowseList && showHistoryList"></div>
     <history-list
+      class="browse-history"
       v-if="showBrowseList"
       title="历史浏览"
       :list="companyBrowseHistory"
@@ -85,16 +87,34 @@ export default {
   methods: {
     ...mapActions('search', ['removeHistory', 'setHistory']),
     // 历史搜索、历史浏览
-    getHistoryInfo() {
-      getHistoryQuery({ type: '2,3' }).then((res) => {
-        if (res.success === true) {
-          this.companySearchHistory = res?.search || []
-          res?.browse.forEach((s) => {
-            s.label = s.name
-          })
-          this.companyBrowseHistory = res?.browse || []
+    async getHistoryInfo() {
+      try {
+        if (!this.isLogin) return
+        const res = await getHistoryQuery({ type: '2,3' })
+        if (res.success) {
+          this.processSearchHistory(res.search)
+          this.processBrowseHistory(res.browse)
+        } else {
+          // 处理success为false的情况,例如记录日志、提示用户等
+          console.log('获取历史信息失败')
         }
+      } catch (error) {
+        // 错误处理,例如记录日志、提示用户等
+        console.error('获取历史信息时发生错误:', error)
+      }
+    },
+    processSearchHistory(searchHistory) {
+      if (!searchHistory || !Array.isArray(searchHistory)) return
+      this.companySearchHistory = searchHistory.map((s) =>
+        s.length > 20 ? s.slice(0, 20) : s
+      )
+    },
+    processBrowseHistory(browseHistory) {
+      if (!browseHistory || !Array.isArray(browseHistory)) return
+      browseHistory.forEach((item) => {
+        item.label = item.name
       })
+      this.companyBrowseHistory = browseHistory
     },
     clear() {
       this.type = 'history'
@@ -158,12 +178,14 @@ export default {
           landname: data.label
         })
       )
-      saveViewHistoryQuery({
-        type: 'ent',
-        name: data?.name + '_' + data?.entId || data?.id,
-      }).then((res) => {
-        console.log(res, 'res')
-      })
+      if (this.isLogin) {
+        saveViewHistoryQuery({
+          type: 'ent',
+          name: data?.name + '_' + data?.entId || data?.id,
+        }).then((res) => {
+          console.log(res, 'res')
+        })
+      }
       openAppOrWxPage(LINKS.企业画像页面, {
         query: {
           eId: data?.entId || data?.id,
@@ -227,5 +249,17 @@ export default {
     height: 12px;
     background: #F7F9FA;
   }
+  .browse-history{
+    ::v-deep {
+      .hover-css--slide{
+        max-width: 100%;
+      }
+      .content-text {
+        white-space: nowrap;
+        overflow: hidden;
+        text-overflow: ellipsis;
+      }
+    }
+  }
 }
 </style>

+ 9 - 7
apps/mobile/src/views/search/result/bidding/index.vue

@@ -1371,6 +1371,10 @@ export default {
         }
       }
 
+      const rexIndustry = FilterHistoryViewModel2AjaxModel.formatIndustry(
+        this.filters.industry
+      )
+
       const params = {
         pageNum: this.listState.pageNum,
         pageSize: this.listState.pageSize,
@@ -1392,9 +1396,7 @@ export default {
         additionalWords,
         selectType: this.filters.scope.join(','), // 搜索范围
         price: FilterHistoryViewModel2AjaxModel.formatPrice(price),
-        industry: FilterHistoryViewModel2AjaxModel.formatIndustry(
-          this.filters.industry
-        ), // 行业
+        industry: FilterHistoryViewModel2AjaxModel.formatFilterApiOther(rexIndustry), // 行业
         buyerClass: this.filters.buyerClass.join(','),
         winnerTel: this.filters.winnerConcat.join(','),
         buyerTel: this.filters.buyerConcat.join(','),
@@ -1959,7 +1961,9 @@ export default {
           additionalWords = moreKeywordsMode.tags.join(',')
         }
       }
-
+      const rexIndustry = FilterHistoryViewModel2AjaxModel.formatIndustry(
+        this.filters.industry
+      )
       const params = {
         searchvalue: this.topSearch.input,
         selectType: this.filters.scope.join(','), // 搜索范围
@@ -1967,9 +1971,7 @@ export default {
         area, // 地区省份(保存筛选接口用到)
         city,
         district,
-        industry: FilterHistoryViewModel2AjaxModel.formatIndustry(
-          this.filters.industry
-        ), // 行业
+        industry: FilterHistoryViewModel2AjaxModel.formatFilterApiOther(rexIndustry), // 行业
         minprice: this.filters.price.start,
         maxprice: this.filters.price.end,
         publishtime: FilterHistoryViewModel2AjaxModel.formatTime(