|
|
|
@ -172,15 +172,7 @@ |
|
|
|
} else if (content.includes('您有一笔预约订单可以出餐啦')) { |
|
|
|
this.onPlayAudio(9) |
|
|
|
} |
|
|
|
const printData = this.parsePushExtras(this.getPushInAppExtras(result)); |
|
|
|
if (printData && printData.order_id) { |
|
|
|
// 将消息数据推入打印队列 |
|
|
|
this.globalData.printData.push(printData) |
|
|
|
// 若当前未在打印,则启动队列处理 |
|
|
|
if (!this.globalData.isPrinting) { |
|
|
|
this.processPrintQueue() |
|
|
|
} |
|
|
|
} |
|
|
|
this.enqueuePrintFromPush(result); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -252,19 +244,46 @@ |
|
|
|
getPushInAppExtras(result) { |
|
|
|
if (!result) return ''; |
|
|
|
if (this.NB.isAndroidOrIOS() == 'iOS') { |
|
|
|
return result.ios && result.ios.inAppExtras ? result.ios.inAppExtras : result.extras; |
|
|
|
if (result.ios && result.ios.inAppExtras) return result.ios.inAppExtras; |
|
|
|
if (result.iOS && result.iOS.inAppExtras) return result.iOS.inAppExtras; |
|
|
|
if (result.extras && Object.keys(result.extras).length > 0) return result.extras; |
|
|
|
return result.iOS || ''; |
|
|
|
} |
|
|
|
return result.android && result.android.inAppExtras ? result.android.inAppExtras : result.extras; |
|
|
|
}, |
|
|
|
parsePushExtras(extras) { |
|
|
|
if (!extras) return null; |
|
|
|
if (typeof extras === 'object') return extras; |
|
|
|
if (typeof extras === 'object') { |
|
|
|
if (extras._j_data_) { |
|
|
|
try { |
|
|
|
return Object.assign({}, extras, JSON.parse(extras._j_data_)); |
|
|
|
} catch (e) { |
|
|
|
return extras; |
|
|
|
} |
|
|
|
} |
|
|
|
return extras; |
|
|
|
} |
|
|
|
try { |
|
|
|
return JSON.parse(extras); |
|
|
|
} catch (e) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
}, |
|
|
|
enqueuePrintFromPush(result) { |
|
|
|
const printData = this.parsePushExtras(this.getPushInAppExtras(result)); |
|
|
|
if (!printData) return; |
|
|
|
if (!printData.order_id && printData.orderId) { |
|
|
|
printData.order_id = printData.orderId; |
|
|
|
} |
|
|
|
if (!printData.order_id) { |
|
|
|
console.log('JPush print skipped, missing order_id:', JSON.stringify(printData)); |
|
|
|
return; |
|
|
|
} |
|
|
|
this.globalData.printData.push(printData) |
|
|
|
if (!this.globalData.isPrinting) { |
|
|
|
this.processPrintQueue() |
|
|
|
} |
|
|
|
}, |
|
|
|
autoConnectPrinter() { |
|
|
|
if (!uni.getStorageSync('bluetoothDeviceId')) return; |
|
|
|
const bluetooth = new Bluetooth({ |
|
|
|
@ -296,6 +315,10 @@ |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!data.order_id && data.orderId) { |
|
|
|
data.order_id = data.orderId; |
|
|
|
} |
|
|
|
if (!data.order_id) return; |
|
|
|
const targetUrl = `/pages/shop/orderDetail?id=${data.order_id}`; |
|
|
|
uni.setStorageSync('push_jump_url', targetUrl); |
|
|
|
const pages = getCurrentPages(); |
|
|
|
|