吉安感知网项目-前端
张含笑
2026-02-27 075f13e2f8c792af6d4f2afdc4832e9fe34957f7
feat:关闭弹框
3 files modified
31 ■■■■■ changed files
applications/mobile-web-view/src/appPages/voiceCallDetail/index.vue 20 ●●●●● patch | view | raw | blame | history
uniapps/work-app/src/hooks/useGlobalWS.js 1 ●●●● patch | view | raw | blame | history
uniapps/work-app/src/subPackages/voiceCallDetail/index.vue 10 ●●●●● patch | view | raw | blame | history
applications/mobile-web-view/src/appPages/voiceCallDetail/index.vue
@@ -448,9 +448,7 @@
    send('accept', incomingFrom, null)
    log('✅ 已点击接听,发送 accept 给', incomingFrom)
    // 停止铃声
//     const transmitData = { data: { type: 'stopVoice' } }
// uni.postMessage(transmitData)
    state.value = 'calling'
    // 如果 offer 已经提前到达(我们暂存了),立刻 answer
@@ -458,6 +456,9 @@
        answerOffer(lastOfferSdp, incomingFrom)
        lastOfferSdp = null
    }
    // 停止
    const transmitData = { data: { sign:'closeBox' } }
    uni.postMessage(transmitData)
}
function rejectCall() {
@@ -466,11 +467,8 @@
    // 你后端没有 reject,用 busy 表示拒绝/不可接听
    send('busy', incomingFrom, null)
    log('❌ 已拒绝来电,发送 busy 给', incomingFrom)
    const transmitData = { data: { type: 'hangupVoice' } }
    const transmitData = { data: { type: 'hangupVoice',sign:'closeBox'  } }
uni.postMessage(transmitData)
    // 停止铃声
//     const transmitData = { data: { type: 'stopVoice' } }
// uni.postMessage(transmitData)
    incomingFrom = null
    acceptedByMe = false
@@ -579,7 +577,8 @@
        // 对方挂断:显示提示,延迟10秒跳转
        callEnded.value = true
        endMessage.value = '对方已挂断'
        const transmitData = { data: { type: 'hangupVoice',sign:'closeBox'  } }
        uni.postMessage(transmitData)
        // 延迟5秒后跳转页面
        endTimer.value = setTimeout(() => {
            // 返回上一页(uni-app的语音通话列表页面)
@@ -588,11 +587,10 @@
            } else {
                log('❌ uni对象不存在,无法返回上一页')
            }
            const transmitData = { data: { type: 'hangupVoice' } }
            uni.postMessage(transmitData)
            // 重置通话结束状态
            callEnded.value = false
        }, 3000)
        }, 2000)
    }
}
uniapps/work-app/src/hooks/useGlobalWS.js
@@ -21,7 +21,6 @@
      console.log('📨 useGlobalWS 收到 WebView 消息:', data)
      // 处理挂断消息
      if (data?.type === 'hangupVoice') {
        console.log('📞 收到挂断消息')
        initWS()
      }
    });
uniapps/work-app/src/subPackages/voiceCallDetail/index.vue
@@ -17,7 +17,7 @@
const userParams = userStore?.userInfo ? JSON.stringify(userStore.userInfo) : '{}'
const sWebViewRef = ref(null);
const viewUrl = ref("");
const typeSign = ref('')
// #ifdef APP-PLUS
/**
 * 请求 Android 麦克风权限
@@ -80,6 +80,14 @@
});
function onPostMessage(data) {
typeSign.value = data?.sign || ''
if(typeSign.value === 'closeBox'){
    setTimeout(() => {
    // 关闭弹窗
    cancelIncomingCallNotification()
    }, 1000)
}
    // 将WebView消息传递给全局WebSocket处理
    if (typeof uni !== 'undefined' && uni.$emit) {
        uni.$emit('webViewMessage', data);