From 49b6ad612dcc44e9e45c7e1256acfad24ff94393 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期三, 11 二月 2026 10:23:01 +0800
Subject: [PATCH] 消息推送及消息列表,点击已读
---
src/api/login.js | 28 +++++++++++++
src/pages/message.vue | 35 +++++++++++------
src/App.vue | 24 +++++++----
3 files changed, 65 insertions(+), 22 deletions(-)
diff --git a/src/App.vue b/src/App.vue
index 092696f..bd95a27 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -7,6 +7,7 @@
<script setup>
import { ref, onMounted } from "vue";
import Splash from "./components/Splash.vue";
+ import { confirmMessage } from "@/api/login.js";
const showSplash = ref(true);
onMounted(() => {
@@ -54,16 +55,21 @@
// 澶勭悊鎺ㄩ�佹秷鎭偣鍑讳簨浠�
const handlePushClick = msg => {
console.log("鐐瑰嚮鎺ㄩ�佹秷鎭�:", msg);
+ console.log("瑙f瀽鍚�:", msg.payload.noticeId);
try {
- if (msg.payload.indexOf("/") === 0) {
- uni.navigateTo({
- url: msg.payload,
- });
- } else {
- uni.navigateTo({
- url: "/" + msg.payload,
- });
- }
+ confirmMessage(msg.payload.noticeId, 1).then(res => {
+ if (msg.payload.url) {
+ if (msg.payload.url.indexOf("/") === 0) {
+ uni.navigateTo({
+ url: msg.payload.url,
+ });
+ } else {
+ uni.navigateTo({
+ url: "/" + msg.payload.url,
+ });
+ }
+ }
+ });
} catch (error) {
uni.showToast({
title: "璺緞:" + msg.payload,
diff --git a/src/api/login.js b/src/api/login.js
index 180e192..29a149d 100644
--- a/src/api/login.js
+++ b/src/api/login.js
@@ -76,4 +76,30 @@
method: 'get',
params: { consigneeId }
})
-}
\ No newline at end of file
+}
+
+// 鏍囪娑堟伅涓哄凡璇�
+export function markAsRead(noticeId, status) {
+ return request({
+ url: "/system/notice",
+ method: "put",
+ data: { noticeId, status },
+ });
+}
+
+// 涓�閿爣璁版墍鏈夋秷鎭负宸茶
+export function markAllAsRead() {
+ return request({
+ url: "/system/notice/readAll",
+ method: "post",
+ });
+}
+
+// 纭娑堟伅
+export function confirmMessage(noticeId, status) {
+ return request({
+ url: "/system/notice",
+ method: "put",
+ data: { noticeId, status },
+ });
+}
diff --git a/src/pages/message.vue b/src/pages/message.vue
index 2392c08..77f1d34 100644
--- a/src/pages/message.vue
+++ b/src/pages/message.vue
@@ -37,10 +37,11 @@
<text class="message-time">{{ formatTime(item.createTime) }}</text>
</view>
<text class="message-desc">{{ item.noticeContent }}</text>
- <view class="message-footer">
+ <view v-if="activeTab === 0"
+ class="message-footer">
<text class="message-view"
@click="goToDetail(item)">
- 鍘绘煡鐪� >
+ 纭娑堟伅
</text>
</view>
</view>
@@ -61,7 +62,7 @@
<script setup>
import { ref, reactive, onMounted } from "vue";
- import { listNotice } from "@/api/login.js";
+ import { listNotice, confirmMessage } from "@/api/login.js";
import useUserStore from "@/store/modules/user";
// 鏍囩椤垫暟鎹�
@@ -100,15 +101,25 @@
// 璺宠浆鍒拌鎯呴〉
const goToDetail = item => {
- if (item.appJumpPath.indexOf("/") === 0) {
- uni.navigateTo({
- url: item.appJumpPath,
- });
- } else {
- uni.navigateTo({
- url: "/" + item.appJumpPath,
- });
- }
+ confirmMessage(item.noticeId, 1).then(res => {
+ if (res.code === 200) {
+ uni.showToast({ title: "纭鎴愬姛", icon: "success" });
+ loadMessages(false);
+ if (item.appJumpPath) {
+ if (item.appJumpPath.indexOf("/") === 0) {
+ uni.navigateTo({
+ url: item.appJumpPath,
+ });
+ } else {
+ uni.navigateTo({
+ url: "/" + item.appJumpPath,
+ });
+ }
+ }
+ } else {
+ uni.showToast({ title: "纭澶辫触", icon: "none" });
+ }
+ });
};
const userStore = useUserStore();
const userId = ref("");
--
Gitblit v1.9.3