2024-09-22 15:07:01 +08:00
|
|
|
|
<template>
|
2024-10-15 15:24:01 +08:00
|
|
|
|
<view class="container">
|
2024-10-21 17:08:12 +08:00
|
|
|
|
<VNavigationBar background-color="#fff" title-color="#333" title="消息中心" :showClear="showClear" @clearNoRead="clearNoReadFun"></VNavigationBar>
|
2024-10-15 15:24:01 +08:00
|
|
|
|
<view class="body">
|
|
|
|
|
<view class="messageList">
|
|
|
|
|
<scroll-view style="height: 100%;" scroll-y="true" class="itemContent" bindscrolltolower="onReachBottom"
|
|
|
|
|
refresher-enabled @refresherrefresh="onRefresherrefresh" :refresher-triggered="isTriggered">
|
2024-10-21 17:08:12 +08:00
|
|
|
|
<view v-for="(item, index) in messageList" :key="index" class="messageItem" @click="readNotice(item)">
|
2024-10-15 15:24:01 +08:00
|
|
|
|
<image class="messageIcon" src="../../static/icons/message-icon1.png" mode="aspectFit"></image>
|
|
|
|
|
<view class="messageContent">
|
2024-10-21 17:08:12 +08:00
|
|
|
|
<view :class="{'messageTitle':item.readStatus,'noReadTitle':!item.readStatus}" >系统通知</view>
|
|
|
|
|
<view class="messageContent_content">{{item.templateContent}}</view>
|
|
|
|
|
<view class="messageContent_content" style="text-align: right">{{formatTime(item.createTime)}}</view>
|
2024-10-15 15:24:01 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
|
|
|
|
<view style="text-align: center" v-if="messageList.length==0">
|
|
|
|
|
<image class="" src="@/static/images/nothing.png"></image>
|
|
|
|
|
</view>
|
|
|
|
|
</scroll-view>
|
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2024-10-21 17:08:12 +08:00
|
|
|
|
<!-- 普通弹窗 -->
|
|
|
|
|
<uni-popup ref="popup" background-color="#fff" >
|
|
|
|
|
<view class="popup-content" :class="{ 'popup-height': type === 'left' || type === 'right' }">
|
|
|
|
|
<text class="text popup-content-text">{{ nowReadItem.templateContent }}</text>
|
|
|
|
|
<button class="button popup-info" @click="dialogToggle"><text
|
|
|
|
|
class="button-text info-text">知道了</text></button>
|
|
|
|
|
</view>
|
|
|
|
|
</uni-popup>
|
2024-10-15 15:24:01 +08:00
|
|
|
|
</view>
|
2024-09-22 15:07:01 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import VNavigationBar from '@/components/VNavigationBar.vue'
|
2024-10-21 17:08:12 +08:00
|
|
|
|
import request from "@/utils/request";
|
|
|
|
|
import {formatTimestamp} from "@/utils/utils";
|
2024-09-22 15:07:01 +08:00
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
components: {
|
|
|
|
|
VNavigationBar,
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
2024-10-21 17:08:12 +08:00
|
|
|
|
type:"center",
|
|
|
|
|
messageList: [],
|
2024-10-15 15:24:01 +08:00
|
|
|
|
pageNo: 1,
|
2024-10-21 17:08:12 +08:00
|
|
|
|
pageSize: 15,
|
2024-10-15 15:24:01 +08:00
|
|
|
|
total: 0,
|
|
|
|
|
//下来刷新状态
|
|
|
|
|
isTriggered:false,
|
2024-10-21 17:08:12 +08:00
|
|
|
|
//是否显示一键清空
|
|
|
|
|
showClear:true,
|
|
|
|
|
nowReadItem:{},
|
2024-09-22 15:07:01 +08:00
|
|
|
|
};
|
2024-10-15 15:24:01 +08:00
|
|
|
|
},
|
|
|
|
|
onLoad(){
|
2024-10-21 17:08:12 +08:00
|
|
|
|
|
2024-10-15 15:24:01 +08:00
|
|
|
|
},
|
2024-10-21 17:08:12 +08:00
|
|
|
|
onShow(){
|
2024-10-15 15:24:01 +08:00
|
|
|
|
this.getList()
|
|
|
|
|
},
|
2024-10-21 17:08:12 +08:00
|
|
|
|
methods:{
|
|
|
|
|
/**
|
|
|
|
|
* 点击阅读消息
|
|
|
|
|
*/
|
|
|
|
|
async readNotice(item) {
|
|
|
|
|
this.nowReadItem = item
|
|
|
|
|
// open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
|
|
|
|
|
this.$refs.popup.open(this.type)
|
|
|
|
|
//直接请求后台已读
|
|
|
|
|
await request({
|
|
|
|
|
url: "/app-api/system/notify-message/update-read",
|
|
|
|
|
method: "PUT",
|
|
|
|
|
params:{ids:this.nowReadItem.id},
|
|
|
|
|
tenantIdFlag:false
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
if(res.code==200){
|
|
|
|
|
this.onRefresherrefresh()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 消息设置为已读
|
|
|
|
|
*/
|
|
|
|
|
dialogToggle(){
|
|
|
|
|
this.$refs.popup.close()
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 一键清空未读消息
|
|
|
|
|
*/
|
|
|
|
|
async clearNoReadFun(){
|
|
|
|
|
console.log("清空了")
|
|
|
|
|
await request({
|
|
|
|
|
url: "/app-api/system/notify-message/update-all-read",
|
|
|
|
|
method: "PUT",
|
|
|
|
|
tenantIdFlag:false
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
if(res.code==200){
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '操作成功',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
})
|
|
|
|
|
setTimeout(()=>{
|
|
|
|
|
this.onRefresherrefresh()
|
|
|
|
|
},500)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
formatTime(value){
|
|
|
|
|
return formatTimestamp(value)
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 上滑加载数据
|
|
|
|
|
*/
|
|
|
|
|
onReachBottom() {
|
|
|
|
|
//判断 如果页码*页容量大于等于总条数,提示该页数据加载完毕
|
|
|
|
|
if (this.pageNo * this.pageSize >= this.total) {
|
|
|
|
|
uni.$u.toast('没有更多数据了')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
//页码+1,调用获取数据的方法获取第二页数据
|
|
|
|
|
this.pageNo++
|
|
|
|
|
//此处调用自己获取数据列表的方法
|
|
|
|
|
this.getList()
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 下拉刷新数据
|
|
|
|
|
*/
|
|
|
|
|
onRefresherrefresh(){
|
|
|
|
|
this.isTriggered = true
|
|
|
|
|
this.pageNo = 1
|
|
|
|
|
this.total = 0
|
|
|
|
|
this.messageList = []
|
|
|
|
|
this.getList()
|
|
|
|
|
},
|
|
|
|
|
/**
|
|
|
|
|
* 分页查询
|
|
|
|
|
*/
|
|
|
|
|
async getList(){
|
|
|
|
|
await request({
|
|
|
|
|
url: "/app-api/system/notify-message/my-page",
|
|
|
|
|
method: "GET",
|
|
|
|
|
params:{
|
|
|
|
|
pageNo:this.pageNo,
|
|
|
|
|
pageSize:this.pageSize
|
|
|
|
|
},
|
|
|
|
|
tenantIdFlag:false
|
|
|
|
|
}).then((res) => {
|
|
|
|
|
//判断 如果获取的数据的页码不是第一页,就让之前赋值获取过的数组数据 concat连接 刚获取的第n页数据
|
|
|
|
|
if (this.pageNo != 1) {
|
|
|
|
|
this.messageList = this.messageList.concat(res.data.list)
|
|
|
|
|
} else {
|
|
|
|
|
this.messageList = res.data.list
|
|
|
|
|
}
|
|
|
|
|
//将获取的总条数赋值
|
|
|
|
|
this.total = res.data.total
|
|
|
|
|
this.isTriggered = false
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
}
|
2024-09-22 15:07:01 +08:00
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
|
|
.container {
|
|
|
|
|
height: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
.body {
|
|
|
|
|
flex: 1;
|
2024-10-21 17:08:12 +08:00
|
|
|
|
height: calc(100vh - env(safe-area-inset-top));
|
2024-09-22 15:07:01 +08:00
|
|
|
|
overflow: auto;
|
|
|
|
|
}
|
|
|
|
|
.messageList {
|
|
|
|
|
padding: 0 32rpx;
|
2024-10-21 17:08:12 +08:00
|
|
|
|
height: 100%;
|
2024-09-22 15:07:01 +08:00
|
|
|
|
}
|
|
|
|
|
.messageItem {
|
|
|
|
|
padding: 30rpx 0;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
column-gap: 20rpx;
|
|
|
|
|
border-bottom: 1rpx solid #EEEEEE;
|
2024-10-15 15:24:01 +08:00
|
|
|
|
|
2024-09-22 15:07:01 +08:00
|
|
|
|
.messageIcon {
|
|
|
|
|
width: 80rpx;
|
|
|
|
|
height: 80rpx;
|
|
|
|
|
}
|
2024-10-21 17:08:12 +08:00
|
|
|
|
.noReadTitle {
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
font-size: 32rpx;
|
|
|
|
|
color: #333333;
|
|
|
|
|
}
|
|
|
|
|
.noReadTitle:after{
|
|
|
|
|
content: "*";
|
|
|
|
|
color: red;
|
|
|
|
|
display: block; /* 或者其他的块级显示类型,比如 inline-block, table 等 */
|
|
|
|
|
position: absolute; /* 或者 absolute 或者 fixed,取决于你的布局需求 */
|
|
|
|
|
z-index: 1; /* 确保它在元素的上方 */
|
|
|
|
|
right: 0;
|
|
|
|
|
}
|
2024-10-15 15:24:01 +08:00
|
|
|
|
|
2024-09-22 15:07:01 +08:00
|
|
|
|
.messageContent {
|
|
|
|
|
flex: 1;
|
|
|
|
|
width: 0;
|
|
|
|
|
}
|
|
|
|
|
.messageTitle {
|
|
|
|
|
font-size: 32rpx;
|
|
|
|
|
color: #333333;
|
|
|
|
|
}
|
|
|
|
|
.messageContent_content {
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
font-size: 28rpx;
|
|
|
|
|
color: #858BA0;
|
2024-10-15 15:24:01 +08:00
|
|
|
|
|
2024-09-22 15:07:01 +08:00
|
|
|
|
overflow: hidden;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
}
|
2024-10-21 17:08:12 +08:00
|
|
|
|
}
|
|
|
|
|
.popup-content {
|
|
|
|
|
padding: 15px;
|
|
|
|
|
height: auto;
|
|
|
|
|
margin: auto;
|
|
|
|
|
width: 80%;
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
}
|
|
|
|
|
.popup-content-text {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.text {
|
|
|
|
|
color: #333;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.popup-info {
|
|
|
|
|
margin-top: 30rpx;
|
|
|
|
|
color: #fff;
|
|
|
|
|
background-color: #f2f6fc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.info-text {
|
|
|
|
|
color: #909399;
|
|
|
|
|
}
|
2024-09-22 15:07:01 +08:00
|
|
|
|
}
|
|
|
|
|
</style>
|