feat:增加系统 消息通知

This commit is contained in:
aihe 2024-12-29 18:06:51 +08:00
parent 2e0f36f302
commit f144549e0b
3 changed files with 29 additions and 9 deletions

View File

@ -1,4 +1,5 @@
import { setClipboardData, showToast } from "@/common/untool"
import { pushAddEventListenerInit } from "@/common/messageNotice/socket"
// #ifdef APP-PLUS
var jpushModule = uni.requireNativePlugin("JG-JPush");
@ -24,6 +25,7 @@ const getPushClientId = ()=> {
}
export const onPushMessage = async()=> {
pushAddEventListenerInit() // 监听 消息栏的点击事件
uni.onPushMessage((res) => {
console.log("收到推送消息 onPushMessage ===== ",res) //监听推送消息
showToast(JSON.stringify(res))

View File

@ -10,6 +10,7 @@ export const currentSocketTask = {
export const createSocketMessage = ({ userInfo })=> {
const reConnectSock = ()=> {
console.log("reConnectSock 重试连接=====")
socketTask = null
createSocketMessage({ userInfo })
}
@ -51,14 +52,6 @@ export const createSocketMessage = ({ userInfo })=> {
})
socketTask.onOpen((res)=> {
console.log('socketTask.onOpen: ', res);
// TODO, 测试消息通知效果
createSysMessage({
"clickPath": "/123123/123",
"uid": 357,
"title": "测试消息c2",
"noticeId": 25,
"content": "测试消息内容c2",
})
})
socketTask.onMessage(function (res) {
console.log('onSocketMessage 收到服务器内容:', res?.data);
@ -71,6 +64,31 @@ export const createSocketMessage = ({ userInfo })=> {
});
}
// #ifdef APP-PLUS
// 监听plusready事件
export const pushAddEventListenerInit = ()=> {
// 监听 消息栏的点击事件
plus.push.addEventListener('click', function(msg = {}){
// 分析msg.payload处理业务逻辑
console.log("push.addEventListener You clicked:", msg)
// {
// "__UUID__": "androidPushMsg96147834",
// "title": "测试消息c2",
// "appid": "__UNI__BCB0FB5",
// "content": "测试消息内容c2",
// "payload": {
// "clickPath": "/123123/123",
// "uid": 357,
// "title": "测试消息c2",
// "noticeId": 25,
// "content": "测试消息内容c2"
// }
// }
console.log("notice msg-- clickPath ", msg?.payload?.clickPath)
}, false );
}
// #endif
export const createSysMessage = (opt = {})=> {
showToast(`${opt.title} ${opt.content}`)
playAudio(audioTypeEnum.notifyTone)

View File

@ -3,7 +3,7 @@
"appid" : "__UNI__BCB0FB5",
"description" : "探路国际速运",
"versionName" : "1.0.1",
"versionCode" : "1052",
"versionCode" : "1053",
"transformPx" : false,
/* 5+App特有相关 */
"app-plus" : {