From ce07f34c2b1aca1cc85b380d437c96174ba3ef78 Mon Sep 17 00:00:00 2001 From: duoaohui <928970622@qq.com> Date: Sun, 7 Jun 2026 11:44:35 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E9=80=9A=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/pages/cloud-law/video-call.vue | 32 +++++++++++++++++++-- frontend/src/utils/cloudLawVoiceCall.js | 16 +++++++++-- 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/frontend/src/pages/cloud-law/video-call.vue b/frontend/src/pages/cloud-law/video-call.vue index fa33bd9..9b7ba3b 100644 --- a/frontend/src/pages/cloud-law/video-call.vue +++ b/frontend/src/pages/cloud-law/video-call.vue @@ -479,9 +479,19 @@ const requestCloudLawCommands = (url) => { } const notifyCloudLawEnd = () => { - if (!callId.value) return Promise.resolve() const role = isLawRole.value ? 'law' : 'caller' const roomCode = meetingStore.currentRoom?.room_code || formattedCode.value || '' + console.log('[CloudLawVideoCall] notifyCloudLawEnd called', { + callId: callId.value, + role, + roomCode, + cloudLawApiBase: cloudLawApiBase.value, + hasToken: !!cloudLawToken.value + }) + if (!callId.value) { + console.warn('[CloudLawVideoCall] notifyCloudLawEnd SKIP: callId 为空,不会发结束请求') + return Promise.resolve() + } return notifyCloudLawBackendEnd(callId.value, role, cloudLawApiBase.value, cloudLawToken.value, roomCode) } @@ -1021,15 +1031,26 @@ const minimizeToMiniProgram = () => { } const hangup = async () => { - if (leaving.value) return + console.log('[CloudLawVideoCall] hangup CLICKED', { + leaving: leaving.value, + isLawRole: isLawRole.value, + callId: callId.value, + roomCode: meetingStore.currentRoom?.room_code || formattedCode.value || '' + }) + if (leaving.value) { + console.log('[CloudLawVideoCall] hangup SKIP: leaving 已为 true(重复点击)') + return + } userInitiatedHangup.value = true leaving.value = true stopCommandPolling() try { + console.log('[CloudLawVideoCall] hangup -> 调 notifyCloudLawEnd 前') // 先通知云律后端结束本次通话: // - 用户端:/api/applet/voiceConnection/{callId}/end // - 律师端:/api/law/voiceCall/{callId}/end → 后端 CloudLawEndMeeting 结束会议(双方都收到 room.ended) await notifyCloudLawEnd() + console.log('[CloudLawVideoCall] hangup -> notifyCloudLawEnd 已返回') if (isLawRole.value) { // 律师为参会者(非主持人),EndRoom 是 host-only。会议已由上面的 /end 在后端结束, // 这里仅本地离会即可(直接 endMeeting 会因非主持人 403,徒增一次失败请求)。 @@ -1088,10 +1109,15 @@ const hangup = async () => { console.warn('[CloudLawVideoCall] postMessage failed', e) } // 主路径:URL 桥接(最可靠)。失败再退回 navigateBack 兜底。 - if (!notifyNativeMiniProgramHangup()) { + const bridged = notifyNativeMiniProgramHangup() + console.log('[CloudLawVideoCall] hangup finally -> URL桥接结果:', bridged, 'hasMp:', !!mp) + if (!bridged) { try { if (mp && typeof mp.navigateBack === 'function') { mp.navigateBack({ delta: 1 }) + console.log('[CloudLawVideoCall] hangup finally -> 已调 navigateBack 兜底') + } else { + console.warn('[CloudLawVideoCall] hangup finally -> 无 mp.navigateBack,无法兜底导航') } } catch (e) { console.warn('[CloudLawVideoCall] navigateBack failed', e) diff --git a/frontend/src/utils/cloudLawVoiceCall.js b/frontend/src/utils/cloudLawVoiceCall.js index 2684ebe..7780ce2 100644 --- a/frontend/src/utils/cloudLawVoiceCall.js +++ b/frontend/src/utils/cloudLawVoiceCall.js @@ -132,14 +132,24 @@ const CLOUD_LAW_HANGUP_QUERY = 'cloudLawHangup' /** 小程序 web-view 内挂断:改 URL 触发原生页 @load,立即调 /end(不依赖 web-view 销毁) */ export function notifyNativeMiniProgramHangup() { // #ifdef H5 - if (typeof window === 'undefined') return false + if (typeof window === 'undefined') { + console.warn('[cloudLawVoiceCall] bridge skip: window undefined') + return false + } try { const mp = window.wx && window.wx.miniProgram - if (!mp) return false + if (!mp) { + console.warn('[cloudLawVoiceCall] bridge skip: window.wx.miniProgram 不存在(jweixin 未加载/不在小程序 web-view 内)') + return false + } const href = String(window.location.href || '') - if (href.includes(`${CLOUD_LAW_HANGUP_QUERY}=1`)) return true + if (href.includes(`${CLOUD_LAW_HANGUP_QUERY}=1`)) { + console.log('[cloudLawVoiceCall] bridge: URL 已含 cloudLawHangup=1,跳过重复重载') + return true + } const url = new URL(href) url.searchParams.set(CLOUD_LAW_HANGUP_QUERY, '1') + console.log('[cloudLawVoiceCall] bridge: location.replace ->', url.toString()) window.location.replace(url.toString()) return true } catch (e) {