| | |
| | | <script setup> |
| | | import { ref, onMounted } from "vue"; |
| | | import Splash from "./components/Splash.vue"; |
| | | import { confirmMessage } from "@/api/login.js"; |
| | | |
| | | const showSplash = ref(true); |
| | | onMounted(() => { |
| | |
| | | console.log("使用 plus.push.getClientInfo 获取客户端标识"); |
| | | plus.push.getClientInfoAsync(info => { |
| | | console.log("客户端推送标识:", info); |
| | | uni.setStorageSync("clientid", info.clientid); |
| | | |
| | | // 这里可以将客户端标识发送到服务器 |
| | | }); |
| | | setTimeout(() => { |
| | |
| | | // 处理推送消息点击事件 |
| | | const handlePushClick = msg => { |
| | | console.log("点击推送消息:", msg); |
| | | uni.navigateTo({ |
| | | url: msg.payload.pagePath, |
| | | }); |
| | | console.log("解析后:", msg.payload.noticeId); |
| | | try { |
| | | 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, |
| | | icon: "none", |
| | | }); |
| | | uni.showToast({ |
| | | title: "跳转失败:" + error.message, |
| | | icon: "none", |
| | | }); |
| | | } |
| | | // 解析并处理推送消息... |
| | | }; |
| | | |