集成融云1
This commit is contained in:
118
App.vue
118
App.vue
@@ -1,72 +1,72 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
// #ifdef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
import { setSdkLanguageFromSystem } from '@/uni_modules/tuikit-atomic-x/utils/setSdkLanguageFromSystem'
|
import { setSdkLanguageFromSystem } from '@/uni_modules/tuikit-atomic-x/utils/setSdkLanguageFromSystem'
|
||||||
// #endif
|
// #endif
|
||||||
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
|
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app'
|
||||||
import { reLaunch } from './utils/router'
|
import { reLaunch } from './utils/router'
|
||||||
import { useAuthUser } from './composables/useAuthUser'
|
import { useAuthUser } from './composables/useAuthUser'
|
||||||
import { useUserStore } from './stores/user'
|
import { useUserStore } from './stores/user'
|
||||||
import { TUIChatKit } from './TUIKit'
|
import { TUIChatKit } from './TUIKit'
|
||||||
import { getIpBlack } from './api'
|
import { getIpBlack } from './api'
|
||||||
|
|
||||||
TUIChatKit.init()
|
TUIChatKit.init()
|
||||||
|
|
||||||
const { token, tencentUserSig } = useAuthUser()
|
const { token, tencentUserSig } = useAuthUser()
|
||||||
const { loginTencentIM } = useUserStore()
|
const { loginTencentIM } = useUserStore()
|
||||||
/** 静默登录逻辑 */
|
/** 静默登录逻辑 */
|
||||||
const silentLogin = async (e: any) => {
|
const silentLogin = async (e : any) => {
|
||||||
if (token.value) {
|
if (token.value) {
|
||||||
loginTencentIM()
|
loginTencentIM()
|
||||||
// reLaunch('/TUIKit/components/TUIConversation/index')
|
// reLaunch('/TUIKit/components/TUIConversation/index')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(tencentUserSig, '=====222==')
|
console.log(tencentUserSig, '=====222==')
|
||||||
if (e?.query?.invitationCode) {
|
if (e?.query?.invitationCode) {
|
||||||
reLaunch('/pages/login/phone-register/phone-register', {
|
reLaunch('/pages/login/phone-register/phone-register', {
|
||||||
invitationCode: e.query.invitationCode
|
invitationCode: e.query.invitationCode
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
// 没有token去登录页
|
// 没有token去登录页
|
||||||
reLaunch('/pages/login/login')
|
reLaunch('/pages/login/login')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onLaunch((e: any) => {
|
onLaunch((e : any) => {
|
||||||
// return
|
// return
|
||||||
console.log('App Launch111')
|
console.log('App Launch111')
|
||||||
silentLogin(e)
|
silentLogin(e)
|
||||||
|
|
||||||
// #ifdef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
setSdkLanguageFromSystem()
|
setSdkLanguageFromSystem()
|
||||||
// #endif
|
// #endif
|
||||||
})
|
})
|
||||||
|
|
||||||
onShow(() => {
|
onShow(() => {
|
||||||
console.log('App Show222')
|
console.log('App Show222')
|
||||||
})
|
})
|
||||||
|
|
||||||
onHide(async () => {
|
onHide(async () => {
|
||||||
if (token.value) {
|
if (token.value) {
|
||||||
const show = await getIpBlack(false)
|
const show = await getIpBlack(false)
|
||||||
console.log(show.data.data, '======')
|
console.log(show.data.data, '======')
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('App Hide333')
|
console.log('App Hide333')
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
/*每个页面公共css */
|
/*每个页面公共css */
|
||||||
@import './styles/global.scss';
|
@import './styles/global.scss';
|
||||||
|
|
||||||
/* common css for page */
|
/* common css for page */
|
||||||
// uni-page-body,
|
// uni-page-body,
|
||||||
// html,
|
// html,
|
||||||
// body,
|
// body,
|
||||||
// page {
|
// page {
|
||||||
// width: 100% !important;
|
// width: 100% !important;
|
||||||
// height: 100% !important;
|
// height: 100% !important;
|
||||||
// overflow: hidden;
|
// overflow: hidden;
|
||||||
// }
|
// }
|
||||||
</style>
|
</style>
|
||||||
@@ -112,27 +112,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nativePlugins" : {
|
"nativePlugins" : {
|
||||||
"RongCloud-Beauty" : {
|
|
||||||
"__plugin_info__" : {
|
|
||||||
"name" : "RCUniBeauty",
|
|
||||||
"description" : "融云基础版美颜插件,服务于 RCUniRtc 或 RCUniCall",
|
|
||||||
"platforms" : "Android,iOS",
|
|
||||||
"url" : "https://ext.dcloud.net.cn/plugin?id=7982",
|
|
||||||
"android_package_name" : "",
|
|
||||||
"ios_bundle_id" : "",
|
|
||||||
"isCloud" : true,
|
|
||||||
"bought" : 1,
|
|
||||||
"pid" : "7982",
|
|
||||||
"parameters" : {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"RongCloud-Call" : {
|
"RongCloud-Call" : {
|
||||||
"__plugin_info__" : {
|
"__plugin_info__" : {
|
||||||
"name" : "RCUniCall",
|
"name" : "RCUniCall",
|
||||||
"description" : "融云实时音视频 SDK uni 原生插件",
|
"description" : "融云实时音视频 SDK uni 原生插件",
|
||||||
"platforms" : "Android,iOS",
|
"platforms" : "Android,iOS",
|
||||||
"url" : "https://ext.dcloud.net.cn/plugin?id=6372",
|
"url" : "https://ext.dcloud.net.cn/plugin?id=6372",
|
||||||
"android_package_name" : "uni.app.UNI9EFDC69WWCC",
|
"android_package_name" : "uni.app.UNI9EFDC69",
|
||||||
"ios_bundle_id" : "",
|
"ios_bundle_id" : "",
|
||||||
"isCloud" : true,
|
"isCloud" : true,
|
||||||
"bought" : 1,
|
"bought" : 1,
|
||||||
@@ -146,7 +132,7 @@
|
|||||||
"description" : "融云即时通讯 SDK uni 原生插件V2",
|
"description" : "融云即时通讯 SDK uni 原生插件V2",
|
||||||
"platforms" : "Android,iOS",
|
"platforms" : "Android,iOS",
|
||||||
"url" : "https://ext.dcloud.net.cn/plugin?id=9227",
|
"url" : "https://ext.dcloud.net.cn/plugin?id=9227",
|
||||||
"android_package_name" : "uni.app.UNI9EFDC69WWCC",
|
"android_package_name" : "uni.app.UNI9EFDC69",
|
||||||
"ios_bundle_id" : "",
|
"ios_bundle_id" : "",
|
||||||
"isCloud" : true,
|
"isCloud" : true,
|
||||||
"bought" : 1,
|
"bought" : 1,
|
||||||
|
|||||||
23
pages.json
23
pages.json
@@ -441,6 +441,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"path" : "pages/room/room",
|
||||||
|
"style" :
|
||||||
|
{
|
||||||
|
"navigationBarTitleText": "Room",
|
||||||
|
"enablePullDownRefresh": false,
|
||||||
|
"navigationStyle":"custom",
|
||||||
|
"gestureBack":"NO"
|
||||||
|
}
|
||||||
|
},
|
||||||
// #endif
|
// #endif
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
{
|
{
|
||||||
@@ -459,14 +469,11 @@
|
|||||||
},
|
},
|
||||||
// #endif
|
// #endif
|
||||||
{
|
{
|
||||||
"path" : "pages/room/room",
|
"path": "pages/room/incom",
|
||||||
"style" :
|
"style": {
|
||||||
{
|
"navigationBarTitleText": "来电",
|
||||||
"navigationBarTitleText": "Room",
|
"navigationStyle": "custom"
|
||||||
"enablePullDownRefresh": false,
|
}
|
||||||
"navigationStyle":"custom",
|
|
||||||
"gestureBack":"NO"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/adduser/index",
|
"path": "pages/adduser/index",
|
||||||
|
|||||||
353
pages/room/incom.vue
Normal file
353
pages/room/incom.vue
Normal file
@@ -0,0 +1,353 @@
|
|||||||
|
<template>
|
||||||
|
<!-- 来电接听界面 -->
|
||||||
|
<view class="incoming-call">
|
||||||
|
<!-- 背景模糊层 -->
|
||||||
|
<view class="blur-background" v-if="callBackground">
|
||||||
|
<image :src="callBackground" mode="aspectFill" class="bg-image"></image>
|
||||||
|
<view class="bg-overlay"></view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 主内容区 -->
|
||||||
|
<view class="caller-info">
|
||||||
|
<view class="caller-avatar-container">
|
||||||
|
<view class="caller-avatar" :class="{'avatar-ring': isRinging}">
|
||||||
|
<image v-if="callerAvatar" :src="callerAvatar" class="avatar-image"></image>
|
||||||
|
<uni-icons v-else type="contact-filled" size="50" color="#fff"></uni-icons>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<text class="caller-name">{{callerName}}</text>
|
||||||
|
<text class="call-type">{{ localSession.mediaType === 0 ? '语音通话' : "视频通话" }}</text>
|
||||||
|
<text class="call-status">{{callStatus}}</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<!-- 控制按钮 -->
|
||||||
|
<view class="incoming-controls">
|
||||||
|
<view class="incoming-control" @click="cutFn(false)">
|
||||||
|
<view class="call-btn decline-btn" :class="{'btn-active': activeBtn === 'decline'}">
|
||||||
|
<uni-icons type="closeempty" size="32" color="#fff"></uni-icons>
|
||||||
|
</view>
|
||||||
|
<text class="btn-text">拒绝</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="incoming-control" @click="cutFn(true)">
|
||||||
|
<view class="call-btn accept-btn" :class="{'btn-active': activeBtn === 'accept'}">
|
||||||
|
<uni-icons type="checkmarkempty" size="28" color="#fff"></uni-icons>
|
||||||
|
</view>
|
||||||
|
<text class="btn-text">接听</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
import * as call from "@/uni_modules/RongCloud-CallWrapper/lib/index"
|
||||||
|
// #endif
|
||||||
|
export default {
|
||||||
|
name: "incoming-call",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 通话状态
|
||||||
|
isRinging: true,
|
||||||
|
isCalling: false,
|
||||||
|
isEnded: false,
|
||||||
|
|
||||||
|
// 通话时间
|
||||||
|
callDuration: 0,
|
||||||
|
callTimer: null,
|
||||||
|
|
||||||
|
// 控制按钮状态
|
||||||
|
activeBtn: null,
|
||||||
|
|
||||||
|
// 通话设置
|
||||||
|
isMuted: false,
|
||||||
|
isSpeakerOn: true,
|
||||||
|
isVideoOn: true,
|
||||||
|
|
||||||
|
// 控制界面显示
|
||||||
|
showActionBar: false,
|
||||||
|
callerName: "用户id",
|
||||||
|
callerAvatar: "/static/images/public/random2.png",
|
||||||
|
callBackground: "/static/images/public/random2.png",
|
||||||
|
localSession: null,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
// 30秒后自动挂断
|
||||||
|
setTimeout(() => {
|
||||||
|
if (!this.isCalling && !this.isEnded) {
|
||||||
|
this.autoDecline();
|
||||||
|
}
|
||||||
|
}, 30000);
|
||||||
|
},
|
||||||
|
onLoad() {
|
||||||
|
uni.getStorage({
|
||||||
|
key: "room-parameters",
|
||||||
|
success: (res) => {
|
||||||
|
console.log('res: ',res);
|
||||||
|
this.localSession = res.data
|
||||||
|
this.callerName = res.data.mine
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
//是否接入
|
||||||
|
cutFn(isFlag){
|
||||||
|
//确认接入
|
||||||
|
console.log('isFlag: ',isFlag);
|
||||||
|
if(isFlag){
|
||||||
|
this.isEnded = true;
|
||||||
|
console.log('localSession: ',this.localSession);
|
||||||
|
if (this.localSession.callId && this.localSession.callId.length > 0) {
|
||||||
|
this.onCallReceived(this.localSession);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
//取消接入
|
||||||
|
call.hangup();
|
||||||
|
uni.navigateBack()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
//是否接收逻辑
|
||||||
|
onCallReceived(session) {
|
||||||
|
// //呼入
|
||||||
|
uni.setStorageSync('room-parameters', {
|
||||||
|
callType: 'in',
|
||||||
|
mediaType: session.mediaType === 0 ? 'audio' : 'video'
|
||||||
|
});
|
||||||
|
//跳转.nvue
|
||||||
|
uni.redirectTo({
|
||||||
|
url:'/pages/room/room'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 自动拒绝(无人接听)
|
||||||
|
autoDecline() {
|
||||||
|
this.stopRinging();
|
||||||
|
this.isEnded = true;
|
||||||
|
this.callStatus = "未接听";
|
||||||
|
|
||||||
|
call.hangup();
|
||||||
|
|
||||||
|
// 2秒后关闭界面
|
||||||
|
setTimeout(() => {
|
||||||
|
uni.navigateBack()
|
||||||
|
}, 2000);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.incoming-call {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
z-index: 9999;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
|
background-color: #000;
|
||||||
|
|
||||||
|
.blur-background {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
z-index: 0;
|
||||||
|
|
||||||
|
.bg-image {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
filter: blur(20px);
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bg-overlay {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
background: rgba(0, 0, 0, 0.5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.caller-info {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding-top: 100rpx;
|
||||||
|
z-index: 1;
|
||||||
|
|
||||||
|
.caller-avatar-container {
|
||||||
|
position: relative;
|
||||||
|
margin-bottom: 40rpx;
|
||||||
|
|
||||||
|
.caller-avatar {
|
||||||
|
width: 180rpx;
|
||||||
|
height: 180rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: linear-gradient(135deg, #1aad19, #129611);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
.avatar-image {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.avatar-ring {
|
||||||
|
animation: ringPulse 1.5s infinite;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.caller-name {
|
||||||
|
font-size: 48rpx;
|
||||||
|
color: #fff;
|
||||||
|
font-weight: 500;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.call-type {
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.9);
|
||||||
|
margin-bottom: 10rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.call-status {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: rgba(255, 255, 255, 0.7);
|
||||||
|
}
|
||||||
|
|
||||||
|
.call-timer {
|
||||||
|
margin-top: 30rpx;
|
||||||
|
padding: 10rpx 30rpx;
|
||||||
|
background: rgba(255, 255, 255, 0.1);
|
||||||
|
border-radius: 30rpx;
|
||||||
|
|
||||||
|
.timer-text {
|
||||||
|
font-size: 32rpx;
|
||||||
|
color: #fff;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.incoming-controls {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-around;
|
||||||
|
padding: 80rpx 100rpx 120rpx;
|
||||||
|
z-index: 1;
|
||||||
|
|
||||||
|
.incoming-control {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.call-btn {
|
||||||
|
width: 120rpx;
|
||||||
|
height: 120rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
transition: all 0.2s;
|
||||||
|
|
||||||
|
&.decline-btn {
|
||||||
|
background-color: #f43f3b;
|
||||||
|
|
||||||
|
&.btn-active {
|
||||||
|
transform: scale(0.9);
|
||||||
|
background-color: #d93632;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.accept-btn {
|
||||||
|
background-color: #07c160;
|
||||||
|
|
||||||
|
&.btn-active {
|
||||||
|
transform: scale(0.9);
|
||||||
|
background-color: #06ad56;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-text {
|
||||||
|
font-size: 28rpx;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-bar {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 60rpx;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-around;
|
||||||
|
padding: 0 60rpx;
|
||||||
|
z-index: 1;
|
||||||
|
|
||||||
|
.action-item {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
.action-icon {
|
||||||
|
width: 100rpx;
|
||||||
|
height: 100rpx;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: rgba(255, 255, 255, 0.2);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-bottom: 20rpx;
|
||||||
|
transition: all 0.3s;
|
||||||
|
|
||||||
|
&.active {
|
||||||
|
background-color: rgba(255, 255, 255, 0.4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-text {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes ringPulse {
|
||||||
|
0% {
|
||||||
|
box-shadow: 0 0 0 0 rgba(26, 173, 25, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
70% {
|
||||||
|
box-shadow: 0 0 0 30rpx rgba(26, 173, 25, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
box-shadow: 0 0 0 0 rgba(26, 173, 25, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 响应式调整 */
|
||||||
|
@media (max-height: 600px) {
|
||||||
|
.incoming-controls {
|
||||||
|
padding: 40rpx 100rpx 80rpx !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.action-bar {
|
||||||
|
bottom: 40rpx !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,497 +0,0 @@
|
|||||||
<template>
|
|
||||||
<view class="content">
|
|
||||||
<!-- 单人视频 -->
|
|
||||||
<view v-if="users.length<=2">
|
|
||||||
<RongCloud-Call-RCUniCallView class="bigVideoView"
|
|
||||||
:style="{width:windowWidth+'px',height:windowHeight+'px'}" ref="bigVideoView">
|
|
||||||
</RongCloud-Call-RCUniCallView>
|
|
||||||
<RongCloud-Call-RCUniCallView class="smallVideoView" :style="{width:200+'upx',height:200+'upx'}"
|
|
||||||
ref="smallVideoView">
|
|
||||||
</RongCloud-Call-RCUniCallView>
|
|
||||||
</view>
|
|
||||||
<view class="nav">
|
|
||||||
<text class="nav-com" @click="closeCameraCur">
|
|
||||||
{{curCamera?'关闭':'开启'}}摄像头
|
|
||||||
</text>
|
|
||||||
<text class="nav-com" @click="switchCamera">
|
|
||||||
切换摄像头
|
|
||||||
</text>
|
|
||||||
<text class="nav-com" @click="microphone">
|
|
||||||
{{isMicrophone?'关闭':'开启'}}麦克风
|
|
||||||
</text>
|
|
||||||
<text class="nav-com" @click="enableSpeaker">
|
|
||||||
{{isEnableSpeaker?'关闭':'开启'}}扬声器
|
|
||||||
</text>
|
|
||||||
</view>
|
|
||||||
<view class="container" :style="{width:windowWidth+'px'}">
|
|
||||||
<text class="hangup" @click="hangup">挂断 </text>
|
|
||||||
<text v-if="mediaTypeCur === 'video' " class="hangup" @click="changeMediaType">切换语音 </text>
|
|
||||||
</view>
|
|
||||||
</view>
|
|
||||||
</template>
|
|
||||||
<script>
|
|
||||||
import * as call from "@/uni_modules/RongCloud-CallWrapper/lib/index"
|
|
||||||
// import * as im from "@/uni_modules/RongCloud-IMWrapper/js_sdk/index"
|
|
||||||
export default {
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
mediaType: "video",
|
|
||||||
callType: "out",
|
|
||||||
callWay: 0, //呼叫方式 0 单聊 1 群聊
|
|
||||||
targetId: "",
|
|
||||||
bottomHeight: 0,
|
|
||||||
isConnected: false,
|
|
||||||
isSelf: false,
|
|
||||||
viewArr: [],
|
|
||||||
callSelect: 'single',
|
|
||||||
groupId: '',
|
|
||||||
userIds: [],
|
|
||||||
windowWidth: '',
|
|
||||||
windowHeight: '',
|
|
||||||
isMicrophone: true,
|
|
||||||
isEnableSpeaker: true,
|
|
||||||
curCamera: true,
|
|
||||||
backCamera: true,
|
|
||||||
isMe: true,
|
|
||||||
users: [],
|
|
||||||
currentCallSession: {},
|
|
||||||
isMark: false,
|
|
||||||
inviteUsersIds: '',
|
|
||||||
mediaTypeCur: 'audio',
|
|
||||||
isBeauty: false,
|
|
||||||
curIndex: '0',
|
|
||||||
curFilte: 0,
|
|
||||||
whiteVal: 0,
|
|
||||||
ruddyVal: 0,
|
|
||||||
buffingVal: 0,
|
|
||||||
brightnessVal: 5,
|
|
||||||
isChecked: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onLoad: function() {
|
|
||||||
console.log("来room页面了?");
|
|
||||||
var _this = this;
|
|
||||||
uni.getStorage({
|
|
||||||
key: "room-parameters",
|
|
||||||
success: (res) => {
|
|
||||||
this.mediaType = res.data.mediaType;
|
|
||||||
this.callType = res.data.callType ? res.data.callType : 'in';
|
|
||||||
this.groupId = res.data.groupId ? res.data.groupId : '';
|
|
||||||
this.userIds = res.data.userIds ? res.data.userIds : '';
|
|
||||||
if (this.callType === 'out') {
|
|
||||||
console.log('呼出out')
|
|
||||||
this.targetId = res.data.targetId;
|
|
||||||
this.startCall();
|
|
||||||
} else {
|
|
||||||
console.log('呼入接受')
|
|
||||||
this.accept();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
uni.getSystemInfo({
|
|
||||||
success: function(res) {
|
|
||||||
_this.windowWidth = res.windowWidth;
|
|
||||||
_this.windowHeight = res.windowHeight;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
uni.$on('OnCallConnected', this.onCallConnected)
|
|
||||||
uni.$on('OnCallDisconnected', this.onCallDisconnected)
|
|
||||||
// this.initBeautyOpton();
|
|
||||||
},
|
|
||||||
beforeDestroy() {
|
|
||||||
uni.$off('OnCallDisconnected');
|
|
||||||
uni.$off('OnCallConnected');
|
|
||||||
},
|
|
||||||
onUnload() {
|
|
||||||
call.hangup();
|
|
||||||
},
|
|
||||||
onHide() {
|
|
||||||
const session = call.getCurrentCallSession();
|
|
||||||
if (session) {
|
|
||||||
call.hangup();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
changeMediaType() {
|
|
||||||
this.mediaTypeCur = 'audio';
|
|
||||||
call.changeMediaType(0);
|
|
||||||
},
|
|
||||||
switchVideo() {
|
|
||||||
this.isMe = !this.isMe;
|
|
||||||
let session = call.getCurrentCallSession();
|
|
||||||
if (this.isMe) {
|
|
||||||
switch (uni.getSystemInfoSync().platform) {
|
|
||||||
case 'android':
|
|
||||||
call.setVideoView(session.targetId, this.$refs.bigVideoView.ref, 0, false);
|
|
||||||
call.setVideoView(session.mine.userId, this.$refs.smallVideoView.ref, 0, true);
|
|
||||||
break;
|
|
||||||
case 'ios':
|
|
||||||
call.setVideoView(session.targetId, this.$refs.bigVideoView.ref, 0);
|
|
||||||
call.setVideoView(session.mine.userId, this.$refs.smallVideoView.ref, 0);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
console.log('运行在开发者工具上')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
switch (uni.getSystemInfoSync().platform) {
|
|
||||||
case 'android':
|
|
||||||
call.setVideoView(session.mine.userId, this.$refs.bigVideoView.ref, 0, false);
|
|
||||||
call.setVideoView(session.targetId, this.$refs.smallVideoView.ref, 0, true);
|
|
||||||
break;
|
|
||||||
case 'ios':
|
|
||||||
call.setVideoView(session.mine.userId, this.$refs.bigVideoView.ref, 0);
|
|
||||||
call.setVideoView(session.targetId, this.$refs.smallVideoView.ref, 0);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
console.log('运行在开发者工具上')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
closeCameraCur() {
|
|
||||||
this.curCamera = !this.curCamera;
|
|
||||||
let camera = call.currentCamera();
|
|
||||||
call.enableCamera(this.curCamera, camera)
|
|
||||||
},
|
|
||||||
closeCameraBack() {
|
|
||||||
this.backCamera = !this.backCamera;
|
|
||||||
call.enableCamera(this.backCamera, 1)
|
|
||||||
},
|
|
||||||
switchCamera() {
|
|
||||||
call.switchCamera();
|
|
||||||
},
|
|
||||||
microphone() {
|
|
||||||
this.isMicrophone = !this.isMicrophone;
|
|
||||||
call.enableMicrophone(this.isMicrophone);
|
|
||||||
},
|
|
||||||
enableSpeaker() {
|
|
||||||
this.isEnableSpeaker = !this.isEnableSpeaker;
|
|
||||||
call.enableSpeaker(this.isEnableSpeaker);
|
|
||||||
},
|
|
||||||
hangup() {
|
|
||||||
this.isSelf = true;
|
|
||||||
call.hangup();
|
|
||||||
uni.navigateBack({
|
|
||||||
delta: 1
|
|
||||||
})
|
|
||||||
},
|
|
||||||
accept() {
|
|
||||||
call.accept();
|
|
||||||
},
|
|
||||||
startCall() {
|
|
||||||
const type = this.mediaType === 'audio' ? 0 : 1;
|
|
||||||
this.mediaTypeCur = this.mediaType;
|
|
||||||
if (this.targetId.length > 0) {
|
|
||||||
call.enableSpeaker(true);
|
|
||||||
call.startSingleCall(this.targetId, type, null);
|
|
||||||
this.currentCallSession = call.getCurrentCallSession();
|
|
||||||
this.users = this.currentCallSession.users ? this.currentCallSession.users : [];
|
|
||||||
} else {
|
|
||||||
call.startGroupCall(this.groupId, this.userIds, [], type, '');
|
|
||||||
this.users = this.userIds;
|
|
||||||
|
|
||||||
console.log(this.users);
|
|
||||||
this.currentCallSession = call.getCurrentCallSession();
|
|
||||||
this.users = this.currentCallSession.users ? this.currentCallSession.users : [];
|
|
||||||
}
|
|
||||||
let _this = this;
|
|
||||||
// im.getCurrentUserId(function(result){
|
|
||||||
// _this.systemInfoSync(result.userId,_this.$refs.bigVideoView.ref,false);
|
|
||||||
// })
|
|
||||||
if (this.currentCallSession) {
|
|
||||||
this.systemInfoSync(this.currentCallSession.mine.userId, this.$refs.bigVideoView.ref, false);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onCallConnected() {
|
|
||||||
let context = this;
|
|
||||||
console.log('oncallconnected接收了');
|
|
||||||
this.mediaTypeCur = this.mediaType;
|
|
||||||
call.enableSpeaker(true);
|
|
||||||
this.currentCallSession = call.getCurrentCallSession();
|
|
||||||
this.callWay = this.currentCallSession.callType;
|
|
||||||
this.users = this.currentCallSession.users ? this.currentCallSession.users : [];
|
|
||||||
let isHasMine = this.users.findIndex((item) => {
|
|
||||||
return item.userId === this.currentCallSession.mine.userId;
|
|
||||||
});
|
|
||||||
if (isHasMine === -1) {
|
|
||||||
this.users.push(this.currentCallSession.mine);
|
|
||||||
}
|
|
||||||
if (this.currentCallSession && this.currentCallSession.users.length > 0) {
|
|
||||||
//视频是两个的时候
|
|
||||||
if (this.currentCallSession.users.length <= 2) {
|
|
||||||
setTimeout(() => {
|
|
||||||
this.systemInfoSync(this.currentCallSession.mine.userId, this.$refs.smallVideoView.ref,
|
|
||||||
true);
|
|
||||||
this.viewArr = this.currentCallSession.users.filter((item) => {
|
|
||||||
return item.userId !== this.currentCallSession.mine.userId;
|
|
||||||
});
|
|
||||||
this.viewArr.forEach((itm) => {
|
|
||||||
this.targetId = itm.userId;
|
|
||||||
this.systemInfoSync(itm.userId, this.$refs.bigVideoView.ref, false);
|
|
||||||
});
|
|
||||||
}, 100);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// 视频超过三个
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.systemInfoSync(this.currentCallSession.mine.userId, this.$refs.bigVideoView.ref,
|
|
||||||
false);
|
|
||||||
this.viewArr = this.currentCallSession.users.filter((item) => {
|
|
||||||
return item.userId !== this.currentCallSession.mine.userId;
|
|
||||||
});
|
|
||||||
setTimeout(() => {
|
|
||||||
this.viewArr.forEach((itm) => {
|
|
||||||
this.systemInfoSync(itm.userId, this.$refs[itm.userId][0].ref,
|
|
||||||
false);
|
|
||||||
});
|
|
||||||
}, 100)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
systemInfoSync(userId, ref, isZOrderOnTop) {
|
|
||||||
switch (uni.getSystemInfoSync().platform) {
|
|
||||||
case 'android':
|
|
||||||
call.setVideoView(userId, ref, 0, isZOrderOnTop);
|
|
||||||
break;
|
|
||||||
case 'ios':
|
|
||||||
call.setVideoView(userId, ref, 0);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
console.log('运行在开发者工具上')
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onCallDisconnected() {
|
|
||||||
this.isMe = true;
|
|
||||||
if (!this.isSelf) {
|
|
||||||
uni.navigateBack({
|
|
||||||
delta: 1
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
switchChange() {
|
|
||||||
this.isChecked = !this.isChecked;
|
|
||||||
if (!this.isChecked) {
|
|
||||||
this.reset();
|
|
||||||
} else {
|
|
||||||
this.setBeautyOption();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.content {
|
|
||||||
flex: 1;
|
|
||||||
flex-direction: column;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bigVideoView {
|
|
||||||
background: #000;
|
|
||||||
}
|
|
||||||
|
|
||||||
.smallVideoView {
|
|
||||||
position: absolute;
|
|
||||||
right: 0;
|
|
||||||
top: 50upx;
|
|
||||||
width: 200upx;
|
|
||||||
height: 200upx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.smallViews {
|
|
||||||
flex-wrap: wrap;
|
|
||||||
flex-direction: row;
|
|
||||||
background: #ccc;
|
|
||||||
}
|
|
||||||
|
|
||||||
.smallView {
|
|
||||||
width: 200upx;
|
|
||||||
height: 200upx;
|
|
||||||
margin-right: 20upx;
|
|
||||||
background: pink;
|
|
||||||
}
|
|
||||||
|
|
||||||
.container {
|
|
||||||
position: absolute;
|
|
||||||
bottom: 20upx;
|
|
||||||
height: 100upx;
|
|
||||||
flex-direction: row;
|
|
||||||
justify-content: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav {
|
|
||||||
position: fixed;
|
|
||||||
bottom: 200upx;
|
|
||||||
right: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.camera {
|
|
||||||
background: #ccc;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-com {
|
|
||||||
margin-top: 10upx;
|
|
||||||
color: #fff;
|
|
||||||
background: rgba(0, 0, 0, 0.5);
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.hangup {
|
|
||||||
width: 200upx;
|
|
||||||
height: 100upx;
|
|
||||||
color: #fff;
|
|
||||||
text-align: center;
|
|
||||||
line-height: 100upx;
|
|
||||||
background: red;
|
|
||||||
margin-right: 50upx;
|
|
||||||
border-radius: 50upx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.box-mark {
|
|
||||||
position: fixed;
|
|
||||||
left: 0;
|
|
||||||
top: 0;
|
|
||||||
background: rgba(0, 0, 0, .5);
|
|
||||||
z-index: 9999;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.box-cen {
|
|
||||||
padding: 30upx;
|
|
||||||
width: 500upx;
|
|
||||||
height: 500upx;
|
|
||||||
background: #222831;
|
|
||||||
}
|
|
||||||
|
|
||||||
.box-des {
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.box-input {
|
|
||||||
margin-top: 30upx;
|
|
||||||
color: #fff;
|
|
||||||
border: 1upx solid #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.box-tit {
|
|
||||||
margin-top: 30upx;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.box-btn {
|
|
||||||
margin-top: 30upx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.box-btns {
|
|
||||||
flex-direction: row;
|
|
||||||
justify-content: space-between;
|
|
||||||
padding: 0 30upx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.box-btn {
|
|
||||||
padding: 0 20upx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.beauty {
|
|
||||||
height: 500upx;
|
|
||||||
position: fixed;
|
|
||||||
bottom: 0;
|
|
||||||
background: #000;
|
|
||||||
}
|
|
||||||
|
|
||||||
.beauty-btn {
|
|
||||||
height: 100upx;
|
|
||||||
padding-right: 20upx;
|
|
||||||
flex-direction: row;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
|
|
||||||
.change-btn {
|
|
||||||
padding-top: 20upx;
|
|
||||||
flex-direction: row;
|
|
||||||
}
|
|
||||||
|
|
||||||
.switch-btn {
|
|
||||||
border: 1upx;
|
|
||||||
border-color: #fff;
|
|
||||||
padding: 20upx;
|
|
||||||
background: blue;
|
|
||||||
color: #fff;
|
|
||||||
margin-left: 20upx;
|
|
||||||
margin-top: -10upx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ch-tit {
|
|
||||||
margin-top: 8upx;
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ch-res {
|
|
||||||
margin-top: -10upx;
|
|
||||||
margin-left: 20upx;
|
|
||||||
color: #fff;
|
|
||||||
padding: 20upx;
|
|
||||||
border-radius: 10upx;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
background: #4e6ef2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.close-btn {
|
|
||||||
padding-top: 20upx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.close-tit {
|
|
||||||
color: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.beauty-view {
|
|
||||||
flex: 1;
|
|
||||||
background: #ccc;
|
|
||||||
}
|
|
||||||
|
|
||||||
.com-view {
|
|
||||||
padding-top: 40upx;
|
|
||||||
background: #ccc;
|
|
||||||
padding-left: 30upx;
|
|
||||||
padding-right: 30upx;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.beauty-tab {
|
|
||||||
border-top: 1px;
|
|
||||||
border-top-color: #000000;
|
|
||||||
padding: 0 20upx;
|
|
||||||
flex: 1;
|
|
||||||
background: #fff;
|
|
||||||
flex-direction: row;
|
|
||||||
justify-content: space-between;
|
|
||||||
padding-top: 40upx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.filte-view {}
|
|
||||||
|
|
||||||
.tab-item {
|
|
||||||
width: 100upx;
|
|
||||||
height: 100upx;
|
|
||||||
border: 1px;
|
|
||||||
border-color: #000000;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.current {
|
|
||||||
background: yellow;
|
|
||||||
}
|
|
||||||
|
|
||||||
.white-view {}
|
|
||||||
</style>
|
|
||||||
1028
pages/room/room.nvue
1028
pages/room/room.nvue
File diff suppressed because it is too large
Load Diff
@@ -222,11 +222,13 @@ export const useUserStore = defineStore('user', () => {
|
|||||||
// //呼入
|
// //呼入
|
||||||
uni.setStorageSync('room-parameters', {
|
uni.setStorageSync('room-parameters', {
|
||||||
callType: 'in',
|
callType: 'in',
|
||||||
mediaType: session.mediaType === 0 ? 'audio' : 'video'
|
mediaType: session.mediaType === 0 ? 'audio' : 'video',
|
||||||
|
callId: res.data.callId,
|
||||||
|
mine: res.data.mine.userId
|
||||||
});
|
});
|
||||||
//跳转.nvue
|
//跳转.nvue
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url:'/pages/room/room'
|
url:'/pages/room/incom'
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -258,6 +260,7 @@ export const useUserStore = defineStore('user', () => {
|
|||||||
res.data.reason
|
res.data.reason
|
||||||
)
|
)
|
||||||
uni.$emit('OnCallDisconnected');
|
uni.$emit('OnCallDisconnected');
|
||||||
|
uni.navigateBack()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user