feat: 更新职业图谱接口配置和appUserInfo接口路径
This commit is contained in:
@@ -10,6 +10,6 @@ export function appUserInfo() {
|
||||
return request({
|
||||
url: '/app/user/appUserInfo',
|
||||
method: 'get',
|
||||
baseUrlType: 'user' // 使用用户接口专用baseUrl
|
||||
baseUrlType: 'appUserInfo' // 使用appUserInfo接口专用baseUrl
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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,7 +166,12 @@ async function getRemindInfo() {
|
||||
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 ??
|
||||
@@ -197,6 +201,7 @@ async function getRemindInfo() {
|
||||
if (!currentJobName.value) {
|
||||
currentJobName.value = '市场专员';
|
||||
}
|
||||
}
|
||||
|
||||
// 判断 idCard 是否存在(包括空字符串、undefined、null 的情况)
|
||||
const hasIdCard = idCard !== null && idCard !== undefined && idCard !== '';
|
||||
@@ -215,7 +220,12 @@ async function getRemindInfo() {
|
||||
const cachedUserInfo = uni.getStorageSync('userInfo') || {};
|
||||
const idCard = cachedUserInfo?.resume?.idCard ?? cachedUserInfo?.idCard ?? null;
|
||||
|
||||
// 从缓存中获取职位信息
|
||||
// 从缓存中获取职位信息(优先从 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 ??
|
||||
@@ -230,6 +240,7 @@ async function getRemindInfo() {
|
||||
if (!currentJobName.value) {
|
||||
currentJobName.value = '市场专员';
|
||||
}
|
||||
}
|
||||
|
||||
if (!idCard || idCard === null || idCard === '') {
|
||||
remindList.value = ['请完善个人信息'];
|
||||
@@ -275,7 +286,22 @@ async function handleConfirm() {
|
||||
}
|
||||
|
||||
// 如果 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 ??
|
||||
@@ -289,6 +315,29 @@ async function handleConfirm() {
|
||||
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,18 +349,27 @@ function switchTab(index) {
|
||||
if (index === 0 && !currentJobId.value) {
|
||||
const cachedUserInfo = uni.getStorageSync('userInfo') || {};
|
||||
|
||||
const newJobId = cachedUserInfo?.jobId ??
|
||||
cachedUserInfo?.currentJobId ??
|
||||
cachedUserInfo?.resume?.jobId ??
|
||||
cachedUserInfo?.resume?.currentJobId ??
|
||||
null;
|
||||
// 优先从缓存中的 jobTitles 数组获取职位信息(取第一个)
|
||||
const cachedJobTitles = Array.isArray(cachedUserInfo?.jobTitles) ? cachedUserInfo.jobTitles : [];
|
||||
let newJobName = '';
|
||||
|
||||
const newJobName = currentJobName.value ||
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
<script setup>
|
||||
import { ref, computed, watch, onMounted } from 'vue';
|
||||
import { recommendJob } from '@/apiRc/jobRecommend.js';
|
||||
import { getJobSkillDetail } from '@/apiRc/jobSkill.js';
|
||||
import { appUserInfo } from '@/apiRc/user/user.js';
|
||||
|
||||
const props = defineProps({
|
||||
currentJobId: {
|
||||
@@ -79,7 +79,15 @@ const isLoadingRecommend = ref(false);
|
||||
// 计算属性
|
||||
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 = []) {
|
||||
return (Array.isArray(skillList) ? skillList : [])
|
||||
.map(item => item?.skillName || '')
|
||||
@@ -88,38 +96,15 @@ function extractSkillNames(skillList = []) {
|
||||
|
||||
// 获取当前职位的技能标签
|
||||
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;
|
||||
try {
|
||||
const response = await getJobSkillDetail({
|
||||
jobName: props.currentJobName
|
||||
});
|
||||
// 优先从 appUserInfo 接口获取技能标签
|
||||
const response = await appUserInfo();
|
||||
const userInfo = response?.data || {};
|
||||
|
||||
const skillList = Array.isArray(response?.data) ? response.data : [];
|
||||
const apiSkills = extractSkillNames(skillList);
|
||||
// 从 appSkillsList 中提取技能名称
|
||||
const appSkillsList = Array.isArray(userInfo?.appSkillsList) ? userInfo.appSkillsList : [];
|
||||
const apiSkills = extractSkillsFromAppSkillsList(appSkillsList);
|
||||
|
||||
// 如果接口返回了技能数据,使用接口数据
|
||||
if (apiSkills.length > 0) {
|
||||
@@ -127,13 +112,11 @@ async function fetchCurrentJobSkills() {
|
||||
} else {
|
||||
// 如果接口没有返回技能数据,从缓存中读取
|
||||
const cachedUserInfo = uni.getStorageSync('userInfo') || {};
|
||||
const cachedSkills = cachedUserInfo?.resume?.skillList ??
|
||||
cachedUserInfo?.skillList ??
|
||||
cachedUserInfo?.appSkillsList ??
|
||||
[];
|
||||
const cachedAppSkills = Array.isArray(cachedUserInfo?.appSkillsList) ? cachedUserInfo.appSkillsList : [];
|
||||
const cachedSkills = extractSkillsFromAppSkillsList(cachedAppSkills);
|
||||
|
||||
if (Array.isArray(cachedSkills) && cachedSkills.length > 0) {
|
||||
skillTags.value = extractSkillNames(cachedSkills);
|
||||
if (cachedSkills.length > 0) {
|
||||
skillTags.value = cachedSkills;
|
||||
} else {
|
||||
skillTags.value = [];
|
||||
}
|
||||
@@ -145,15 +128,13 @@ async function fetchCurrentJobSkills() {
|
||||
recommendedJobs: recommendedJobs.value
|
||||
});
|
||||
} catch (error) {
|
||||
// 接口调用失败时,从缓存中读取
|
||||
// appUserInfo 接口调用失败时,从缓存中读取
|
||||
const cachedUserInfo = uni.getStorageSync('userInfo') || {};
|
||||
const cachedSkills = cachedUserInfo?.resume?.skillList ??
|
||||
cachedUserInfo?.skillList ??
|
||||
cachedUserInfo?.appSkillsList ??
|
||||
[];
|
||||
const cachedAppSkills = Array.isArray(cachedUserInfo?.appSkillsList) ? cachedUserInfo.appSkillsList : [];
|
||||
const cachedSkills = extractSkillsFromAppSkillsList(cachedAppSkills);
|
||||
|
||||
if (Array.isArray(cachedSkills) && cachedSkills.length > 0) {
|
||||
skillTags.value = extractSkillNames(cachedSkills);
|
||||
if (cachedSkills.length > 0) {
|
||||
skillTags.value = cachedSkills;
|
||||
} else {
|
||||
skillTags.value = [];
|
||||
}
|
||||
|
||||
@@ -26,11 +26,14 @@ let exports = {
|
||||
// baseUrl: 'http://ks.zhaopinzao8dian.com/api/ks', // 已从根目录config.js引用,不再重复配置
|
||||
|
||||
// ========== 职业图谱专用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',
|
||||
|
||||
// ========== 用户接口专用baseUrl(appUserInfo等接口使用) ==========
|
||||
// ========== 用户接口专用baseUrl(其他用户接口使用) ==========
|
||||
userBaseUrl: 'http://ks.zhaopinzao8dian.com/api/ks', // 用户相关接口使用根目录config.js的baseUrl
|
||||
|
||||
// ========== appUserInfo接口专用baseUrl ==========
|
||||
appUserInfoBaseUrl: 'http://222.80.110.161:11111/api/ks', // appUserInfo接口专用,与其他接口路径不一致
|
||||
|
||||
|
||||
|
||||
// 应用信息
|
||||
|
||||
@@ -14,6 +14,7 @@ let timeout = 10000
|
||||
const baseUrl = configRc.baseUrl
|
||||
const zytpBaseUrl = configRc.zytpBaseUrl || ''
|
||||
const userBaseUrl = configRc.userBaseUrl || ''
|
||||
const appUserInfoBaseUrl = configRc.appUserInfoBaseUrl || ''
|
||||
|
||||
const request = config => {
|
||||
// 是否需要设置 token
|
||||
@@ -31,6 +32,8 @@ const request = config => {
|
||||
requestBaseUrl = zytpBaseUrl
|
||||
} else if (baseType === 'user' && userBaseUrl) {
|
||||
requestBaseUrl = userBaseUrl
|
||||
} else if (baseType === 'appUserInfo' && appUserInfoBaseUrl) {
|
||||
requestBaseUrl = appUserInfoBaseUrl
|
||||
}
|
||||
let requestUrl = config.fullUrl ? config.fullUrl : (requestBaseUrl + (config.url || ''))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user