tianyi 5 days ago
parent
commit
60a7e7a070
  1. 36
      App.vue

36
App.vue

@ -228,65 +228,42 @@
},
},
methods: {
/**
* 打印队列处理器取队头数据打印打印完成后删除队头继续处理下一条
* 保证同一时间只有一条消息在打印按接收顺序依次执行
*/
processPrintQueue() {
// 退
if (this.globalData.printData.length === 0) {
this.globalData.isPrinting = false
return
}
//
this.globalData.isPrinting = true
// onDone
printer.getData(() => {
//
this.globalData.printData.shift()
//
this.processPrintQueue()
})
},
//
handlePushClick(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
});
@ -361,8 +338,8 @@
}
})
} else {
jpushModule.isNotificationEnabled((result) => { //android
if (result.code == 0) { //0
jpushModule.isNotificationEnabled((result) => {
if (result.code == 0) {
this.noticMsgTool()
}
})
@ -370,7 +347,6 @@
},
noticMsgTool() {
if (uni.getSystemInfoSync().platform == "ios") {
//
uni.showModal({
title: '通知权限开启提醒',
content: '您还没有开启通知权限,无法接受到消息通知,请前往设置!',
@ -387,7 +363,6 @@
}
});
} else {
//android
var main = plus.android.runtimeMainActivity();
var pkName = main.getPackageName();
var uid = main.getApplicationInfo().plusGetAttribute("uid");
@ -400,20 +375,19 @@
if (res.confirm) {
var Intent = plus.android.importClass('android.content.Intent');
var Build = plus.android.importClass("android.os.Build");
//android 8.0
if (Build.VERSION.SDK_INT >= 26) {
var intent = new Intent('android.settings.APP_NOTIFICATION_SETTINGS');
intent.putExtra('android.provider.extra.APP_PACKAGE', pkName);
} else if (Build.VERSION.SDK_INT >= 21) { //android 5.0-7.0
} else if (Build.VERSION.SDK_INT >= 21) {
var intent = new Intent('android.settings.APP_NOTIFICATION_SETTINGS');
intent.putExtra("app_package", pkName);
intent.putExtra("app_uid", uid);
} else { //(<21)--
} else {
intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
var uri = Uri.fromParts("package", mainActivity.getPackageName(), null);
intent.setData(uri);
}
//
main.startActivity(intent);
}
}

Loading…
Cancel
Save