时间展示优化
parent
f49fc45272
commit
e5ea9577ac
|
|
@ -19,8 +19,10 @@
|
|||
@click="gotoDevice(item)"
|
||||
class="message-item"
|
||||
>
|
||||
<!-- 时间标签 -->
|
||||
<view class="time-label">{{ formatTime(item.time) }}</view>
|
||||
<!-- 时间标签:如果是第一条或者与上一条时间不同才显示 -->
|
||||
<view class="time-label" v-if="index === 0 || !isSameMinute(item.time, messageList[index - 1].time)">
|
||||
{{ formatTime(item.time) }}
|
||||
</view>
|
||||
|
||||
<!-- <!– 点赞消息卡片 –>
|
||||
<view class="like-card" v-if="item.type === 'like'">
|
||||
|
|
@ -140,6 +142,19 @@ export default {
|
|||
this.getSortDate();
|
||||
},
|
||||
methods: {
|
||||
goTo(id) {
|
||||
this.scrollId = id;
|
||||
},
|
||||
// 判断两个时间是否是同一天同一分钟
|
||||
isSameMinute(time1, time2) {
|
||||
const date1 = new Date(time1);
|
||||
const date2 = new Date(time2);
|
||||
return date1.getFullYear() === date2.getFullYear() &&
|
||||
date1.getMonth() === date2.getMonth() &&
|
||||
date1.getDate() === date2.getDate() &&
|
||||
date1.getHours() === date2.getHours() &&
|
||||
date1.getMinutes() === date2.getMinutes();
|
||||
},
|
||||
formatTime(timeStr) {
|
||||
const now = new Date();
|
||||
const target = new Date(timeStr);
|
||||
|
|
|
|||
Loading…
Reference in New Issue