From 1bb4170b5070660480ab8f0fea37230245949d3c Mon Sep 17 00:00:00 2001 From: cc <824295981@qq.com> Date: Thu, 5 Feb 2026 17:54:43 +0800 Subject: [PATCH 1/5] 1 --- manifest.json | 2 +- pages.json | 21 +- pages/room/room.nvue | 1153 ++++++++++++++++++------------------------ stores/user.js | 105 ++-- 4 files changed, 586 insertions(+), 695 deletions(-) diff --git a/manifest.json b/manifest.json index 47bb6d0..2c77095 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name" : "密谈IM", - "appid" : "__UNI__D40A151", + "appid" : "__UNI__BE00EFC", "description" : "", "versionName" : "1.1.3", "versionCode" : 112, diff --git a/pages.json b/pages.json index 33996f2..c002ee4 100644 --- a/pages.json +++ b/pages.json @@ -441,17 +441,6 @@ } } }, - { - "path" : "pages/room/room", - "style" : - { - "navigationBarTitleText": "Room", - "enablePullDownRefresh": false, - "navigationStyle":"custom", - "gestureBack":"NO" - } - - }, // #endif // #ifdef H5 { @@ -469,6 +458,16 @@ } }, // #endif + { + "path" : "pages/room/room", + "style" : + { + "navigationBarTitleText": "Room", + "enablePullDownRefresh": false, + "navigationStyle":"custom", + "gestureBack":"NO" + } + }, { "path": "pages/adduser/index", "style": { diff --git a/pages/room/room.nvue b/pages/room/room.nvue index 9aa6a5c..1244e66 100644 --- a/pages/room/room.nvue +++ b/pages/room/room.nvue @@ -1,712 +1,557 @@ - - \ No newline at end of file diff --git a/stores/user.js b/stores/user.js index 2d315ab..86908d8 100644 --- a/stores/user.js +++ b/stores/user.js @@ -21,7 +21,11 @@ import { import * as CallLib from "@/uni_modules/RongCloud-CallWrapper/lib/index" import RCIMIWEngine from '@/uni_modules/RongCloud-IMWrapper-V2/js_sdk/RCIMEngine' import permision from "@/js_sdk/wa-permission/permission.js" -import {reasonDeal,errorDeal,imCode} from '@/utils/code.js' +import { + reasonDeal, + errorDeal, + imCode +} from '@/utils/code.js' // #endif // #ifdef H5 import { @@ -85,6 +89,7 @@ export const useUserStore = defineStore('user', () => { /** 用户积分数 */ const integralData = ref(0) + // 融云 const imEngine = ref(null) /** @@ -173,7 +178,9 @@ export const useUserStore = defineStore('user', () => { const options = { naviServer: '' } - imEngine.value = await RCIMIWEngine.create(tencentUserSig.value.appKey, options) + if(!imEngine.value){ + imEngine.value = await RCIMIWEngine.create(tencentUserSig.value.appKey, options) + } imEngine.value.setOnConnectedListener((res) => { if (res.code != 0) { uni.hideLoading(); @@ -187,8 +194,6 @@ export const useUserStore = defineStore('user', () => { CallLib.init({}); onAllListeners() console.log('call.init') - // this.libPage = true; - // this.loginUserId = res.userId; uni.hideLoading(); console.log('登录成功') if (uni.getSystemInfoSync().platform === 'android') { @@ -205,38 +210,54 @@ export const useUserStore = defineStore('user', () => { }) } } - - function onAllListeners(){ + + function onAllListeners() { CallLib.onCallReceived(res => { - console.log(res) - console.log( - 'Engine:OnCallReceived=>' + '监听通话呼入, 目标id=>', - res.data.targetId - ) + console.log(res) + console.log( + 'Engine:OnCallReceived=>' + '监听通话呼入, 目标id=>', + res.data.targetId + ) + let session = res.data + // //呼入 + uni.setStorageSync('room-parameters', { + callType: 'in', + mediaType: session.mediaType === 0 ? 'audio' : 'video' + }); + //跳转.nvue + uni.navigateTo({ + url:'/pages/room/room' + }); }) - + CallLib.onCallConnected(res => { - console.log(res) - console.log( - 'Engine:OnCallConnected=>' + - '已建立通话通话接通时,通过回调 onCallConnected 通知当前 call 的详细信息', - res - ) + console.log(res) + console.log( + 'Engine:OnCallConnected=>' + + '已建立通话通话接通时,通过回调 onCallConnected 通知当前 call 的详细信息', + res + ) }) - + CallLib.onRemoteUserInvited((res)=>{ + console.log("Engine:OnRemoteUserInvited=>"+"通话中的某一个参与者,邀请好友加入通话 ,远端Id为=>", res.data.userId); + uni.$emit('OnCallConnected'); + }) + CallLib.onRemoteUserJoined(res => { - console.log( - 'Engine:OnRemoteUserJoined=>' + - '主叫端拨出电话,被叫端收到请求后,加入通话,被叫端Id为=>', - res.data.userId - ) + console.log( + 'Engine:OnRemoteUserJoined=>' + + '主叫端拨出电话,被叫端收到请求后,加入通话,被叫端Id为=>', + res.data.userId + ) + uni.$emit('OnCallConnected'); }) - + CallLib.onCallDisconnected(res => { - console.log( - 'Engine:OnCallDisconnected=>' + '挂断成功, 挂断原因=>', - res.data.reason - ) + console.log( + 'Engine:OnCallDisconnected=>' + '挂断成功, 挂断原因=>', + res.data.reason + ) + uni.$emit('OnCallDisconnected'); }) } @@ -264,6 +285,7 @@ export const useUserStore = defineStore('user', () => { // #ifdef APP-PLUS removeFriendList() removeGroupList() + removeAllListeners() await useLoginState().logout() // #endif // #ifdef H5 @@ -278,6 +300,31 @@ export const useUserStore = defineStore('user', () => { reLaunch('/pages/login/login') } } + + function removeAllListeners(){ + CallLib.unInit(); + //移除监听-接收到通话呼入 + CallLib.removeCallReceivedListener(); + // 移除监听-开始呼叫通话的回调 + CallLib.removeCallOutgoingListener(); + // 移除监听-通话已接通 + CallLib.removeCallReceivedListener(); + // 移除监听-通话已结束 + CallLib.removeCallDisconnectedListener(); + // 移除监听-对端用户正在振铃 + CallLib.removeRemoteUserRingingListener(); + // 移除监听-对端用户加入了通话 + CallLib.removeRemoteUserJoinedListener(); + // 移除监听-有用户被邀请加入通话 + CallLib.removeRemoteUserInvited(); + // 移除监听-对端用户挂断 + CallLib.removeRemoteUserLeftListener(); + // 移除监听-对端用户切换了媒体类型 + CallLib.removeRemoteUserMediaTypeChangedListener(); + // 移除监听-通话出现错误的回调 + CallLib.removeErrorListener(); + + } /** 清空所有用户缓存 */ const clearAllUserInfo = async () => { From 7a12024578a806dee0d846444ee4bb11cf540968 Mon Sep 17 00:00:00 2001 From: cc <824295981@qq.com> Date: Thu, 5 Feb 2026 17:54:53 +0800 Subject: [PATCH 2/5] 1 --- pages/room/room - 副本.nvue | 497 ++++++++++++++++++++++++++++++++++++ 1 file changed, 497 insertions(+) create mode 100644 pages/room/room - 副本.nvue diff --git a/pages/room/room - 副本.nvue b/pages/room/room - 副本.nvue new file mode 100644 index 0000000..b9e1af9 --- /dev/null +++ b/pages/room/room - 副本.nvue @@ -0,0 +1,497 @@ + + + + \ No newline at end of file From 32540a8ad78630b5596fbff24aa561270004a5a2 Mon Sep 17 00:00:00 2001 From: lmx <824295981@qq.com> Date: Fri, 6 Feb 2026 20:59:42 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E9=9B=86=E6=88=90=E8=9E=8D=E4=BA=911?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 118 ++-- manifest.json | 18 +- pages.json | 23 +- pages/room/incom.vue | 353 ++++++++++++ pages/room/room - 副本.nvue | 497 ----------------- pages/room/room.nvue | 1028 ++++++++++++++++++----------------- stores/user.js | 7 +- 7 files changed, 974 insertions(+), 1070 deletions(-) create mode 100644 pages/room/incom.vue delete mode 100644 pages/room/room - 副本.nvue diff --git a/App.vue b/App.vue index 7722c59..9d7af53 100644 --- a/App.vue +++ b/App.vue @@ -1,72 +1,72 @@ + /* common css for page */ + // uni-page-body, + // html, + // body, + // page { + // width: 100% !important; + // height: 100% !important; + // overflow: hidden; + // } + \ No newline at end of file diff --git a/manifest.json b/manifest.json index 2c77095..7acf74e 100644 --- a/manifest.json +++ b/manifest.json @@ -112,27 +112,13 @@ } }, "nativePlugins" : { - "RongCloud-Beauty" : { - "__plugin_info__" : { - "name" : "RCUniBeauty", - "description" : "融云基础版美颜插件,服务于 RCUniRtc 或 RCUniCall", - "platforms" : "Android,iOS", - "url" : "https://ext.dcloud.net.cn/plugin?id=7982", - "android_package_name" : "", - "ios_bundle_id" : "", - "isCloud" : true, - "bought" : 1, - "pid" : "7982", - "parameters" : {} - } - }, "RongCloud-Call" : { "__plugin_info__" : { "name" : "RCUniCall", "description" : "融云实时音视频 SDK uni 原生插件", "platforms" : "Android,iOS", "url" : "https://ext.dcloud.net.cn/plugin?id=6372", - "android_package_name" : "uni.app.UNI9EFDC69WWCC", + "android_package_name" : "uni.app.UNI9EFDC69", "ios_bundle_id" : "", "isCloud" : true, "bought" : 1, @@ -146,7 +132,7 @@ "description" : "融云即时通讯 SDK uni 原生插件V2", "platforms" : "Android,iOS", "url" : "https://ext.dcloud.net.cn/plugin?id=9227", - "android_package_name" : "uni.app.UNI9EFDC69WWCC", + "android_package_name" : "uni.app.UNI9EFDC69", "ios_bundle_id" : "", "isCloud" : true, "bought" : 1, diff --git a/pages.json b/pages.json index c002ee4..926a115 100644 --- a/pages.json +++ b/pages.json @@ -441,6 +441,16 @@ } } }, + { + "path" : "pages/room/room", + "style" : + { + "navigationBarTitleText": "Room", + "enablePullDownRefresh": false, + "navigationStyle":"custom", + "gestureBack":"NO" + } + }, // #endif // #ifdef H5 { @@ -459,14 +469,11 @@ }, // #endif { - "path" : "pages/room/room", - "style" : - { - "navigationBarTitleText": "Room", - "enablePullDownRefresh": false, - "navigationStyle":"custom", - "gestureBack":"NO" - } + "path": "pages/room/incom", + "style": { + "navigationBarTitleText": "来电", + "navigationStyle": "custom" + } }, { "path": "pages/adduser/index", diff --git a/pages/room/incom.vue b/pages/room/incom.vue new file mode 100644 index 0000000..de92acb --- /dev/null +++ b/pages/room/incom.vue @@ -0,0 +1,353 @@ + + + + + \ No newline at end of file diff --git a/pages/room/room - 副本.nvue b/pages/room/room - 副本.nvue deleted file mode 100644 index b9e1af9..0000000 --- a/pages/room/room - 副本.nvue +++ /dev/null @@ -1,497 +0,0 @@ - - - - \ No newline at end of file diff --git a/pages/room/room.nvue b/pages/room/room.nvue index 1244e66..7b79b4f 100644 --- a/pages/room/room.nvue +++ b/pages/room/room.nvue @@ -1,459 +1,361 @@ - - - \ No newline at end of file diff --git a/stores/user.js b/stores/user.js index 86908d8..b07eb13 100644 --- a/stores/user.js +++ b/stores/user.js @@ -222,11 +222,13 @@ export const useUserStore = defineStore('user', () => { // //呼入 uni.setStorageSync('room-parameters', { callType: 'in', - mediaType: session.mediaType === 0 ? 'audio' : 'video' + mediaType: session.mediaType === 0 ? 'audio' : 'video', + callId: res.data.callId, + mine: res.data.mine.userId }); //跳转.nvue uni.navigateTo({ - url:'/pages/room/room' + url:'/pages/room/incom' }); }) @@ -258,6 +260,7 @@ export const useUserStore = defineStore('user', () => { res.data.reason ) uni.$emit('OnCallDisconnected'); + uni.navigateBack() }) } From ea2ef96379f638c27ff82063621c8d6247be67d0 Mon Sep 17 00:00:00 2001 From: lmx <824295981@qq.com> Date: Fri, 6 Feb 2026 23:41:19 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=9F=B3=E8=A7=86?= =?UTF-8?q?=E9=A2=91=E9=80=9A=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 149 +++++++++++- pages/room/incom.vue | 20 +- stores/user.js | 568 +++++++++++++++++++++---------------------- 3 files changed, 422 insertions(+), 315 deletions(-) diff --git a/App.vue b/App.vue index 9d7af53..c14e36f 100644 --- a/App.vue +++ b/App.vue @@ -1,6 +1,7 @@ + \ No newline at end of file diff --git a/pages.json b/pages.json index e259bfc..a9ed9a1 100644 --- a/pages.json +++ b/pages.json @@ -444,14 +444,14 @@ { "path": "pages/room/room", "style": { - "navigationBarTitleText": "拨打电话", + "navigationBarTitleText": "拨打视频", "navigationStyle": "custom" } }, { "path": "pages/room/incom", "style": { - "navigationBarTitleText": "拨打视频", + "navigationBarTitleText": "拨打电话", "navigationStyle": "custom" } }, diff --git a/pages/room/room.nvue b/pages/room/room.nvue index f010f5e..c939d28 100644 --- a/pages/room/room.nvue +++ b/pages/room/room.nvue @@ -150,24 +150,16 @@ }, onUnload() { call.hangup() - // this.removeAllListeners() }, onHide() { const session = call.getCurrentCallSession() if (session) { call.hangup() } - // this.removeAllListeners() + uni.$off('OnCallDisconnected') + uni.$off('OnCallConnected') }, methods: { - removeAllListeners(){ - //移除监听-接收到通话呼入 - call.removeRemoteUserJoinedListener(); - // 移除监听-通话已结束 - call.removeCallDisconnectedListener(); - // 移除监听-通话出现错误的回调 - call.removeErrorListener(); - }, changeMediaType() { if (this.mediaTypeCur == 'video') { this.mediaTypeCur = 'audio' @@ -284,9 +276,9 @@ hangup() { this.isSelf = true call.hangup() - uni.navigateBack({ - delta: 1 - }) + // uni.navigateBack({ + // delta: 1 + // }) }, accept() { call.accept() @@ -324,12 +316,61 @@ ) } }, - onCallConnected() { let context = this console.log('oncallconnected接收了') + console.log('call: ',call); + // 使用 Promise 确保 call 对象完全初始化 + this.initializeCall(call) + .then(() => { + this.processCallSession() + }) + .catch(error => { + console.error('初始化通话失败:', error) + }) + }, + async initializeCall(callObj) { + // 等待 call 对象就绪 + await this.waitForCallReady(callObj) + + // 设置扬声器 + if (callObj.enableSpeaker && typeof callObj.enableSpeaker === 'function') { + try { + callObj.enableSpeaker(true) + } catch (error) { + console.warn('设置扬声器失败:', error) + } + } + + return callObj + }, + + waitForCallReady(callObj, timeout = 2000) { + return new Promise((resolve, reject) => { + const startTime = Date.now() + + const check = () => { + const now = Date.now() + + if (callObj && + callObj.enableSpeaker && + callObj.getCurrentCallSession && + typeof callObj.getCurrentCallSession === 'function') { + resolve(callObj) + } else if (now - startTime > timeout) { + reject(new Error('call 对象初始化超时')) + } else { + setTimeout(check, 50) + } + } + + check() + }) + }, + + processCallSession(){ + // call.enableSpeaker(true) this.mediaTypeCur = this.mediaType - call.enableSpeaker(true) this.currentCallSession = call.getCurrentCallSession() this.callWay = this.currentCallSession.callType this.users = this.currentCallSession.users @@ -347,6 +388,7 @@ ) { //视频是两个的时候 if (this.currentCallSession.users.length <= 2) { + console.log("视频是两个的时候"); setTimeout(() => { this.systemInfoSync( this.currentCallSession.mine.userId, @@ -397,6 +439,7 @@ } } }, + systemInfoSync(userId, ref, isZOrderOnTop) { switch (uni.getSystemInfoSync().platform) { case 'android':