From 07d20fb107d5e8438a9dc5df2b26fa06820c51bb Mon Sep 17 00:00:00 2001 From: Jason Date: Wed, 26 Jan 2022 17:43:21 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E9=9F=B3=E9=A2=91=E9=80=9A=E8=AF=9D?= =?UTF-8?q?=EF=BC=8C=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifest.json | 3 +- pages.json | 7 + pages/im/friends/info.vue | 366 ++++++++++++++++++++------------------ pages/im/private/call.vue | 60 +++++++ utils/im/index.js | 85 ++++++--- 5 files changed, 317 insertions(+), 204 deletions(-) create mode 100644 pages/im/private/call.vue diff --git a/manifest.json b/manifest.json index fe85297..c09ce08 100644 --- a/manifest.json +++ b/manifest.json @@ -21,7 +21,8 @@ "OAuth" : {}, "Payment" : {}, "Share" : {}, - "SQLite" : {} + "SQLite" : {}, + "VideoPlayer" : {} }, /* 应用发布信息 */ "distribute" : { diff --git a/pages.json b/pages.json index 8e0bfba..f322b7a 100644 --- a/pages.json +++ b/pages.json @@ -393,6 +393,13 @@ } } }, + { + "path": "pages/im/private/call", + "name": "imPrivateCall", + "style": { + "navigationStyle": "custom" + } + }, { "path": "pages/im/private/setting", "name": "imPrivateSetting", diff --git a/pages/im/friends/info.vue b/pages/im/friends/info.vue index 5e55e6c..943b80a 100644 --- a/pages/im/friends/info.vue +++ b/pages/im/friends/info.vue @@ -1,78 +1,76 @@ @@ -82,7 +80,8 @@ pedingFriend, deleteFriend } from '@/apis/interfaces/im.js' - import * as RongIMLib from "@/uni_modules/RongCloud-IMWrapper/js_sdk/index" + import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index' + import * as CallLib from '@/uni_modules/RongCloud-CallWrapper/lib/index' export default { data() { @@ -92,12 +91,22 @@ status: false, // 0 是免打扰,1是正常通知 isTop: false, block: false, - conversationType: 1 + conversationType: 1, + callActions: [{ + type: 0, + name: '语音通话' + }, + { + type: 1, + name: '视频通话' + } + ], + callShow: false } }, onLoad(e) { this.targetId = e.targetId - getFriendInfo(e.targetId).then(res => { + getFriendInfo(e.targetId).then(res => { this.userInfo = res uni.setNavigationBarTitle({ title: res.name @@ -135,9 +144,9 @@ }) }, setRemark() { - uni.showToast({ - title: '开发中', - icon : 'none' + uni.showToast({ + title: '开发中', + icon: 'none' }) }, deleteFriend() { @@ -152,11 +161,11 @@ RongIMLib.removeConversation(1, this.targetId) uni.showToast({ icon: 'none', - title: '好友删除成功', - success() { - uni.switchTab({ - url: '/pages/im/index' - }) + title: '好友删除成功', + success() { + uni.switchTab({ + url: '/pages/im/index' + }) } }) }) @@ -179,9 +188,6 @@ this.isTop = conversation.isTop }) }) - }, - setBlock() { - }, // 申请好友 toBeFriend() { @@ -197,7 +203,10 @@ duration: 2000 }) }) - } + }, + singleCall(e) { + CallLib.startSingleCall(this.targetId, e.type, ''); + }, } }; @@ -205,98 +214,103 @@ diff --git a/pages/im/private/call.vue b/pages/im/private/call.vue new file mode 100644 index 0000000..b548f92 --- /dev/null +++ b/pages/im/private/call.vue @@ -0,0 +1,60 @@ + + + + + diff --git a/utils/im/index.js b/utils/im/index.js index 89f531f..69e4d7e 100644 --- a/utils/im/index.js +++ b/utils/im/index.js @@ -1,4 +1,5 @@ -import * as RongIMLib from "@/uni_modules/RongCloud-IMWrapper/js_sdk/index" +import * as RongIMLib from '@/uni_modules/RongCloud-IMWrapper/js_sdk/index' +import * as CallLib from '@/uni_modules/RongCloud-CallWrapper/lib/index' import store from '@/store/index.js' import { getFriends, @@ -7,6 +8,7 @@ import { const initIm = (KEY) => { RongIMLib.init(KEY) + CallLib.init() addListeners() } @@ -38,8 +40,8 @@ const setNotifyBadge = () => { */ const connect = (token, userInfo, callback) => { RongIMLib.connect(token, res => { - console.log('连接结果', res); - + console.log('连接结果', res); + callback(res) }) @@ -58,23 +60,23 @@ const connect = (token, userInfo, callback) => { const disconnect = () => { RongIMLib.disconnect() -} - -// 允许通知的消息类型,触发更新消息列表操作 -const notifyMsgTypes = [ - 'RC:TxtMsg', - 'RC:VcMsg', - 'RC:HQVCMsg', - 'RC:ImgMsg', - 'RC:GIFMsg', - 'RC:ImgTextMsg', - 'RC:FileMsg', - 'RC:LBSMsg', - 'RC:SightMsg', - 'RC:ReferenceMsg', - 'RC:CombineMsg', -] - +} + +// 允许通知的消息类型,触发更新消息列表操作 +const notifyMsgTypes = [ + 'RC:TxtMsg', + 'RC:VcMsg', + 'RC:HQVCMsg', + 'RC:ImgMsg', + 'RC:GIFMsg', + 'RC:ImgTextMsg', + 'RC:FileMsg', + 'RC:LBSMsg', + 'RC:SightMsg', + 'RC:ReferenceMsg', + 'RC:CombineMsg', +] + function inArray(search, array) { for (var i in array) { if (array[i] == search) { @@ -82,22 +84,51 @@ function inArray(search, array) { } } return false; -} +} const addListeners = () => { // 添加连接状态监听函数 RongIMLib.addConnectionStatusListener((res) => { - console.log('连接状态监', res.data.status); + console.log('连接状态监', res.data.status); store.dispatch('updateConnectionStatus', res.data.status) }) // 添加消息监听函数 RongIMLib.addReceiveMessageListener((res) => { - console.log('收到消息', res.data.message); - const message = res.data.message - if (inArray(message.objectName, notifyMsgTypes)) { - newMessage(message) + console.log('收到消息', res.data.message); + const message = res.data.message + if (inArray(message.objectName, notifyMsgTypes)) { + newMessage(message) } }) + // 监听通话呼入 + CallLib.onCallReceived((res) => { + console.log("Engine:OnCallReceived=>" + "监听通话呼入, 目标id=>", res.data.targetId); + console.log('RES', res); + uni.navigateTo({ + url: '/pages/im/private/call?targetId=' + res.data.targetId, + success: (err) => { + console.log('跳转视频通话成功'); + }, + fail: (err) => { + console.log('跳转视频页失败', err); + } + }) + }) + CallLib.onCallOutgoing((res) => { + console.log("主叫端拨出电话后,通过回调 onCallOutgoing,通知当前 call 的详细信息", res) + }) + CallLib.onCallConnected((res) => { + console.log("Engine:OnCallConnected=>" + "通话接通时,通过回调 onCallConnected 通知当前 call 的详细信息", res) + }); + CallLib.onRemoteUserJoined((res) => { + console.log("Engine:OnRemoteUserJoined=>" + "主叫端拨出电话,被叫端收到请求后,加入通话,被叫端Id为=>", res.data.userId); + }) + CallLib.onCallDisconnected((res) => { + console.log("Engine:OnCallDisconnected=>" + "挂断成功, 挂断原因=>", res.data.reason) + }) + CallLib.onRemoteUserLeft((res) => { + console.log("Engine:OnRemoteUserLeft=>" + "远端用户挂断,远端Id为=>", res.data.reason) + }) } // 维护消息列表 @@ -194,6 +225,6 @@ export default { connect, sendMsg, setNotifyBadge, - syncFriends, + syncFriends, syncUserInfo } From 1caaab3492da453becc5f5bf698b0c86d23f2d48 Mon Sep 17 00:00:00 2001 From: Jason Date: Thu, 27 Jan 2022 10:05:14 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=AF=AD=E9=9F=B3=E9=80=9A=E8=AF=9D?= =?UTF-8?q?=E7=AE=80=E6=98=93=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .DS_Store | Bin 12292 -> 12292 bytes pages/im/friends/info.vue | 14 +++- pages/im/private/call.vue | 154 ++++++++++++++++++++++++++++++++++---- utils/im/index.js | 18 +---- utils/im/视频呼入.json | 51 +++++++++++++ utils/im/语音呼入.json | 51 +++++++++++++ 6 files changed, 254 insertions(+), 34 deletions(-) create mode 100644 utils/im/视频呼入.json create mode 100644 utils/im/语音呼入.json diff --git a/.DS_Store b/.DS_Store index f7fcacf741c606ff5c08652fd677643fd7131d2f..5d1d9e1c4a9f6dab94f1ea676483da240df8bd4f 100644 GIT binary patch delta 121 zcmZokXi1phFB;9jz`)GFAi%(o$WX$N$&l=slb<~CqVi+|9hQmRT$48nXl>l@!_TO( z`G$Zo|HKDp7>zdbD3~%&E>@A;9HO$4dGbwl-iZqYC-Vv{nA|JjwwYby8w*QuZobQ8 QSvC31QfiMGQB^nt0N89NeEz`)GFAi%&-%22|P%1~60VHiB|qVi+|9hQmRT$5SVWhNUc2yZ;% z&d;bfSwVf_#EE*F`2`I484Wk{D3~%!@-pNxBm%W&GL!+e7ck@i4N3>{@+K>Yh}1La z{Rab}Ees4el`<6Pq#Fh&=jRrHlrcSe@eaT0+ { + console.log('跳转视频页失败', err); + } + }) }, } }; diff --git a/pages/im/private/call.vue b/pages/im/private/call.vue index b548f92..b15c8a9 100644 --- a/pages/im/private/call.vue +++ b/pages/im/private/call.vue @@ -3,44 +3,122 @@ - - - - + + + {{userInfo.name}} + + + 等待对方接听 + + + 已接通 + + + {{ mediaType == 0 ? '邀请您语音通话' : '邀请您视频通话' }} + + + + + 麦克风 + 挂断 + 接听 + 扬声器 + + + + diff --git a/pages/im/friends/info.vue b/pages/im/friends/info.vue index fe4924e..98c117a 100644 --- a/pages/im/friends/info.vue +++ b/pages/im/friends/info.vue @@ -55,7 +55,7 @@ 视频通话 - + @@ -207,8 +207,7 @@ singleCall(e) { CallLib.startSingleCall(this.targetId, e.type, ''); uni.redirectTo({ - url: '/pages/im/private/call?targetId=' + this.targetId + '&mediaType=' + - e.mediaType, + url: '/pages/im/private/call', success: (err) => { console.log('跳转视频通话成功'); }, diff --git a/pages/im/group/index.vue b/pages/im/group/index.vue index 047b2fb..3d1727e 100644 --- a/pages/im/group/index.vue +++ b/pages/im/group/index.vue @@ -1,19 +1,10 @@ diff --git a/pages/im/private/call.vue b/pages/im/private/call.vue deleted file mode 100644 index b15c8a9..0000000 --- a/pages/im/private/call.vue +++ /dev/null @@ -1,182 +0,0 @@ - - - - - diff --git a/pages/im/private/index.vue b/pages/im/private/index.vue index e4dfe4b..9f5029d 100644 --- a/pages/im/private/index.vue +++ b/pages/im/private/index.vue @@ -5,21 +5,24 @@ - + - {{ item.content.content }} + {{ item.content.content }} - - - 10" - + + + 10" + {{targetId}}{{ item.sentStatus == 50 ? '已读': '未读'}} - - + + @@ -29,34 +32,36 @@ - - - - - - - - - - - + + + + + + + + + + + - - - - - - 录音中 {{transcribeTime}} s + + + + + + 录音中 {{transcribeTime}} s -