applications/mobile-web-view/src/appPages/voiceCallDetail/index.vue
@@ -48,8 +48,9 @@ </template> <script setup> import { ref, computed, onBeforeUnmount, onMounted } from 'vue' import { useRoute } from 'vue-router' const route = useRoute() /** ✅ 你的 WS 地址前缀(后面拼 userId) */ const WS_BASE = 'wss://wrj.shuixiongit.com/ws/chat?userId=' @@ -176,7 +177,8 @@ const stream = e.streams[0] if (remoteAudio.value) { remoteAudio.value.srcObject = stream remoteAudio.value.play().catch(() => {}) remoteAudio.value.play().catch(() => { }) } } @@ -476,6 +478,8 @@ } onMounted(() => { const receiveParameters = route.query.contact console.log('接收参数', receiveParameters) // 解析URL参数 parseUrlParams() }) uniapps/work-app/src/pages/voiceCall/index.vue
@@ -120,15 +120,11 @@ } // 拨打电话方法 const makeCall = (contact) => { const contactName = contact.friendNickName || '未知联系人' console.log('拨打电话给', contactName) // 这里可以添加实际的拨打电话逻辑 // uni.showToast({ // title: `正在拨打${contactName}的电话`, // icon: 'none' // }) console.log('拨打电话', contact) // 将contact对象转换为JSON字符串并URL编码 const contactStr = encodeURIComponent(JSON.stringify(contact)) uni.navigateTo({ url: `/subPackages/voiceCallDetail/index`, url: `/subPackages/voiceCallDetail/index?contact=${contactStr}`, }) } uniapps/work-app/src/subPackages/voiceCallDetail/index.vue
@@ -1,6 +1,5 @@ <!-- 登录页 --> <template> <!-- <web-view :src="`${viewUrl}`" @message="viewMessage" :allow="allow"/> --> <WebViewPlus ref="sWebViewRef" :src="`${viewUrl}`" @@ -9,15 +8,20 @@ </template> <script setup> import { useUserStore } from "@/store/index.js" import { getWebViewUrl } from "@/utils/index.js"; import { onLoad } from "@dcloudio/uni-app"; const userStore = useUserStore() const userParams = userStore?.userInfo ? JSON.stringify(userStore.userInfo) : '{}' const sWebViewRef = ref(null); const viewUrl = ref(""); onLoad((options) => { // const currentItem = options.currentItem; // viewUrl.value = getWebViewUrl("/mapWork", { currentItem: currentItem }); // viewUrl.value = getWebViewUrl("/voiceCallDetail"); viewUrl.value = 'https://192.168.57.124:5175/drone-command/demo'; // 解析传递过来的contact参数 const contact = options.contact ? JSON.parse(decodeURIComponent(options.contact)) : null; // 构建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 = 'https://192.168.57.124:5178/drone-command/demo'; }); function onPostMessage(data) {} // #ifdef APP-PLUS