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 @@
-
-
-
-
- {{userInfo.name}}
- 地址:{{userInfo.address}}
-
-
-
-
-
-
- 保密
- 男
- 女
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -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
}