diff --git a/packageA/pages/UnitDetails/UnitDetails.vue b/packageA/pages/UnitDetails/UnitDetails.vue index f6af695..f631944 100644 --- a/packageA/pages/UnitDetails/UnitDetails.vue +++ b/packageA/pages/UnitDetails/UnitDetails.vue @@ -18,9 +18,6 @@ {{ companyInfo?.name || '未知公司' }} - - 互联网 - {{ getScaleLabel(companyInfo?.scale) }} @@ -41,41 +38,41 @@ - 在招职位 - @@ -121,7 +118,7 @@ pageSize: 10, }); const companyInfo = ref({ - jobInfoList: [], + jobList: [], }); const baseUrl = config.imgBaseUrl; const getItemBackgroundStyle = (imageName) => ({ @@ -146,7 +143,7 @@ scale: resData.data.scale || '未知规模', description: resData.data.description || '暂无公司介绍', isCollection: resData.data.isCollection || 0, - jobInfoList: [] // 新数据格式中没有岗位列表,初始化为空数组 + jobList: resData.data.jobList || [] // 使用正确的jobList字段 }; console.log('Company details loaded successfully'); } else { @@ -157,7 +154,7 @@ scale: '-', description: '无法获取公司信息,请稍后重试', isCollection: 0, - jobInfoList: [] + jobList: [] }; } }).catch((error) => { @@ -168,7 +165,7 @@ scale: '-', description: '网络请求失败,请检查网络连接', isCollection: 0, - jobInfoList: [] + jobList: [] }; }); } @@ -213,7 +210,7 @@ // 获取企业规模字典数据 onLoad(async (options) => { // 初始化companyInfo - companyInfo.value = { jobInfoList: [] }; + companyInfo.value = { jobList: [] }; // 加载字典数据 await dictStore.getDictData(); @@ -222,7 +219,7 @@ companyInfo.value = JSON.parse(options.job); } catch (error) { console.error('Error parsing job data:', error); - companyInfo.value = { jobInfoList: [] }; + companyInfo.value = { jobList: [] }; } // 处理companyId参数 } else if (options.companyId) { @@ -237,7 +234,7 @@ getCompanyDetailsById(options.bussinessId); } else { console.warn('No valid parameters provided'); - companyInfo.value = { jobInfoList: [] }; + companyInfo.value = { jobList: [] }; } }); @@ -273,6 +270,91 @@ return '-'; } } + + // 根据experience值获取对应的文本 + function getExperienceLabel(experience) { + if (experience === undefined || experience === null || experience === '') return '经验不限'; + + try { + const experienceStr = String(experience); + const label = dictStore.dictLabel('experience', experienceStr); + if (!label) { + const defaultExperienceMap = { + '0': '经验不限', + '1': '1年以内', + '2': '1-3年', + '3': '3-5年', + '4': '5-10年', + '5': '10年以上' + }; + return defaultExperienceMap[experienceStr] || '经验不限'; + } + return label; + } catch (error) { + console.error('获取经验标签失败:', error); + return '经验不限'; + } + } + + // 根据education值获取对应的文本 + function getEducationLabel(education) { + if (education === undefined || education === null || education === '') return '学历不限'; + + try { + const educationStr = String(education); + const label = dictStore.dictLabel('education', educationStr); + if (!label) { + const defaultEducationMap = { + '-1': '学历不限', + '1': '初中及以下', + '2': '高中', + '3': '中专', + '4': '大专', + '5': '本科', + '6': '硕士', + '7': '博士' + }; + return defaultEducationMap[educationStr] || '学历不限'; + } + return label; + } catch (error) { + console.error('获取学历标签失败:', error); + return '学历不限'; + } + } + + // 格式化发布时间 + function formatPublishTime(publishTime) { + if (!publishTime) return ''; + + try { + const date = new Date(publishTime); + const now = new Date(); + const diffTime = Math.abs(now - date); + const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)); + + if (diffDays === 1) { + return '今天发布'; + } else if (diffDays <= 7) { + return `${diffDays}天前发布`; + } else { + const year = date.getFullYear(); + const month = String(date.getMonth() + 1).padStart(2, '0'); + const day = String(date.getDate()).padStart(2, '0'); + return `${year}-${month}-${day}发布`; + } + } catch (error) { + console.error('格式化发布时间失败:', error); + return ''; + } + } + + // 跳转到职位详情页面 + function navToJobDetail(jobId) { + if (jobId) { + navTo(`/packageA/pages/post/post?jobId=${encodeURIComponent(jobId)}`); + } + }