feat: 更新职业图谱接口配置和appUserInfo接口路径

This commit is contained in:
2025-11-27 19:10:42 +08:00
parent 7f00dc69a8
commit 7ae6d8f340
5 changed files with 169 additions and 122 deletions

View File

@@ -67,7 +67,6 @@
<script setup>
import { ref, inject, nextTick, onMounted } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { getJobSkillDetail } from '@/apiRc/jobSkill.js';
import { appUserInfo } from '@/apiRc/user/user.js';
import RemindPopup from './components/RemindPopup.vue';
import PageHeader from './components/PageHeader.vue';
@@ -167,35 +166,41 @@ async function getRemindInfo() {
idCard = cachedUserInfo?.resume?.idCard ?? cachedUserInfo?.idCard ?? null;
}
// 优先从接口数据中获取职位信息
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 ??
// 优先从接口数据中的 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 = cachedUserInfo?.jobName ??
cachedUserInfo?.currentJobName ??
cachedUserInfo?.resume?.jobName ??
cachedUserInfo?.resume?.currentJobName ??
currentJobName.value = userInfo?.jobName ??
userInfo?.currentJobName ??
userInfo?.resume?.jobName ??
userInfo?.resume?.currentJobName ??
'';
}
// 如果还是没有职位信息,使用默认值
if (!currentJobName.value) {
currentJobName.value = '市场专员';
// 如果接口数据中没有职位信息,从缓存中读取
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 的情况)
@@ -215,20 +220,26 @@ async function getRemindInfo() {
const cachedUserInfo = uni.getStorageSync('userInfo') || {};
const idCard = cachedUserInfo?.resume?.idCard ?? cachedUserInfo?.idCard ?? null;
// 从缓存中获取职位信息
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 = '市场专员';
// 从缓存中获取职位信息(优先从 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 = '市场专员';
}
}
if (!idCard || idCard === null || idCard === '') {
@@ -275,19 +286,57 @@ async function handleConfirm() {
}
// 如果 idCard 存在,说明已经完善了信息,直接显示页面内容
// 从缓存中更新职位信息
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 = '市场专员';
// 从接口获取最新的职位信息
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;
@@ -300,19 +349,28 @@ function switchTab(index) {
if (index === 0 && !currentJobId.value) {
const cachedUserInfo = uni.getStorageSync('userInfo') || {};
// 优先从缓存中的 jobTitles 数组获取职位信息(取第一个)
const cachedJobTitles = Array.isArray(cachedUserInfo?.jobTitles) ? cachedUserInfo.jobTitles : [];
let newJobName = '';
if (cachedJobTitles.length > 0) {
newJobName = cachedJobTitles[0];
} else {
// 如果缓存中没有 jobTitles从其他字段获取
newJobName = currentJobName.value ||
(cachedUserInfo?.jobName ??
cachedUserInfo?.currentJobName ??
cachedUserInfo?.resume?.jobName ??
cachedUserInfo?.resume?.currentJobName ??
'市场专员');
}
const newJobId = cachedUserInfo?.jobId ??
cachedUserInfo?.currentJobId ??
cachedUserInfo?.resume?.jobId ??
cachedUserInfo?.resume?.currentJobId ??
null;
const newJobName = currentJobName.value ||
(cachedUserInfo?.jobName ??
cachedUserInfo?.currentJobName ??
cachedUserInfo?.resume?.jobName ??
cachedUserInfo?.resume?.currentJobName ??
'市场专员');
currentJobId.value = newJobId;
currentJobName.value = newJobName;
}
@@ -383,23 +441,23 @@ async function handleJobCardClick(job) {
mask: true
});
const fallbackSkills = Array.isArray(job?.rawSkills) ? job.rawSkills : [];
const params = {};
if (job?.jobId) {
params.jobId = job.jobId;
}
if (job?.title) {
params.jobName = job.title;
} else if (job?.jobName) {
params.jobName = job.jobName;
}
try {
const response = await getJobSkillDetail(params);
const skillList = Array.isArray(response?.data) ? response.data : [];
// 从 appUserInfo 接口获取技能数据
const response = await appUserInfo();
const userInfo = response?.data || {};
const appSkillsList = Array.isArray(userInfo?.appSkillsList) ? userInfo.appSkillsList : [];
// 将 appSkillsList 转换为 splitSkillListByScore 需要的格式
const skillList = appSkillsList.map(item => ({
skillName: item?.nameStr || '',
skillScore: item?.levelStr || 0
})).filter(item => item.skillName);
const { possessed, improvement } = splitSkillListByScore(skillList);
if (possessed.length === 0 && improvement.length === 0) {
// 如果 appUserInfo 中没有技能数据,尝试使用推荐职位数据中的技能信息
const fallbackSkills = Array.isArray(job?.rawSkills) ? job.rawSkills : [];
if (fallbackSkills.length === 0) {
uni.showToast({
title: '暂无技能数据',
@@ -416,6 +474,8 @@ async function handleJobCardClick(job) {
}
skillDetailPopup.value?.open();
} catch (error) {
// 接口调用失败,尝试使用推荐职位数据中的技能信息
const fallbackSkills = Array.isArray(job?.rawSkills) ? job.rawSkills : [];
if (fallbackSkills.length > 0) {
const fallbackSplit = splitSkillListByScore(fallbackSkills);
selectedJobPossessedSkills.value = fallbackSplit.possessed;