From 126e26c21c1b20837707bd4dc1dca632810e392b Mon Sep 17 00:00:00 2001 From: tianyi <13521030702@163.com> Date: Fri, 24 Apr 2026 18:02:23 +0800 Subject: [PATCH] 1 --- App.vue | 67 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 18 deletions(-) diff --git a/App.vue b/App.vue index 112aca8..b3e0cde 100644 --- a/App.vue +++ b/App.vue @@ -46,8 +46,8 @@ // mainurl: 'https://taketest.sdwanyue.com/api/?s=', // mainurl: 'https://take.sdwanyue.com/api/?s=', // mainurl: 'https://dev.xenjoyou.com/hiver', - mainurl: 'https://hbkuaishi.com/hiver', - // mainurl: 'http://192.168.1.192:8888/hiver', + // mainurl: 'https://hbkuaishi.com/hiver', + mainurl: 'http://192.168.1.192:8888/hiver', // #endif // weburl: 'https://taketest.sdwanyue.com/', weburl: 'https://takeout.sdwanyue.com/', @@ -69,7 +69,7 @@ $t: '', userInfo: {}, registrationID: '', - printData:[] + printData: [] }, onLaunch: function() { let context = this; @@ -83,7 +83,7 @@ // this.getRegistrationID() // #ifdef APP-PLUS jpushModule.initJPushService(); - + jpushModule.setLoggerEnable(true); plus.screen.lockOrientation("portrait-primary"); // // 设置别名 @@ -94,13 +94,13 @@ //监听 极光推送连接状态 this.getNotificationEnabled(); jpushModule.addConnectEventListener(result => { - console.log('----------------------------',result) + console.log('----------------------------', result) let connectEnable = result.connectEnable if (connectEnable == true) { - + this.getRegistrationID() } else { - + } console.log('监听到了连接状态变化 --- ') }); @@ -110,13 +110,22 @@ let notificationEventType = result.notificationEventType let woopId = result.extras && result.extras.dataType === 'woop' && result.extras.value; console.log("通知", result) - - this.globalData.printData.push(JSON.parse(result.android.inAppExtras)) - console.log("通知数据",this.globalData.printData) - // printer.getIsData("1") - printer.getData() + if (result.content.includes('订单出餐已超时')) { + this.onPlayAudio(2) + } else{ + if(result.content.includes('您有一笔新的订单')){ + this.onPlayAudio(4) + }else if(result.content.includes('您有一笔新的到店订单')){ + this.onPlayAudio(3) + } else if(result.content.includes('您有一笔订单申请退款')){ + this.onPlayAudio(1) + } + this.globalData.printData.push(JSON.parse(result.android.inAppExtras)) + printer.getData() + } + console.log("通知数据", this.globalData.printData) }); - + jpushModule.isPushStopped(res => { // code 0已停止推送 1未停止推送 const { @@ -151,16 +160,16 @@ // #ifdef MP-WEIXIN this.globalData.GaoDeKey_amapkey = '52de86da47be2ea547c37dd382025a0c' // #endif - if(!uni.getStorageSync('bluetoothDeviceId')){ + if (!uni.getStorageSync('bluetoothDeviceId')) { uni.showModal({ title: '提示', content: '您还没有连接打印机,将无法为您打印小票!', - confirmText:'连接蓝牙', - cancelText:'暂不连接', - success: function (res) { + confirmText: '连接蓝牙', + cancelText: '暂不连接', + success: function(res) { if (res.confirm) { uni.navigateTo({ - url:'/pages/myCenter/setPrint' + url: '/pages/myCenter/setPrint' }) } } @@ -174,6 +183,28 @@ }, }, methods: { + onPlayAudio(type) { + var audio = null; + audio = uni.getBackgroundAudioManager(); + audio.title = "通知音"; + audio.singer = "通知音"; + // #ifdef APP-PLUS + if (type == 1) { //退款 + audio.src = 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/cb24e35cfb1b48a58823633f23398d45.mp3'; + } else if (type == 2) { //超时 + audio.src = 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/4d20a1cbc92c42f4b70de1b9dacb7979.mp3'; + } else if (type == 3) { //到店订单 + audio.src = 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/3ced308cf72348a3adeb07d003ced5f3.mp3'; + } else if (type == 4) { //新订单 + audio.src = 'https://jewel-shop.oss-cn-beijing.aliyuncs.com/c60ef3944e58461fbe7ce23ae38c70a2.mp3'; + } + // #endif + + audio.play(); + audio.onEnded(function(res) { + audio = null; + }) + }, getAreaSize() { var res = uni.getSystemInfoSync() // console.log(res)