gaoluyang
3 天以前 c4d25912d11ab9059f8165c25a161634bb9b5e97
src/App.vue
@@ -1,21 +1,23 @@
<template>
  <Splash v-if="showSplash" />
  <div v-else>
  <view v-else>
    <router-view />
  </div>
  </view>
</template>
<script setup>
  import { ref, onMounted } from "vue";
  import Splash from "./components/Splash.vue";
  import { confirmMessage } from "@/api/login.js";
  const showSplash = ref(true);
  onMounted(() => {
    setTimeout(() => {
      showSplash.value = false;
    }, 5000);
    // 初始化推送服务
    initPushService();
    // 初始化推送服务,暂时注释,客户需要打开
    // initPushService();
  });
  // 初始化推送服务(uni-push 1.0)
  const initPushService = () => {
@@ -54,10 +56,45 @@
  // 处理推送消息点击事件
  const handlePushClick = msg => {
    console.log("点击推送消息:", msg);
    uni.navigateTo({
      url: "/" + msg.payload,
      // url: "/pages/managementMeetings/sealManagement/index?applicationNum=5",
    });
    console.log("解析后:", msg.payload.noticeId);
    try {
      if (msg.payload.needMarkRead) {
        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,
              });
            }
          }
        });
      } else {
        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",
      });
    }
    // 解析并处理推送消息...
  };