Feat:资讯显示最新两条数据

This commit is contained in:
LinCyJang
2025-07-04 00:02:41 +08:00
parent a3fb2e5bcf
commit 383318eb6b
2 changed files with 90 additions and 1 deletions
+90
View File
@@ -343,6 +343,77 @@
</view> </view>
</view> </view>
</view> </view>
<view class="comment-list" v-if="item.latestReplyList">
<view class="v12-mt-2" v-for="(comment, i) in item.latestReplyList" :key="i">
<view class="user-info v12-align-center">
<view class="user-avatar">
<u-avatar :src="comment.userAvatar"></u-avatar>
</view>
<view class="user-name v12-ml-3">
<view class="v12-font-bold v12-dark-text v12-font-32">
<text>{{ comment.userNickName }}</text>
<text v-if="comment.userIsAdmin" class="v12-ml-1 v12-primary v12-white-text v12-font-24 v12-font-weight-400 v12-px-1 v12-radius-8">
{{ '店主' }}
</text>
</view>
<view class="v12-font-22 v12-secondary-dark-text v12-mt-1">
<text>{{ formatterTime(comment.createTime) }}</text>
<text v-if="comment.at">
{{ ' 回复 ' + comment.at.atNickName }}
</text>
</view>
</view>
</view>
<view class="user-info v12-d-flex" >
<view class="user-avatar">
<view style="opacity: 0;">
<u-avatar></u-avatar>
</view>
</view>
<view class="user-name v12-ml-3">
<view class="v12-font-28 v12-dark-text">
{{ comment.reply }}
</view>
<view v-if="comment.children">
<view class="v12-mt-2" v-for="(_comment, atIndex) in comment.children" :key="atIndex">
<view class="user-info v12-align-center">
<view class="user-avatar">
<u-avatar size="35" :src="_comment.userAvatar"></u-avatar>
</view>
<view class="user-name v12-ml-3">
<view class="v12-font-bold v12-dark-text v12-font-32">
<text>{{ _comment.userNickName }}</text>
<text v-if="_comment.userIsAdmin" class="v12-ml-1 v12-primary v12-white-text v12-font-24 v12-font-weight-400 v12-px-1 v12-radius-8">
{{ '店主' }}
</text>
</view>
<view class="v12-font-22 v12-secondary-dark-text v12-mt-1">
<text>{{ formatterTime(_comment.createTime) }}</text>
<text v-if="_comment.at && _comment.parentReplyId !== comment.id">
{{ ' 回复 ' + _comment.at.atNickName }}
</text>
</view>
</view>
</view>
<view class="user-info v12-align-center">
<view class="user-avatar">
<view style="opacity: 0;">
<u-avatar size="35"></u-avatar>
</view>
</view>
<view class="user-name v12-ml-3">
<view class="v12-font-28 v12-dark-text">
{{ _comment.reply }}
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view> </view>
</view> </view>
</view> </view>
@@ -622,6 +693,25 @@ export default {
} }
}, },
methods: { methods: {
formatterTime(time) {
const now = new Date();
const date = new Date(time);
const diff = now - date;
const diffMin = Math.floor(diff / 1000 / 60);
const diffHour = Math.floor(diff / 1000 / 60 / 60);
const diffDay = Math.floor(diff / 1000 / 60 / 60 / 24);
if (diffMin < 1) {
return "刚刚";
} else if (diffHour < 1) {
return diffMin + "分钟前";
} else if (diffDay < 1) {
return diffHour + "小时前";
} else if (diffDay < 7) {
return diffDay + "天前";
} else {
return date.getFullYear() + "年" + (date.getMonth() + 1) + "月" + date.getDate() + "日";
}
},
goHome(e) { goHome(e) {
this.id = e.id this.id = e.id
this.isLoad = false this.isLoad = false
-1
View File
@@ -275,7 +275,6 @@ export default {
} else { } else {
return date.getFullYear() + "年" + (date.getMonth() + 1) + "月" + date.getDate() + "日"; return date.getFullYear() + "年" + (date.getMonth() + 1) + "月" + date.getDate() + "日";
} }
}, },
/** /**
* 发评论 * 发评论