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

144
App.vue

@ -66,43 +66,43 @@
$t: '', $t: '',
userInfo: {}, userInfo: {},
registrationID: '', registrationID: '',
printData: [], // printData: [], //
isPrinting: false, // isPrinting: false, //
}, },
onLaunch: function() { onLaunch: function() {
let context = this; let context = this;
// //
// #ifdef APP-PLUS // #ifdef APP-PLUS
plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) { plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
// uni.request({ // uni.request({
// url: '', // url: '',
// data: { // data: {
// version: widgetInfo.version, // version: widgetInfo.version,
// name: widgetInfo.name // name: widgetInfo.name
// }, // },
// success: (result) => { // success: (result) => {
// var data = result.data; // var data = result.data;
// if (data.update && data.wgtUrl) { // if (data.update && data.wgtUrl) {
// uni.downloadFile({ // uni.downloadFile({
// url: data.wgtUrl, // url: data.wgtUrl,
// success: (downloadResult) => { // success: (downloadResult) => {
// if (downloadResult.statusCode === 200) { // if (downloadResult.statusCode === 200) {
// plus.runtime.install(downloadResult.tempFilePath, { // plus.runtime.install(downloadResult.tempFilePath, {
// force: false // force: false
// }, function() { // }, function() {
// console.log('install success...'); // console.log('install success...');
// plus.runtime.restart(); // plus.runtime.restart();
// }, function(e) { // }, function(e) {
// console.error('install fail...'); // console.error('install fail...');
// }); // });
// } // }
// } // }
// }); // });
// } // }
// } // }
// }); // });
}); });
// #endif // #endif
this.globalData._i18n = this.$i18n //$i18n this.globalData._i18n = this.$i18n //$i18n
this.globalData.$t = function(str) { this.globalData.$t = function(str) {
@ -137,12 +137,23 @@
plus.runtime.setBadgeNumber(0); plus.runtime.setBadgeNumber(0);
let notificationEventType = result.notificationEventType let notificationEventType = result.notificationEventType
let woopId = result.extras && result.extras.dataType === 'woop' && result.extras.value; let woopId = result.extras && result.extras.dataType === 'woop' && result.extras.value;
//
if(result.notificationEventType == 'notificationArrived'){ 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('订单出餐已超时')) { if (result.content.includes('订单出餐已超时')) {
this.onPlayAudio(2) this.onPlayAudio(2)
} else if (result.content.includes('您有一笔配送订单无人接单')){ } else if (result.content.includes('您有一笔配送订单无人接单')) {
this.onPlayAudio(5) this.onPlayAudio(5)
} else if (result.content.includes('您有中转配送订单超时未送达中转点')) {
this.onPlayAudio(7)
} else { } else {
if (result.content.includes('您有一笔新的订单')) { if (result.content.includes('您有一笔新的订单')) {
this.onPlayAudio(4) this.onPlayAudio(4)
@ -150,9 +161,9 @@
this.onPlayAudio(3) this.onPlayAudio(3)
} else if (result.content.includes('您有一笔订单申请退款')) { } else if (result.content.includes('您有一笔订单申请退款')) {
this.onPlayAudio(1) this.onPlayAudio(1)
} else if(result.content.includes('您有一笔商家自配送订单,请立即处理')){ } else if (result.content.includes('您有一笔商家自配送订单,请立即处理')) {
this.onPlayAudio(6) this.onPlayAudio(6)
} }
// //
this.globalData.printData.push(JSON.parse(result.android.inAppExtras)) this.globalData.printData.push(JSON.parse(result.android.inAppExtras))
// //
@ -161,9 +172,8 @@
} }
} }
} }
});
});
jpushModule.isPushStopped(res => { jpushModule.isPushStopped(res => {
// code 0 1 // code 0 1
const { const {
@ -240,6 +250,52 @@
this.processPrintQueue() 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) { onPlayAudio(type) {
var audio = null; var audio = null;
audio = uni.getBackgroundAudioManager(); audio = uni.getBackgroundAudioManager();
@ -248,19 +304,21 @@
// #ifdef APP-PLUS // #ifdef APP-PLUS
if (type == 1) { //退 if (type == 1) { //退
audio.src = 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/cb24e35cfb1b48a58823633f23398d45.mp3'; audio.src = 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/cb24e35cfb1b48a58823633f23398d45.mp3';
} else if (type == 2) { // } else if (type == 2) { //
audio.src = 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/4d20a1cbc92c42f4b70de1b9dacb7979.mp3'; audio.src = 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/4d20a1cbc92c42f4b70de1b9dacb7979.mp3';
} else if (type == 3) { // } else if (type == 3) { //
audio.src = 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/3ced308cf72348a3adeb07d003ced5f3.mp3'; audio.src = 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/3ced308cf72348a3adeb07d003ced5f3.mp3';
} else if (type == 4) { // } else if (type == 4) { //
audio.src = 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/c60ef3944e58461fbe7ce23ae38c70a2.mp3'; audio.src = 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/c60ef3944e58461fbe7ce23ae38c70a2.mp3';
} else if(type == 5){ // } else if (type == 5) { //
audio.src = 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/e41404ed7c964ec4a203f0a7404585af.mp3'; audio.src = 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/e41404ed7c964ec4a203f0a7404585af.mp3';
} else if(type == 6){ // } else if (type == 6) { //
audio.src = 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/7050e7134dc24f56992fe405605d480e.mp3'; 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 // #endif
audio.play(); audio.play();
audio.onEnded(function(res) { audio.onEnded(function(res) {
audio = null; audio = null;

Loading…
Cancel
Save