视频通话
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user