音频通话,测试
This commit is contained in:
@@ -21,7 +21,8 @@
|
|||||||
"OAuth" : {},
|
"OAuth" : {},
|
||||||
"Payment" : {},
|
"Payment" : {},
|
||||||
"Share" : {},
|
"Share" : {},
|
||||||
"SQLite" : {}
|
"SQLite" : {},
|
||||||
|
"VideoPlayer" : {}
|
||||||
},
|
},
|
||||||
/* 应用发布信息 */
|
/* 应用发布信息 */
|
||||||
"distribute" : {
|
"distribute" : {
|
||||||
|
|||||||
@@ -393,6 +393,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path": "pages/im/private/call",
|
||||||
|
"name": "imPrivateCall",
|
||||||
|
"style": {
|
||||||
|
"navigationStyle": "custom"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/im/private/setting",
|
"path": "pages/im/private/setting",
|
||||||
"name": "imPrivateSetting",
|
"name": "imPrivateSetting",
|
||||||
|
|||||||
@@ -2,12 +2,7 @@
|
|||||||
<view class="content">
|
<view class="content">
|
||||||
<!-- 用户信息 -->
|
<!-- 用户信息 -->
|
||||||
<view class="info-flex">
|
<view class="info-flex">
|
||||||
<u-avatar
|
<u-avatar :src="userInfo.portraitUrl" shape="square" size="50" bg-color="#fff"></u-avatar>
|
||||||
:src="userInfo.portraitUrl"
|
|
||||||
shape="square"
|
|
||||||
size="50"
|
|
||||||
bg-color="#fff"
|
|
||||||
></u-avatar>
|
|
||||||
<view class="info-text">
|
<view class="info-text">
|
||||||
<view class="nickname">{{userInfo.name}}</view>
|
<view class="nickname">{{userInfo.name}}</view>
|
||||||
<view class="address" @longpress="copyAddress">地址:{{userInfo.address}}</view>
|
<view class="address" @longpress="copyAddress">地址:{{userInfo.address}}</view>
|
||||||
@@ -25,15 +20,15 @@
|
|||||||
|
|
||||||
<block v-if="userInfo.is_friend">
|
<block v-if="userInfo.is_friend">
|
||||||
<view class="info-btns">
|
<view class="info-btns">
|
||||||
<view class="item" @click="setRemark">
|
<view class="item u-border-bottom" @click="setRemark">
|
||||||
<label>设置备注</label>
|
<label>设置备注</label>
|
||||||
<u-icon name="arrow-right" color="#999" size="16"></u-icon>
|
<u-icon name="arrow-right" color="#999" size="16"></u-icon>
|
||||||
</view>
|
</view>
|
||||||
<view class="item" @click="setRemark">
|
<view class="item u-border-bottom" @click="setRemark">
|
||||||
<label>设置标签</label>
|
<label>设置标签</label>
|
||||||
<u-icon name="arrow-right" color="#999" size="16"></u-icon>
|
<u-icon name="arrow-right" color="#999" size="16"></u-icon>
|
||||||
</view>
|
</view>
|
||||||
<view class="item">
|
<view class="item u-border-bottom">
|
||||||
<label>聊天免打扰</label>
|
<label>聊天免打扰</label>
|
||||||
<u-switch size="22" v-model="status" activeColor="#34CE98" @change="setStatus"></u-switch>
|
<u-switch size="22" v-model="status" activeColor="#34CE98" @change="setStatus"></u-switch>
|
||||||
</view>
|
</view>
|
||||||
@@ -55,7 +50,7 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="text">发送消息</view>
|
<view class="text">发送消息</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="footer-item" @click="toPrivate">
|
<view class="footer-item" @click="callShow = true">
|
||||||
<view class="icon">
|
<view class="icon">
|
||||||
<u-icon class="icon-u" name="camera-fill" color="#fff" size="26"></u-icon>
|
<u-icon class="icon-u" name="camera-fill" color="#fff" size="26"></u-icon>
|
||||||
</view>
|
</view>
|
||||||
@@ -73,6 +68,9 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</block>
|
</block>
|
||||||
|
<u-action-sheet :actions="callActions" cancelText="取消" @close="callShow = false" @select="singleCall"
|
||||||
|
:show="callShow">
|
||||||
|
</u-action-sheet>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -82,7 +80,8 @@
|
|||||||
pedingFriend,
|
pedingFriend,
|
||||||
deleteFriend
|
deleteFriend
|
||||||
} from '@/apis/interfaces/im.js'
|
} 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 {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
@@ -92,7 +91,17 @@
|
|||||||
status: false, // 0 是免打扰,1是正常通知
|
status: false, // 0 是免打扰,1是正常通知
|
||||||
isTop: false,
|
isTop: false,
|
||||||
block: false,
|
block: false,
|
||||||
conversationType: 1
|
conversationType: 1,
|
||||||
|
callActions: [{
|
||||||
|
type: 0,
|
||||||
|
name: '语音通话'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 1,
|
||||||
|
name: '视频通话'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
callShow: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(e) {
|
onLoad(e) {
|
||||||
@@ -137,7 +146,7 @@
|
|||||||
setRemark() {
|
setRemark() {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '开发中',
|
title: '开发中',
|
||||||
icon : 'none'
|
icon: 'none'
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
deleteFriend() {
|
deleteFriend() {
|
||||||
@@ -179,9 +188,6 @@
|
|||||||
this.isTop = conversation.isTop
|
this.isTop = conversation.isTop
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
|
||||||
setBlock() {
|
|
||||||
|
|
||||||
},
|
},
|
||||||
// 申请好友
|
// 申请好友
|
||||||
toBeFriend() {
|
toBeFriend() {
|
||||||
@@ -197,7 +203,10 @@
|
|||||||
duration: 2000
|
duration: 2000
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
|
singleCall(e) {
|
||||||
|
CallLib.startSingleCall(this.targetId, e.type, '');
|
||||||
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
@@ -211,23 +220,26 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 用户信息
|
// 用户信息
|
||||||
.info-flex{
|
.info-flex {
|
||||||
padding: $padding;
|
padding: $padding;
|
||||||
margin: 0 $margin;
|
margin: 0 $margin;
|
||||||
display: flex;
|
display: flex;
|
||||||
background: white;
|
background: white;
|
||||||
border-radius: $radius;
|
border-radius: $radius;
|
||||||
.info-text{
|
|
||||||
|
.info-text {
|
||||||
width: calc(100% - 50px);
|
width: calc(100% - 50px);
|
||||||
padding-left: $padding;
|
padding-left: $padding;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
.nickname{
|
|
||||||
|
.nickname {
|
||||||
line-height: 30px;
|
line-height: 30px;
|
||||||
font-size: $title-size + 6;
|
font-size: $title-size + 6;
|
||||||
color: $text-color;
|
color: $text-color;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
.address{
|
|
||||||
|
.address {
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
font-size: $title-size-sm;
|
font-size: $title-size-sm;
|
||||||
color: $text-gray;
|
color: $text-gray;
|
||||||
@@ -238,7 +250,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// footer
|
// footer
|
||||||
.footer{
|
.footer {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
@@ -246,22 +258,26 @@
|
|||||||
padding: $padding*2 $padding;
|
padding: $padding*2 $padding;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
.footer-item{
|
|
||||||
|
.footer-item {
|
||||||
margin: 0 $margin/2;
|
margin: 0 $margin/2;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
.icon{
|
|
||||||
|
.icon {
|
||||||
background: $main-color;
|
background: $main-color;
|
||||||
width: 88rpx;
|
width: 88rpx;
|
||||||
height: 88rpx;
|
height: 88rpx;
|
||||||
line-height: 88rpx;
|
line-height: 88rpx;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
.icon-u{
|
|
||||||
|
.icon-u {
|
||||||
margin-top: calc((88rpx/2) - 13px);
|
margin-top: calc((88rpx/2) - 13px);
|
||||||
margin-left: calc((88rpx/2) - 13px);
|
margin-left: calc((88rpx/2) - 13px);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.text{
|
|
||||||
|
.text {
|
||||||
color: $main-color;
|
color: $main-color;
|
||||||
font-size: $title-size-m;
|
font-size: $title-size-m;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@@ -272,25 +288,24 @@
|
|||||||
|
|
||||||
// btns
|
// btns
|
||||||
|
|
||||||
.info-btns{
|
.info-btns {
|
||||||
background: white;
|
background: white;
|
||||||
margin: $margin;
|
margin: $margin;
|
||||||
border-radius: $radius;
|
border-radius: $radius;
|
||||||
.item{
|
|
||||||
|
.item {
|
||||||
line-height: 100rpx;
|
line-height: 100rpx;
|
||||||
border-bottom: solid 1rpx $border-color;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 0 $padding;
|
padding: 0 $padding;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
font-size: $title-size-lg;
|
font-size: $title-size-lg;
|
||||||
&:last-child{
|
|
||||||
border-bottom: none;
|
label {
|
||||||
}
|
|
||||||
label{
|
|
||||||
width: 200rpx;
|
width: 200rpx;
|
||||||
}
|
}
|
||||||
.text{
|
|
||||||
|
.text {
|
||||||
width: calc(100% - 200rpx);
|
width: calc(100% - 200rpx);
|
||||||
color: $text-gray-m;
|
color: $text-gray-m;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
@@ -298,5 +313,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
60
pages/im/private/call.vue
Normal file
60
pages/im/private/call.vue
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<template>
|
||||||
|
<view>
|
||||||
|
<view class="video">
|
||||||
|
<RongCloud-Call-RCUniCallView style="width: 100%;height: 100%" ref="bigVideoView">
|
||||||
|
</RongCloud-Call-RCUniCallView>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<button type="default" @click="accept">接听</button>
|
||||||
|
<button type="default" @click="hangup">挂断</button>
|
||||||
|
<button type="default" @click="toHome">回主页</button>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import * as CallLib from '@/uni_modules/RongCloud-CallWrapper/lib/index'
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
targetId: '',
|
||||||
|
users: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onLoad(e) {
|
||||||
|
this.targetId = e.targetId
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
accept() {
|
||||||
|
CallLib.accept()
|
||||||
|
|
||||||
|
CallLib.enableCamera(true, 0)
|
||||||
|
|
||||||
|
const currentCallSession = CallLib.getCurrentCallSession()
|
||||||
|
console.log(currentCallSession);
|
||||||
|
this.users = currentCallSession.users
|
||||||
|
setTimeout(() => {
|
||||||
|
CallLib.setVideoView(currentCallSession.mine.userId, 'bigVideoView', 0, true)
|
||||||
|
}, 500);
|
||||||
|
},
|
||||||
|
hangup() {
|
||||||
|
CallLib.hangup()
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.navigateBack()
|
||||||
|
}, 200);
|
||||||
|
},
|
||||||
|
toHome() {
|
||||||
|
uni.switchTab({
|
||||||
|
url: '/pages/im/index'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.video {
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vw;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -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 store from '@/store/index.js'
|
||||||
import {
|
import {
|
||||||
getFriends,
|
getFriends,
|
||||||
@@ -7,6 +8,7 @@ import {
|
|||||||
|
|
||||||
const initIm = (KEY) => {
|
const initIm = (KEY) => {
|
||||||
RongIMLib.init(KEY)
|
RongIMLib.init(KEY)
|
||||||
|
CallLib.init()
|
||||||
addListeners()
|
addListeners()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,6 +100,35 @@ const addListeners = () => {
|
|||||||
newMessage(message)
|
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)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 维护消息列表
|
// 维护消息列表
|
||||||
|
|||||||
Reference in New Issue
Block a user