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 --- 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 () => {