|
|
|
@ -124,52 +124,55 @@ |
|
|
|
plus.runtime.setBadgeNumber(0); |
|
|
|
let notificationEventType = result.notificationEventType |
|
|
|
let woopId = result.extras && result.extras.dataType === 'woop' && result.extras.value; |
|
|
|
const content = result.content || '' |
|
|
|
//用户点击了通知消息 |
|
|
|
if (result.notificationEventType === 'notificationOpened') { |
|
|
|
if (this.NB.isAndroidOrIOS() == 'iOS') { |
|
|
|
this.handlePushClick(result.ios.inAppExtras); |
|
|
|
} else { |
|
|
|
this.handlePushClick(result.android.inAppExtras); |
|
|
|
const inAppExtras = this.getPushInAppExtras(result); |
|
|
|
if (inAppExtras) { |
|
|
|
this.handlePushClick(inAppExtras); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
//用户收到了通知消息 |
|
|
|
if (result.notificationEventType == 'notificationArrived') { |
|
|
|
if (result.content.includes('订单出餐已超时')) { |
|
|
|
if (content.includes('订单出餐已超时')) { |
|
|
|
this.onPlayAudio(2) |
|
|
|
} else if (result.content.includes('您有一笔配送订单无人接单')) { |
|
|
|
} else if (content.includes('您有一笔配送订单无人接单')) { |
|
|
|
this.onPlayAudio(5) |
|
|
|
} else if (result.content.includes('您有一笔新的指定配送单,请及时接单')) { |
|
|
|
} else if (content.includes('您有一笔新的指定配送单,请及时接单')) { |
|
|
|
this.onPlayAudio(10) |
|
|
|
} else if (result.content.includes('您有一笔配送中订单用户申请退款')) { |
|
|
|
} else if (content.includes('您有一笔配送中订单用户申请退款')) { |
|
|
|
this.onPlayAudio(11) |
|
|
|
} else if (result.content.includes('抢单大厅来新单啦')) { |
|
|
|
} else if (content.includes('抢单大厅来新单啦')) { |
|
|
|
this.onPlayAudio(12) |
|
|
|
} else if (result.content.includes('您有中转配送订单超时未送达中转点')) { |
|
|
|
} else if (content.includes('您有中转配送订单超时未送达中转点')) { |
|
|
|
this.onPlayAudio(7) |
|
|
|
} else if (result.content.includes('您有一笔订单用户申请售后,请尽快处理')) { |
|
|
|
} else if (content.includes('您有一笔订单用户申请售后,请尽快处理')) { |
|
|
|
this.onPlayAudio(8) |
|
|
|
} else if (result.content.includes('您有一个后台指派单,请及时查看')) { |
|
|
|
} else if (content.includes('您有一个后台指派单,请及时查看')) { |
|
|
|
this.onPlayAudio(13) |
|
|
|
} else if (result.content.includes('您有一笔订单被改派')) { |
|
|
|
} else if (content.includes('您有一笔订单被改派')) { |
|
|
|
this.onPlayAudio(14) |
|
|
|
} else { |
|
|
|
if (result.content.includes('您有一笔新的订单')) { |
|
|
|
if (content.includes('您有一笔新的订单')) { |
|
|
|
this.onPlayAudio(4) |
|
|
|
} else if (result.content.includes('您有一笔新的到店订单')) { |
|
|
|
} else if (content.includes('您有一笔新的到店订单')) { |
|
|
|
this.onPlayAudio(3) |
|
|
|
} else if (result.content.includes('您有一笔订单申请退款')) { |
|
|
|
} else if (content.includes('您有一笔订单申请退款')) { |
|
|
|
this.onPlayAudio(1) |
|
|
|
} else if (result.content.includes('您有一笔商家自配送订单,请立即处理')) { |
|
|
|
} else if (content.includes('您有一笔商家自配送订单,请立即处理')) { |
|
|
|
this.onPlayAudio(6) |
|
|
|
} else if (result.content.includes('您有一笔预约订单可以出餐啦')) { |
|
|
|
} else if (content.includes('您有一笔预约订单可以出餐啦')) { |
|
|
|
this.onPlayAudio(9) |
|
|
|
} |
|
|
|
// 将消息数据推入打印队列 |
|
|
|
this.globalData.printData.push(JSON.parse(result.android.inAppExtras)) |
|
|
|
// 若当前未在打印,则启动队列处理 |
|
|
|
if (!this.globalData.isPrinting) { |
|
|
|
this.processPrintQueue() |
|
|
|
const printData = this.parsePushExtras(this.getPushInAppExtras(result)); |
|
|
|
if (printData && printData.order_id) { |
|
|
|
// 将消息数据推入打印队列 |
|
|
|
this.globalData.printData.push(printData) |
|
|
|
// 若当前未在打印,则启动队列处理 |
|
|
|
if (!this.globalData.isPrinting) { |
|
|
|
this.processPrintQueue() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -232,6 +235,22 @@ |
|
|
|
}, |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
getPushInAppExtras(result) { |
|
|
|
if (!result) return ''; |
|
|
|
if (this.NB.isAndroidOrIOS() == 'iOS') { |
|
|
|
return result.ios && result.ios.inAppExtras ? result.ios.inAppExtras : result.extras; |
|
|
|
} |
|
|
|
return result.android && result.android.inAppExtras ? result.android.inAppExtras : result.extras; |
|
|
|
}, |
|
|
|
parsePushExtras(extras) { |
|
|
|
if (!extras) return null; |
|
|
|
if (typeof extras === 'object') return extras; |
|
|
|
try { |
|
|
|
return JSON.parse(extras); |
|
|
|
} catch (e) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
}, |
|
|
|
autoConnectPrinter() { |
|
|
|
if (!uni.getStorageSync('bluetoothDeviceId')) return; |
|
|
|
const bluetooth = new Bluetooth({ |
|
|
|
@ -345,10 +364,17 @@ |
|
|
|
if (registerID) { |
|
|
|
this.globalData.registrationID = registerID |
|
|
|
uni.setStorageSync("registerID", registerID) |
|
|
|
this.reportClientId(registerID) |
|
|
|
} |
|
|
|
// uni.setStorageSync("signPerson", result.signPerson) |
|
|
|
}) |
|
|
|
}, |
|
|
|
reportClientId(clientId) { |
|
|
|
if (!clientId || !uni.getStorageSync('hiver_token')) return; |
|
|
|
this.NB.sendRequest('/auth/updateClientId', { |
|
|
|
clientId: clientId |
|
|
|
}, false, 'POST', 'application/x-www-form-urlencoded').catch(() => {}); |
|
|
|
}, |
|
|
|
getNotificationEnabled() { |
|
|
|
if (uni.getSystemInfoSync().platform == "ios") { |
|
|
|
jpushModule.requestNotificationAuthorization((result) => { |
|
|
|
|