|
|
@@ -3,9 +3,11 @@
|
|
|
<uni-collapse>
|
|
|
<uni-collapse-item title-border="show" :border="true" :show-animation="anime" :open="open">
|
|
|
<template v-slot:title>
|
|
|
- <uni-section :title="title" type="line" titleFontSize="1.5rem"></uni-section>
|
|
|
+ <view>
|
|
|
+ <uni-section :title="title" type="line" titleFontSize="1.3rem"></uni-section>
|
|
|
+ </view>
|
|
|
</template>
|
|
|
- <View style="height: 67.8vh;">
|
|
|
+ <View style="height: 69.5vh;">
|
|
|
<z-paging :fixed="false" @query="queryData" :value="list" :default-page-size="pSize"
|
|
|
:default-page-no="pageNo" ref="paging">
|
|
|
<template #top>
|
|
|
@@ -36,9 +38,8 @@
|
|
|
</view>
|
|
|
</uni-col>
|
|
|
<uni-col :xs="6" :sm="4">
|
|
|
- <view class="message_time"
|
|
|
- v-for="(item, index) in message.sendtime.split(' ')" :key="index">
|
|
|
- {{ item }}
|
|
|
+ <view class="message_time">
|
|
|
+ {{ formatDate(message.sendtime) }}
|
|
|
</view>
|
|
|
</uni-col>
|
|
|
</view>
|
|
|
@@ -60,7 +61,6 @@
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
import { onMounted, ref } from 'vue';
|
|
|
-const current = ref(0)
|
|
|
|
|
|
const props = defineProps({
|
|
|
anime: { type: Boolean, default: false }, // 是否开启动画
|
|
|
@@ -70,13 +70,13 @@ const props = defineProps({
|
|
|
list: { type: Array, required: true }, // 消息数据
|
|
|
pSize: { type: Number, default: 10 }, // 分页大小
|
|
|
pageNo: { type: Number, default: 1 }, // 默认页
|
|
|
+ defaultCurrent: {type: Number, default: 0}, // 默认选中项
|
|
|
})
|
|
|
const emits = defineEmits([
|
|
|
'clickSegment', // 点击分段器
|
|
|
'clickItem', // 点击内容项
|
|
|
'scrollToBottom' // 到达底部
|
|
|
])
|
|
|
-
|
|
|
// 分段器 键值
|
|
|
const segmentKeys = ref({})
|
|
|
const segmentValues = ref({})
|
|
|
@@ -103,6 +103,7 @@ function complete(list, total, pageNo) {
|
|
|
}
|
|
|
}
|
|
|
// 点击分段器
|
|
|
+const current = ref(props.defaultCurrent)
|
|
|
function onClickItem({ currentIndex }) {
|
|
|
current.value = currentIndex
|
|
|
// 重新加载数据 pageNo恢复为默认值
|
|
|
@@ -147,9 +148,33 @@ function scrollQuery(pageNo, pSize) {
|
|
|
function handleToDetail(message) {
|
|
|
emits('clickItem', message)
|
|
|
}
|
|
|
+// 格式化时间
|
|
|
+function formatDate(now) {
|
|
|
+ const [date, time] = now.split(" ")
|
|
|
+ if (isInTimeRange(now)) {
|
|
|
+ return time
|
|
|
+ } else {
|
|
|
+ return date
|
|
|
+ }
|
|
|
+}
|
|
|
+//判断时间是否在今天内
|
|
|
+function isInTimeRange(inputDate) {
|
|
|
+ const inputTime = new Date(inputDate).getTime();
|
|
|
+ // 获取当前时间戳
|
|
|
+ const now = new Date();
|
|
|
+ const year = now.getFullYear();
|
|
|
+ const month = now.getMonth();
|
|
|
+ const day = now.getDate();
|
|
|
+
|
|
|
+ // 构建当天的起始时间和结束时间的时间戳
|
|
|
+ const startTime = new Date(year, month, day, 0, 0, 0).getTime();
|
|
|
+ const endTime = new Date(year, month, day, 23, 59, 59).getTime();
|
|
|
+ // 判断当前时间是否在范围内
|
|
|
+ return inputTime >= startTime && inputTime <= endTime;
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
-<style lang="scss" scoped>
|
|
|
+<style lang="scss">
|
|
|
.hidden_over {
|
|
|
white-space: nowrap; // 不换行
|
|
|
overflow: hidden; // 超出内容隐藏
|
|
|
@@ -157,9 +182,7 @@ function handleToDetail(message) {
|
|
|
display: inline-block;
|
|
|
max-width: 100%;
|
|
|
}
|
|
|
-
|
|
|
.msg_list_content {
|
|
|
-
|
|
|
.message_container {
|
|
|
border-left: #7b7b7b .4rem solid;
|
|
|
|
|
|
@@ -186,6 +209,7 @@ function handleToDetail(message) {
|
|
|
color: #888;
|
|
|
text-align: right;
|
|
|
font-size: 0.8rem;
|
|
|
+ line-height: 1.8rem;
|
|
|
}
|
|
|
}
|
|
|
|