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

@@ -10,6 +10,6 @@ export function appUserInfo() {
return request({ return request({
url: '/app/user/appUserInfo', url: '/app/user/appUserInfo',
method: 'get', method: 'get',
baseUrlType: 'user' // 使用用户接口专用baseUrl baseUrlType: 'appUserInfo' // 使用appUserInfo接口专用baseUrl
}) })
} }

View File

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

View File

@@ -55,7 +55,7 @@
<script setup> <script setup>
import { ref, computed, watch, onMounted } from 'vue'; import { ref, computed, watch, onMounted } from 'vue';
import { recommendJob } from '@/apiRc/jobRecommend.js'; import { recommendJob } from '@/apiRc/jobRecommend.js';
import { getJobSkillDetail } from '@/apiRc/jobSkill.js'; import { appUserInfo } from '@/apiRc/user/user.js';
const props = defineProps({ const props = defineProps({
currentJobId: { currentJobId: {
@@ -79,7 +79,15 @@ const isLoadingRecommend = ref(false);
// 计算属性 // 计算属性
const currentJobDisplay = computed(() => props.currentJobName || '市场专员'); const currentJobDisplay = computed(() => props.currentJobName || '市场专员');
// 从技能列表中提取技能名称用于显示
// 从 appSkillsList 中提取技能名称
function extractSkillsFromAppSkillsList(appSkillsList = []) {
return (Array.isArray(appSkillsList) ? appSkillsList : [])
.map(item => item?.nameStr || '')
.filter(name => !!name && name.trim().length > 0);
}
// 从技能列表中提取技能名称用于显示(用于推荐职位数据)
function extractSkillNames(skillList = []) { function extractSkillNames(skillList = []) {
return (Array.isArray(skillList) ? skillList : []) return (Array.isArray(skillList) ? skillList : [])
.map(item => item?.skillName || '') .map(item => item?.skillName || '')
@@ -88,38 +96,15 @@ function extractSkillNames(skillList = []) {
// 获取当前职位的技能标签 // 获取当前职位的技能标签
async function fetchCurrentJobSkills() { async function fetchCurrentJobSkills() {
// 如果没有职位名称,从缓存中获取技能标签
if (!props.currentJobName || props.currentJobName === '市场专员') {
const cachedUserInfo = uni.getStorageSync('userInfo') || {};
const cachedSkills = cachedUserInfo?.resume?.skillList ??
cachedUserInfo?.skillList ??
cachedUserInfo?.appSkillsList ??
[];
// 如果缓存中有技能数据,使用缓存的数据
if (Array.isArray(cachedSkills) && cachedSkills.length > 0) {
skillTags.value = extractSkillNames(cachedSkills);
} else {
skillTags.value = [];
}
// 通知父组件技能数据已更新
emit('skills-updated', {
currentJobSkills: skillTags.value,
recommendedJobs: recommendedJobs.value
});
return;
}
// 优先调用接口获取技能数据
isLoadingSkillTags.value = true; isLoadingSkillTags.value = true;
try { try {
const response = await getJobSkillDetail({ // 优先从 appUserInfo 接口获取技能标签
jobName: props.currentJobName const response = await appUserInfo();
}); const userInfo = response?.data || {};
const skillList = Array.isArray(response?.data) ? response.data : []; // 从 appSkillsList 中提取技能名称
const apiSkills = extractSkillNames(skillList); const appSkillsList = Array.isArray(userInfo?.appSkillsList) ? userInfo.appSkillsList : [];
const apiSkills = extractSkillsFromAppSkillsList(appSkillsList);
// 如果接口返回了技能数据,使用接口数据 // 如果接口返回了技能数据,使用接口数据
if (apiSkills.length > 0) { if (apiSkills.length > 0) {
@@ -127,13 +112,11 @@ async function fetchCurrentJobSkills() {
} else { } else {
// 如果接口没有返回技能数据,从缓存中读取 // 如果接口没有返回技能数据,从缓存中读取
const cachedUserInfo = uni.getStorageSync('userInfo') || {}; const cachedUserInfo = uni.getStorageSync('userInfo') || {};
const cachedSkills = cachedUserInfo?.resume?.skillList ?? const cachedAppSkills = Array.isArray(cachedUserInfo?.appSkillsList) ? cachedUserInfo.appSkillsList : [];
cachedUserInfo?.skillList ?? const cachedSkills = extractSkillsFromAppSkillsList(cachedAppSkills);
cachedUserInfo?.appSkillsList ??
[];
if (Array.isArray(cachedSkills) && cachedSkills.length > 0) { if (cachedSkills.length > 0) {
skillTags.value = extractSkillNames(cachedSkills); skillTags.value = cachedSkills;
} else { } else {
skillTags.value = []; skillTags.value = [];
} }
@@ -145,15 +128,13 @@ async function fetchCurrentJobSkills() {
recommendedJobs: recommendedJobs.value recommendedJobs: recommendedJobs.value
}); });
} catch (error) { } catch (error) {
// 接口调用失败时,从缓存中读取 // appUserInfo 接口调用失败时,从缓存中读取
const cachedUserInfo = uni.getStorageSync('userInfo') || {}; const cachedUserInfo = uni.getStorageSync('userInfo') || {};
const cachedSkills = cachedUserInfo?.resume?.skillList ?? const cachedAppSkills = Array.isArray(cachedUserInfo?.appSkillsList) ? cachedUserInfo.appSkillsList : [];
cachedUserInfo?.skillList ?? const cachedSkills = extractSkillsFromAppSkillsList(cachedAppSkills);
cachedUserInfo?.appSkillsList ??
[];
if (Array.isArray(cachedSkills) && cachedSkills.length > 0) { if (cachedSkills.length > 0) {
skillTags.value = extractSkillNames(cachedSkills); skillTags.value = cachedSkills;
} else { } else {
skillTags.value = []; skillTags.value = [];
} }

View File

@@ -26,10 +26,13 @@ let exports = {
// baseUrl: 'http://ks.zhaopinzao8dian.com/api/ks', // 已从根目录config.js引用不再重复配置 // baseUrl: 'http://ks.zhaopinzao8dian.com/api/ks', // 已从根目录config.js引用不再重复配置
// ========== 职业图谱专用baseUrl ========== // ========== 职业图谱专用baseUrl ==========
zytpBaseUrl: 'http://ks.zhaopinzao8dian.com/api/ks_zytp/admin-api/zytp', zytpBaseUrl: 'http://222.80.110.161:11111/career-map/api/ks_zytp/admin-api/zytp',
// ========== 用户接口专用baseUrlappUserInfo等接口使用) ========== // ========== 用户接口专用baseUrl其他用户接口使用) ==========
userBaseUrl: 'http://ks.zhaopinzao8dian.com/api/ks', // 用户相关接口使用根目录config.js的baseUrl userBaseUrl: 'http://ks.zhaopinzao8dian.com/api/ks', // 用户相关接口使用根目录config.js的baseUrl
// ========== appUserInfo接口专用baseUrl ==========
appUserInfoBaseUrl: 'http://222.80.110.161:11111/api/ks', // appUserInfo接口专用与其他接口路径不一致

View File

@@ -14,6 +14,7 @@ let timeout = 10000
const baseUrl = configRc.baseUrl const baseUrl = configRc.baseUrl
const zytpBaseUrl = configRc.zytpBaseUrl || '' const zytpBaseUrl = configRc.zytpBaseUrl || ''
const userBaseUrl = configRc.userBaseUrl || '' const userBaseUrl = configRc.userBaseUrl || ''
const appUserInfoBaseUrl = configRc.appUserInfoBaseUrl || ''
const request = config => { const request = config => {
// 是否需要设置 token // 是否需要设置 token
@@ -31,6 +32,8 @@ const request = config => {
requestBaseUrl = zytpBaseUrl requestBaseUrl = zytpBaseUrl
} else if (baseType === 'user' && userBaseUrl) { } else if (baseType === 'user' && userBaseUrl) {
requestBaseUrl = userBaseUrl requestBaseUrl = userBaseUrl
} else if (baseType === 'appUserInfo' && appUserInfoBaseUrl) {
requestBaseUrl = appUserInfoBaseUrl
} }
let requestUrl = config.fullUrl ? config.fullUrl : (requestBaseUrl + (config.url || '')) let requestUrl = config.fullUrl ? config.fullUrl : (requestBaseUrl + (config.url || ''))