fix: 修复

This commit is contained in:
2025-11-12 19:31:46 +08:00
parent 1468002fe2
commit 967317367c
17 changed files with 1002 additions and 560 deletions

View File

@@ -40,9 +40,20 @@
:current-job-id="currentJobId"
:current-job-name="currentJobName"
@job-card-click="handleJobCardClick"
@skills-updated="handleRecommendSkillsUpdated"
/>
<CareerPath
v-else-if="activeTab === 1"
:current-job-name="currentJobName"
@path-data-updated="handlePathDataUpdated"
/>
<SkillDevelopment
v-else
:current-job-skills="recommendSkillsData.currentJobSkills"
:recommended-jobs="recommendSkillsData.recommendedJobs"
:path-data="pathSkillsData.pathData"
:target-career="pathSkillsData.targetCareer"
/>
<CareerPath v-else-if="activeTab === 1" />
<SkillDevelopment v-else />
</scroll-view>
</view>
@@ -56,8 +67,8 @@
<script setup>
import { ref, inject, nextTick, onMounted } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import { appUserInfo } from '@/apiRc/user/user.js';
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';
import SkillDetailPopup from './components/SkillDetailPopup.vue';
@@ -66,7 +77,7 @@ import CareerPath from './components/CareerPath.vue';
import SkillDevelopment from './components/SkillDevelopment.vue';
import CustomTabBar from '@/components/CustomTabBar/CustomTabBar.vue';
const { navBack } = inject('globalFunction');
const { navBack, navTo } = inject('globalFunction');
// 弹窗引用
const remindPopup = ref(null);
@@ -85,80 +96,150 @@ const isLoadingJobSkill = ref(false);
const currentJobId = ref(null);
const currentJobName = ref('');
// 技能发展所需的数据
const recommendSkillsData = ref({
currentJobSkills: [],
recommendedJobs: []
});
const pathSkillsData = ref({
pathData: {
start: { title: '', skills: [] },
steps: [],
end: { title: '', skills: [] }
},
targetCareer: ''
});
// 打开弹窗
function openRemindPopup() {
nextTick(() => {
if (remindPopup.value) {
remindPopup.value.open();
try {
remindPopup.value.open();
} catch (error) {
// 静默处理错误
}
} else {
setTimeout(() => {
if (remindPopup.value) {
remindPopup.value.open();
try {
remindPopup.value.open();
} catch (error) {
// 静默处理错误
}
} else {
setTimeout(() => {
remindPopup.value?.open();
}, 200);
if (remindPopup.value) {
try {
remindPopup.value.open();
} catch (error) {
// 静默处理错误
}
}
}, 500);
}
}, 300);
}, 500);
}
});
}
// 获取提醒信息的接口
// 检查用户是否完善了个人信息(调用接口获取)
let hasCheckedRemindInfo = false;
async function getRemindInfo() {
if (hasCheckedRemindInfo) {
return;
}
hasCheckedRemindInfo = true;
try {
const response = await appUserInfo();
if (response && response.code === 200) {
const data = response.data || {};
const reminders = [];
currentJobId.value = data?.jobId ?? data?.currentJobId ?? null;
currentJobName.value = data?.jobName ?? data?.currentJobName ?? '';
if (Array.isArray(data.remindList) && data.remindList.length > 0) {
reminders.push(
...data.remindList
.filter(item => typeof item === 'string' && item.trim().length > 0)
.map(item => item.trim())
);
} else {
const jobTitles = Array.isArray(data.jobTitles) ? data.jobTitles : [];
const appSkillsList = Array.isArray(data.appSkillsList) ? data.appSkillsList : [];
if (!currentJobName.value && jobTitles.length > 0) {
currentJobName.value = jobTitles[0];
}
if (jobTitles.length === 0) {
reminders.push('请完善求职期望');
}
if (appSkillsList.length === 0) {
reminders.push('请完善技能信息');
}
}
if (reminders.length === 0) {
reminders.push('暂无待完善信息');
}
remindList.value = reminders;
if (!currentJobName.value) {
currentJobName.value = '前端开发工程师';
}
openRemindPopup();
return;
const userInfo = response?.data || {};
// 优先从接口数据中获取 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;
}
throw new Error('接口返回异常');
} catch (error) {
console.error('获取提醒信息失败:', error);
currentJobId.value = 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 ??
null;
currentJobName.value = cachedUserInfo?.jobName ??
cachedUserInfo?.currentJobName ??
cachedUserInfo?.resume?.jobName ??
cachedUserInfo?.resume?.currentJobName ??
'';
}
// 如果还是没有职位信息,使用默认值
if (!currentJobName.value) {
currentJobName.value = '前端开发工程师';
currentJobName.value = '市场专员';
}
remindList.value = ['获取提醒信息失败,请稍后重试'];
openRemindPopup();
// 判断 idCard 是否存在包括空字符串、undefined、null 的情况)
const hasIdCard = idCard !== null && idCard !== undefined && idCard !== '';
if (!hasIdCard) {
remindList.value = ['请完善个人信息'];
} else {
remindList.value = ['暂无待完善信息'];
}
setTimeout(() => {
openRemindPopup();
}, 500);
} catch (error) {
// 接口调用失败时,使用缓存作为降级方案
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 = '市场专员';
}
if (!idCard || idCard === null || idCard === '') {
remindList.value = ['请完善个人信息'];
} else {
remindList.value = ['暂无待完善信息'];
}
setTimeout(() => {
openRemindPopup();
}, 500);
}
}
@@ -169,30 +250,87 @@ function handleCancel() {
}
// 确认按钮
function handleConfirm() {
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 存在,说明已经完善了信息,直接显示页面内容
// 从缓存中更新职位信息
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;
}
// 切换tab
function switchTab(index) {
activeTab.value = index;
if (index === 0 && !currentJobId.value) {
const cachedUserInfo = uni.getStorageSync('userInfo') || {};
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;
}
}
// 搜索点击
function handleSearchClick() {
// TODO: 跳转到搜索页面
console.log('搜索点击');
navTo('/pages/search/search');
}
// 菜单点击
function handleMenuClick() {
console.log('菜单点击');
// TODO: 实现菜单功能
}
// 更多点击
function handleMoreClick() {
console.log('更多点击');
// TODO: 实现更多功能
}
function normalizeSkillLevel(score) {
@@ -278,7 +416,6 @@ async function handleJobCardClick(job) {
}
skillDetailPopup.value?.open();
} catch (error) {
console.error('获取职位技能详情失败:', error);
if (fallbackSkills.length > 0) {
const fallbackSplit = splitSkillListByScore(fallbackSkills);
selectedJobPossessedSkills.value = fallbackSplit.possessed;
@@ -301,13 +438,37 @@ function handleSkillPopupClose() {
// 可以在这里处理关闭后的逻辑
}
// 处理职业推荐技能数据更新
function handleRecommendSkillsUpdated(data) {
recommendSkillsData.value = {
currentJobSkills: data.currentJobSkills || [],
recommendedJobs: data.recommendedJobs || []
};
}
// 处理职业路径数据更新
function handlePathDataUpdated(data) {
pathSkillsData.value = {
pathData: data.pathData || {
start: { title: '', skills: [] },
steps: [],
end: { title: '', skills: [] }
},
targetCareer: data.targetCareer || ''
};
}
onLoad(() => {
getRemindInfo();
});
onMounted(() => {
if (remindList.value.length > 0 && !showContent.value) {
openRemindPopup();
setTimeout(() => {
if (remindPopup.value) {
openRemindPopup();
}
}, 300);
}
});
</script>
@@ -349,7 +510,6 @@ onMounted(() => {
position: relative;
z-index: 1;
overflow: hidden;
padding-bottom: 88rpx;
}
@@ -357,6 +517,8 @@ onMounted(() => {
flex: 1;
height: 0;
width: 100%;
padding-bottom: calc(88rpx + env(safe-area-inset-bottom));
box-sizing: border-box;
}
.tabbar-wrapper {
@@ -366,4 +528,4 @@ onMounted(() => {
right: 0;
z-index: 999;
}
</style>
</style>