| | |
| | | // 存储铃声实例 |
| | | let ringtoneInstance = null |
| | | |
| | | // 监听WebView消息事件 |
| | | if (typeof uni !== 'undefined' && uni.$on) { |
| | | uni.$on('webViewMessage', (data) => { |
| | | console.log('📨 useGlobalWS 收到 WebView 消息:', data) |
| | | // 处理挂断消息 |
| | | if (data?.type === 'hangupVoice') { |
| | | console.log('📞 收到挂断消息') |
| | | initWS() |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // 设置默认用户ID为3 |
| | | const defaultUserId = '2021474815063486465'; |
| | | // WebSocket基础URL |
| | |
| | | return |
| | | } |
| | | recoverTimer = setInterval(() => { |
| | | // console.log('shouldRecoverWS()',shouldRecoverWS(),'----------',websocketService.getConnected()) |
| | | if (shouldRecoverWS() && !websocketService.getConnected()) { |
| | | initWS() |
| | | } |
| | |
| | | } |
| | | |
| | | function initWS() { |
| | | websocketService.close() |
| | | const userStore = useUserStore() |
| | | accessToken.value =userStore?.userInfo.access_token |
| | | if (!accessToken.value || isVoiceCallDetailActive()) { |