Merge remote-tracking branch 'origin/test-audio'
This commit is contained in:
153
App.vue
153
App.vue
@@ -1,6 +1,7 @@
|
|||||||
<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'
|
||||||
|
import * as call from "@/uni_modules/RongCloud-CallWrapper/lib/index"
|
||||||
// #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'
|
||||||
@@ -8,13 +9,15 @@
|
|||||||
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'
|
||||||
|
import {reasonDeal,errorDeal,imCode} from '@/utils/code.js'
|
||||||
|
import { navigateTo } from '@/utils/router'
|
||||||
|
|
||||||
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')
|
||||||
@@ -32,13 +35,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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()
|
||||||
|
onAllListeners()
|
||||||
// #endif
|
// #endif
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -51,9 +55,152 @@
|
|||||||
const show = await getIpBlack(false)
|
const show = await getIpBlack(false)
|
||||||
console.log(show.data.data, '======')
|
console.log(show.data.data, '======')
|
||||||
}
|
}
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
removeAllListeners()
|
||||||
|
// #endif
|
||||||
console.log('App Hide333')
|
console.log('App Hide333')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function onAllListeners () {
|
||||||
|
call.onCallReceived( (res)=> {
|
||||||
|
console.log(res)
|
||||||
|
console.log("Engine:OnCallReceived=>"+"监听通话呼入, 目标id=>", res.data.targetId);
|
||||||
|
if (res.data.targetId) {
|
||||||
|
// let url = res.data.mediaType == 0 ? "" : "/pages/room/room"
|
||||||
|
uni.setStorageSync('room-parameters', {
|
||||||
|
callType: 'in',
|
||||||
|
mediaType: res.data.mediaType === 0 ? 'audio' : 'video'
|
||||||
|
});
|
||||||
|
uni.showToast({
|
||||||
|
title:"有通话呼入该跳转了"+res.data.targetId,
|
||||||
|
duration:3000
|
||||||
|
})
|
||||||
|
navigateTo("/pages/room/incom", {
|
||||||
|
type: res.data.extra,
|
||||||
|
callType: 'in',
|
||||||
|
mediaType: res.data.mediaType == 0 ? "audio" : "video",
|
||||||
|
userID: res.data.mine.userId // 对方的用户id
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
call.onCallDisconnected((res)=>{
|
||||||
|
console.log(res)
|
||||||
|
console.log("Engine:OnCallDisconnected=>"+"通话挂断/拒绝, 挂断原因=>", res.data.reason);
|
||||||
|
// 重新渲染视频视图
|
||||||
|
// uni.$emit('OnCallDisconnected');
|
||||||
|
uni.showToast({
|
||||||
|
title:reasonDeal(res.data.reason),
|
||||||
|
error:"error",
|
||||||
|
icon:'none',
|
||||||
|
duration:2000
|
||||||
|
})
|
||||||
|
goback()
|
||||||
|
});
|
||||||
|
call.onCallConnected((res)=>{
|
||||||
|
console.log(res)
|
||||||
|
console.log("Engine:OnCallConnected=>"+"已建立通话通话接通时,通过回调 onCallConnected 通知当前 call 的详细信息", res);
|
||||||
|
});
|
||||||
|
call.onRemoteUserInvited((res)=>{
|
||||||
|
console.log("Engine:OnRemoteUserInvited=>"+"通话中的某一个参与者,邀请好友加入通话 ,远端Id为=>", res.data.userId);
|
||||||
|
uni.$emit('OnCallConnected');
|
||||||
|
})
|
||||||
|
call.onRemoteUserJoined((res)=>{
|
||||||
|
console.log("Engine:OnRemoteUserJoined=>"+"主叫端拨出电话,被叫端收到请求后,加入通话,对端Id为=>", res.data.userId);
|
||||||
|
uni.$emit('OnCallConnected');
|
||||||
|
})
|
||||||
|
call.onRemoteUserLeft((res)=>{
|
||||||
|
console.log("Engine:OnRemoteUserLeft=>"+"远端用户挂断(群聊触发),远端Id为=>", res.data.reason);
|
||||||
|
uni.$emit('OnCallConnected');
|
||||||
|
uni.showToast({
|
||||||
|
title:reasonDeal(res.data.reason),
|
||||||
|
error:"error",
|
||||||
|
icon:'none',
|
||||||
|
duration:2000
|
||||||
|
})
|
||||||
|
})
|
||||||
|
call.onCallOutgoing((res)=>{
|
||||||
|
console.log('电话已拨出 主叫端拨出电话后,通过回调 onCallOutgoing 通知当前 call 的详细信息')
|
||||||
|
})
|
||||||
|
call.onRemoteUserRinging((res)=>{
|
||||||
|
console.log('被叫端正在振铃,主叫端拨出电话,被叫端收到请求,发出振铃响应时,回调 onRemoteUserRingin,对端Id为=>', res.data.userId)
|
||||||
|
})
|
||||||
|
call.onError((res)=>{
|
||||||
|
console.log('通话过程中,发生异常')
|
||||||
|
uni.showToast({
|
||||||
|
title:errorDeal(res.data.reason),
|
||||||
|
error:"error",
|
||||||
|
icon:'none',
|
||||||
|
duration:2000
|
||||||
|
});
|
||||||
|
goback()
|
||||||
|
})
|
||||||
|
call.onRemoteUserMediaTypeChanged((res)=>{
|
||||||
|
console.log('当通话中的某一个参与者切换通话类型,例如由 audio 切换至 video,回调 onMediaTypeChanged,切换媒体类型的Id为=>',res.data.user.userId);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function goback () {
|
||||||
|
const pages = getCurrentPages()
|
||||||
|
console.log('pages: ',pages);
|
||||||
|
if (pages.length > 1) {
|
||||||
|
console.log("走返回");
|
||||||
|
uni.showToast({
|
||||||
|
title:"走返回",
|
||||||
|
duration:3000
|
||||||
|
})
|
||||||
|
uni.navigateBack({
|
||||||
|
delta: 1
|
||||||
|
})
|
||||||
|
const currentPage = pages[pages.length - 1]
|
||||||
|
const prevPage = pages[pages.length - 2]
|
||||||
|
|
||||||
|
// 判断上一页是否是 tabBar 页面
|
||||||
|
// const isPrevPageTabBar = isTabBarPage(currentPage.route)
|
||||||
|
// if(!isPrevPageTabBar){
|
||||||
|
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判断页面是否是 tabBar 页面
|
||||||
|
function isTabBarPage(route) {
|
||||||
|
// 这里根据你的 pages.json 配置来判断
|
||||||
|
const tabBarPages = [
|
||||||
|
'TUIKit/components/TUIConversation/index',
|
||||||
|
'TUIKit/components/TUIContact/index',
|
||||||
|
'pages/discover/discover',
|
||||||
|
'pages/my-index/my-index'
|
||||||
|
]
|
||||||
|
|
||||||
|
// 判断路由是否在 tabBar 页面列表中
|
||||||
|
return tabBarPages.includes(route)
|
||||||
|
}
|
||||||
|
|
||||||
|
function removeAllListeners(){
|
||||||
|
call.unInit();
|
||||||
|
//移除监听-接收到通话呼入
|
||||||
|
call.removeCallReceivedListener();
|
||||||
|
// 移除监听-开始呼叫通话的回调
|
||||||
|
call.removeCallOutgoingListener();
|
||||||
|
// 移除监听-通话已接通
|
||||||
|
call.removeCallReceivedListener();
|
||||||
|
// 移除监听-通话已结束
|
||||||
|
call.removeCallDisconnectedListener();
|
||||||
|
// 移除监听-对端用户正在振铃
|
||||||
|
call.removeRemoteUserRingingListener();
|
||||||
|
// 移除监听-对端用户加入了通话
|
||||||
|
call.removeRemoteUserJoinedListener();
|
||||||
|
// 移除监听-有用户被邀请加入通话
|
||||||
|
call.removeRemoteUserInvited();
|
||||||
|
// 移除监听-对端用户挂断
|
||||||
|
call.removeRemoteUserLeftListener();
|
||||||
|
// 移除监听-对端用户切换了媒体类型
|
||||||
|
call.removeRemoteUserMediaTypeChangedListener();
|
||||||
|
// 移除监听-通话出现错误的回调
|
||||||
|
call.removeErrorListener();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|||||||
@@ -15,9 +15,9 @@
|
|||||||
const props = withDefaults(
|
const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
/** 通话状态: 0 语音 1 视频 */
|
/** 通话状态: 0 语音 1 视频 */
|
||||||
type?: '0' | '1'
|
type ?: '0' | '1'
|
||||||
/** 信息数据 */
|
/** 信息数据 */
|
||||||
currentConversation?: IConversationModel
|
currentConversation ?: IConversationModel
|
||||||
}>(),
|
}>(),
|
||||||
{
|
{
|
||||||
type: '0',
|
type: '0',
|
||||||
@@ -44,21 +44,23 @@
|
|||||||
emits('onDialogPopupShowOrHide', true)
|
emits('onDialogPopupShowOrHide', true)
|
||||||
|
|
||||||
if (isType.value) {
|
if (isType.value) {
|
||||||
let params ={
|
let params = {
|
||||||
to: props.currentConversation.conversationID,
|
to: props.currentConversation.conversationID,
|
||||||
conversationType: TUIChatEngine.TYPES.CONV_C2C,
|
conversationType: TUIChatEngine.TYPES.CONV_C2C,
|
||||||
payload: {
|
payload: {
|
||||||
text: "拨打语音"
|
text: "拨打语音"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log('params: ',params);
|
console.log('params: ', params);
|
||||||
// TUIChatService.sendTextMessage(params)
|
// TUIChatService.sendTextMessage(params)
|
||||||
navigateTo('/pages/room/incom', {
|
navigateTo('/pages/room/incom', {
|
||||||
type: 'call',
|
type: 'call',
|
||||||
userID: data.userID
|
userID: data.userID,
|
||||||
|
mediaType: 'audio',
|
||||||
|
callType: 'out',
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
let params ={
|
let params = {
|
||||||
to: props.currentConversation.conversationID,
|
to: props.currentConversation.conversationID,
|
||||||
conversationType: TUIChatEngine.TYPES.CONV_C2C,
|
conversationType: TUIChatEngine.TYPES.CONV_C2C,
|
||||||
payload: {
|
payload: {
|
||||||
@@ -91,15 +93,9 @@
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<!-- needBottomPopup -->
|
<!-- needBottomPopup -->
|
||||||
<ToolbarItemContainer
|
<ToolbarItemContainer ref="container" :iconFile="evaluateIcon" :iconWidth="isUniFrameWork ? '34px' : '20px'"
|
||||||
ref="container"
|
:iconHeight="isUniFrameWork ? '34px' : '20px'" :title="isType ? '语音通话' : '视频通话'" @onDialogShow="onDialogShow"
|
||||||
:iconFile="evaluateIcon"
|
@onDialogClose="onDialogClose">
|
||||||
:iconWidth="isUniFrameWork ? '34px' : '20px'"
|
|
||||||
:iconHeight="isUniFrameWork ? '34px' : '20px'"
|
|
||||||
:title="isType ? '语音通话' : '视频通话'"
|
|
||||||
@onDialogShow="onDialogShow"
|
|
||||||
@onDialogClose="onDialogClose"
|
|
||||||
>
|
|
||||||
<!-- <view class="box-index">
|
<!-- <view class="box-index">
|
||||||
<view class="top-icon">
|
<view class="top-icon">
|
||||||
<uni-icons
|
<uni-icons
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "密谈IM",
|
"name" : "密谈IM",
|
||||||
"appid" : "__UNI__D40A151",
|
"appid" : "__UNI__BE00EFC",
|
||||||
"description" : "",
|
"description" : "",
|
||||||
"versionName" : "1.1.3",
|
"versionName" : "1.1.3",
|
||||||
"versionCode" : 112,
|
"versionCode" : 112,
|
||||||
@@ -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,
|
||||||
|
|||||||
@@ -444,14 +444,14 @@
|
|||||||
{
|
{
|
||||||
"path": "pages/room/room",
|
"path": "pages/room/room",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "拨打电话",
|
"navigationBarTitleText": "拨打视频",
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path": "pages/room/incom",
|
"path": "pages/room/incom",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "拨打视频",
|
"navigationBarTitleText": "拨打电话",
|
||||||
"navigationStyle": "custom"
|
"navigationStyle": "custom"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -71,52 +71,52 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import * as CallLib from '@/uni_modules/RongCloud-CallWrapper/lib/index'
|
import * as CallLib from '@/uni_modules/RongCloud-CallWrapper/lib/index'
|
||||||
import { ref, watch } from 'vue'
|
import { ref, watch } from 'vue'
|
||||||
import { onLoad, onUnload, onHide } from '@dcloudio/uni-app'
|
import { onLoad, onUnload, onHide } from '@dcloudio/uni-app'
|
||||||
import { TUIUserService } from '@tencentcloud/chat-uikit-engine-lite'
|
import { TUIUserService } from '@tencentcloud/chat-uikit-engine-lite'
|
||||||
import { useUI } from '../../utils/use-ui'
|
import { useUI } from '../../utils/use-ui'
|
||||||
import { navigateBack } from '../../utils/router'
|
import { navigateBack } from '../../utils/router'
|
||||||
|
|
||||||
CallLib.init({})
|
|
||||||
const { showLoading, hideLoading } = useUI()
|
const { showLoading, hideLoading } = useUI()
|
||||||
const callBackground = ref('/static/images/public/random2.png')
|
const callBackground = ref('/static/images/public/random2.png')
|
||||||
/** 呼叫用户信息 */
|
/** 呼叫用户信息 */
|
||||||
const callerInfo = ref({})
|
const callerInfo = ref({})
|
||||||
/** 通话状态 */
|
/** 通话状态 */
|
||||||
const isRinging = ref(true)
|
const isRinging = ref(true)
|
||||||
/** 控制按钮状态 */
|
/** 控制按钮状态 */
|
||||||
const activeBtn = ref(null)
|
const activeBtn = ref(null)
|
||||||
/**
|
/**
|
||||||
* 拨打状态
|
* 拨打状态
|
||||||
* call: 发起呼叫
|
* call: 发起呼叫
|
||||||
* answer: 接听
|
* answer: 接听
|
||||||
* dialogue: 对话中
|
* dialogue: 对话中
|
||||||
*/
|
*/
|
||||||
const callState = ref('')
|
const callState = ref('')
|
||||||
CallLib.onRemoteUserJoined(res => {
|
CallLib.onRemoteUserJoined(res => {
|
||||||
console.log(
|
console.log(
|
||||||
'Engine:OnRemoteUserJoined=>' +
|
'Engine:OnRemoteUserJoined=>' +
|
||||||
'主叫端拨出电话,被叫端收到请求后,加入通话,被叫端Id为=>',
|
'主叫端拨出电话,被叫端收到请求后,加入通话,被叫端Id为=>',
|
||||||
res.data.userId
|
res.data.userId
|
||||||
)
|
)
|
||||||
callState.value = 'dialogue'
|
callState.value = 'dialogue'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
// CallLib.onRemoteUserRinging(res => {
|
// CallLib.onRemoteUserRinging(res => {
|
||||||
// console.log(
|
// console.log(
|
||||||
// '主叫端拨出电话,被叫端收到请求,发出振铃响应时触发,对端Id为=>',
|
// '主叫端拨出电话,被叫端收到请求,发出振铃响应时触发,对端Id为=>',
|
||||||
// res.data.userId
|
// res.data.userId
|
||||||
// )
|
// )
|
||||||
// })
|
// })
|
||||||
|
|
||||||
// CallLib.onError(res => {
|
// CallLib.onError(res => {
|
||||||
// console.log('通话过程中,发生异常,异常原因=>', res.data.reason)
|
// console.log('通话过程中,发生异常,异常原因=>', res.data.reason)
|
||||||
// })
|
// })
|
||||||
|
|
||||||
/** 按钮状态 */
|
/** 按钮状态 */
|
||||||
const cutFn = show => {
|
const cutFn = show => {
|
||||||
if (show) {
|
if (show) {
|
||||||
// 接听电话 dialogue
|
// 接听电话 dialogue
|
||||||
if(mediaType.value === 'audio'){
|
if(mediaType.value === 'audio'){
|
||||||
@@ -132,13 +132,13 @@
|
|||||||
} else {
|
} else {
|
||||||
//取消接听,返回上一页
|
//取消接听,返回上一页
|
||||||
CallLib.hangup()
|
CallLib.hangup()
|
||||||
navigateBack()
|
// navigateBack()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const mediaType= ref("audio")
|
const mediaType= ref("audio")
|
||||||
|
|
||||||
onLoad(async e => {
|
onLoad(async e => {
|
||||||
callState.value = e.type
|
callState.value = e.type
|
||||||
mediaType.value = e.mediaType
|
mediaType.value = e.mediaType
|
||||||
console.log(e)
|
console.log(e)
|
||||||
@@ -158,28 +158,12 @@
|
|||||||
}
|
}
|
||||||
console.log('callState.value: ',callState.value);
|
console.log('callState.value: ',callState.value);
|
||||||
console.log('===好友信息', res)
|
console.log('===好友信息', res)
|
||||||
})
|
})
|
||||||
|
|
||||||
// onUnload( ()=>{
|
|
||||||
// removeAllListeners()
|
|
||||||
// })
|
|
||||||
|
|
||||||
// onHide( ()=>{
|
|
||||||
// removeAllListeners()
|
|
||||||
// })
|
|
||||||
|
|
||||||
function removeAllListeners(){
|
|
||||||
//移除监听-接收到通话呼入
|
|
||||||
CallLib.removeRemoteUserJoinedListener();
|
|
||||||
// 移除监听-通话已结束
|
|
||||||
CallLib.removeCallDisconnectedListener();
|
|
||||||
// 移除监听-通话出现错误的回调
|
|
||||||
CallLib.removeErrorListener();
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.incoming-call {
|
.incoming-call {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
@@ -366,9 +350,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes ringPulse {
|
@keyframes ringPulse {
|
||||||
0% {
|
0% {
|
||||||
box-shadow: 0 0 0 0 rgba(26, 173, 25, 0.4);
|
box-shadow: 0 0 0 0 rgba(26, 173, 25, 0.4);
|
||||||
}
|
}
|
||||||
@@ -380,10 +364,10 @@
|
|||||||
100% {
|
100% {
|
||||||
box-shadow: 0 0 0 0 rgba(26, 173, 25, 0);
|
box-shadow: 0 0 0 0 rgba(26, 173, 25, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 响应式调整 */
|
/* 响应式调整 */
|
||||||
@media (max-height: 600px) {
|
@media (max-height: 600px) {
|
||||||
.incoming-controls {
|
.incoming-controls {
|
||||||
padding: 40rpx 100rpx 80rpx !important;
|
padding: 40rpx 100rpx 80rpx !important;
|
||||||
}
|
}
|
||||||
@@ -391,5 +375,5 @@
|
|||||||
.action-bar {
|
.action-bar {
|
||||||
bottom: 40rpx !important;
|
bottom: 40rpx !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -150,24 +150,16 @@
|
|||||||
},
|
},
|
||||||
onUnload() {
|
onUnload() {
|
||||||
call.hangup()
|
call.hangup()
|
||||||
// this.removeAllListeners()
|
|
||||||
},
|
},
|
||||||
onHide() {
|
onHide() {
|
||||||
const session = call.getCurrentCallSession()
|
const session = call.getCurrentCallSession()
|
||||||
if (session) {
|
if (session) {
|
||||||
call.hangup()
|
call.hangup()
|
||||||
}
|
}
|
||||||
// this.removeAllListeners()
|
uni.$off('OnCallDisconnected')
|
||||||
|
uni.$off('OnCallConnected')
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
removeAllListeners(){
|
|
||||||
//移除监听-接收到通话呼入
|
|
||||||
call.removeRemoteUserJoinedListener();
|
|
||||||
// 移除监听-通话已结束
|
|
||||||
call.removeCallDisconnectedListener();
|
|
||||||
// 移除监听-通话出现错误的回调
|
|
||||||
call.removeErrorListener();
|
|
||||||
},
|
|
||||||
changeMediaType() {
|
changeMediaType() {
|
||||||
if (this.mediaTypeCur == 'video') {
|
if (this.mediaTypeCur == 'video') {
|
||||||
this.mediaTypeCur = 'audio'
|
this.mediaTypeCur = 'audio'
|
||||||
@@ -284,9 +276,9 @@
|
|||||||
hangup() {
|
hangup() {
|
||||||
this.isSelf = true
|
this.isSelf = true
|
||||||
call.hangup()
|
call.hangup()
|
||||||
uni.navigateBack({
|
// uni.navigateBack({
|
||||||
delta: 1
|
// delta: 1
|
||||||
})
|
// })
|
||||||
},
|
},
|
||||||
accept() {
|
accept() {
|
||||||
call.accept()
|
call.accept()
|
||||||
@@ -324,12 +316,61 @@
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onCallConnected() {
|
onCallConnected() {
|
||||||
let context = this
|
let context = this
|
||||||
console.log('oncallconnected接收了')
|
console.log('oncallconnected接收了')
|
||||||
|
console.log('call: ',call);
|
||||||
|
// 使用 Promise 确保 call 对象完全初始化
|
||||||
|
this.initializeCall(call)
|
||||||
|
.then(() => {
|
||||||
|
this.processCallSession()
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('初始化通话失败:', error)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async initializeCall(callObj) {
|
||||||
|
// 等待 call 对象就绪
|
||||||
|
await this.waitForCallReady(callObj)
|
||||||
|
|
||||||
|
// 设置扬声器
|
||||||
|
if (callObj.enableSpeaker && typeof callObj.enableSpeaker === 'function') {
|
||||||
|
try {
|
||||||
|
callObj.enableSpeaker(true)
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('设置扬声器失败:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return callObj
|
||||||
|
},
|
||||||
|
|
||||||
|
waitForCallReady(callObj, timeout = 2000) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const startTime = Date.now()
|
||||||
|
|
||||||
|
const check = () => {
|
||||||
|
const now = Date.now()
|
||||||
|
|
||||||
|
if (callObj &&
|
||||||
|
callObj.enableSpeaker &&
|
||||||
|
callObj.getCurrentCallSession &&
|
||||||
|
typeof callObj.getCurrentCallSession === 'function') {
|
||||||
|
resolve(callObj)
|
||||||
|
} else if (now - startTime > timeout) {
|
||||||
|
reject(new Error('call 对象初始化超时'))
|
||||||
|
} else {
|
||||||
|
setTimeout(check, 50)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
check()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
processCallSession(){
|
||||||
|
// call.enableSpeaker(true)
|
||||||
this.mediaTypeCur = this.mediaType
|
this.mediaTypeCur = this.mediaType
|
||||||
call.enableSpeaker(true)
|
|
||||||
this.currentCallSession = call.getCurrentCallSession()
|
this.currentCallSession = call.getCurrentCallSession()
|
||||||
this.callWay = this.currentCallSession.callType
|
this.callWay = this.currentCallSession.callType
|
||||||
this.users = this.currentCallSession.users
|
this.users = this.currentCallSession.users
|
||||||
@@ -347,6 +388,7 @@
|
|||||||
) {
|
) {
|
||||||
//视频是两个的时候
|
//视频是两个的时候
|
||||||
if (this.currentCallSession.users.length <= 2) {
|
if (this.currentCallSession.users.length <= 2) {
|
||||||
|
console.log("视频是两个的时候");
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.systemInfoSync(
|
this.systemInfoSync(
|
||||||
this.currentCallSession.mine.userId,
|
this.currentCallSession.mine.userId,
|
||||||
@@ -397,6 +439,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
systemInfoSync(userId, ref, isZOrderOnTop) {
|
systemInfoSync(userId, ref, isZOrderOnTop) {
|
||||||
switch (uni.getSystemInfoSync().platform) {
|
switch (uni.getSystemInfoSync().platform) {
|
||||||
case 'android':
|
case 'android':
|
||||||
|
|||||||
182
stores/user.js
182
stores/user.js
@@ -1,4 +1,6 @@
|
|||||||
import { defineStore } from 'pinia'
|
import {
|
||||||
|
defineStore
|
||||||
|
} from 'pinia'
|
||||||
import {
|
import {
|
||||||
getToken,
|
getToken,
|
||||||
getUserInfoData,
|
getUserInfoData,
|
||||||
@@ -13,29 +15,68 @@ import {
|
|||||||
} from '@/utils/storage'
|
} from '@/utils/storage'
|
||||||
|
|
||||||
// #ifdef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
import { useLoginState } from '@/uni_modules/tuikit-atomic-x/state/LoginState'
|
import {
|
||||||
|
useLoginState
|
||||||
|
} from '@/uni_modules/tuikit-atomic-x/state/LoginState'
|
||||||
import * as CallLib from '@/uni_modules/RongCloud-CallWrapper/lib/index'
|
import * as CallLib from '@/uni_modules/RongCloud-CallWrapper/lib/index'
|
||||||
import RCIMIWEngine from '@/uni_modules/RongCloud-IMWrapper-V2/js_sdk/RCIMEngine'
|
import RCIMIWEngine from '@/uni_modules/RongCloud-IMWrapper-V2/js_sdk/RCIMEngine'
|
||||||
import { reasonDeal, errorDeal, imCode } from '@/utils/code.js'
|
import {
|
||||||
|
reasonDeal,
|
||||||
|
errorDeal,
|
||||||
|
imCode
|
||||||
|
} from '@/utils/code.js'
|
||||||
// #endif
|
// #endif
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
import { useLoginState } from 'tuikit-atomicx-vue3'
|
import {
|
||||||
|
useLoginState
|
||||||
|
} from 'tuikit-atomicx-vue3'
|
||||||
// #endif
|
// #endif
|
||||||
import { useTokenStore } from './token'
|
import {
|
||||||
import { getUserData, userLogout, updateUserData } from '@/api'
|
useTokenStore
|
||||||
import { ref } from 'vue'
|
} from './token'
|
||||||
import { useUI } from '@/utils/use-ui'
|
import {
|
||||||
import { reLaunch } from '@/utils/router'
|
getUserData,
|
||||||
import { getTencentUserSig } from '@/api'
|
userLogout,
|
||||||
import { TUILogin } from '@tencentcloud/tui-core-lite'
|
updateUserData
|
||||||
import { TUIChatEngine } from '@tencentcloud/chat-uikit-engine-lite'
|
} from '@/api'
|
||||||
import { getUserIntegral } from '@/api/my-index'
|
import {
|
||||||
import { removeFriendList, removeGroupList } from '../utils/storage'
|
ref
|
||||||
import { getRongYunLoginInfo } from '../api'
|
} from 'vue'
|
||||||
|
import {
|
||||||
|
useUI
|
||||||
|
} from '@/utils/use-ui'
|
||||||
|
import {
|
||||||
|
reLaunch
|
||||||
|
} from '@/utils/router'
|
||||||
|
import {
|
||||||
|
getTencentUserSig
|
||||||
|
} from '@/api'
|
||||||
|
import {
|
||||||
|
TUILogin
|
||||||
|
} from '@tencentcloud/tui-core-lite'
|
||||||
|
import {
|
||||||
|
TUIChatEngine
|
||||||
|
} from '@tencentcloud/chat-uikit-engine-lite'
|
||||||
|
import {
|
||||||
|
getUserIntegral
|
||||||
|
} from '@/api/my-index'
|
||||||
|
import {
|
||||||
|
removeFriendList,
|
||||||
|
removeGroupList
|
||||||
|
} from '../utils/storage'
|
||||||
|
import {
|
||||||
|
getRongYunLoginInfo
|
||||||
|
} from '../api'
|
||||||
|
import permision from "@/js_sdk/wa-permission/permission.js"
|
||||||
|
|
||||||
export const useUserStore = defineStore('user', () => {
|
export const useUserStore = defineStore('user', () => {
|
||||||
const { clearToken } = useTokenStore()
|
const {
|
||||||
const { showDialog, showToast } = useUI()
|
clearToken
|
||||||
|
} = useTokenStore()
|
||||||
|
const {
|
||||||
|
showDialog,
|
||||||
|
showToast
|
||||||
|
} = useUI()
|
||||||
|
|
||||||
const userInfo = ref(
|
const userInfo = ref(
|
||||||
getUserInfoData() ? JSON?.parse(getUserInfoData()) : {}
|
getUserInfoData() ? JSON?.parse(getUserInfoData()) : {}
|
||||||
@@ -129,103 +170,38 @@ export const useUserStore = defineStore('user', () => {
|
|||||||
})
|
})
|
||||||
console.log(tencentUserSig.value.appKey, '====')
|
console.log(tencentUserSig.value.appKey, '====')
|
||||||
await connectIM()
|
await connectIM()
|
||||||
// #endif
|
|
||||||
// #ifdef APP-PLUS
|
|
||||||
// CallLib.init({})
|
|
||||||
CallLib.onCallReceived(res => {
|
|
||||||
console.log(
|
|
||||||
'Engine:OnCallReceived=>' + '监听通话呼入, 目标id=>',
|
|
||||||
res.data
|
|
||||||
)
|
|
||||||
console.log('res: ',res.data);
|
|
||||||
if (res.data.targetId) {
|
|
||||||
// let url = res.data.mediaType == 0 ? "" : "/pages/room/room"
|
|
||||||
uni.setStorageSync('room-parameters', {
|
|
||||||
callType: 'in',
|
|
||||||
mediaType: res.data.mediaType === 0 ? 'audio' : 'video'
|
|
||||||
});
|
|
||||||
uni.navigateTo("/pages/room/incom", {
|
|
||||||
type: res.data.extra,
|
|
||||||
callType: 'in',
|
|
||||||
mediaType: res.data.mediaType == 0 ? "audio" : "video",
|
|
||||||
userID: res.data.mine.userId // 对方的用户id
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
/** 挂断电话 */
|
|
||||||
CallLib.onCallDisconnected(res => {
|
|
||||||
console.log(
|
|
||||||
'Engine:OnCallDisconnected=>' + '挂断成功, 挂断原因=>',
|
|
||||||
res.data.reason
|
|
||||||
)
|
|
||||||
uni.navigateBack()
|
|
||||||
})
|
|
||||||
|
|
||||||
CallLib.onError(res => {
|
|
||||||
console.log('通话过程中,发生异常,异常原因=>', res.data.reason)
|
|
||||||
uni.navigateBack()
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
// #endif
|
// #endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//连接融云IM
|
//连接融云IM
|
||||||
const connectIM = async () => {
|
const connectIM = async () => {
|
||||||
const options = {
|
let options = {}
|
||||||
naviServer: ''
|
imEngine.value = await RCIMIWEngine.create(tencentUserSig.value.appKey, options)
|
||||||
}
|
imEngine.value.setOnConnectedListener((res) => {
|
||||||
imEngine.value = await RCIMIWEngine.create(
|
|
||||||
tencentUserSig.value.appKey,
|
|
||||||
options
|
|
||||||
)
|
|
||||||
imEngine.value.setOnConnectedListener(res => {
|
|
||||||
if (res.code != 0) {
|
if (res.code != 0) {
|
||||||
uni.hideLoading()
|
uni.hideLoading();
|
||||||
uni.showToast({
|
// uni.showToast({
|
||||||
title: 'OnCon:' + res.code,
|
// title: 'OnCon:' + res.code,
|
||||||
icon: 'error'
|
// icon: 'error'
|
||||||
})
|
// })
|
||||||
return
|
console.log("连接已存在");
|
||||||
|
// return
|
||||||
}
|
}
|
||||||
//连接成功
|
//连接成功
|
||||||
CallLib.init({})
|
CallLib.init({});
|
||||||
console.log('call.init')
|
console.log('call.init')
|
||||||
// this.libPage = true;
|
uni.hideLoading();
|
||||||
// this.loginUserId = res.userId;
|
uni.showToast({
|
||||||
uni.hideLoading()
|
title: res.userId
|
||||||
console.log('登录成功')
|
});
|
||||||
})
|
if (uni.getSystemInfoSync().platform === 'android') {
|
||||||
const callback = {
|
permision.requestAndroidPermission('android.permission.CAMERA');
|
||||||
onDatabaseOpened: res => {
|
permision.requestAndroidPermission('android.permission.RECORD_AUDIO');
|
||||||
console.log('数据库打开')
|
|
||||||
},
|
|
||||||
onConnected: res => {
|
|
||||||
console.log(res)
|
|
||||||
if (res.code === 0) {
|
|
||||||
// uni.showToast({
|
|
||||||
// title: '连接成功',
|
|
||||||
// icon: 'none'
|
|
||||||
// })
|
|
||||||
console.log('连接成功')
|
|
||||||
} else if (res.code === 34001) {
|
|
||||||
// uni.showToast({
|
|
||||||
// title: '连接已存在,不需要再连接',
|
|
||||||
// icon: 'none'
|
|
||||||
// })
|
|
||||||
console.log('连接已存在,不需要再连接')
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
let code = await imEngine.value.connect(tencentUserSig.value.ryToken, 10)
|
||||||
}
|
|
||||||
let code = await imEngine.value.connect(
|
|
||||||
tencentUserSig.value.ryToken,
|
|
||||||
10,
|
|
||||||
callback
|
|
||||||
)
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
uni.hideLoading()
|
uni.hideLoading();
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: 'connect:' + code,
|
title: 'connect:' + code,
|
||||||
icon: 'error'
|
icon: 'error'
|
||||||
|
|||||||
Reference in New Issue
Block a user