|
|
@ -1,6 +1,6 @@ |
|
|
<script> |
|
|
<script> |
|
|
import { go2 } from '@/utils/hook.js' |
|
|
import { go2 } from '@/utils/hook.js' |
|
|
import { isObject } from '@/utils/is.js' |
|
|
|
|
|
|
|
|
import { isString } from '@/utils/is.js' |
|
|
import store from '@/store/index.js' |
|
|
import store from '@/store/index.js' |
|
|
import handlePushMsg from '@/utils/handlePushMsg.js' |
|
|
import handlePushMsg from '@/utils/handlePushMsg.js' |
|
|
export default { |
|
|
export default { |
|
|
@ -28,23 +28,25 @@ export default { |
|
|
plus.push.addEventListener( |
|
|
plus.push.addEventListener( |
|
|
'receive', |
|
|
'receive', |
|
|
function (msg) { |
|
|
function (msg) { |
|
|
if (!isObject(msg.payload)) { |
|
|
|
|
|
|
|
|
if (isString(msg.payload)) { |
|
|
msg.payload = JSON.parse(msg.payload) |
|
|
msg.payload = JSON.parse(msg.payload) |
|
|
} |
|
|
} |
|
|
if (client === 'ios') { |
|
|
if (client === 'ios') { |
|
|
if (msg.aps == null && msg.type == 'receive') { |
|
|
if (msg.aps == null && msg.type == 'receive') { |
|
|
let content = msg.payload.content |
|
|
|
|
|
let title = msg.payload.title |
|
|
|
|
|
|
|
|
let content = msg.content |
|
|
|
|
|
let title = msg.title |
|
|
let payload = JSON.stringify(msg.payload) |
|
|
let payload = JSON.stringify(msg.payload) |
|
|
plus.push.createMessage(content, payload, { |
|
|
plus.push.createMessage(content, payload, { |
|
|
title: title |
|
|
|
|
|
|
|
|
title: title, |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (client === 'android') { |
|
|
if (client === 'android') { |
|
|
let title = msg.payload.title |
|
|
|
|
|
let content = msg.payload.content |
|
|
|
|
|
plus.push.createMessage(content, msg.payload, { title: title }) |
|
|
|
|
|
|
|
|
let title = msg.title |
|
|
|
|
|
let content = msg.content |
|
|
|
|
|
plus.push.createMessage(content, JSON.stringify(msg.payload), { |
|
|
|
|
|
title: title, |
|
|
|
|
|
}) |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
false |
|
|
false |
|
|
@ -56,7 +58,7 @@ export default { |
|
|
// 先默认进入应用就清除所有消息 |
|
|
// 先默认进入应用就清除所有消息 |
|
|
plus.runtime.setBadgeNumber(0) |
|
|
plus.runtime.setBadgeNumber(0) |
|
|
}, |
|
|
}, |
|
|
onHide: function () {} |
|
|
|
|
|
|
|
|
onHide: function () {}, |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
|