tianyi 1 month ago
parent
commit
a418b80c9d
  1. 60
      App.vue

60
App.vue

@ -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;
// AndroidJSONiOSObject
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

Loading…
Cancel
Save