Merge remote-tracking branch 'origin/main'
# Conflicts: # packageA/pages/UnitDetails/UnitDetails.vue # pages.json # pages/careerfair/careerfair.vue
This commit is contained in:
@@ -16,25 +16,52 @@ const props = defineProps({
|
||||
},
|
||||
});
|
||||
|
||||
// 获取雷达图数据
|
||||
function getRadarData() {
|
||||
if (!props.value || !props.value.radarChart) {
|
||||
// 如果没有数据,使用默认值0
|
||||
const defaultRadarChart = {
|
||||
skill: 0,
|
||||
experience: 0,
|
||||
education: 0,
|
||||
salary: 0,
|
||||
age: 0,
|
||||
location: 0
|
||||
};
|
||||
const labels = ['学历', '年龄', '工作地', '技能', '工作经验', '期望薪资'];
|
||||
const data = [defaultRadarChart.education, defaultRadarChart.age, defaultRadarChart.location,
|
||||
defaultRadarChart.skill, defaultRadarChart.experience, defaultRadarChart.salary].map((item) => item * 0.05);
|
||||
return { labels, data };
|
||||
}
|
||||
|
||||
const { skill, experience, education, salary, age, location } = props.value.radarChart;
|
||||
const labels = ['学历', '年龄', '工作地', '技能', '工作经验', '期望薪资'];
|
||||
const data = [education, age, location, skill, experience, salary].map((item) => item * 0.05);
|
||||
return { labels, data };
|
||||
}
|
||||
|
||||
// 监听页面初始化
|
||||
onMounted(() => {
|
||||
if (Object.keys(props.value).length > 0) {
|
||||
rawRadarChart();
|
||||
}
|
||||
// 延迟执行,确保 canvas 已经渲染
|
||||
setTimeout(() => {
|
||||
const { labels, data } = getRadarData();
|
||||
rawRadarChart(labels, data);
|
||||
}, 100);
|
||||
});
|
||||
|
||||
// 监听 props.value 变化
|
||||
watch(
|
||||
() => props.value,
|
||||
(newVal) => {
|
||||
if (newVal && Object.keys(newVal).length > 0) {
|
||||
const { skill, experience, education, salary, age, location } = newVal.radarChart;
|
||||
const labels = ['学历', '年龄', '工作地', '技能', '工作经验', '期望薪资'];
|
||||
const data = [education, age, location, skill, experience, salary].map((item) => item * 0.05);
|
||||
rawRadarChart(labels, data);
|
||||
if (newVal) {
|
||||
// 延迟执行,确保数据更新完成
|
||||
setTimeout(() => {
|
||||
const { labels, data } = getRadarData();
|
||||
rawRadarChart(labels, data);
|
||||
}, 50);
|
||||
}
|
||||
},
|
||||
{ deep: true, immediate: false } // deep 递归监听对象内部变化
|
||||
{ deep: true, immediate: true } // deep 递归监听对象内部变化,immediate 立即执行一次
|
||||
);
|
||||
|
||||
function rawRadarChart(labels, data) {
|
||||
|
||||
@@ -208,7 +208,20 @@ const jobInfo = ref({});
|
||||
const state = reactive({});
|
||||
const mapCovers = ref([]);
|
||||
const jobIdRef = ref();
|
||||
const raderData = ref({});
|
||||
// 竞争力分析数据,初始化为包含默认值的完整结构,确保雷达图能正常渲染
|
||||
const raderData = ref({
|
||||
matchScore: 0,
|
||||
rank: 0,
|
||||
percentile: 0,
|
||||
radarChart: {
|
||||
skill: 0,
|
||||
experience: 0,
|
||||
education: 0,
|
||||
salary: 0,
|
||||
age: 0,
|
||||
location: 0
|
||||
}
|
||||
});
|
||||
const videoPalyerRef = ref(null);
|
||||
const explainUrlRef = ref('');
|
||||
|
||||
@@ -247,10 +260,17 @@ onLoad((option) => {
|
||||
});
|
||||
|
||||
onShow(() => {
|
||||
const option = parseQueryParams(); // 兼容微信内置浏览器
|
||||
if (option.jobId) {
|
||||
initLoad(option);
|
||||
// 仅在 H5 环境中从 URL 获取参数(小程序环境中 onShow 不会传递 URL 参数)
|
||||
// #ifdef H5
|
||||
try {
|
||||
const option = parseQueryParams(); // 兼容微信内置浏览器
|
||||
if (option.jobId) {
|
||||
initLoad(option);
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('onShow 中解析 URL 参数失败:', e);
|
||||
}
|
||||
// #endif
|
||||
});
|
||||
|
||||
function initLoad(option) {
|
||||
@@ -318,8 +338,59 @@ function getTextWidth(text, size = 12) {
|
||||
|
||||
function getCompetivetuveness(jobId) {
|
||||
$api.createRequest(`/app/job/competitiveness/${jobId}`, {}, 'GET').then((resData) => {
|
||||
raderData.value = resData.data;
|
||||
currentStep.value = resData.data.matchScore * 0.04;
|
||||
// 如果接口返回的数据为 null 或空,使用默认值0
|
||||
if (resData && resData.data) {
|
||||
// 确保 radarChart 字段存在,如果不存在则使用默认值
|
||||
const radarChart = resData.data.radarChart || {
|
||||
skill: 0,
|
||||
experience: 0,
|
||||
education: 0,
|
||||
salary: 0,
|
||||
age: 0,
|
||||
location: 0
|
||||
};
|
||||
|
||||
raderData.value = {
|
||||
matchScore: resData.data.matchScore || 0,
|
||||
rank: resData.data.rank || 0,
|
||||
percentile: resData.data.percentile || 0,
|
||||
radarChart: radarChart
|
||||
};
|
||||
currentStep.value = (resData.data.matchScore || 0) * 0.04;
|
||||
} else {
|
||||
// 接口返回 null 或空数据时,使用默认值0
|
||||
raderData.value = {
|
||||
matchScore: 0,
|
||||
rank: 0,
|
||||
percentile: 0,
|
||||
radarChart: {
|
||||
skill: 0,
|
||||
experience: 0,
|
||||
education: 0,
|
||||
salary: 0,
|
||||
age: 0,
|
||||
location: 0
|
||||
}
|
||||
};
|
||||
currentStep.value = 0;
|
||||
}
|
||||
}).catch((error) => {
|
||||
// 接口请求失败时,使用默认值0
|
||||
console.error('获取竞争力分析失败:', error);
|
||||
raderData.value = {
|
||||
matchScore: 0,
|
||||
rank: 0,
|
||||
percentile: 0,
|
||||
radarChart: {
|
||||
skill: 0,
|
||||
experience: 0,
|
||||
education: 0,
|
||||
salary: 0,
|
||||
age: 0,
|
||||
location: 0
|
||||
}
|
||||
};
|
||||
currentStep.value = 0;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user