diff --git a/apiRc/jobSkill.js b/apiRc/jobSkill.js index 4c9f8ac..8741153 100644 --- a/apiRc/jobSkill.js +++ b/apiRc/jobSkill.js @@ -13,6 +13,16 @@ export function getJobSkillDetail(params) { }) } +// 获取技能权重 +export function getJobSkillWeight(params) { + return request({ + url: '/jobSkillDet/getJobSkillWeight', + method: 'get', + params, + baseUrlType: 'zytp' + }) +} + // 暂未使用 - 如果需要在 CareerPath.vue 中点击路径职位查看详细技能信息时使用 // 使用场景:获取职业路径中某个职位的详细技能信息(包含技能分数、类型等) // export function getJobPathSkill(data) { diff --git a/apiRc/user/user.js b/apiRc/user/user.js index 2e956fc..0599c98 100644 --- a/apiRc/user/user.js +++ b/apiRc/user/user.js @@ -8,8 +8,7 @@ import request from '@/utilsRc/request' // 获取用户信息(职业规划推荐用) export function appUserInfo() { return request({ - url: '/app/user/appUserInfo', - method: 'get', - baseUrlType: 'appUserInfo' // 使用appUserInfo接口专用baseUrl + fullUrl: 'http://ks.zhaopinzao8dian.com/api/ks/app/user/appUserInfo', + method: 'get' }) } diff --git a/pages/service/career-planning.vue b/pages/service/career-planning.vue index b87aaae..264b96f 100644 --- a/pages/service/career-planning.vue +++ b/pages/service/career-planning.vue @@ -49,10 +49,8 @@ /> @@ -157,59 +155,68 @@ async function getRemindInfo() { const response = await appUserInfo(); const userInfo = response?.data || {}; - // 优先从接口数据中获取 idCard + // 检查 idCard(身份证)- 必须项 let idCard = userInfo?.resume?.idCard ?? userInfo?.idCard ?? null; - - // 如果接口返回的数据中没有 idCard,则从缓存中读取 const cachedUserInfo = uni.getStorageSync('userInfo') || {}; if (!idCard || idCard === null || idCard === '') { idCard = cachedUserInfo?.resume?.idCard ?? cachedUserInfo?.idCard ?? null; } - - // 优先从接口数据中的 jobTitles 数组获取职位信息(取第一个) - const jobTitles = Array.isArray(userInfo?.jobTitles) ? userInfo.jobTitles : []; - if (jobTitles.length > 0) { - currentJobName.value = jobTitles[0]; - } else { - // 如果接口数据中没有 jobTitles,尝试从其他字段获取 - currentJobId.value = userInfo?.jobId ?? - userInfo?.currentJobId ?? - userInfo?.resume?.jobId ?? - userInfo?.resume?.currentJobId ?? - null; - currentJobName.value = userInfo?.jobName ?? - userInfo?.currentJobName ?? - userInfo?.resume?.jobName ?? - userInfo?.resume?.currentJobName ?? - ''; - - // 如果接口数据中没有职位信息,从缓存中读取 - if (!currentJobId.value && !currentJobName.value) { - currentJobId.value = cachedUserInfo?.jobId ?? - cachedUserInfo?.currentJobId ?? - cachedUserInfo?.resume?.jobId ?? - cachedUserInfo?.resume?.currentJobId ?? - null; - currentJobName.value = cachedUserInfo?.jobName ?? - cachedUserInfo?.currentJobName ?? - cachedUserInfo?.resume?.jobName ?? - cachedUserInfo?.resume?.currentJobName ?? - ''; - } - - // 如果还是没有职位信息,使用默认值 - if (!currentJobName.value) { - currentJobName.value = '市场专员'; - } - } - - // 判断 idCard 是否存在(包括空字符串、undefined、null 的情况) const hasIdCard = idCard !== null && idCard !== undefined && idCard !== ''; - if (!hasIdCard) { - remindList.value = ['请完善个人信息']; + // 检查职位信息:优先从 jobTitles 数组获取 + const jobTitles = Array.isArray(userInfo?.jobTitles) ? userInfo.jobTitles : []; + const hasJobTitle = jobTitles.length > 0; + + // 如果 jobTitles 为空,尝试从其他字段获取 + let jobName = ''; + if (!hasJobTitle) { + jobName = userInfo?.jobName ?? + userInfo?.currentJobName ?? + userInfo?.resume?.jobName ?? + userInfo?.resume?.currentJobName ?? + ''; + } + const hasJobInfo = hasJobTitle || (jobName && jobName.trim() !== ''); + + // 检查技能标签:从 appSkillsList 获取 + const appSkillsList = Array.isArray(userInfo?.appSkillsList) ? userInfo.appSkillsList : []; + // 检查是否有有效的技能(name 或 nameStr 不为空) + const hasSkills = appSkillsList.some(skill => { + const skillName = skill?.name || skill?.nameStr; + return skillName && skillName.trim() !== ''; + }); + + // 判断信息是否完整(idCard、职位信息、技能标签都必须有) + const isComplete = hasIdCard && hasJobInfo && hasSkills; + + if (!isComplete) { + // 收集缺失的信息提示 + const missingItems = []; + if (!hasIdCard) { + missingItems.push('身份证信息'); + } + if (!hasJobInfo) { + missingItems.push('职位信息'); + } + if (!hasSkills) { + missingItems.push('技能标签'); + } + remindList.value = [`请完善${missingItems.join('、')}`]; } else { - remindList.value = ['暂无待完善信息']; + // 信息完整,设置职位信息 + if (hasJobTitle) { + currentJobName.value = jobTitles[0]; + } else { + currentJobName.value = jobName; + currentJobId.value = userInfo?.jobId ?? + userInfo?.currentJobId ?? + userInfo?.resume?.jobId ?? + userInfo?.resume?.currentJobId ?? + null; + } + // 信息完整,直接显示页面内容 + showContent.value = true; + return; } setTimeout(() => { @@ -218,34 +225,62 @@ async function getRemindInfo() { } catch (error) { // 接口调用失败时,使用缓存作为降级方案 const cachedUserInfo = uni.getStorageSync('userInfo') || {}; + + // 检查 idCard const idCard = cachedUserInfo?.resume?.idCard ?? cachedUserInfo?.idCard ?? null; + const hasIdCard = idCard !== null && idCard !== undefined && idCard !== ''; - // 从缓存中获取职位信息(优先从 jobTitles 数组获取) + // 检查职位信息 const cachedJobTitles = Array.isArray(cachedUserInfo?.jobTitles) ? cachedUserInfo.jobTitles : []; - if (cachedJobTitles.length > 0) { - currentJobName.value = cachedJobTitles[0]; - } else { - // 如果缓存中没有 jobTitles,从其他字段获取 - currentJobId.value = cachedUserInfo?.jobId ?? - cachedUserInfo?.currentJobId ?? - cachedUserInfo?.resume?.jobId ?? - cachedUserInfo?.resume?.currentJobId ?? - null; - currentJobName.value = cachedUserInfo?.jobName ?? - cachedUserInfo?.currentJobName ?? - cachedUserInfo?.resume?.jobName ?? - cachedUserInfo?.resume?.currentJobName ?? - ''; - // 如果缓存中没有职位信息,使用默认值 - if (!currentJobName.value) { - currentJobName.value = '市场专员'; - } + const hasJobTitle = cachedJobTitles.length > 0; + let jobName = ''; + if (!hasJobTitle) { + jobName = cachedUserInfo?.jobName ?? + cachedUserInfo?.currentJobName ?? + cachedUserInfo?.resume?.jobName ?? + cachedUserInfo?.resume?.currentJobName ?? + ''; } + const hasJobInfo = hasJobTitle || (jobName && jobName.trim() !== ''); - if (!idCard || idCard === null || idCard === '') { - remindList.value = ['请完善个人信息']; + // 检查技能标签 + const cachedAppSkillsList = Array.isArray(cachedUserInfo?.appSkillsList) ? cachedUserInfo.appSkillsList : []; + const hasSkills = cachedAppSkillsList.some(skill => { + const skillName = skill?.name || skill?.nameStr; + return skillName && skillName.trim() !== ''; + }); + + // 判断信息是否完整(idCard、职位信息、技能标签都必须有) + const isComplete = hasIdCard && hasJobInfo && hasSkills; + + if (!isComplete) { + // 收集缺失的信息提示 + const missingItems = []; + if (!hasIdCard) { + missingItems.push('身份证信息'); + } + if (!hasJobInfo) { + missingItems.push('职位信息'); + } + if (!hasSkills) { + missingItems.push('技能标签'); + } + remindList.value = [`请完善${missingItems.join('、')}`]; } else { - remindList.value = ['暂无待完善信息']; + // 信息完整,设置职位信息 + if (hasJobTitle) { + currentJobName.value = cachedJobTitles[0]; + } else { + currentJobName.value = jobName; + currentJobId.value = cachedUserInfo?.jobId ?? + cachedUserInfo?.currentJobId ?? + cachedUserInfo?.resume?.jobId ?? + cachedUserInfo?.resume?.currentJobId ?? + null; + } + // 信息完整,直接显示页面内容 + showContent.value = true; + return; } setTimeout(() => { @@ -264,82 +299,8 @@ function handleCancel() { async function handleConfirm() { remindPopup.value?.close(); - // 直接从缓存中读取 idCard(因为接口返回的数据中没有 idCard) - const cachedUserInfo = uni.getStorageSync('userInfo') || {}; - let idCard = cachedUserInfo?.resume?.idCard ?? cachedUserInfo?.idCard ?? null; - - // 如果缓存中也没有,尝试从接口获取(虽然接口通常也没有) - if (!idCard || idCard === null || idCard === '') { - try { - const response = await appUserInfo(); - const userInfo = response?.data || {}; - idCard = userInfo?.resume?.idCard ?? userInfo?.idCard ?? null; - } catch (error) { - // 接口调用失败,继续使用缓存数据 - } - } - - // 如果 idCard 为空,才跳转到完善信息页面 - if (!idCard || idCard === null || idCard === '') { - navTo('/pages/complete-info/complete-info'); - return; - } - - // 如果 idCard 存在,说明已经完善了信息,直接显示页面内容 - // 从接口获取最新的职位信息 - try { - const response = await appUserInfo(); - const userInfo = response?.data || {}; - - // 优先从接口数据中的 jobTitles 数组获取职位信息(取第一个) - const jobTitles = Array.isArray(userInfo?.jobTitles) ? userInfo.jobTitles : []; - if (jobTitles.length > 0) { - currentJobName.value = jobTitles[0]; - } else { - // 如果接口数据中没有 jobTitles,从缓存中获取 - const cachedJobTitles = Array.isArray(cachedUserInfo?.jobTitles) ? cachedUserInfo.jobTitles : []; - if (cachedJobTitles.length > 0) { - currentJobName.value = cachedJobTitles[0]; - } else { - // 从其他字段获取 - currentJobId.value = cachedUserInfo?.jobId ?? - cachedUserInfo?.currentJobId ?? - cachedUserInfo?.resume?.jobId ?? - cachedUserInfo?.resume?.currentJobId ?? - null; - currentJobName.value = cachedUserInfo?.jobName ?? - cachedUserInfo?.currentJobName ?? - cachedUserInfo?.resume?.jobName ?? - cachedUserInfo?.resume?.currentJobName ?? - ''; - if (!currentJobName.value) { - currentJobName.value = '市场专员'; - } - } - } - } catch (error) { - // 接口调用失败,从缓存中获取 - const cachedJobTitles = Array.isArray(cachedUserInfo?.jobTitles) ? cachedUserInfo.jobTitles : []; - if (cachedJobTitles.length > 0) { - currentJobName.value = cachedJobTitles[0]; - } else { - currentJobId.value = cachedUserInfo?.jobId ?? - cachedUserInfo?.currentJobId ?? - cachedUserInfo?.resume?.jobId ?? - cachedUserInfo?.resume?.currentJobId ?? - null; - currentJobName.value = cachedUserInfo?.jobName ?? - cachedUserInfo?.currentJobName ?? - cachedUserInfo?.resume?.jobName ?? - cachedUserInfo?.resume?.currentJobName ?? - ''; - if (!currentJobName.value) { - currentJobName.value = '市场专员'; - } - } - } - - showContent.value = true; + // 跳转到完善信息页面 + navTo('/pages/complete-info/complete-info'); } // 切换tab @@ -449,8 +410,8 @@ async function handleJobCardClick(job) { // 将 appSkillsList 转换为 splitSkillListByScore 需要的格式 const skillList = appSkillsList.map(item => ({ - skillName: item?.nameStr || '', - skillScore: item?.levelStr || 0 + skillName: item?.name || item?.nameStr || '', + skillScore: item?.levels || item?.levelStr || 0 })).filter(item => item.skillName); const { possessed, improvement } = splitSkillListByScore(skillList); diff --git a/pages/service/components/CareerRecommend.vue b/pages/service/components/CareerRecommend.vue index 2dff73f..74a8260 100644 --- a/pages/service/components/CareerRecommend.vue +++ b/pages/service/components/CareerRecommend.vue @@ -21,6 +21,7 @@ {{ skill }} 暂无技能数据 + 加载中... @@ -35,7 +36,6 @@ :key="index" @click="handleJobCardClick(job)" > - {{ job.title }} @@ -79,11 +79,10 @@ const isLoadingRecommend = ref(false); // 计算属性 const currentJobDisplay = computed(() => props.currentJobName || '市场专员'); - // 从 appSkillsList 中提取技能名称 function extractSkillsFromAppSkillsList(appSkillsList = []) { return (Array.isArray(appSkillsList) ? appSkillsList : []) - .map(item => item?.nameStr || '') + .map(item => item?.name || item?.nameStr || '') .filter(name => !!name && name.trim().length > 0); } @@ -202,17 +201,15 @@ onMounted(() => { watch( () => [props.currentJobId, props.currentJobName], () => { - fetchCurrentJobSkills(); - fetchRecommendedJobs(); + if (props.currentJobName) { + fetchCurrentJobSkills(); + fetchRecommendedJobs(); + } }, { immediate: true } ); // 事件处理 -function handleJobSearch(job) { - // TODO: 实现职位搜索跳转 -} - function handleJobCardClick(job) { emit('job-card-click', job); } @@ -296,24 +293,8 @@ function handleJobCardClick(job) { cursor: pointer; } -.search-btn { - position: absolute; - top: 16rpx; - right: 16rpx; - background-color: #FFDAB9; - color: #FF6347; - font-size: 20rpx; - padding: 6rpx 14rpx; - border-radius: 6rpx; - border: 1rpx solid #FFA07A; - white-space: nowrap; - z-index: 10; - line-height: 1.2; -} - .job-header { margin-bottom: 16rpx; - padding-right: 100rpx; } .job-title { diff --git a/pages/service/components/PageHeader.vue b/pages/service/components/PageHeader.vue index eaedd4b..055655c 100644 --- a/pages/service/components/PageHeader.vue +++ b/pages/service/components/PageHeader.vue @@ -1,5 +1,5 @@