Forráskód Böngészése

fix:融创筛选,与本地缓存存储存在问题,需要优化

zhangsiya 1 éve
szülő
commit
ae4398ce5e

+ 5 - 2
apps/bigmember_pc/src/views/search/bidding/components/search-bid-filter.vue

@@ -62,20 +62,23 @@ if(inBIPropertyIframe) {
 
 // 中国移动定制搜索条件-融创
 async function getCustomInfo () {
+  const _storageKey = 'search_bidding_expandSearchParams'
+  localStorage.removeItem(_storageKey)
   const { error_code:code, data = [] } = await getCMCustomInfo()
   if(code === 0) {
     if (data) {
-      // const expandSearchParams = {}
+      const expandSearchParams = {}
       data.forEach(item => {
         if(item.key && item.defaultVal) {
           const par = {
             key: item.key,
             value: item.defaultVal
           }
-          // expandSearchParams[item.key] = item.defaultVal
+          expandSearchParams[item.key] = item.defaultVal
           updateFilterBase(par)
         }
       })
+      localStorage.setItem(_storageKey, JSON.stringify(expandSearchParams))
       doUpdateData(data, 'more')
       doQuery({}, 'firstPage')
     }

+ 25 - 7
apps/bigmember_pc/src/views/search/bidding/model/base.js

@@ -857,6 +857,8 @@ export default function () {
    * @param item
    */
   function onSelectedFilter (item) {
+    // 动态插入的存储的筛选条件
+    const _expand = getExpandSearchParams()
     const { isPay } = item
     // 恢复选中状态
     if (isFree?.value && isPay) {
@@ -891,13 +893,13 @@ export default function () {
             notkey: '',
             buyer: '',
             winner: '',
-            agency: ''
+            agency: '',
           })
-          restoreFilter(params, 'saveBack')
+          restoreFilter(params, 'saveBack', {_expand})
           historyFilterDialogVisible.value = false
         })
     } else {
-      restoreFilter(item, 'saveBack')
+      restoreFilter(item, 'saveBack', {_expand})
     }
   }
   function restoreFilter (viewFilter, type, expandFilter) {
@@ -912,8 +914,8 @@ export default function () {
       Object.assign(resultFilter, expandFilter)
     }
     doChangeTab({ key: resultFilter.searchGroup })
+    let  _expand = resultFilter._expand || {}
 
-    const _expand = resultFilter._expand || {}
     filterState.value = {
       bidField: isBidField ? 'medical' : '',
       publishTime: resultFilter.publishTime,
@@ -1322,7 +1324,9 @@ export default function () {
       if(urlKeywords) {
         expandFilter.input = urlKeywords
       }
-      restoreFilter(JSON.parse(params), 'localBack', expandFilter)
+      // 身份切换时候,本地缓存的上次筛选条件有融创等动态拓展筛选条件,但是切换到的身份没有时候,需要移除这些动态筛选条件
+      const jParams = JSON.parse(params)
+      restoreFilter(jParams, 'localBack', expandFilter)
     }
   }
 
@@ -1361,7 +1365,10 @@ export default function () {
           if(isVip.value && !jParams) {
             // 付费用户,优先恢复本地缓存,本地无缓存,则恢复已存筛选第一条数据
             if(Array.isArray(arr) && arr.length > 0) {
-              const expandFilter = {}
+              const _expand = getExpandSearchParams()
+              const expandFilter = {
+                _expand: _expand,
+              }
               if(urlSelectType) {
                 expandFilter.selectType = urlSelectType.split(',')
               }
@@ -1381,6 +1388,16 @@ export default function () {
       firstSearch()
     }
   }
+  // 获取本地缓存的动态插入的筛选条件
+  function getExpandSearchParams () {
+    // 动态获取存储的筛选条件
+    const expandSearchParams = localStorage.getItem('search_bidding_expandSearchParams')
+    let _expand = {}
+    if(expandSearchParams) {
+      _expand = JSON.parse(expandSearchParams)
+    }
+    return  _expand
+  }
 
   function firstSearch () {
     return doQuery({}, 'firstSearch')
@@ -1540,6 +1557,7 @@ export default function () {
     toggleBlurModeTip,
     doToggleSearchBlurMode,
     recommendCardCircleModel,
-    getWhiteList
+    getWhiteList,
+    storageConfig
   }
 }

+ 23 - 14
apps/bigmember_pc/src/views/search/bidding/model/modules/filter.js

@@ -39,9 +39,7 @@ export function useSearchFilterModel(conf) {
     // 招标代理机构
     agency: [],
     // 其它动态获取的筛选条件
-    _expand: {
-
-    }
+    _expand: {}
   })
   const filterProperty = ref({
     bidField: 'BIProperty',
@@ -91,6 +89,8 @@ export function useSearchFilterModel(conf) {
   // 格式化招标采购基础筛选条件
   function getFormatApiBaseParams (expendObj = {}) {
     const { publishTime, regionMap, industry, notkey, buyerclass, subtype, _expand } = filterState.value
+    console.log(66666666)
+    console.log(filterState.value)
     const { area, city, district } = FilterHistoryViewModel2AjaxModel.formatAreaCity(regionMap)
     const rPublishTime = publishTime?.indexOf('_') > -1 ? FilterHistoryViewModel2AjaxModel.formatExactTime(publishTime, '-') :  FilterHistoryViewModel2AjaxModel.formatTime(publishTime, true, '-')
     const rIndustry = FilterHistoryViewModel2AjaxModel.formatIndustry(industry)
@@ -180,23 +180,31 @@ export function useSearchFilterModel(conf) {
   // 动态更新筛选条件
   function updateFilterBase (keyObj = {}) {
     const {key, value } = keyObj
-
+    const _expand = filterState.value._expand || {}
     if(keyObj && Object.keys(keyObj).length > 0) {
-      const _expand = filterBase.value._expand || {}
-      if(!filterBase.value[key]) {
-        filterBase.value = Object.assign(filterBase.value, {
-          [key]: value
-        })
+      filterBase.value = Object.assign(filterBase.value, {
+        [key]: value
+      })
+      let _expandResult = {
+        _expand: {}
       }
-      if(Object.keys(_expand).length === 0 || !_expand[key]) {
-        filterBase.value._expand = Object.assign(_expand, {
+      if(Object.keys(_expand).length  > 0 || filterState.value[key]) {
+        _expandResult._expand =  Object.assign(_expand, { [key]: value })
+      } else {
+        _expandResult._expand =  {
           [key]: value
-        })
+        }
       }
       if(!inBIPropertyIframe) {
-        filterState.value = Object.assign(filterBase.value, filterState.value)
+        filterState.value = Object.assign(filterBase.value, filterState.value, _expandResult)
       }
     } else {
+      // 动态获取存储的筛选条件
+      const expandSearchParams = localStorage.getItem('search_bidding_expandSearchParams')
+      let _expand = {}
+      if(expandSearchParams) {
+        _expand = JSON.parse(expandSearchParams)
+      }
       filterBase.value = Object.assign(filterBase.value, {
         bidField: isBidField ? 'medical' : '',
         // 发布时间
@@ -226,7 +234,8 @@ export function useSearchFilterModel(conf) {
         // 中标企业
         winner: [],
         // 招标代理机构
-        agency: []
+        agency: [],
+        ..._expand
       })
       if(!inBIPropertyIframe) {
         filterState.value = filterBase.value