From 60a7e7a070564194e88fc478c9884c2f34c3f09f Mon Sep 17 00:00:00 2001 From: tianyi <13521030702@163.com> Date: Thu, 23 Jul 2026 18:02:27 +0800 Subject: [PATCH] 1 --- App.vue | 36 +++++------------------------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/App.vue b/App.vue index 57ecbcd..38496d2 100644 --- a/App.vue +++ b/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; - - // 兼容处理:Android有时返回JSON字符串,iOS返回Object 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); } }