单位详情页面发布时间优化
This commit is contained in:
@@ -48,15 +48,12 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="card-tags">
|
<view class="card-tags">
|
||||||
<view class="tag jy">
|
<view class="tag jy">
|
||||||
<image :src="`${baseUrl}/jobfair/jy.png`" mode=""></image>
|
|
||||||
{{ getExperienceLabel(job.experience) }}
|
{{ getExperienceLabel(job.experience) }}
|
||||||
</view>
|
</view>
|
||||||
<view class="tag xl">
|
<view class="tag xl">
|
||||||
<image :src="`${baseUrl}/jobfair/xx.png`" mode=""></image>
|
|
||||||
{{ getEducationLabel(job.education) }}
|
{{ getEducationLabel(job.education) }}
|
||||||
</view>
|
</view>
|
||||||
<view class="tag yd" v-if="job.vacancies">
|
<view class="tag yd" v-if="job.vacancies">
|
||||||
<image :src="`${baseUrl}/jobfair/lx-1.png`" mode=""></image>
|
|
||||||
招聘{{ job.vacancies }}人
|
招聘{{ job.vacancies }}人
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -66,8 +63,7 @@
|
|||||||
{{ job.jobLocation }}
|
{{ job.jobLocation }}
|
||||||
</view>
|
</view>
|
||||||
<view class="push-time" v-if="job.postingDate">
|
<view class="push-time" v-if="job.postingDate">
|
||||||
<image class="point3" src="/static/icon/point3.png"></image>
|
{{ formatPublishTime(job.postingDate) }}
|
||||||
{{ job.postingDate.split(' ')[0] }}
|
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
@@ -323,7 +319,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 格式化发布时间
|
// 格式化发布时间为相对时间
|
||||||
function formatPublishTime(publishTime) {
|
function formatPublishTime(publishTime) {
|
||||||
if (!publishTime) return '';
|
if (!publishTime) return '';
|
||||||
|
|
||||||
@@ -331,17 +327,30 @@
|
|||||||
const date = new Date(publishTime);
|
const date = new Date(publishTime);
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const diffTime = Math.abs(now - date);
|
const diffTime = Math.abs(now - date);
|
||||||
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
const diffSeconds = Math.floor(diffTime / 1000);
|
||||||
|
const diffMinutes = Math.floor(diffSeconds / 60);
|
||||||
|
const diffHours = Math.floor(diffMinutes / 60);
|
||||||
|
const diffDays = Math.floor(diffHours / 24);
|
||||||
|
const diffWeeks = Math.floor(diffDays / 7);
|
||||||
|
const diffMonths = Math.floor(diffDays / 30);
|
||||||
|
const diffYears = Math.floor(diffDays / 365);
|
||||||
|
|
||||||
if (diffDays === 1) {
|
if (diffSeconds < 60) {
|
||||||
return '今天发布';
|
return '刚刚发布';
|
||||||
} else if (diffDays <= 7) {
|
} else if (diffMinutes < 60) {
|
||||||
|
return `${diffMinutes}分钟前发布`;
|
||||||
|
} else if (diffHours < 24) {
|
||||||
|
return `${diffHours}小时前发布`;
|
||||||
|
} else if (diffDays === 1) {
|
||||||
|
return '昨天发布';
|
||||||
|
} else if (diffDays < 7) {
|
||||||
return `${diffDays}天前发布`;
|
return `${diffDays}天前发布`;
|
||||||
|
} else if (diffWeeks < 4) {
|
||||||
|
return `${diffWeeks}周前发布`;
|
||||||
|
} else if (diffMonths < 12) {
|
||||||
|
return `${diffMonths}个月前发布`;
|
||||||
} else {
|
} else {
|
||||||
const year = date.getFullYear();
|
return `${diffYears}年前发布`;
|
||||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
||||||
const day = String(date.getDate()).padStart(2, '0');
|
|
||||||
return `${year}-${month}-${day}发布`;
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('格式化发布时间失败:', error);
|
console.error('格式化发布时间失败:', error);
|
||||||
|
|||||||
Reference in New Issue
Block a user