From ffa816c14e386b0cc2ceed728af0d2487a2b76dc Mon Sep 17 00:00:00 2001
From: 张含笑 <zhx18749296735@163.com>
Date: Wed, 11 Feb 2026 14:08:43 +0800
Subject: [PATCH] feat:更换id
---
applications/mobile-web-view/src/appPages/voiceCallDetail/index.vue | 132 ++++++++++++++++++++++----------------------
applications/drone-command/src/views/audioCall.vue | 8 +-
uniapps/work-app/src/hooks/useGlobalWS.js | 5 +
3 files changed, 73 insertions(+), 72 deletions(-)
diff --git a/applications/drone-command/src/views/audioCall.vue b/applications/drone-command/src/views/audioCall.vue
index aa0cbaf..161c2fa 100644
--- a/applications/drone-command/src/views/audioCall.vue
+++ b/applications/drone-command/src/views/audioCall.vue
@@ -36,10 +36,10 @@
import { ref, computed, onBeforeUnmount } from 'vue'
/** ✅ 你的 WS 地址前缀(后面拼 userId) */
-const WS_BASE = 'wss://wrj.shuixiongit.com/ws/chat?userId='
+const WS_BASE = 'ws://218.202.104.82:38201/ws/chat'
-const uid = ref('2')
-const peerUid = ref('3')
+const uid = ref('1')
+const peerUid = ref('2011686857615683585')
const connected = ref(false)
const state = ref('idle') // idle | calling | ringing | in-call
@@ -310,7 +310,7 @@
function connectWS() {
if (ws) ws.close()
- ws = new WebSocket(WS_BASE + encodeURIComponent(uid.value))
+ ws = new WebSocket(WS_BASE, "eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VyX2tleSI6IjBkM2NlYmZhLTU4NTUtNDQ1OS04YWQwLTk2NzBlODM2N2Q2OCIsInVzZXJuYW1lIjoiYWRtaW4ifQ.ALOJPzPad4OGNIwx3U61eXEZaGeVd46KlJhVXVWBXMg9q-ks8LqJTx8eXoS-SjjrYDegdAZCkn_TW-xqbe6C6A")
ws.onopen = () => {
connected.value = true
diff --git a/applications/mobile-web-view/src/appPages/voiceCallDetail/index.vue b/applications/mobile-web-view/src/appPages/voiceCallDetail/index.vue
index ec529b9..def0475 100644
--- a/applications/mobile-web-view/src/appPages/voiceCallDetail/index.vue
+++ b/applications/mobile-web-view/src/appPages/voiceCallDetail/index.vue
@@ -43,73 +43,9 @@
/** ✅ 你的 WS 地址前缀(后面拼 userId) */
// const WS_BASE = 'ws://218.202.104.82:38201/ws/chat?userId='
const WS_BASE = 'ws://218.202.104.82:38201/ws/chat'
-// 解析URL参数
-const parseUrlParams = () => {
- // 1. 优先从route.query.voiceparams获取参数
- if (route.query && route.query.voiceparams) {
- console.log('从route.query.voiceparams获取参数:', route.query.voiceparams);
- try {
- // 解码并解析voiceparams参数
- const params = JSON.parse(decodeURIComponent(route.query.voiceparams));
- console.log('解析后的voiceparams:', params);
-
- if (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('❌ 解析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));
- }
- }
-}
-
-// 从URL参数或本地存储获取用户ID
-const getUserIdFromStorage = () => {
- // 从url获取用户id
- const contact = JSON.parse(decodeURIComponent(receiveParameters.value))
- console.log('从url获取用户id',contact?.userId)
- // 从本地获取用户id
- const userId = localStorage.getItem('userId') || sessionStorage.getItem('userId')
- console.log('从本地存储获取userId:', userId)
- if (userId) {
- return userId
- }
- return '3' // 默认值
-}
-
-const uid = ref('3')
-const peerUid = ref('2')
+const uid = ref('2011686857615683585')
+const peerUid = ref('1')
// 联系人名称
const contactName = ref('张三')
@@ -151,6 +87,70 @@
if (timer) clearInterval(timer)
timer = null
}
+// 解析URL参数
+const parseUrlParams = () => {
+ // 1. 优先从route.query.voiceparams获取参数
+ if (route.query && route.query.voiceparams) {
+ console.log('从route.query.voiceparams获取参数:', route.query.voiceparams);
+ try {
+ // 解码并解析voiceparams参数
+ const params = JSON.parse(decodeURIComponent(route.query.voiceparams));
+ console.log('解析后的voiceparams:', params);
+
+ if (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('❌ 解析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));
+ }
+ }
+}
+
+// 从URL参数或本地存储获取用户ID
+const getUserIdFromStorage = () => {
+ // 从url获取用户id
+ const contact = JSON.parse(decodeURIComponent(receiveParameters.value))
+ console.log('从url获取用户id',contact?.userId)
+ // 从本地获取用户id
+ const userId = localStorage.getItem('userId') || sessionStorage.getItem('userId')
+ console.log('从本地存储获取userId:', userId)
+ if (userId) {
+ return userId
+ }
+ return '2011686857615683585' // 默认值
+}
// 心跳
let pingTimer = null
diff --git a/uniapps/work-app/src/hooks/useGlobalWS.js b/uniapps/work-app/src/hooks/useGlobalWS.js
index b8595a3..ec6a57d 100644
--- a/uniapps/work-app/src/hooks/useGlobalWS.js
+++ b/uniapps/work-app/src/hooks/useGlobalWS.js
@@ -8,9 +8,10 @@
const callStatus = ref(null)
// 设置默认用户ID为3
- const defaultUserId = '8';
+ const defaultUserId = '2011686857615683585';
// WebSocket基础URL
- const WS_BASE = 'wss://wrj.shuixiongit.com/ws/chat?userId=';
+ // const WS_BASE = 'wss://wrj.shuixiongit.com/ws/chat?userId=';
+ const WS_BASE = 'ws://218.202.104.82:38201/ws/chat';
// 消息处理
function messageHandler(payload) {
--
Gitblit v1.9.3