Browse Source

feat: 保存回显超前项目筛选项

zhangyuhan 1 year ago
parent
commit
72f673fc13

+ 13 - 0
apps/bigmember_pc/src/api/modules/detail.js

@@ -85,3 +85,16 @@ export function useResourcePack(data) {
     data: qs.stringify(data)
   })
 }
+
+// 保存筛选条件到后端SESSION,用于回显
+export function ajaxSetSearchFilterForSession(data) {
+  return request({
+    url: '/front/dataExport/superSearchExport',
+    method: 'post',
+    noToast: true,
+    headers: {
+      jump_source: '1'
+    },
+    data: qs.stringify(data)
+  })
+}

+ 34 - 3
apps/bigmember_pc/src/views/article-content/components/RecommendOpportunities.vue

@@ -11,6 +11,7 @@ import ArticleItem from '@/components/article-item/ArticleItem.vue'
 import { dateFromNow } from '@/utils'
 import CollectInfo from '@/components/collect-info/CollectInfo.vue'
 import RecommendServesCard from '@/views/article-content/components/RecommendServesCard.vue'
+import { ajaxSetSearchFilterForSession } from '@/api/modules/detail'
 
 function dateFormat(str) {
   if (str) {
@@ -79,19 +80,49 @@ const canShowProjectMask = computed(() => {
   return ContentExpandsModel.value.recommendProjects?.popup
 })
 
+function getRecentThreeMonthsTimestamps() {
+  const oneDay = 24 * 60 * 60 * 1000 // 一天的毫秒数
+  const threeMonths = 3 * 30 * oneDay // 三个月的毫秒数(大致估算)
+
+  // 获取当前时间的时间戳
+  const now = new Date().getTime()
+  // 获取三个月前的时间戳
+  const threeMonthsAgo = now - threeMonths
+
+  // 转换为UTC时间的起始秒数
+  const nowUTCStart = Math.floor(now / 1000)
+  const threeMonthsAgoUTCStart = Math.floor(threeMonthsAgo / 1000)
+
+  // 返回格式化的字符串
+  return `${threeMonthsAgoUTCStart}_${nowUTCStart}`
+}
+
 /**
  * 打开超前项目查看更多
  * 1.1 判断是否有超前项目权限
  *  > 是,带入条件进入超前项目搜索
  *  > 否,留资弹窗
  */
-function doOpenProjectMore() {
+async function doOpenProjectMore() {
   if (canShowProjectMask.value) {
     doOpenCollectDialog()
   } else {
-    const name = '超前项目'
+    const searchFilter = Object.assign(
+      {},
+      ContentExpandsModel.value.recommendProjects?.search,
+      {
+        selectType: 'content',
+        searchGroup: '2',
+        subtype: '',
+        publishtime: getRecentThreeMonthsTimestamps(),
+        timeslot: getRecentThreeMonthsTimestamps()
+      }
+    )
+    await ajaxSetSearchFilterForSession(searchFilter)
+    const link = location.origin + '/jylab/supsearch/index.html'
     window.open(
-      `/jylab/supsearch/index.html?tab=2&searchGroup=2&keywords=${name}&selectType=title,content`,
+      '/page_workDesktop/work-bench/page?link=' +
+        encodeURIComponent(link + '?goback&tab=2&searchGroup=2'),
       '_blank'
     )
   }