吉安感知网项目-前端
张含笑
2026-01-15 3c19d8e89a48137bdabee24e9bb1187e748618fc
feat:语音通话更新
4 files modified
54 ■■■■ changed files
applications/mobile-web-view/src/appPages/voiceCallDetail/index.vue 50 ●●●● patch | view | raw | blame | history
uniapps/work-app/src/hooks/useGlobalWS.js 2 ●●● patch | view | raw | blame | history
uniapps/work-app/src/subPackages/voiceCallDetail/index.vue 2 ●●● patch | view | raw | blame | history
uniapps/work-app/src/utils/common/index.js patch | view | raw | blame | history
applications/mobile-web-view/src/appPages/voiceCallDetail/index.vue
@@ -62,17 +62,51 @@
// 解析URL参数
const parseUrlParams = () => {
    const url = new URL(window.location.href)
    const paramsStr = url.searchParams.get('params')
    if (paramsStr) {
    // 1. 优先从route.query.voiceparams获取参数
    if (route.query && route.query.voiceparams) {
        console.log('从route.query.voiceparams获取参数:', route.query.voiceparams);
        try {
            const params = JSON.parse(decodeURIComponent(paramsStr))
            // 解码并解析voiceparams参数
            const params = JSON.parse(decodeURIComponent(route.query.voiceparams));
            console.log('解析后的voiceparams:', params);
            if (params.peerUid) {
                peerUid.value = String(params.peerUid)
                log('🔗 从URL参数获取peerUid:', params.peerUid)
                peerUid.value = String(params.peerUid);
                log('🔗 从voiceparams获取peerUid:', params.peerUid);
            }
            // 如果是来电类型,直接触发来电状态
            if (params.type === 'incoming') {
                log('📞 voiceparams检测到来电,直接进入来电状态');
                incomingFrom = String(params.from);
                peerUid.value = incomingFrom;
                acceptedByMe = false;
                offeredByPeer = false;
                state.value = 'ringing';
                log('📞 收到来电 call,来自', incomingFrom);
                // 开始来电提示(铃声和震动)
                playRingtone();
                startVibration();
            }
        } catch (e) {
            log('❌ 解析URL参数失败:', String(e))
            log('❌ 解析voiceparams参数失败:', String(e));
        }
    }
    // 2. 同时保留原有的URL参数解析逻辑,作为备选
    const url = new URL(window.location.href);
    const paramsStr = url.searchParams.get('params');
    if (paramsStr) {
        try {
            const params = JSON.parse(decodeURIComponent(paramsStr));
            if (params.peerUid) {
                peerUid.value = String(params.peerUid);
                log('🔗 从URL参数获取peerUid:', params.peerUid);
            }
        } catch (e) {
            log('❌ 解析URL参数失败:', String(e));
        }
    }
}
@@ -600,6 +634,8 @@
}
onMounted(() => {
console.log('收拾收拾',route.query.voiceparams);
    const receiveParameters = route.query.contact
    console.log('接收参数', receiveParameters)
uniapps/work-app/src/hooks/useGlobalWS.js
@@ -35,7 +35,7 @@
      const encodedParams = encodeURIComponent(JSON.stringify(callParams));
      
      // 跳转到mobile-web-view应用中的语音通话页面
      const voiceCallUrl = `http://localhost:9527/work-app/#/subPackages/voiceCallDetail/index?params=${encodedParams}`;
      const voiceCallUrl = `http://localhost:9527/work-app/#/subPackages/voiceCallDetail/index?voiceparams=${encodedParams}`;
      
      console.log('🔗 准备导航到:', voiceCallUrl)
uniapps/work-app/src/subPackages/voiceCallDetail/index.vue
@@ -21,7 +21,7 @@
  // 构建viewUrl,将contact参数拼接到URL中
  const contactParam = contact ? encodeURIComponent(JSON.stringify(contact)) : '';
  // viewUrl.value = `https://192.168.1.157:5176/mobile-web-view/#/webViewWrapper/voiceCallDetail?params=${encodeURIComponent(userParams)}&contact=${contactParam}`;
  viewUrl.value = getWebViewUrl("/voiceCallDetail", { contact: options.contact });
  viewUrl.value = getWebViewUrl("/voiceCallDetail", { contact: options.contact ,voiceparams: options.voiceparams});
});
function onPostMessage(data) {}
// #ifdef APP-PLUS
uniapps/work-app/src/utils/common/index.js