音频通话,测试

This commit is contained in:
2022-01-26 17:43:21 +08:00
parent 4d5d595329
commit 07d20fb107
5 changed files with 317 additions and 204 deletions

View File

@@ -1,78 +1,76 @@
<template>
<view class="content">
<!-- 用户信息 -->
<view class="info-flex">
<u-avatar
:src="userInfo.portraitUrl"
shape="square"
size="50"
bg-color="#fff"
></u-avatar>
<view class="info-text">
<view class="nickname">{{userInfo.name}}</view>
<view class="address" @longpress="copyAddress">地址{{userInfo.address}}</view>
</view>
</view>
<!-- 用户资料 -->
<view class="info-btns">
<view class="item">
<label>性别</label>
<view class="text" v-if="userInfo.gender === 0">保密</view>
<view class="text" v-if="userInfo.gender === 1"></view>
<view class="text" v-if="userInfo.gender === 2"></view>
</view>
</view>
<block v-if="userInfo.is_friend">
<view class="info-btns">
<view class="item" @click="setRemark">
<label>设置备注</label>
<u-icon name="arrow-right" color="#999" size="16"></u-icon>
</view>
<view class="item" @click="setRemark">
<label>设置标签</label>
<u-icon name="arrow-right" color="#999" size="16"></u-icon>
</view>
<view class="item">
<label>聊天免打扰</label>
<u-switch size="22" v-model="status" activeColor="#34CE98" @change="setStatus"></u-switch>
</view>
<view class="item">
<label>聊天置顶</label>
<u-switch size="22" v-model="isTop" activeColor="#34CE98" @change="setTop"></u-switch>
</view>
</view>
<view class="footer">
<view class="footer-item" @click="deleteFriend">
<view class="icon">
<u-icon class="icon-u" name="close-circle-fill" color="#fff" size="26"></u-icon>
</view>
<view class="text">删除好友</view>
</view>
<view class="footer-item" @click="toPrivate">
<view class="icon">
<u-icon class="icon-u" name="chat-fill" color="#fff" size="26"></u-icon>
</view>
<view class="text">发送消息</view>
</view>
<view class="footer-item" @click="toPrivate">
<view class="icon">
<u-icon class="icon-u" name="camera-fill" color="#fff" size="26"></u-icon>
</view>
<view class="text">视频通话</view>
</view>
<!-- 用户信息 -->
<view class="info-flex">
<u-avatar :src="userInfo.portraitUrl" shape="square" size="50" bg-color="#fff"></u-avatar>
<view class="info-text">
<view class="nickname">{{userInfo.name}}</view>
<view class="address" @longpress="copyAddress">地址{{userInfo.address}}</view>
</view>
</view>
<!-- 用户资料 -->
<view class="info-btns">
<view class="item">
<label>性别</label>
<view class="text" v-if="userInfo.gender === 0">保密</view>
<view class="text" v-if="userInfo.gender === 1"></view>
<view class="text" v-if="userInfo.gender === 2"></view>
</view>
</view>
<block v-if="userInfo.is_friend">
<view class="info-btns">
<view class="item u-border-bottom" @click="setRemark">
<label>设置备注</label>
<u-icon name="arrow-right" color="#999" size="16"></u-icon>
</view>
<view class="item u-border-bottom" @click="setRemark">
<label>设置标签</label>
<u-icon name="arrow-right" color="#999" size="16"></u-icon>
</view>
<view class="item u-border-bottom">
<label>聊天免打扰</label>
<u-switch size="22" v-model="status" activeColor="#34CE98" @change="setStatus"></u-switch>
</view>
<view class="item">
<label>聊天置顶</label>
<u-switch size="22" v-model="isTop" activeColor="#34CE98" @change="setTop"></u-switch>
</view>
</view>
<view class="footer">
<view class="footer-item" @click="deleteFriend">
<view class="icon">
<u-icon class="icon-u" name="close-circle-fill" color="#fff" size="26"></u-icon>
</view>
<view class="text">删除好友</view>
</view>
<view class="footer-item" @click="toPrivate">
<view class="icon">
<u-icon class="icon-u" name="chat-fill" color="#fff" size="26"></u-icon>
</view>
<view class="text">发送消息</view>
</view>
<view class="footer-item" @click="callShow = true">
<view class="icon">
<u-icon class="icon-u" name="camera-fill" color="#fff" size="26"></u-icon>
</view>
<view class="text">视频通话</view>
</view>
</view>
</block>
<block v-else>
<view class="footer">
<view class="footer-item" @click="toBeFriend">
<view class="icon">
<u-icon class="icon-u" name="plus-people-fill" color="#fff" size="26"></u-icon>
</view>
<view class="text">申请好友</view>
</view>
<view class="footer">
<view class="footer-item" @click="toBeFriend">
<view class="icon">
<u-icon class="icon-u" name="plus-people-fill" color="#fff" size="26"></u-icon>
</view>
<view class="text">申请好友</view>
</view>
</view>
</block>
<u-action-sheet :actions="callActions" cancelText="取消" @close="callShow = false" @select="singleCall"
:show="callShow">
</u-action-sheet>
</view>
</template>
@@ -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, '');
},
}
};
</script>
@@ -205,98 +214,103 @@
<style lang="scss" scoped>
.content {
min-height: 100vh;
background: $window-color;
padding-top: $padding;
background: $window-color;
padding-top: $padding;
box-sizing: border-box;
}
// 用户信息
.info-flex{
padding: $padding;
margin: 0 $margin;
display: flex;
background: white;
border-radius: $radius;
.info-text{
width: calc(100% - 50px);
padding-left: $padding;
box-sizing: border-box;
.nickname{
line-height: 30px;
font-size: $title-size + 6;
color: $text-color;
text-align: left;
}
.address{
line-height: 20px;
font-size: $title-size-sm;
color: $text-gray;
text-align: left;
@extend .nowrap;
}
}
}
// footer
.footer{
position: fixed;
bottom: 0;
left: 0;
right: 0;
padding: $padding*2 $padding;
display: flex;
justify-content: space-around;
.footer-item{
margin: 0 $margin/2;
text-align: center;
.icon{
background: $main-color;
width: 88rpx;
height: 88rpx;
line-height: 88rpx;
display: inline-block;
border-radius: 50%;
.icon-u{
margin-top: calc((88rpx/2) - 13px);
margin-left: calc((88rpx/2) - 13px);
}
}
.text{
color: $main-color;
font-size: $title-size-m;
text-align: center;
padding-top: 10rpx;
}
}
}
// btns
.info-btns{
background: white;
margin: $margin;
border-radius: $radius;
.item{
line-height: 100rpx;
border-bottom: solid 1rpx $border-color;
display: flex;
align-items: center;
padding: 0 $padding;
justify-content: space-between;
font-size: $title-size-lg;
&:last-child{
border-bottom: none;
}
label{
width: 200rpx;
}
.text{
width: calc(100% - 200rpx);
color: $text-gray-m;
text-align: right;
@extend .nowrap;
}
}
}
}
// 用户信息
.info-flex {
padding: $padding;
margin: 0 $margin;
display: flex;
background: white;
border-radius: $radius;
.info-text {
width: calc(100% - 50px);
padding-left: $padding;
box-sizing: border-box;
.nickname {
line-height: 30px;
font-size: $title-size + 6;
color: $text-color;
text-align: left;
}
.address {
line-height: 20px;
font-size: $title-size-sm;
color: $text-gray;
text-align: left;
@extend .nowrap;
}
}
}
// footer
.footer {
position: fixed;
bottom: 0;
left: 0;
right: 0;
padding: $padding*2 $padding;
display: flex;
justify-content: space-around;
.footer-item {
margin: 0 $margin/2;
text-align: center;
.icon {
background: $main-color;
width: 88rpx;
height: 88rpx;
line-height: 88rpx;
display: inline-block;
border-radius: 50%;
.icon-u {
margin-top: calc((88rpx/2) - 13px);
margin-left: calc((88rpx/2) - 13px);
}
}
.text {
color: $main-color;
font-size: $title-size-m;
text-align: center;
padding-top: 10rpx;
}
}
}
// btns
.info-btns {
background: white;
margin: $margin;
border-radius: $radius;
.item {
line-height: 100rpx;
display: flex;
align-items: center;
padding: 0 $padding;
justify-content: space-between;
font-size: $title-size-lg;
label {
width: 200rpx;
}
.text {
width: calc(100% - 200rpx);
color: $text-gray-m;
text-align: right;
@extend .nowrap;
}
}
}
</style>