From b447026f99e2824d1a4c73af90ee52f0c05da959 Mon Sep 17 00:00:00 2001 From: xiebing Date: Fri, 28 Nov 2025 17:22:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B2=97=E4=BD=8D=E6=8E=A8=E8=8D=90=E5=9B=BA?= =?UTF-8?q?=E5=AE=9A=E6=8F=92=E5=85=A5=E6=94=B9=E4=B8=BA=E9=9A=8F=E6=9C=BA?= =?UTF-8?q?=E6=8F=92=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/components/index-one.vue | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pages/index/components/index-one.vue b/pages/index/components/index-one.vue index 6de61d6..3b50ec1 100644 --- a/pages/index/components/index-one.vue +++ b/pages/index/components/index-one.vue @@ -359,7 +359,11 @@ function getJobRecommend(type = 'add') { ...pageState.search, ...conditionSearch.value, }; - let comd = { recommend: true, jobCategory: '', tip: '确认你的兴趣,为您推荐更多合适的岗位' }; + let comd = { + recommend: true, + jobCategory: '', + tip: '确认你的兴趣,为您推荐更多合适的岗位', + }; $api.createRequest('/app/job/recommend', params).then((resData) => { const { data, total } = resData; pageState.total = 0; @@ -380,7 +384,16 @@ function getJobRecommend(type = 'add') { if (question) { comd.jobCategory = question; - data.unshift(comd); + // 生成随机插入位置,排除前两个和最后两个位置 + let insertIndex; + if (data.length <= 4) { + // 如果数据长度小于等于4,直接插入到中间位置 + insertIndex = Math.floor(data.length / 2); + } else { + // 生成2到data.length-2之间的随机位置 + insertIndex = Math.floor(Math.random() * (data.length - 4)) + 2; + } + data.splice(insertIndex, 0, comd); } } const reslist = dataToImg(data);