From 25975d7ec42b1691512ff6f29041bd3bd1a4a1e3 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期一, 12 一月 2026 14:32:57 +0800
Subject: [PATCH] fix: 消息通知接口联调,页面跳转
---
src/layout/components/NotificationCenter/index.vue | 69 +++++++++++++++++++++++++++-------
1 files changed, 55 insertions(+), 14 deletions(-)
diff --git a/src/layout/components/NotificationCenter/index.vue b/src/layout/components/NotificationCenter/index.vue
index 2864aae..df42650 100644
--- a/src/layout/components/NotificationCenter/index.vue
+++ b/src/layout/components/NotificationCenter/index.vue
@@ -25,12 +25,12 @@
</el-icon>
</div>
<div class="notification-content-wrapper">
- <div class="notification-title">{{ item.title }}</div>
- <div class="notification-detail">{{ item.content }}</div>
+ <div class="notification-title">{{ item.noticeTitle }}</div>
+ <div class="notification-detail">{{ item.noticeContent }}</div>
<div class="notification-time">{{ item.createTime }}</div>
</div>
<div class="notification-action">
- <el-button type="primary" size="small" @click="handleConfirm(item.id)">
+ <el-button type="primary" size="small" @click="handleConfirm(item)">
纭
</el-button>
</div>
@@ -53,8 +53,8 @@
</el-icon>
</div>
<div class="notification-content-wrapper">
- <div class="notification-title">{{ item.title }}</div>
- <div class="notification-detail">{{ item.content }}</div>
+ <div class="notification-title">{{ item.noticeTitle }}</div>
+ <div class="notification-detail">{{ item.noticeContent }}</div>
<div class="notification-time">{{ item.createTime }}</div>
</div>
</div>
@@ -82,7 +82,11 @@
import { Bell } from '@element-plus/icons-vue'
import { listMessage, markAsRead, markAllAsRead, confirmMessage, getUnreadCount } from '@/api/system/message'
import { ElMessage } from 'element-plus'
+import useUserStore from '@/store/modules/user'
+import { useRouter } from 'vue-router'
+const userStore = useUserStore()
+const router = useRouter()
const emit = defineEmits(['unreadCountChange'])
const activeTab = ref('unread')
@@ -96,19 +100,25 @@
// 鍔犺浇娑堟伅鍒楄〃
const loadMessages = async () => {
try {
+ const consigneeId = userStore.id
+ if (!consigneeId) {
+ console.warn('鏈幏鍙栧埌褰撳墠鐧诲綍鐢ㄦ埛ID')
+ return
+ }
const params = {
+ consigneeId: consigneeId,
pageNum: pageNum.value,
pageSize: pageSize.value,
- isRead: activeTab.value === 'read' ? 1 : 0
+ status: activeTab.value === 'read' ? 1 : 0
}
const res = await listMessage(params)
if (res.code === 200) {
if (activeTab.value === 'unread') {
- unreadList.value = res.rows || []
+ unreadList.value = res.data.records || []
} else {
- readList.value = res.rows || []
+ readList.value = res.data.records || []
}
- total.value = res.total || 0
+ total.value = res.data.total || 0
}
} catch (error) {
console.error('鍔犺浇娑堟伅鍒楄〃澶辫触:', error)
@@ -118,7 +128,12 @@
// 鍔犺浇鏈鏁伴噺
const loadUnreadCount = async () => {
try {
- const res = await getUnreadCount()
+ const consigneeId = userStore.id
+ if (!consigneeId) {
+ console.warn('鏈幏鍙栧埌褰撳墠鐧诲綍鐢ㄦ埛ID')
+ return
+ }
+ const res = await getUnreadCount(consigneeId)
if (res.code === 200) {
unreadCount.value = res.data || 0
emit('unreadCountChange', unreadCount.value)
@@ -135,16 +150,42 @@
}
// 纭娑堟伅
-const handleConfirm = async (messageId) => {
+const handleConfirm = async (item) => {
try {
- const res = await confirmMessage(messageId)
+ console.log('item', item)
+ const res = await confirmMessage(item.noticeId, 1)
if (res.code === 200) {
ElMessage.success('纭鎴愬姛')
- // 鏍囪涓哄凡璇�
- await markAsRead(messageId)
// 閲嶆柊鍔犺浇鏁版嵁
loadMessages()
loadUnreadCount()
+
+ // 鏍规嵁 jumpPath 杩涜椤甸潰璺宠浆
+ if (item.jumpPath) {
+ try {
+ // 瑙f瀽 jumpPath锛屽垎绂昏矾寰勫拰鏌ヨ鍙傛暟
+ const [path, queryString] = item.jumpPath.split('?')
+ let query = {}
+
+ if (queryString) {
+ // 瑙f瀽鏌ヨ鍙傛暟
+ queryString.split('&').forEach(param => {
+ const [key, value] = param.split('=')
+ if (key && value) {
+ query[key] = decodeURIComponent(value)
+ }
+ })
+ }
+
+ // 璺宠浆鍒版寚瀹氶〉闈�
+ router.push({
+ path: path,
+ query: query
+ })
+ } catch (error) {
+ console.error('椤甸潰璺宠浆澶辫触:', error)
+ }
+ }
}
} catch (error) {
console.error('纭娑堟伅澶辫触:', error)
--
Gitblit v1.9.3