|
|
|
@ -137,12 +137,23 @@ |
|
|
|
plus.runtime.setBadgeNumber(0); |
|
|
|
let notificationEventType = result.notificationEventType |
|
|
|
let woopId = result.extras && result.extras.dataType === 'woop' && result.extras.value; |
|
|
|
//用户点击了通知消息 |
|
|
|
if (result.notificationEventType === 'notificationOpened') { |
|
|
|
console.log('用户点击了通知消息') |
|
|
|
if (this.NB.isAndroidOrIOS() == 'iOS') { |
|
|
|
this.handlePushClick(result.ios.inAppExtras); |
|
|
|
} else { |
|
|
|
this.handlePushClick(result.android.inAppExtras); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
if (result.notificationEventType == 'notificationArrived') { |
|
|
|
if (result.content.includes('订单出餐已超时')) { |
|
|
|
this.onPlayAudio(2) |
|
|
|
} else if (result.content.includes('您有一笔配送订单无人接单')) { |
|
|
|
this.onPlayAudio(5) |
|
|
|
} else if (result.content.includes('您有中转配送订单超时未送达中转点')) { |
|
|
|
this.onPlayAudio(7) |
|
|
|
} else { |
|
|
|
if (result.content.includes('您有一笔新的订单')) { |
|
|
|
this.onPlayAudio(4) |
|
|
|
@ -163,7 +174,6 @@ |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
jpushModule.isPushStopped(res => { |
|
|
|
// code 0已停止推送 1未停止推送 |
|
|
|
const { |
|
|
|
@ -240,6 +250,52 @@ |
|
|
|
this.processPrintQueue() |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 统一处理推送点击逻辑 |
|
|
|
handlePushClick(extras) { |
|
|
|
console.log('消息内容',extras) |
|
|
|
if (!extras) return; |
|
|
|
|
|
|
|
// 兼容处理:Android有时返回JSON字符串,iOS返回Object |
|
|
|
let data = extras; |
|
|
|
if (typeof data === 'string') { |
|
|
|
try { |
|
|
|
data = JSON.parse(data); |
|
|
|
} catch (e) { |
|
|
|
console.error('解析推送extras失败', e); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 判断是否是订单详情推送 |
|
|
|
|
|
|
|
const targetUrl = `/pages/shop/orderDetail?id=${data.order_id}`; |
|
|
|
|
|
|
|
// 将跳转路径存入本地缓存(关键:用于冷启动时首页接管) |
|
|
|
uni.setStorageSync('push_jump_url', targetUrl); |
|
|
|
|
|
|
|
// 尝试直接跳转(针对热启动) |
|
|
|
const pages = getCurrentPages(); |
|
|
|
if (pages.length > 0) { |
|
|
|
// 延迟300ms,确保页面栈稳定 |
|
|
|
setTimeout(() => { |
|
|
|
this.executeJump(targetUrl); |
|
|
|
}, 300); |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 执行跳转 |
|
|
|
executeJump(url) { |
|
|
|
uni.navigateTo({ |
|
|
|
url: url, |
|
|
|
fail: (err) => { |
|
|
|
// 如果页面栈超过10层导致 navigateTo 失败,则降级使用 redirectTo |
|
|
|
console.warn('navigateTo失败,尝试redirectTo', err); |
|
|
|
uni.redirectTo({ |
|
|
|
url: url |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
onPlayAudio(type) { |
|
|
|
var audio = null; |
|
|
|
audio = uni.getBackgroundAudioManager(); |
|
|
|
@ -258,6 +314,8 @@ |
|
|
|
audio.src = 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/e41404ed7c964ec4a203f0a7404585af.mp3'; |
|
|
|
} else if (type == 6) { //自配送 |
|
|
|
audio.src = 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/7050e7134dc24f56992fe405605d480e.mp3'; |
|
|
|
} else if (type == 7) { //中转超时 |
|
|
|
audio.src = 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/2fe04974ece245a79cd078dc7def773d.mp3'; |
|
|
|
} |
|
|
|
// #endif |
|
|
|
|
|
|
|
|