| | |
| | | <script setup> |
| | | import { ref, onMounted } from "vue"; |
| | | import Splash from "./components/Splash.vue"; |
| | | import { confirmMessage } from "@/api/login.js"; |
| | | |
| | | const showSplash = ref(true); |
| | | onMounted(() => { |
| | |
| | | // 处理推送消息点击事件 |
| | | const handlePushClick = msg => { |
| | | console.log("点击推送消息:", msg); |
| | | console.log("解析后:", msg.payload.noticeId); |
| | | try { |
| | | if (msg.payload.indexOf("/") === 0) { |
| | | confirmMessage(msg.payload.noticeId, 1).then(res => { |
| | | if (msg.payload.url) { |
| | | if (msg.payload.url.indexOf("/") === 0) { |
| | | uni.navigateTo({ |
| | | url: msg.payload, |
| | | url: msg.payload.url, |
| | | }); |
| | | } else { |
| | | uni.navigateTo({ |
| | | url: "/" + msg.payload, |
| | | url: "/" + msg.payload.url, |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | } catch (error) { |
| | | uni.showToast({ |
| | | title: "路径:" + msg.payload, |
| | |
| | | params: { consigneeId } |
| | | }) |
| | | } |
| | | |
| | | // 标记消息为已读 |
| | | 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 }, |
| | | }); |
| | | } |
| | |
| | | <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> |
| | |
| | | |
| | | <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"; |
| | | |
| | | // 标签页数据 |
| | |
| | | |
| | | // 跳转到详情页 |
| | | const goToDetail = item => { |
| | | 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, |
| | |
| | | url: "/" + item.appJumpPath, |
| | | }); |
| | | } |
| | | } |
| | | } else { |
| | | uni.showToast({ title: "确认失败", icon: "none" }); |
| | | } |
| | | }); |
| | | }; |
| | | const userStore = useUserStore(); |
| | | const userId = ref(""); |