You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

301 lines
6.8 KiB

<template>
<view class="container">
<!-- 导航栏 -->
<view class="nav-bar">
<text class="nav-back" @click="goBack"></text>
<text class="nav-title">通知</text>
<text class="nav-right"></text>
</view>
<!-- 通知列表 -->
<view class="notification-list">
<view
class="notification-item"
v-for="(item, index) in notificationList"
:key="index"
@click="viewNotification(item)"
>
<view class="notification-content">
<view class="notification-header">
<text class="notification-title">{{ item.title }}</text>
<view class="notification-status" v-if="!item.isRead">
<text class="unread-dot"></text>
</view>
</view>
<text class="notification-summary">{{ item.summary }}</text>
<text class="notification-time">{{ item.time }}</text>
</view>
<text class="notification-arrow">></text>
</view>
<!-- 空状态 -->
<view class="empty-state" v-if="notificationList.length === 0">
<image src="/static/logo.png" class="empty-icon" />
<text class="empty-text">暂无通知消息</text>
</view>
</view>
<!-- 通知详情弹窗 -->
<view class="notification-modal" v-if="showModal" @click="closeModal">
<view class="modal-content" @click.stop>
<view class="modal-header">
<text class="modal-title">{{ selectedNotification.title }}</text>
<text class="modal-close" @click="closeModal">×</text>
</view>
<view class="modal-body">
<text class="modal-time">{{ selectedNotification.time }}</text>
<text class="modal-text">{{ selectedNotification.content }}</text>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
showModal: false,
selectedNotification: {},
notificationList: [
{
id: 1,
title: '系统维护通知',
summary: '系统将于今晚22:00-24:00进行维护升级,期间可能影响正常使用...',
content: '尊敬的用户,为了提供更好的服务体验,我们将于今晚22:00-24:00对系统进行维护升级。维护期间,部分功能可能暂时无法使用,给您带来的不便敬请谅解。维护完成后,系统将恢复正常运行。',
time: '2024-01-15 14:30',
isRead: false
},
{
id: 2,
title: '电费缴费提醒',
summary: '您有一笔电费即将到期,请及时缴费以免影响正常用电...',
content: '您好,您的电费账单已生成,金额为¥156.80,缴费截止日期为2024年1月20日。请您及时缴费,避免因逾期而影响正常用电。如有疑问,请联系客服。',
time: '2024-01-14 09:15',
isRead: true
},
{
id: 3,
title: '月度用电报告',
summary: '您的12月份用电报告已生成,请查看详细用电情况...',
content: '您的12月份用电报告已生成。本月总用电量:245.6度,环比上月增长8.5%。其中峰时用电:156.2度,谷时用电:89.4度。建议您合理安排用电时间,节约用电成本。',
time: '2024-01-01 08:00',
isRead: true
},
{
id: 4,
title: '新功能上线通知',
summary: '电费管理系统新增在线客服功能,欢迎体验使用...',
content: '为了更好地为您服务,我们新增了在线客服功能。您可以通过"我的-联系客服"功能,随时咨询电费相关问题。客服工作时间:周一至周五 9:00-18:00。',
time: '2023-12-28 16:45',
isRead: true
}
]
}
},
methods: {
goBack() {
uni.navigateBack()
},
viewNotification(item) {
this.selectedNotification = item
this.showModal = true
// 标记为已读
if (!item.isRead) {
item.isRead = true
this.updateNotificationStatus(item.id)
}
},
closeModal() {
this.showModal = false
this.selectedNotification = {}
},
updateNotificationStatus(id) {
// 这里可以调用API更新通知状态
console.log('标记通知为已读:', id)
}
}
}
</script>
<style scoped>
.container {
background-color: #f5f5f5;
min-height: 100vh;
}
.nav-bar {
background-color: #007aff;
color: white;
height: 44px;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 15px;
position: sticky;
top: 0;
z-index: 100;
}
.nav-back {
font-size: 24px;
font-weight: bold;
width: 60px;
}
.nav-title {
font-size: 18px;
font-weight: bold;
flex: 1;
text-align: center;
}
.nav-right {
width: 60px;
}
.notification-list {
padding: 15px;
}
.notification-item {
background-color: white;
border-radius: 10px;
padding: 15px;
margin-bottom: 10px;
display: flex;
align-items: center;
justify-content: space-between;
}
.notification-content {
flex: 1;
}
.notification-header {
display: flex;
align-items: center;
margin-bottom: 8px;
}
.notification-title {
font-size: 16px;
font-weight: bold;
color: #333;
flex: 1;
}
.notification-status {
margin-left: 10px;
}
.unread-dot {
display: inline-block;
width: 8px;
height: 8px;
background-color: #ff4757;
border-radius: 4px;
}
.notification-summary {
font-size: 14px;
color: #666;
line-height: 1.4;
margin-bottom: 8px;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.notification-time {
font-size: 12px;
color: #999;
}
.notification-arrow {
color: #ccc;
font-size: 16px;
margin-left: 10px;
}
.empty-state {
text-align: center;
padding: 60px 20px;
}
.empty-icon {
width: 80px;
height: 80px;
opacity: 0.3;
margin-bottom: 20px;
}
.empty-text {
font-size: 16px;
color: #999;
}
.notification-modal {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
z-index: 1000;
}
.modal-content {
background-color: white;
border-radius: 15px;
margin: 20px;
max-height: 70vh;
overflow: hidden;
}
.modal-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 20px;
border-bottom: 1px solid #f0f0f0;
}
.modal-title {
font-size: 18px;
font-weight: bold;
color: #333;
flex: 1;
}
.modal-close {
font-size: 24px;
color: #999;
width: 30px;
text-align: center;
}
.modal-body {
padding: 20px;
max-height: 50vh;
overflow-y: auto;
}
.modal-time {
font-size: 12px;
color: #999;
margin-bottom: 15px;
display: block;
}
.modal-text {
font-size: 16px;
color: #333;
line-height: 1.6;
}
</style>