H5端首页显示内容修改

This commit is contained in:
冯辉
2025-11-18 10:57:59 +08:00
parent 7ee291158e
commit 5c7bd3a6bc
5 changed files with 40 additions and 30 deletions

View File

@@ -129,7 +129,7 @@
// 根据公司ID获取公司详情
function getCompanyDetailsById(companyId) {
// 使用全局注入的$api调用接口
$api.createRequest('/app/company/' + companyId, 'GET', 9100).then((resData) => {
$api.createRequest('/app/company/' + companyId).then((resData) => {
if (resData && resData.code === 200 && resData.data) {
console.log('Company details:', resData.data);
// 确保数据格式符合页面需求,并为关键字段提供默认值

View File

@@ -443,6 +443,32 @@ function getClass(index) {
return '';
}
}
// 格式化发布时间
function formatPublishTime(dateString) {
if (!dateString) return '';
const date = new Date(dateString);
const now = new Date();
const diffTime = Math.abs(now - date);
const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24));
if (diffDays === 0) {
return '今天发布';
} else if (diffDays === 1) {
return '昨天发布';
} else if (diffDays < 7) {
return `${diffDays}天前发布`;
} else if (diffDays < 30) {
const weeks = Math.floor(diffDays / 7);
return `${weeks}周前发布`;
} else {
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
return `${year}-${month.toString().padStart(2, '0')}-${day.toString().padStart(2, '0')}`;
}
}
</script>
<style lang="stylus" scoped>