ai页面岗位跳转bug修复
This commit is contained in:
@@ -19,30 +19,31 @@ const md = new MarkdownIt({
|
||||
if (lang === 'job-json') {
|
||||
const result = safeExtractJson(str);
|
||||
if (result) { // json解析成功
|
||||
let jobId = result.appJobUrl;
|
||||
let encryptJobId = result.appJobUrl;
|
||||
// If appJobUrl contains 'jobId=', extract the value after it, otherwise use it directly
|
||||
if (jobId && jobId.includes('jobId=')) {
|
||||
jobId = jobId.split('jobId=')[1];
|
||||
// 如果还有额外的参数,只取jobId部分
|
||||
if (jobId.includes('&')) {
|
||||
jobId = jobId.split('&')[0];
|
||||
if (encryptJobId && encryptJobId.includes('jobId=')) {
|
||||
encryptJobId = encryptJobId.split('jobId=')[1];
|
||||
// 如果还有额外的参数,只取encryptJobId部分
|
||||
if (encryptJobId.includes('&')) {
|
||||
encryptJobId = encryptJobId.split('&')[0];
|
||||
}
|
||||
}
|
||||
console.log('Job JSON result:', result, 'Extracted jobId:', jobId);
|
||||
|
||||
// 确保jobId有效
|
||||
if (!jobId || jobId === 'undefined' || jobId === 'null') {
|
||||
console.error('Invalid jobId extracted:', jobId, 'from appJobUrl:', result.appJobUrl);
|
||||
// 尝试从其他字段获取jobId
|
||||
console.log('Job JSON result:', result, 'Extracted encryptJobId:', encryptJobId);
|
||||
|
||||
// 确保encryptJobId有效
|
||||
if (!encryptJobId || encryptJobId === 'undefined' || encryptJobId === 'null') {
|
||||
console.error('Invalid encryptJobId extracted:', encryptJobId, 'from appJobUrl:', result.appJobUrl);
|
||||
// 尝试从其他字段获取encryptJobId
|
||||
if (result.jobId) {
|
||||
jobId = result.jobId;
|
||||
console.log('Using jobId from result.jobId:', jobId);
|
||||
encryptJobId = result.jobId;
|
||||
console.log('Using jobId from result.jobId as encryptJobId:', encryptJobId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 添加到岗位卡片列表,供小程序端单独渲染
|
||||
jobCardsList.push({
|
||||
jobId,
|
||||
jobId: encryptJobId,
|
||||
encryptJobId,
|
||||
jobTitle: result.jobTitle,
|
||||
salary: result.salary,
|
||||
location: result.location,
|
||||
@@ -50,16 +51,16 @@ const md = new MarkdownIt({
|
||||
education: result.education,
|
||||
experience: result.experience
|
||||
});
|
||||
|
||||
|
||||
// 生成岗位卡片HTML,注意:微信小程序rich-text组件只支持部分HTML属性
|
||||
// 使用普通的href属性,微信小程序rich-text会将其转换为可点击链接
|
||||
// 添加data-job-id属性,方便获取jobId
|
||||
// 添加data-encrypt-job-id属性,方便获取encryptJobId
|
||||
// 为所有平台添加onclick事件,微信小程序可能会忽略,但H5端会生效
|
||||
// 内联基础样式确保在所有平台上正确显示(使用px单位以确保H5兼容性)
|
||||
let domContext = `<a class="custom-card" href="/packageA/pages/post/post?jobId=${jobId}" data-job-id="${jobId}" data-jobid="${jobId}" onclick="if(typeof uni !== 'undefined'){uni.navigateTo({url: '/packageA/pages/post/post?jobId=${jobId}'});return false;}" style="display: flex; flex-direction: column; margin-bottom: 11px; background: #FFFFFF; box-shadow: 0 0 4px rgba(0,0,0,0.04); border-radius: 10px; padding: 14px 12px; font-weight: 400; font-size: 14px; color: #333333; text-decoration: none; overflow: hidden; box-sizing: border-box; width: 100%; max-width: 100%;"><div class="card-title" style="font-weight: 600; display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;"><span class="title-text" style="font-family: 'PingFangSC-Medium', 'PingFang SC', 'Helvetica Neue', Helvetica, Arial, 'Microsoft YaHei', sans-serif; font-size: 16px; line-height: 1.4; color: #333333; max-width: calc(100% - 80px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${result.jobTitle}</span><div class="card-salary" style="font-family: DIN-Medium; font-size: 16px; color: #4C6EFB; line-height: 1.4; font-weight: 500;">${result.salary}</div></div><div class="card-company" style="margin-bottom: 9px; font-size: 14px; color: #6C7282; line-height: 1.4; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${result.location}·${result.companyName}</div><div class="card-info" style="display: flex; align-items: center; justify-content: space-between; padding-right: 20px;"><div class="info-item" style="display: flex; position: relative; align-items: center;"><div class="card-tag" style="font-weight: 400; font-size: 12px; color: #6C7282; width: fit-content; background: #F4F4F4; border-radius: 2px; padding: 3px 10px; margin-right: 10px; display: inline-flex; align-items: center; justify-content: center; height: 15px; line-height: 15px;">${result.education}</div><div class="card-tag" style="font-weight: 400; font-size: 12px; color: #6C7282; width: fit-content; background: #F4F4F4; border-radius: 2px; padding: 3px 10px; margin-right: 10px; display: inline-flex; align-items: center; justify-content: center; height: 15px; line-height: 15px;">${result.experience}</div></div><div class="info-item" style="color: #256BFA; font-size: 14px; padding-right: 5px; position: relative;">查看详情<div class="position-nav" style="position: absolute; right: -5px; top: 50%; transform: translateY(-50%);"></div></div></div></a>`
|
||||
let domContext = `<a class="custom-card" href="/packageA/pages/post/post?encryptJobId=${encryptJobId}" data-encrypt-job-id="${encryptJobId}" onclick="if(typeof uni !== 'undefined'){uni.navigateTo({url: '/packageA/pages/post/post?encryptJobId=${encryptJobId}'});return false;}" style="display: flex; flex-direction: column; margin-bottom: 11px; background: #FFFFFF; box-shadow: 0 0 4px rgba(0,0,0,0.04); border-radius: 10px; padding: 14px 12px; font-weight: 400; font-size: 14px; color: #333333; text-decoration: none; overflow: hidden; box-sizing: border-box; width: 100%; max-width: 100%;"><div class="card-title" style="font-weight: 600; display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;"><span class="title-text" style="font-family: 'PingFangSC-Medium', 'PingFang SC', 'Helvetica Neue', Helvetica, Arial, 'Microsoft YaHei', sans-serif; font-size: 16px; line-height: 1.4; color: #333333; max-width: calc(100% - 80px); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${result.jobTitle}</span><div class="card-salary" style="font-family: DIN-Medium; font-size: 16px; color: #4C6EFB; line-height: 1.4; font-weight: 500;">${result.salary}</div></div><div class="card-company" style="margin-bottom: 9px; font-size: 14px; color: #6C7282; line-height: 1.4; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${result.location}·${result.companyName}</div><div class="card-info" style="display: flex; align-items: center; justify-content: space-between; padding-right: 20px;"><div class="info-item" style="display: flex; position: relative; align-items: center;"><div class="card-tag" style="font-weight: 400; font-size: 12px; color: #6C7282; width: fit-content; background: #F4F4F4; border-radius: 2px; padding: 3px 10px; margin-right: 10px; display: inline-flex; align-items: center; justify-content: center; height: 15px; line-height: 15px;">${result.education}</div><div class="card-tag" style="font-weight: 400; font-size: 12px; color: #6C7282; width: fit-content; background: #F4F4F4; border-radius: 2px; padding: 3px 10px; display: inline-flex; align-items: center; justify-content: center; height: 15px; line-height: 15px;">${result.experience}</div></div><div class="info-item">查看详情<div class="position-nav" style="width: 14px; height: 14px; background: url('@/static/svg/position-nav.svg') center center no-repeat; background-size: 100% 100%; margin-left: 10px;padding-right: 50rpx"></div></div></div></a>`
|
||||
if (result.data) {
|
||||
jobMoreMap.set(jobId, result.data)
|
||||
domContext += `<a class="custom-more" href="/packageA/pages/moreJobs/moreJobs?jobId=${jobId}" data-job-id="${jobId}" data-jobid="${jobId}" onclick="if(typeof uni !== 'undefined'){uni.navigateTo({url: '/packageA/pages/moreJobs/moreJobs?jobId=${jobId}'});return false;}" style="display: flex; justify-content: center; align-items: center; color: #FFFFFF; background: linear-gradient(135deg, #256BFA 0%, #9E74FD 100%); border-radius: 25px; padding: 10px 16px; margin: 10px 0; font-size: 14px; font-weight: 600; box-shadow: 0 4px 12px rgba(37, 107, 250, 0.3); text-decoration: none; box-sizing: border-box; width: 100%;">查看更多岗位<div class="more-icon" style="width: 16px; height: 16px; background: url('@/static/svg/seemore.svg') center center no-repeat; background-size: 100% 100%; margin-left: 6px;"></div></a>`
|
||||
jobMoreMap.set(encryptJobId, result.data)
|
||||
domContext += `<a class="custom-more" href="/packageA/pages/moreJobs/moreJobs?encryptJobId=${encryptJobId}" data-encrypt-job-id="${encryptJobId}" onclick="if(typeof uni !== 'undefined'){uni.navigateTo({url: '/packageA/pages/moreJobs/moreJobs?encryptJobId=${encryptJobId}'});return false;}" style="display: flex; justify-content: center; align-items: center; color: #FFFFFF; background: linear-gradient(135deg, #256BFA 0%, #9E74FD 100%); border-radius: 25px; padding: 10px 16px; margin: 10px 0; font-size: 14px; font-weight: 600; box-shadow: 0 4px 12px rgba(37, 107, 250, 0.3); text-decoration: none; box-sizing: border-box; width: 100%;">查看更多岗位<div class="more-icon" style="width: 16px; height: 16px; background: url('@/static/svg/seemore.svg') center center no-repeat; background-size: 100% 100%; margin-left: 6px;"></div></a>`
|
||||
}
|
||||
return domContext
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user