| | |
| | | <template> |
| | | <div class="call-container" :class="{'incoming-call': state === 'ringing'} "> |
| | | <div class="content-wrapper"> |
| | | <!-- <div class="input-group"> |
| | | <div class="input-item"> |
| | | <span class="input-label">我的 userId:</span> |
| | | <input v-model="uid" class="input-field" /> |
| | | </div> |
| | | |
| | | <div class="input-item"> |
| | | <span class="input-label">对方 userId:</span> |
| | | <input v-model="peerUid" class="input-field" /> |
| | | </div> |
| | | </div>--> |
| | | |
| | | <div class="button-group" v-if="false"> |
| | | <button @click="connectWS" :disabled="connected" class="btn btn-connect">连接WS</button> |
| | | </div> |
| | |
| | | |
| | | |
| | | </div> |
| | | |
| | | <!-- <div class="tip-message"> |
| | | <small>提示:若 getUserMedia 不可用,请用 https 或 localhost 访问页面。</small> |
| | | </div>--> |
| | | |
| | | <!-- <div class="log-container"> |
| | | <div class="log-box"> |
| | | <div class="log-title">日志信息:</div> |
| | | <pre class="log-content">{{ logText }}</pre> |
| | | </div> |
| | | </div>--> |
| | | |
| | | <audio ref="remoteAudio" autoplay class="hidden-audio"></audio> |
| | | </div> |
| | | </template> |
| | |
| | | } |
| | | |
| | | // 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)); |
| | | } |
| | | } |
| | | // 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)); |
| | | // } |
| | | // } |
| | | } |
| | | |
| | | // 从URL参数或本地存储获取用户ID |
| | | const getUserIdFromStorage = () => { |
| | | // 从url获取用户id |
| | | const contact = JSON.parse(decodeURIComponent(receiveParameters.value)).userId |
| | | console.log('从url获取用户id',contact) |
| | | // 从本地获取用户id |
| | | const userId = localStorage.getItem('userId') || sessionStorage.getItem('userId') |
| | | console.log('从本地存储获取userId:', userId) |
| | | if (userId) { |
| | | log('🔗 从本地存储获取userId:', userId) |
| | | return userId |
| | | } |
| | | return '3' // 默认值 |
| | |
| | | callEnded.value = true |
| | | endMessage.value = '对方已挂断' |
| | | |
| | | // 延迟10秒后跳转页面 |
| | | // 延迟5秒后跳转页面 |
| | | endTimer.value = setTimeout(() => { |
| | | log('⏰ 通话结束10秒后自动返回') |
| | | // 返回上一页(uni-app的语音通话列表页面) |
| | | if (window.uni) { |
| | | window.uni.navigateBack() |
| | |
| | | |
| | | onMounted(() => { |
| | | console.log('收拾收拾',route.query.voiceparams); |
| | | console.log('接收参数', receiveParameters.value) |
| | | console.log('接收参数', JSON.parse(decodeURIComponent(receiveParameters.value))) |
| | | |
| | | // 解析并使用contact参数 |
| | | if (receiveParameters.value) { |