修改消息中心ui

feasure-livedata
lld 2026-04-03 21:39:50 +08:00
parent 2b9fe797c3
commit d1e1e0db74
5 changed files with 175 additions and 243 deletions

View File

@ -72,11 +72,11 @@
<view class="item-content"> <view class="item-content">
<view class="item-title"> <view class="item-title">
<text>{{ item.title }}</text> <text>{{ item.title }}</text>
<text class="item-time"> <view class="item-time">
<uni-dateformat v-if="item.createTime" :date="item.createTime" :format="formatTime(item.createTime)" <uni-dateformat v-if="item.createTime" :date="item.createTime" :format="formatTime(item.createTime)"
:threshold="[60000, 3600000]"></uni-dateformat> :threshold="[60000, 3600000]"></uni-dateformat>
<text v-else>--</text> <text v-else>--</text>
</text> </view>
</view> </view>
<view class="item-desc"> <view class="item-desc">
<view v-if="item.content">{{ item.content }}</view> <view v-if="item.content">{{ item.content }}</view>
@ -181,6 +181,10 @@ export default {
cancelText: '取消', cancelText: '取消',
confirmText: '确定', confirmText: '确定',
success: (res) => { success: (res) => {
var unReadNum = this.messageList.filter(item => item.readStatus === 0).length;
if (unReadNum === 0) {
return;
}
updateRead({}).then(response => { updateRead({}).then(response => {
if (response.code === 200) { if (response.code === 200) {
this.getMsgOverview(); this.getMsgOverview();
@ -188,7 +192,6 @@ export default {
}) })
} }
}) })
console.log('清除未读:当前页面全部已读')
}, },
openSetting() { openSetting() {
// //

View File

@ -34,7 +34,7 @@
<uni-load-more iconType="auto" v-if="messageList.length >=10" <uni-load-more iconType="auto" v-if="messageList.length >=10"
:status="status" :content-text="contentText" /> :status="status" :content-text="contentText" />
</scroll-view> </scroll-view>
<view class="empty__item tn-margin-top empty__view" v-else> <view class="empty__item empty__view" v-else>
<tn-empty icon="https://resource.tuniaokj.com/images/empty/alien/2.png" <tn-empty icon="https://resource.tuniaokj.com/images/empty/alien/2.png"
text="近7天暂无消息" :imgWidth="200" text="近7天暂无消息" :imgWidth="200"
:imgHeight="200"></tn-empty> :imgHeight="200"></tn-empty>
@ -222,10 +222,12 @@ export default {
@import '@/colorui/icon.css'; @import '@/colorui/icon.css';
</style> </style>
<style scoped> <style scoped>
page {
background-color: #f5f5f5;
}
/* 页面容器 */ /* 页面容器 */
.message-page { .message-page {
height: 100vh; height: 100vh;
background-color: #f5f5f5;
} }
/* 消息列表 */ /* 消息列表 */

View File

@ -1,5 +1,11 @@
<template> <template>
<view class="message-page"> <view class="message-page">
<z-paging ref="eventPage" refresher-only
:show-empty="false" :show-footer="false" @onRefresh="getEventList">
<template #refresher="{refresherStatus}">
<!-- 此处的custom-refresh为demo中自定义的组件非z-paging的内置组件请在实际项目中自行创建这里插入什么view下拉刷新就显示什么view -->
<custom-refresher :status="refresherStatus" />
</template>
<!-- 消息列表 --> <!-- 消息列表 -->
<scroll-view :scroll-y="true" <scroll-view :scroll-y="true"
class="message-list" class="message-list"
@ -30,31 +36,39 @@
<!-- 底部信息栏 --> <!-- 底部信息栏 -->
<view class="info-bar"> <view class="info-bar">
<view class="sender-info"> <view class="sender-info">
<image class="sender-icon" :src="item.imageUrl || avatarUrl" mode="aspectFill"></image> <image class="sender-icon" :src="item.imgUrl || avatarUrl" mode="aspectFill"></image>
<text class="sender-name">{{ item.createBy || '小策官方团队'}}</text> <text class="sender-name">{{ item.createBy || '小策官方团队'}}</text>
</view> </view>
<text class="send-time">{{ formatTime(item.createTime) }}</text> <text class="send-time">{{ formatTime(item.createTime) }}</text>
</view> </view>
</view> </view>
<uni-load-more v-if="messageList.length>4" iconType="auto" :status="status" :content-text="contentText" /> <!-- 底部提示 -->
<uni-divider-text margin="10rpx 0"
width="50%"
font-size="24rpx"
v-if="messageList.length>0"
lineText="只展示最近7天的消息"/>
<!-- <uni-load-more v-if="messageList.length>4" iconType="auto" :status="status" :content-text="contentText" />-->
</scroll-view> </scroll-view>
<view class="empty__item tn-margin-top empty__view" v-else> <view class="empty__item tn-margin-top empty__view" v-else>
<tn-empty icon="https://resource.tuniaokj.com/images/empty/alien/2.png" <tn-empty icon="https://resource.tuniaokj.com/images/empty/alien/2.png"
text="近7天暂无消息" :imgWidth="200" text="近7天暂无消息" :imgWidth="200"
:imgHeight="200"></tn-empty> :imgHeight="200"></tn-empty>
</view> </view>
</z-paging>
</view> </view>
</template> </template>
<script> <script>
import {formatTime} from "@/utils/agri"; import {formatTime} from "@/utils/agri";
import {listMessage} from "@/api/warn/message"; import {listMessage} from "@/api/warn/message";
import UniDividerText from "@/components/uni-divider/uni-divider-text.vue";
export default { export default {
components: {UniDividerText},
data() { data() {
return { return {
avatarUrl: "https://img.xiaoces.com/photos/logo.png", avatarUrl: "https://img.xiaoces.com/photos/logo.png",
messageList: [], messageList: [],
isHaveOldData: true,
contentText: { contentText: {
contentdown: '查看更多', contentdown: '查看更多',
contentrefresh: '加载中.......', contentrefresh: '加载中.......',
@ -84,22 +98,22 @@ export default {
}, },
getEventList() { getEventList() {
this.status = 'loading' this.status = 'loading'
if (!this.isHaveOldData) { // if (!this.isHaveOldData) {
setTimeout(() => { // setTimeout(() => {
this.$modal.msg("没有更早数据!"); // this.$modal.msg("");
// // //
this.status = 'nomore' // this.status = 'nomore'
}, 800); // }, 800);
return; // return;
} // }
var query = { var query = {
msgType: "event" msgType: "event"
} }
listMessage(query).then(response => { listMessage(query).then(response => {
if (response.code === 200) { if (response.code === 200) {
this.messageList = response.rows.sort((a, b) => new Date(a.createTime) - new Date(b.createTime)); this.messageList = response.rows.sort((a, b) => new Date(a.createTime) - new Date(b.createTime));
if (response.rows.length === 0) { if (this.messageList.length === 0) {
this.isHaveOldData = false; this.$modal.showToast('没有更多数据~')
} }
} }
}).finally(()=>{ }).finally(()=>{
@ -110,6 +124,7 @@ export default {
}); });
// //
this.status = 'nomore' this.status = 'nomore'
this.$refs.eventPage.complete();
}) })
} }

View File

@ -1,96 +1,116 @@
<template> <template>
<view class="notice-page"> <view class="notice-page">
<z-paging ref="noticePage" refresher-only
<!-- 未读/已读标签栏 --> :show-empty="false" :show-footer="false" @onRefresh="getNoticeList">
<view class="tab-bar"> <template #refresher="{refresherStatus}">
<view <!-- 此处的custom-refresh为demo中自定义的组件非z-paging的内置组件请在实际项目中自行创建这里插入什么view下拉刷新就显示什么view -->
class="tab-item" <custom-refresher :status="refresherStatus" />
:class="{ active: currentTab === 0 }" </template>
@click="switchTab(0)" <!-- 未读/已读标签栏 -->
> <view class="tab-bar">
未读 <view
</view> class="tab-item"
<view :class="{ active: currentTab === 0 }"
class="tab-item" @click="switchTab(0)"
:class="{ active: currentTab === 1 }" >
@click="switchTab(1)" 未读
>
已读
</view>
</view>
<!-- 公告列表 -->
<scroll-view :scroll-y="true" class="notice-list" @scrolltolower="onLoadMore" v-if="noticeList.length>0">
<view
v-for="(item, index) in noticeList"
:key="index"
class="notice-item"
@click="handleClick(item)"
>
<!-- 状态点 + 标题 -->
<view class="notice-header">
<view class="status-dot" :style="{ borderColor: item.dotColor }">
<view class="dot-inner" :style="{ backgroundColor: item.dotColor }" v-if="Math.random() < 0.5"></view>
</view>
<text class="notice-title">{{ item.title }}</text>
</view> </view>
<view
<!-- 内容描述 --> class="tab-item"
<view class="notice-content"> :class="{ active: currentTab === 1 }"
<text class="content-text">{{ item.content }}</text> @click="switchTab(1)"
</view> >
已读
<!-- 底部头像 + 作者 + 时间 -->
<view class="notice-footer">
<view class="author-info">
<image class="avatar" :src="authorList[Math.round(Math.random())].avatar" mode="aspectFill"></image>
<text class="author-name">{{ authorList[Math.round(Math.random())].name }}</text>
</view>
<text class="notice-time">{{ item.time }}</text>
</view> </view>
</view> </view>
<uni-load-more v-if="noticeList.length>8" iconType="auto" :status="status" :content-text="contentText" />
</scroll-view>
<view class="empty__item tn-margin-top empty__view" v-else>
<tn-empty icon="https://resource.tuniaokj.com/images/empty/alien/2.png"
text="暂无公告" :imgWidth="200"
:imgHeight="200"></tn-empty>
</view>
<uni-popup ref="showNotice" mode="center" > <!-- 公告列表 -->
<!-- 新增修改运行时间的弹窗 --> <scroll-view :scroll-y="true" class="notice-list" v-if="noticeList.length>0">
<view class="modal-container"> <view
<view class="modal-title">{{ notice.title }}</view> v-for="(item, index) in noticeList"
<view class="modal-content">&nbsp; &nbsp;&nbsp; &nbsp;{{ notice.content }}</view> :key="index"
<view class="modal-remark"> class="notice-item"
<view class="remark"> @click="handleClick(item)"
发布人{{ notice.author }} >
<!-- 状态点 + 标题 -->
<view class="notice-header">
<view class="status-dot" :style="{ borderColor: item.dotColor }">
<view class="dot-inner" :style="{ backgroundColor: item.dotColor }" v-if="Math.random() < 0.5"></view>
</view>
<text class="notice-title">{{ item.title }}</text>
</view> </view>
<view class="remark">
发布时间{{ notice.time }} <!-- 内容描述 -->
<view class="notice-content">
<text class="content-text">{{ item.content }}</text>
</view>
<!-- 底部头像 + 作者 + 时间 -->
<view class="notice-footer">
<view class="author-info">
<image class="avatar" :src=" item.imgUrl || authorList[Math.round(Math.random())].imgUrl" mode="aspectFill"></image>
<text class="author-name">{{ item.createBy || authorList[Math.round(Math.random())].createBy }}</text>
</view>
<text class="notice-time">{{ formatTime(item.createTime) }}</text>
</view> </view>
</view> </view>
<view class="modal-btn-wrap"> <!-- <uni-load-more v-if="noticeList.length>8" iconType="auto" :status="status" :content-text="contentText" />-->
<button class="modal-btn confirm" @click="closeShowNotice"></button>
</view> <uni-divider-text margin="10rpx 0"
width="50%"
font-size="24rpx"
v-if="noticeList.length>0"
lineText="只展示最近7天的消息"/>
</scroll-view>
<view class="empty__item tn-margin-top empty__view" v-else>
<tn-empty icon="https://resource.tuniaokj.com/images/empty/alien/2.png"
text="近7天暂无公告" :imgWidth="200"
:imgHeight="200"></tn-empty>
</view> </view>
</uni-popup>
<uni-popup ref="showNotice" mode="center" >
<!-- 新增修改运行时间的弹窗 -->
<view class="modal-container">
<view class="modal-title">{{ notice.title }}</view>
<view class="modal-content">&nbsp; &nbsp;&nbsp; &nbsp;{{ notice.content }}</view>
<view class="modal-remark">
<view class="remark">
发布人{{ notice.createBy }}
</view>
<view class="remark">
发布时间{{ notice.createTime }}
</view>
</view>
<view class="modal-btn-wrap">
<button class="modal-btn confirm" @click="closeShowNotice"></button>
</view>
</view>
</uni-popup>
</z-paging>
</view> </view>
</template> </template>
<script> <script>
import {formatTime} from "@/utils/agri";
import UniDividerText from "@/components/uni-divider/uni-divider-text.vue";
import {listMessage, updateRead} from "@/api/warn/message";
export default { export default {
components: {UniDividerText},
data() { data() {
return { return {
currentTab: 0, // 0 1 currentTab: 0, // 0 1
authorList: [ authorList: [
{ {
name: '那只猪-图鸟人事部', createBy: '那只猪-图鸟人事部',
avatar: 'https://img.xiaoces.com/photos/profile.jpg' imgUrl: 'https://img.xiaoces.com/photos/profile.jpg'
}, },
{ {
name: '你的名字', createBy: '你的名字',
avatar: 'https://img.xiaoces.com/photos/logo200.png' imgUrl: 'https://img.xiaoces.com/photos/logo200.png'
} }
], ],
dotColorList: [ dotColorList: [
@ -103,140 +123,30 @@ export default {
{ {
title: '2024年春节放假通知', title: '2024年春节放假通知',
content: '各位同事一年一度的春节又到啦根据国家法定节假日规定2024年春节放假安排如下02月01日—...', content: '各位同事一年一度的春节又到啦根据国家法定节假日规定2024年春节放假安排如下02月01日—...',
author: '那只猪-图鸟人事部', createBy: '那只猪-图鸟人事部',
time: '2024-01-26 10:12', createTime: '2024-01-26 10:12',
dotColor: '#e53935', dotColor: '#e53935',
dotInner: true, // dotInner: true, //
isRead: 0, readStatus: 0,
avatar: 'https://img.xiaoces.com/photos/logo.png' // imgUrl: 'https://img.xiaoces.com/photos/logo.png' //
}, },
{ {
title: '2024年春节放假通知', title: '2024年春节放假通知',
content: '各位同事一年一度的春节又到啦根据国家法定节假日规定2024年春节放假安排如下02月01retrt345日—...', content: '各位同事一年一度的春节又到啦根据国家法定节假日规定2024年春节放假安排如下02月01retrt345日—...',
author: '那只猪-图鸟人事部', createBy: '那只猪-图鸟人事部',
time: '2024-01-26 10:12', createTime: '2024-01-26 10:12',
dotColor: '#e53935', dotColor: '#e53935',
dotInner: true, // dotInner: true, //
isRead: 0, readStatus: 0,
avatar: 'https://img.xiaoces.com/photos/logo.png' // imgUrl: 'https://img.xiaoces.com/photos/logo.png' //
},
{
title: '2024年春节放假通知',
content: '各位同事一年一度的春节又到啦根据国家法定节假日规定2024年春45353535节放假安排如下02月01日—...',
author: '那只猪-图鸟人事部',
time: '2024-01-26 10:12',
dotColor: '#e53935',
dotInner: true, //
isRead: 0,
avatar: 'https://img.xiaoces.com/photos/logo.png' //
},
{
title: '2024年春节放假通知',
content: '各位同事一年一度的春节又到啦根据国家法定节假日规定2024年春节放假安排如下02月01日—...',
author: '那只猪-图鸟人事部',
time: '2024-01-26 10:12',
dotColor: '#e53935',
dotInner: true, //
isRead: 0,
avatar: 'https://img.xiaoces.com/photos/logo.png' //
},
{
title: '2024年春节放假通知',
content: '各位同事一年一度的春节又到啦根据国家法定节假日规定2024年春节放假安排如下02月01retrt345日—...',
author: '那只猪-图鸟人事部',
time: '2024-01-26 10:12',
dotColor: '#e53935',
dotInner: true, //
isRead: 0,
avatar: 'https://img.xiaoces.com/photos/logo.png' //
},
{
title: '2024年春节放假通知',
content: '各位同事一年一度的春节又到啦根据国家法定节假日规定2024年春45353535节放假安排如下02月01日—...',
author: '那只猪-图鸟人事部',
time: '2024-01-26 10:12',
dotColor: '#e53935',
dotInner: true, //
isRead: 0,
avatar: 'https://img.xiaoces.com/photos/logo.png' //
},
{
title: '2024年春节放假通知',
content: '各位同事一年一度的春节又到啦根据国家法定节假日规定2024年春节放假安排如下02月01日—...',
author: '那只猪-图鸟人事部',
time: '2024-01-26 10:12',
dotColor: '#e53935',
dotInner: true, //
isRead: 0,
avatar: 'https://img.xiaoces.com/photos/logo.png' //
},
{
title: '2024年春节放假通知',
content: '各位同事一年一度的春节又到啦根据国家法定节假日规定2024年春节放假安排如下02月01retrt345日—...',
author: '那只猪-图鸟人事部',
time: '2024-01-26 10:12',
dotColor: '#e53935',
dotInner: true, //
isRead: 0,
avatar: 'https://img.xiaoces.com/photos/logo.png' //
},
{
title: '2024年春节放假通知',
content: '各位同事一年一度的春节又到啦根据国家法定节假日规定2024年春45353535节放假安排如下02月01日—...',
author: '那只猪-图鸟人事部',
time: '2024-01-26 10:12',
dotColor: '#e53935',
dotInner: true, //
isRead: 0,
avatar: 'https://img.xiaoces.com/photos/logo.png' //
},
{
title: '关于年前请假审批流程通知',
content: '各位同事:这里是一大堆瞎逼逼的描述,为了凑字数,想不出来什么文案了',
author: '你的名字',
time: '2024-01-20 14:02',
dotColor: '#007bff',
dotInner: false, //
isRead: 1,
avatar: 'https://img.xiaoces.com/photos/logo.png'
},
{
title: '图鸟OA系统更新通知',
content: '各位同事:这里是一大堆瞎逼逼的描述,为了凑字数,想不出来什么文案了',
author: '不许凶我吖',
time: '2024-01-12 09:56',
dotColor: '#4caf50',
dotInner: true, // 绿
isRead: 1,
avatar: 'https://img.xiaoces.com/photos/logo.png'
},
{
title: '凑数的文案,凑够一行超出隐藏,不喜勿喷',
content: '各位同事:这里是一大堆瞎逼逼的描述,为了凑字数,想不出来什么文案了',
author: '图鸟西西',
time: '2024-01-06 17:59',
dotColor: '#007bff',
dotInner: false, //
isRead: 1,
avatar: 'https://img.xiaoces.com/photos/logo.png'
},
{
title: '2023年12月考勤统计核对表',
content: '各位同事:这里是一大堆瞎逼逼的描述,为了凑字数,想不出来什么文案了',
author: '',
time: '',
dotColor: '#4caf50',
dotInner: true, // 绿
isRead: 1,
avatar: 'https://img.xiaoces.com/photos/logo.png'
} }
], ],
noticeList: [], noticeList: [],
notice: { notice: {
title:null, title:null,
content:null, content:null,
author:null, createBy:null,
avatar:null createTime:null
}, },
status: 'more', status: 'more',
contentText: { contentText: {
@ -247,55 +157,58 @@ export default {
isHaveOldData: true isHaveOldData: true
} }
}, },
onLoad() {
//
//
this.getNoticeList();
},
methods: { methods: {
formatTime,
switchTab(currentTab) { switchTab(currentTab) {
this.currentTab = currentTab; this.currentTab = currentTab;
this.noticeList = this.contentList.filter(item => this.noticeList = this.contentList.filter(item =>
item.isRead===currentTab); item.readStatus===currentTab);
}, },
handleClick(item) { handleClick(item) {
this.notice = item; this.notice = item;
if (item.readStatus===0) {
updateRead({msgType: "notice",id:item.id}).then(response => {
if (response.code === 200) {
console.info("更新已读成功")
}
})
}
this.$refs.showNotice.open(); this.$refs.showNotice.open();
}, },
closeShowNotice() { closeShowNotice() {
this.$refs.showNotice.close(); this.$refs.showNotice.close();
}, },
onLoadMore() { getNoticeList() {
this.status = 'loading' this.status = 'loading'
if (!this.isHaveOldData) { // if (!this.isHaveOldData) {
setTimeout(() => { // setTimeout(() => {
this.$modal.msg("没有更早数据!"); // this.$modal.msg("");
// // //
this.status = 'nomore' // this.status = 'nomore'
}, 800); // }, 800);
return; // return;
} // }
// listMessage({msgType: "notice"}).then(response => {
setTimeout(() => { if (response.code === 200) {
// 10 this.contentList = response.rows;
const newData = []; if (this.contentList.length === 0) {
for (let i = 0; i < 10; i++) { this.$modal.showToast('没有更多数据~')
newData.push({ }
title: '2024年春节放假通知',
content: '各位同事一年一度的春节又到啦根据国家法定节假日规定2024年春节放假安排如下02月01日—...',
author: '那只猪-图鸟人事部',
time: '2024-01-26 10:12',
dotColor: '#e53935',
dotInner: true,
})
} }
this.noticeList = [ ...this.noticeList,...newData]; }).finally(()=>{
this.status = 'more' this.noticeList = this.contentList.filter(item =>
}, 800); item.readStatus===0);
this.$refs.noticePage.complete();
//
this.status = 'nomore';
})
}, },
}, },
onShow() {
//
//
this.noticeList = this.contentList.filter(item =>
item.isRead===0);
},
} }
</script> </script>

View File

@ -345,7 +345,6 @@ export function isTodayDate(dateInput) {
export function formatTime(timeStr) { export function formatTime(timeStr) {
console.info('timeStr', timeStr)
const now = new Date(); const now = new Date();
const target = new Date(timeStr); const target = new Date(timeStr);
const diff = now - target; const diff = now - target;