| | |
| | | |
| | | // 消息处理 |
| | | function messageHandler(payload) { |
| | | |
| | | // 先尝试直接处理消息(适用于mobile-web-view的voiceCallDetail页面的消息格式) |
| | | const t = (payload.type || '').toString() |
| | | callStatus.value = t |
| | |
| | | if (t === 'call') { |
| | | console.log('📞 全局收到来电 call,来自', payload.from) |
| | | // 触发震动 |
| | | triggerVibration(); |
| | | // triggerVibration(); |
| | | // 构建来电参数 |
| | | const callParams = { |
| | | peerUid: payload.from, |
| | |
| | | // #endif |
| | | // 转义参数以便在URL中传递 |
| | | const encodedParams = encodeURIComponent(JSON.stringify(callParams)); |
| | | |
| | | try { |
| | | // 优先使用uni-app的导航API(适用于同应用内跳转) |
| | | if (typeof uni !== 'undefined' && uni.navigateTo) { |
| | | uni.navigateTo({ |
| | | url: `/subPackages/voiceCallDetail/index?voiceparams=${encodedParams}`, |
| | | }); |
| | | uni.navigateTo({ |
| | | url: `/subPackages/voiceCallDetail/index?voiceparams=${encodedParams}`, |
| | | }); |
| | | } else { |
| | | console.error('无法跳转到语音通话页面:当前环境不支持导航'); |
| | | } |
| | |
| | | console.error('跳转到语音通话页面失败:', error); |
| | | } |
| | | return |
| | | } |
| | | // 通话接听或结束时,取消来电通知 |
| | | if (t === 'accept' || t === 'reject' || t === 'hangup' || t === 'cancel') { |
| | | // #ifdef APP-PLUS |
| | | cancelIncomingCallNotification() |
| | | // #endif |
| | | } |
| | | } |
| | | |