= 职业规划推荐
This commit is contained in:
@@ -26,15 +26,9 @@ const activeTab = ref(0);
|
||||
const selectedJobTitle = ref('');
|
||||
const selectedJobPossessedSkills = ref([]);
|
||||
const selectedJobImprovementSkills = ref([]);
|
||||
const isLoadingJobSkill = ref(false);
|
||||
const currentJobId = ref(null);
|
||||
const currentJobName = ref('');
|
||||
|
||||
// 技能发展所需的数据
|
||||
const recommendSkillsData = ref({
|
||||
currentJobSkills: [],
|
||||
recommendedJobs: []
|
||||
});
|
||||
|
||||
const pathSkillsData = ref({
|
||||
pathData: {
|
||||
@@ -319,121 +313,6 @@ function handleMoreClick() {
|
||||
// TODO: 实现更多功能
|
||||
}
|
||||
|
||||
function normalizeSkillLevel(score) {
|
||||
const numericScore = Number(score);
|
||||
if (Number.isNaN(numericScore)) {
|
||||
return 0;
|
||||
}
|
||||
const rounded = Math.round(numericScore);
|
||||
return Math.max(1, Math.min(6, rounded));
|
||||
}
|
||||
|
||||
function splitSkillListByScore(skills = []) {
|
||||
if (!Array.isArray(skills) || skills.length === 0) {
|
||||
return {
|
||||
possessed: [],
|
||||
improvement: []
|
||||
};
|
||||
}
|
||||
|
||||
const sorted = [...skills].sort((a, b) => (Number(b.skillScore) || 0) - (Number(a.skillScore) || 0));
|
||||
const midpoint = Math.ceil(sorted.length / 2);
|
||||
const mapSkill = (item) => ({
|
||||
name: item?.skillName || '',
|
||||
level: normalizeSkillLevel(item?.skillScore)
|
||||
});
|
||||
|
||||
return {
|
||||
possessed: sorted.slice(0, midpoint).map(mapSkill),
|
||||
improvement: sorted.slice(midpoint).map(mapSkill)
|
||||
};
|
||||
}
|
||||
|
||||
// 处理职位卡片点击
|
||||
async function handleJobCardClick(job) {
|
||||
if (!job) {
|
||||
return;
|
||||
}
|
||||
|
||||
selectedJobTitle.value = job.title || job.jobName || '';
|
||||
selectedJobPossessedSkills.value = [];
|
||||
selectedJobImprovementSkills.value = [];
|
||||
|
||||
if (isLoadingJobSkill.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
isLoadingJobSkill.value = true;
|
||||
uni.showLoading({
|
||||
title: '加载中...',
|
||||
mask: true
|
||||
});
|
||||
|
||||
try {
|
||||
// 从 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?.name || item?.nameStr || '',
|
||||
skillScore: item?.levels || 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: '暂无技能数据',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
const fallbackSplit = splitSkillListByScore(fallbackSkills);
|
||||
selectedJobPossessedSkills.value = fallbackSplit.possessed;
|
||||
selectedJobImprovementSkills.value = fallbackSplit.improvement;
|
||||
} else {
|
||||
selectedJobPossessedSkills.value = possessed;
|
||||
selectedJobImprovementSkills.value = improvement;
|
||||
}
|
||||
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;
|
||||
selectedJobImprovementSkills.value = fallbackSplit.improvement;
|
||||
skillDetailPopup.value?.open();
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '获取技能信息失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
isLoadingJobSkill.value = false;
|
||||
uni.hideLoading();
|
||||
}
|
||||
}
|
||||
|
||||
// 处理技能弹出层关闭
|
||||
function handleSkillPopupClose() {
|
||||
// 可以在这里处理关闭后的逻辑
|
||||
}
|
||||
|
||||
// 处理职业推荐技能数据更新
|
||||
function handleRecommendSkillsUpdated(data) {
|
||||
recommendSkillsData.value = {
|
||||
currentJobSkills: data.currentJobSkills || [],
|
||||
recommendedJobs: data.recommendedJobs || []
|
||||
};
|
||||
}
|
||||
|
||||
// 处理职业路径数据更新
|
||||
function handlePathDataUpdated(data) {
|
||||
pathSkillsData.value = {
|
||||
@@ -485,7 +364,6 @@ onMounted(() => {
|
||||
:job-title="selectedJobTitle"
|
||||
:possessed-skills="selectedJobPossessedSkills"
|
||||
:improvement-skills="selectedJobImprovementSkills"
|
||||
@close="handleSkillPopupClose"
|
||||
/>
|
||||
|
||||
<!-- 页面内容 -->
|
||||
@@ -506,13 +384,7 @@ onMounted(() => {
|
||||
|
||||
<!-- 内容区域 -->
|
||||
<scroll-view scroll-y class="content-scroll">
|
||||
<CareerRecommend
|
||||
v-if="activeTab === 0"
|
||||
:current-job-id="currentJobId"
|
||||
:current-job-name="currentJobName"
|
||||
@job-card-click="handleJobCardClick"
|
||||
@skills-updated="handleRecommendSkillsUpdated"
|
||||
/>
|
||||
<CareerRecommend v-if="activeTab === 0"/>
|
||||
<CareerPath
|
||||
v-else-if="activeTab === 1"
|
||||
:current-job-name="currentJobName"
|
||||
@@ -533,6 +405,65 @@ onMounted(() => {
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss">
|
||||
.query-btn {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
line-height: 40rpx;
|
||||
border-radius: 20rpx;
|
||||
background: linear-gradient(180deg, rgba(18, 125, 240, 1) 0%, rgba(59, 14, 123, 0.71) 100%);
|
||||
color: rgba(255, 255, 255, 1);
|
||||
font-size: 28rpx;
|
||||
text-align: center;
|
||||
font-family: '阿里巴巴普惠体3.0-regular', 'PingFang SC', 'Helvetica Neue', Helvetica, Arial, 'Microsoft YaHei', sans-serif;
|
||||
border: 2rpx solid rgba(187, 187, 187, 1);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 12rpx;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 26rpx;
|
||||
text-align: center;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.input-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 30rpx;
|
||||
}
|
||||
|
||||
.input-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12rpx;
|
||||
}
|
||||
|
||||
.picker-field {
|
||||
background-color: #F5F5F5;
|
||||
border: 1rpx solid #E0E0E0;
|
||||
border-radius: 12rpx;
|
||||
padding: 20rpx 24rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.picker-text {
|
||||
font-size: 28rpx;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.picker-placeholder {
|
||||
font-size: 28rpx;
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.career-planning-page {
|
||||
width: 100vw;
|
||||
|
||||
Reference in New Issue
Block a user