视频通话

This commit is contained in:
duoaohui
2026-06-07 11:44:35 +08:00
parent c033b21b02
commit ce07f34c2b
2 changed files with 42 additions and 6 deletions

View File

@@ -479,9 +479,19 @@ const requestCloudLawCommands = (url) => {
} }
const notifyCloudLawEnd = () => { const notifyCloudLawEnd = () => {
if (!callId.value) return Promise.resolve()
const role = isLawRole.value ? 'law' : 'caller' const role = isLawRole.value ? 'law' : 'caller'
const roomCode = meetingStore.currentRoom?.room_code || formattedCode.value || '' 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) return notifyCloudLawBackendEnd(callId.value, role, cloudLawApiBase.value, cloudLawToken.value, roomCode)
} }
@@ -1021,15 +1031,26 @@ const minimizeToMiniProgram = () => {
} }
const hangup = async () => { 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 userInitiatedHangup.value = true
leaving.value = true leaving.value = true
stopCommandPolling() stopCommandPolling()
try { try {
console.log('[CloudLawVideoCall] hangup -> 调 notifyCloudLawEnd 前')
// 先通知云律后端结束本次通话: // 先通知云律后端结束本次通话:
// - 用户端:/api/applet/voiceConnection/{callId}/end // - 用户端:/api/applet/voiceConnection/{callId}/end
// - 律师端:/api/law/voiceCall/{callId}/end → 后端 CloudLawEndMeeting 结束会议(双方都收到 room.ended // - 律师端:/api/law/voiceCall/{callId}/end → 后端 CloudLawEndMeeting 结束会议(双方都收到 room.ended
await notifyCloudLawEnd() await notifyCloudLawEnd()
console.log('[CloudLawVideoCall] hangup -> notifyCloudLawEnd 已返回')
if (isLawRole.value) { if (isLawRole.value) {
// 律师为参会者非主持人EndRoom 是 host-only。会议已由上面的 /end 在后端结束, // 律师为参会者非主持人EndRoom 是 host-only。会议已由上面的 /end 在后端结束,
// 这里仅本地离会即可(直接 endMeeting 会因非主持人 403徒增一次失败请求 // 这里仅本地离会即可(直接 endMeeting 会因非主持人 403徒增一次失败请求
@@ -1088,10 +1109,15 @@ const hangup = async () => {
console.warn('[CloudLawVideoCall] postMessage failed', e) console.warn('[CloudLawVideoCall] postMessage failed', e)
} }
// 主路径URL 桥接(最可靠)。失败再退回 navigateBack 兜底。 // 主路径URL 桥接(最可靠)。失败再退回 navigateBack 兜底。
if (!notifyNativeMiniProgramHangup()) { const bridged = notifyNativeMiniProgramHangup()
console.log('[CloudLawVideoCall] hangup finally -> URL桥接结果:', bridged, 'hasMp:', !!mp)
if (!bridged) {
try { try {
if (mp && typeof mp.navigateBack === 'function') { if (mp && typeof mp.navigateBack === 'function') {
mp.navigateBack({ delta: 1 }) mp.navigateBack({ delta: 1 })
console.log('[CloudLawVideoCall] hangup finally -> 已调 navigateBack 兜底')
} else {
console.warn('[CloudLawVideoCall] hangup finally -> 无 mp.navigateBack无法兜底导航')
} }
} catch (e) { } catch (e) {
console.warn('[CloudLawVideoCall] navigateBack failed', e) console.warn('[CloudLawVideoCall] navigateBack failed', e)

View File

@@ -132,14 +132,24 @@ const CLOUD_LAW_HANGUP_QUERY = 'cloudLawHangup'
/** 小程序 web-view 内挂断:改 URL 触发原生页 @load立即调 /end不依赖 web-view 销毁) */ /** 小程序 web-view 内挂断:改 URL 触发原生页 @load立即调 /end不依赖 web-view 销毁) */
export function notifyNativeMiniProgramHangup() { export function notifyNativeMiniProgramHangup() {
// #ifdef H5 // #ifdef H5
if (typeof window === 'undefined') return false if (typeof window === 'undefined') {
console.warn('[cloudLawVoiceCall] bridge skip: window undefined')
return false
}
try { try {
const mp = window.wx && window.wx.miniProgram 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 || '') 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) const url = new URL(href)
url.searchParams.set(CLOUD_LAW_HANGUP_QUERY, '1') url.searchParams.set(CLOUD_LAW_HANGUP_QUERY, '1')
console.log('[cloudLawVoiceCall] bridge: location.replace ->', url.toString())
window.location.replace(url.toString()) window.location.replace(url.toString())
return true return true
} catch (e) { } catch (e) {