Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
P
pica-admin-consultation
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
Close sidebar
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
com.pica.cloud.education.frontend
pica-admin-consultation
提交
97968cf1
提交
97968cf1
编写于
4月 09, 2021
作者:
haochangdi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
完善视频逻辑
上级
60e497c0
变更
6
展开全部
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
129 行增加
和
875 行删除
+129
-875
ImMessage.js
src/utils/live/ImMessage.js
+0
-129
WebIM.js
src/utils/live/WebIM.js
+0
-381
initImMixins.js
src/utils/live/initImMixins.js
+0
-93
rtc-client.js
src/utils/live/rtc-client.js
+6
-0
share-client.js
src/utils/live/share-client.js
+0
-243
diagnosis-live.vue
src/views/IM/diagnosis-admin/diagnosis-live.vue
+123
-29
未找到文件。
src/utils/live/ImMessage.js
已删除
100644 → 0
浏览文件 @
60e497c0
export
const
IM_MESSAGE
=
{
PLEASE_ACTION
:
100
,
// 请求连麦-------------------------------------------------------------嘉宾
CALL_ACTION
:
101
,
// 连麦通知
CALL_ACCEPT
:
1
,
// 主播同意嘉宾连麦----------------------------------------------------------主播
CALL_REFUSE
:
0
,
// 主播拒绝嘉宾连麦----------------------------------------------------------主播
DOWN_ACTIONL
:
102
,
//下麦通知
DOWN_COMMAND
:
102
,
//让嘉宾下麦-------------------------------------------------------------主播
CUSTOM_ACTION
:
301
,
//自定义通知
CUSTOM_COMMAND_MC
:
333
,
//自己下麦----------------------------------------------------------嘉宾
CUSTOM_COMMAND_IN
:
666
,
// 自已在房间-------------------------------------------------------嘉宾
CUSTOM_COMMAND_OUT
:
999
,
// 离开房间--------------------------------------------------------嘉宾
CUSTOM_COMMAND_ON
:
777
,
//上课--------------------------------------------------------------主播
CUSTOM_COMMAND_DOWN
:
888
,
//下课------------------------------------------------------------主播
CUSTOM_COMMAND_DOWN_MC
:
852
,
//关闭麦克风----------------------------------------------------主播
CUSTOM_COMMAND_DOWN_V
:
851
,
// 关闭摄像头 ---------------------------------------------------主播
CUSTOM_COMMAND_HERE
:
123
,
//嘉宾还在不在-----------------------------------------------------主播
CUSTOM_COMMAND_YES
:
321
,
//嘉宾还在----------------------------------------------------------嘉宾
CUSTOM_COMMAND_INVITE
:
741
,
//邀请嘉宾连麦----------------------------------------------------主播
CUSTOM_COMMAND_INVITE_OK
:
742
,
//嘉宾同意连麦-------------------------------------------------嘉宾
CUSTOM_COMMAND_INVITE_NO
:
743
,
//嘉宾拒绝连麦-------------------------------------------------嘉宾
CUSTOM_COMMAND_INVITE_EMPTY
:
745
,
//主播告诉嘉宾有空位置--------------------------------------主播
CUSTOM_COMMAND_SPEAKER_ON
:
201
,
//主播设置嘉宾为主讲--------------------------------------------主播
CUSTOM_COMMAND_SPEAKER_DOWN
:
202
,
//主播取消嘉主讲----------------------------------------------主播
}
// 主播发送的消息-------------------------------------------------
export
const
imAgreeCall
=
()
=>
{
let
data
=
{
data
:
'{"version":"","action":'
+
IM_MESSAGE
.
CALL_ACTION
+
',"accept":'
+
IM_MESSAGE
.
CALL_ACCEPT
+
',"reason":"同意连麦"}'
,
description
:
''
,
extension
:
''
}
return
data
}
export
const
imRefuseCall
=
()
=>
{
let
data
=
{
data
:
'{"version":"","action":'
+
IM_MESSAGE
.
CALL_ACTION
+
',"accept":'
+
IM_MESSAGE
.
CALL_REFUSE
+
',"reason":"拒绝连麦"}'
,
description
:
''
,
extension
:
''
}
return
data
}
export
const
imCallDown
=
(
nick
)
=>
{
let
data
=
{
data
:
'{"version":"","action":'
+
IM_MESSAGE
.
DOWN_ACTIONL
+
', "command":"'
+
IM_MESSAGE
.
DOWN_COMMAND
+
'", "accept":0,"message":"'
+
nick
+
'","reason":"下麦"}'
,
description
:
''
,
extension
:
''
}
return
data
}
export
const
imMcDown
=
(
nick
)
=>
{
let
data
=
{
data
:
'{"version":"","action":'
+
IM_MESSAGE
.
CUSTOM_ACTION
+
',"command": "'
+
IM_MESSAGE
.
CUSTOM_COMMAND_DOWN_MC
+
'","accept":0,"message":"'
+
nick
+
'","reason":"主播关闭了您的麦克风"}'
,
description
:
''
,
extension
:
''
}
return
data
}
export
const
imVDown
=
(
nick
)
=>
{
let
data
=
{
data
:
'{"version":"","action":'
+
IM_MESSAGE
.
CUSTOM_ACTION
+
',"command": "'
+
IM_MESSAGE
.
CUSTOM_COMMAND_DOWN_V
+
'","accept":0,"message":"'
+
nick
+
'","reason":"主播关闭了您的摄像头"}'
,
description
:
''
,
extension
:
''
}
return
data
}
export
const
imClassOn
=
()
=>
{
let
data
=
{
data
:
'{"version":"","action":'
+
IM_MESSAGE
.
CUSTOM_ACTION
+
', "command":"'
+
IM_MESSAGE
.
CUSTOM_COMMAND_ON
+
'","accept":0,"reason":"上课啦","message":""}'
,
description
:
''
,
extension
:
''
}
return
data
}
export
const
imClassDown
=
()
=>
{
let
data
=
{
data
:
'{"version":"","action":'
+
IM_MESSAGE
.
CUSTOM_ACTION
+
', "command":"'
+
IM_MESSAGE
.
CUSTOM_COMMAND_DOWN
+
'","accept":0,"reason":"下课啦","message":""}'
,
description
:
''
,
extension
:
''
}
return
data
}
export
const
imJbHere
=
()
=>
{
let
data
=
{
data
:
'{"version":"","action":'
+
IM_MESSAGE
.
CUSTOM_ACTION
+
', "command":"'
+
IM_MESSAGE
.
CUSTOM_COMMAND_HERE
+
'","accept":0,"reason":"在么?","message":""}'
,
description
:
''
,
extension
:
''
}
return
data
}
export
const
imInviteCall
=
(
nick
)
=>
{
let
data
=
{
data
:
'{"version":"","action":'
+
IM_MESSAGE
.
CUSTOM_ACTION
+
', "command":"'
+
IM_MESSAGE
.
CUSTOM_COMMAND_INVITE
+
'","accept":0,"reason":"主播请您连麦","message":"'
+
nick
+
'"}'
,
description
:
''
,
extension
:
''
}
return
data
}
export
const
imInviteEmpty
=
(
nick
,
replaceId
)
=>
{
let
data
=
{
data
:
'{"version":"","action":'
+
IM_MESSAGE
.
CUSTOM_ACTION
+
', "command":"'
+
IM_MESSAGE
.
CUSTOM_COMMAND_INVITE_EMPTY
+
'","accept":0,"reason":"有空位置了,可以连麦了","replaceId":"'
+
replaceId
+
'","message":"'
+
nick
+
'"}'
,
description
:
''
,
extension
:
''
}
return
data
}
export
const
imSetSpeaker
=
(
nick
)
=>
{
let
data
=
{
data
:
'{"version":"","action":'
+
IM_MESSAGE
.
CUSTOM_ACTION
+
', "command":"'
+
IM_MESSAGE
.
CUSTOM_COMMAND_SPEAKER_ON
+
'","accept":0,"reason":"主播设置您为主讲人","message":"'
+
nick
+
'"}'
,
description
:
''
,
extension
:
''
}
return
data
}
export
const
imCancleSpeaker
=
(
nick
)
=>
{
let
data
=
{
data
:
'{"version":"","action":'
+
IM_MESSAGE
.
CUSTOM_ACTION
+
', "command":"'
+
IM_MESSAGE
.
CUSTOM_COMMAND_SPEAKER_DOWN
+
'","accept":0,"reason":"主播取消您的主讲人身份","message":"'
+
nick
+
'"}'
,
description
:
''
,
extension
:
''
}
return
data
}
// 嘉宾发的消息----------------------------------------------------------------------
export
const
imPleaseCall
=
()
=>
{
let
data
=
{
data
:
'{"version":"","action":'
+
IM_MESSAGE
.
PLEASE_ACTION
+
',"accept":1,"reason":"申请连麦"}'
,
description
:
''
,
extension
:
''
}
return
data
}
export
const
imInhome
=
(
nick
,
callStatus
,
pendCalling
,
faceUrl
,
loadingTime
,
isSpeaker
)
=>
{
let
data
=
{
data
:
'{"version":"","action":'
+
IM_MESSAGE
.
CUSTOM_ACTION
+
',"command":"'
+
IM_MESSAGE
.
CUSTOM_COMMAND_IN
+
'","accept":1,"reason":"我已经在房间了" ,"message":"'
+
nick
+
'","callStatus":"'
+
callStatus
+
'","pendCalling":"'
+
pendCalling
+
'","isSpeaker":"'
+
isSpeaker
+
'","loadingTime":"'
+
loadingTime
+
'","faceUrl":"'
+
faceUrl
+
'"}'
,
description
:
''
,
extension
:
''
}
return
data
}
export
const
imMcDownSelf
=
()
=>
{
let
data
=
{
data
:
'{"version":"","action":'
+
IM_MESSAGE
.
CUSTOM_ACTION
+
', "command":"'
+
IM_MESSAGE
.
CUSTOM_COMMAND_MC
+
'","accept":0,"reason":"我下麦了","message":""}'
,
description
:
''
,
extension
:
''
}
return
data
}
export
const
imJbYes
=
()
=>
{
let
data
=
{
data
:
'{"version":"","action":'
+
IM_MESSAGE
.
CUSTOM_ACTION
+
', "command":"'
+
IM_MESSAGE
.
CUSTOM_COMMAND_YES
+
'","accept":0,"reason":"在的","message":""}'
,
description
:
''
,
extension
:
''
}
return
data
}
export
const
imInviteOk
=
(
nick
)
=>
{
let
data
=
{
data
:
'{"version":"","action":'
+
IM_MESSAGE
.
CUSTOM_ACTION
+
', "command":"'
+
IM_MESSAGE
.
CUSTOM_COMMAND_INVITE_OK
+
'","accept":0,"reason":"嘉宾接受主播连麦请求","message":"'
+
nick
+
'"}'
,
description
:
''
,
extension
:
''
}
return
data
}
export
const
imInviteNo
=
(
nick
)
=>
{
let
data
=
{
data
:
'{"version":"","action":'
+
IM_MESSAGE
.
CUSTOM_ACTION
+
', "command":"'
+
IM_MESSAGE
.
CUSTOM_COMMAND_INVITE_NO
+
'","accept":0,"reason":"嘉宾拒绝主播连麦请求","message":"'
+
nick
+
'"}'
,
description
:
''
,
extension
:
''
}
return
data
}
\ No newline at end of file
src/utils/live/WebIM.js
已删除
100644 → 0
浏览文件 @
60e497c0
此差异已折叠。
点击以展开。
src/utils/live/initImMixins.js
已删除
100644 → 0
浏览文件 @
60e497c0
import
WebIMObj
from
'@/utils/live/WebIM.js'
module
.
exports
=
{
data
()
{
return
{
}
},
created
()
{
},
methods
:
{
// 初始化Im
initIM
()
{
this
.
WebIM
=
new
WebIMObj
({
roomId
:
this
.
roomId
})
this
.
WebIM
.
init
(
this
.
sdkAppId
)
this
.
WebIM
.
tim
.
on
(
TIM
.
EVENT
.
SDK_READY
,
this
.
onTimSdkReady
)
this
.
WebIM
.
tim
.
on
(
TIM
.
EVENT
.
SDK_NOT_READY
,
this
.
onTimSdkNotReady
)
this
.
IMlogin
()
},
// TIM SDK 准备完成 注意:这时需要将vue实例传入
onTimSdkReady
()
{
this
.
IMJion
();
console
.
log
(
'TIM SDK 准备完成'
)
// this.createRoom();
// 将vue实例传入,方便消息回调
this
.
WebIM
.
addEvent
(
this
)
},
// SDK 准备失败
onTimSdkNotReady
(
event
)
{
console
.
log
(
'TIM SDK 准备失败 => '
,
event
)
},
// Im登录
IMlogin
()
{
this
.
WebIM
.
login
({
userId
:
this
.
userId
,
userSig
:
this
.
userSig
}).
then
(()
=>
{
// this.IMJion();
},
error
=>
{
console
.
log
(
'抱歉登录失败'
)
})
},
// WebIM创建聊天房间
createRoom
()
{
this
.
WebIM
.
createRoom
(
this
.
roomId
).
then
(()
=>
{
// 创建课堂-end
console
.
log
(
'创建room成功'
)
this
.
IMJion
()
},
error
=>
{
console
.
log
(
'创建room失败'
)
this
.
IMJion
()
})
},
// WebIM加入房间
IMJion
()
{
this
.
WebIM
.
joinRoom
(
this
.
roomId
).
then
(
res
=>
{
this
.
addFriends
(
this
.
nickShow
)
this
.
joined
=
true
this
.
WebIM
.
updateMyProfile
({
nick
:
this
.
nick
,
avatar
:
this
.
faceUrl
}).
then
(()
=>
{
console
.
log
(
'im 个人信息更新成功'
);
}).
catch
((
errr
)
=>
{
console
.
log
(
'更新资料失败'
,
err
)
})
}).
catch
((
err
)
=>
{
console
.
log
(
'加入房间失败'
,
err
)
})
},
// 退出
leaveIm
()
{
vm
.
WebIM
.
quitGroup
(
vm
.
roomId
)
},
//所有消息
onRecvMessage
(
msg
)
{
},
// 被踢出房间
onClassroomDestroy
()
{
},
// WebIm退出
quitClassroom
()
{
vm
.
WebIM
.
quitGroup
().
then
(()
=>
{
}).
catch
((
error
)
=>
{
})
},
//销毁WebIm
destroyClassroom
(
classId
,
callback
)
{
vm
.
WebIM
.
destroyGroup
(
classId
).
then
(
data
=>
{
// vm.ticWebRTC && vm.ticWebRTC.quit()
}).
catch
(
error
=>
{
})
},
}
}
\ No newline at end of file
src/utils/live/rtc-client.js
浏览文件 @
97968cf1
...
...
@@ -267,6 +267,9 @@ class RtcClient {
// 在订阅远程流时触发
this
.
client_
.
on
(
'stream-subscribed'
,
evt
=>
{
console
.
log
(
'==============evt======================'
);
console
.
log
(
evt
);
console
.
log
(
'===================================='
);
const
remoteStream
=
evt
.
stream
;
const
id
=
remoteStream
.
getId
();
const
uid
=
remoteStream
.
userId_
;
...
...
@@ -305,6 +308,9 @@ class RtcClient {
if
(
!
remoteStream
.
hasVideo
())
{
this
.
changeView
(
id
,
'mask'
,
true
)
}
if
(
!
remoteStream
.
hasAudio
())
{
this
.
changeView
(
id
,
'vioce'
,
false
)
}
},
1000
)
});
...
...
src/utils/live/share-client.js
已删除
100644 → 0
浏览文件 @
60e497c0
class
ShareClient
{
constructor
(
options
)
{
this
.
sdkAppId_
=
options
.
sdkAppId
;
this
.
userId_
=
options
.
userId
;
this
.
userSig_
=
options
.
userSig
;
this
.
roomId_
=
options
.
roomId
;
this
.
vueInstance
=
options
.
vueInstance
;;
//vue实例
this
.
isJoined_
=
false
;
this
.
isPublished_
=
false
;
this
.
localStream_
=
null
;
this
.
client_
=
TRTC
.
createClient
({
mode
:
'live'
,
sdkAppId
:
this
.
sdkAppId_
,
userId
:
this
.
userId_
,
userSig
:
this
.
userSig_
});
//设置是否默认接收远端流。该方法可在 join() 调用前使用,若在进房后调用,会接收不到后续进房的远端用户音视频流。
this
.
client_
.
setDefaultMuteRemoteStreams
(
true
);
this
.
handleEvents
();
}
async
join
()
{
// 如果已经加入时报错
if
(
this
.
isJoined_
)
{
// alert('共享失败,请稍后重试');
this
.
vueInstance
.
$message
({
message
:
'共享失败,请稍后重试!'
,
type
:
'error'
});
return
;
}
try
{
await
this
.
client_
.
join
({
roomId
:
this
.
roomId_
});
console
.
log
(
'共享房间进入成功'
);
this
.
isJoined_
=
true
;
// 进入房间就创建共享本地流
this
.
localStream_
=
TRTC
.
createStream
({
// disable audio as RtcClient already enable audio
audio
:
false
,
// enable screen share
screen
:
true
,
userId
:
this
.
userId_
,
});
// 设置视频分辨率等参数
this
.
localStream_
.
setScreenProfile
({
width
:
this
.
vueInstance
.
viedoParams
.
screenProfileWidth
,
height
:
this
.
vueInstance
.
viedoParams
.
screenProfileHeight
,
frameRate
:
this
.
vueInstance
.
viedoParams
.
screenProfileFramerate
,
bitrate
:
this
.
vueInstance
.
viedoParams
.
screenProfileBitrate
/* kbps */
});
await
this
.
publish
()
return
Promise
.
resolve
();
}
catch
(
e
)
{
console
.
error
(
'ShareClient join room failed! '
+
e
);
}
}
// 发布本地流
async
publish
()
{
if
(
!
this
.
isJoined_
)
{
console
.
warn
(
'共享屏幕请加入房间'
);
return
;
}
if
(
this
.
isPublished_
)
{
console
.
warn
(
'共享屏幕已经发布'
);
return
;
}
try
{
await
this
.
stopPush
()
try
{
await
this
.
localStream_
.
initialize
()
}
catch
(
error
)
{
throw
new
Error
(
error
)
}
if
(
!
this
.
vueInstance
.
canshare
)
{
this
.
vueInstance
.
$message
({
message
:
'您当前不是主讲人,无屏幕分享权限!'
,
type
:
'error'
});
this
.
leave
();
return
}
// 监听播放状态 'PLAYING':开始播放 'PAUSED':暂停播放
this
.
localStream_
.
on
(
'player-state-changed'
,
event
=>
{
console
.
log
(
`local stream
${
event
.
type
}
player is
${
event
.
state
}
`
);
});
// // 监听屏幕分享结束
this
.
localStream_
.
on
(
'screen-sharing-stopped'
,
event
=>
{
console
.
log
(
'共享结束'
);
this
.
leave
();
});
this
.
isPublished_
=
true
;
//创建共享屏幕div
var
localVideoWrapEl
=
document
.
getElementById
(
'share_video'
);
if
(
!
localVideoWrapEl
)
{
localVideoWrapEl
=
document
.
createElement
(
'div'
);
localVideoWrapEl
.
id
=
'share_video'
;
document
.
querySelector
(
"#paint_box"
).
insertBefore
(
localVideoWrapEl
,
null
);
}
if
(
localVideoWrapEl
)
{
// 本地流播放
await
this
.
localStream_
.
play
(
localVideoWrapEl
,
{
muted
:
true
,
objectFit
:
'contain'
});
await
this
.
client_
.
publish
(
this
.
localStream_
);
this
.
showShare
()
}
}
catch
(
e
)
{
console
.
log
(
'用户取消'
);
this
.
leave
();
}
}
/**
* 结束推流
*/
async
stopPush
()
{
if
(
this
.
localStream_
&&
this
.
isPublished_
&&
this
.
isJoined_
)
{
await
this
.
client_
.
unpublish
(
this
.
localStream_
);
this
.
isPublished_
=
false
;
if
(
document
.
getElementById
(
'share_video'
))
{
document
.
getElementById
(
'share_video'
).
remove
();
}
this
.
localStream_
.
close
();
}
}
// 退出
async
leave
()
{
if
(
!
this
.
isJoined_
)
{
console
.
warn
(
'leave() - please join() firstly'
);
return
;
}
// 如果是正在发布流,就先停止流
if
(
this
.
isPublished_
)
{
await
this
.
client_
.
unpublish
(
this
.
localStream_
);
this
.
isPublished_
=
false
;
}
await
this
.
client_
.
leave
();
if
(
this
.
localStream_
)
{
this
.
localStream_
.
close
();
this
.
localStream_
=
null
;
}
this
.
isShare
=
false
;
this
.
isJoined_
=
false
;
this
.
hideShare
()
}
handleEvents
()
{
this
.
client_
.
on
(
'error'
,
err
=>
{
console
.
error
(
err
);
this
.
leave
();
// alert(err);
});
this
.
client_
.
on
(
'client-banned'
,
err
=>
{
this
.
leave
();
console
.
error
(
'client has been banned for '
+
err
);
});
// 嘉宾加入房间时触发
this
.
client_
.
on
(
'peer-join'
,
evt
=>
{
const
userId
=
evt
.
userId
;
console
.
log
(
'嘉宾加入房间时触发 '
+
userId
);
});
// 嘉宾离开房间时触发
this
.
client_
.
on
(
'peer-leave'
,
evt
=>
{
const
userId
=
evt
.
userId
;
console
.
log
(
'嘉宾离开房间时触发'
+
userId
);
});
// 在添加远程流时触发
this
.
client_
.
on
(
'stream-added'
,
evt
=>
{
const
remoteStream
=
evt
.
stream
;
const
id
=
remoteStream
.
getId
();
const
userId
=
remoteStream
.
getUserId
();
console
.
log
(
`remote stream added: [
${
userId
}
] ID:
${
id
}
type:
${
remoteStream
.
getType
()}
`
);
console
.
log
(
' 在添加远程流时触发'
);
});
// 在订阅远程流时触发
this
.
client_
.
on
(
'stream-subscribed'
,
evt
=>
{
const
uid
=
evt
.
userId
;
const
remoteStream
=
evt
.
stream
;
const
id
=
remoteStream
.
getId
();
remoteStream
.
on
(
'player-state-changed'
,
event
=>
{
console
.
log
(
`
${
event
.
type
}
player is
${
event
.
state
}
`
);
});
console
.
log
(
'在订阅远程流时触发'
);
});
// 当远程流被移除时触发, e.g. the remote user called Client.unpublish()
this
.
client_
.
on
(
'stream-removed'
,
evt
=>
{
const
remoteStream
=
evt
.
stream
;
const
id
=
remoteStream
.
getId
();
console
.
log
(
`stream-removed ID:
${
id
}
type:
${
remoteStream
.
getType
()}
`
);
console
.
log
(
'当远程流被移除时触发'
);
});
// 当远程流被更新时触发
this
.
client_
.
on
(
'stream-updated'
,
evt
=>
{
const
remoteStream
=
evt
.
stream
;
console
.
log
(
'当远程流被更新时触发'
);
});
this
.
client_
.
on
(
'mute-audio'
,
evt
=>
{
console
.
log
(
evt
.
userId
+
' mute audio'
);
});
this
.
client_
.
on
(
'unmute-audio'
,
evt
=>
{
console
.
log
(
evt
.
userId
+
' unmute audio'
);
});
this
.
client_
.
on
(
'mute-video'
,
evt
=>
{
console
.
log
(
evt
.
userId
+
' mute video'
);
});
this
.
client_
.
on
(
'unmute-video'
,
evt
=>
{
console
.
log
(
evt
.
userId
+
' unmute video'
);
});
}
// 显示分享屏幕div
showShare
()
{
if
(
this
.
vueInstance
)
{
this
.
vueInstance
.
isShare
=
true
;
}
}
// 隐藏分享屏幕div
hideShare
()
{
if
(
this
.
vueInstance
)
{
this
.
vueInstance
.
isShare
=
false
;
}
}
}
export
default
ShareClient
\ No newline at end of file
src/views/IM/diagnosis-admin/diagnosis-live.vue
浏览文件 @
97968cf1
...
...
@@ -63,8 +63,8 @@ export default {
roleAnchor
:
'anchor'
,
// 主播
rtc
:
null
,
roomId
:
100000437
,
sdkAppId
:
1400408299
,
userSig
:
"
eJyrVgrxCdZLrSjILEpVsjI2NDU2MzAw0AGLlqUWKVkpGekZKEH4xSnZiQUFmSlKVoYmBgYmBhZGlpYQmcyU1LySzLRMsAZDAwgwtNA1BEEwx8TYHGZKZjpQka*HZ1igQYB2UGZoRkGJSWFOeqCzRZRTSKhvsKtZYnG6T355Rb6-U2VRer4tVGNJZi7QiYZmhmaWlhbmJka1APpwNHs_
"
,
sdkAppId
:
''
,
userSig
:
""
,
userId
:
"1000000018-1-1-100000437"
,
viedoParams
:
null
,
isMicOn
:
false
,
...
...
@@ -98,16 +98,16 @@ export default {
type
:
''
,
status
:
1
}
]
],
tid
:
''
,
// 群id
diagnoseLogId
:
''
//问诊id
}
},
async
created
()
{
created
()
{
this
.
tid
=
this
.
$route
.
query
.
tid
||
''
;
this
.
diagnoseLogId
=
this
.
$route
.
query
.
diagnoseLogId
||
''
;
openLoading
(
this
)
this
.
getViedoParams
()
// await this.getInfo()
// await this.getAppId()
// await this.getSing()
// await this.clientLogin()
this
.
init
()
},
computed
:
{
title
(){
...
...
@@ -115,31 +115,78 @@ export default {
}
},
methods
:{
init
()
{
if
(
this
.
checkChrome
())
{
this
.
getViedoParams
()
this
.
getInfo
()
}
else
{
this
.
$nextTick
(()
=>
{
this
.
$refs
.
alert
.
init
({
confirmTxt
:
'我知道了'
,
title
:
`请下载新版Chrome浏览器`
})
.
then
(()
=>
{
closeLoading
(
this
)
this
.
$router
.
go
(
-
1
)
})
.
catch
((
err
)
=>
{
closeLoading
(
this
)
this
.
$router
.
go
(
-
1
)
})
})
}
},
// 获取相关信息
getInfo
()
{
let
url
=
`/
team-controller/team/detail
`
;
let
url
=
`/
im/team/detail?tid=
${
this
.
tid
}
`
;
this
.
GET
(
url
).
then
(
res
=>
{
if
(
res
.
code
==
"000000"
)
{
let
{
liveInfo
,
memberList
}
=
res
.
data
if
(
liveInfo
)
{
this
.
startTime
=
liveInfo
.
startTimestamp
this
.
endTime
=
liveInfo
.
endTimestamp
this
.
roomId
=
liveInfo
.
roomId
this
.
type
=
liveInfo
.
liveType
}
if
(
memberList
)
{
memberList
.
forEach
((
item
)
=>
{
if
(
item
.
role
==
1
)
{
this
.
memberList
[
0
]
=
Object
.
assign
(
item
,{
status
:
1
})
}
if
(
item
.
role
==
2
)
{
this
.
memberList
[
1
]
=
Object
.
assign
(
item
,{
status
:
1
})
}
if
(
item
.
role
==
2
)
{
this
.
userId
=
item
.
accId
}
})
}
this
.
getAppId
()
}
else
{
this
.
getErr
()
}
});
}).
catch
(()
=>
{
this
.
getErr
()
})
},
// 获取AppId
getAppId
()
{
let
req
=
{
}
this
.
GET
(
"coupler/app/trtc/sdkappid"
,
req
)
this
.
GET
(
"
/
coupler/app/trtc/sdkappid"
,
req
)
.
then
(
res
=>
{
if
(
res
.
code
==
"000000"
)
{
this
.
sdkAppId
=
res
.
data
.
sdkAppId
this
.
getSing
()
}
else
if
(
res
.
code
==
'200006'
||
res
.
code
==
'200000'
)
{
if
(
this
.
rtc
)
{
this
.
leave
()
}
this
.
$router
.
push
(
`/login?id=
${
this
.
id
}
`
)
this
.
getErr
(
)
}
})
.
catch
((
err
)
=>
{
console
.
log
(
err
);
this
.
getErr
()
})
},
// 获取签名
...
...
@@ -148,24 +195,23 @@ export default {
sdkAppId
:
this
.
sdkAppId
,
userId
:
this
.
userId
}
this
.
POST
(
"coupler/usersig/trtc"
,
req
).
then
(
res
=>
{
// closeLoading(vm);
this
.
POST
(
"/coupler/usersig/trtc"
,
req
).
then
(
res
=>
{
if
(
res
.
code
==
"000000"
)
{
this
.
userSig
=
res
.
data
.
userSig
this
.
userSig
=
res
.
data
.
userSig
this
.
clientLogin
()
}
else
if
(
res
.
code
==
'200006'
||
res
.
code
==
'200000'
)
{
closeLoading
(
this
)
if
(
this
.
rtc
)
{
this
.
leave
()
}
this
.
$router
.
go
(
-
1
)
this
.
getErr
(
)
}
})
.
catch
((
err
)
=>
{
console
.
log
(
err
);
this
.
getErr
()
})
},
// 创建trtcClient
clientLogin
()
{
// 创建trtcClient
let
obj
=
{
roomId
:
this
.
roomId
,
role
:
this
.
roleAnchor
,
...
...
@@ -178,14 +224,23 @@ export default {
this
.
$nextTick
(()
=>
{
this
.
$refs
.
alert
.
init
({
confirmTxt
:
'我知道了'
,
title
:
`为了更好的体验请保证您输出设备的正常使用`
title
:
`为了更好的体验
,
请保证您输出设备的正常使用`
})
.
then
(()
=>
{
this
.
rtc
.
join
()
this
.
ispending
()
let
t
=
setTimeout
(()
=>
{
closeLoading
(
this
);
clearTimeout
(
t
)
},
1000
)
})
.
catch
((
err
)
=>
{
this
.
rtc
.
join
()
this
.
ispending
()
let
t
=
setTimeout
(()
=>
{
closeLoading
(
this
);
clearTimeout
(
t
)
},
1000
)
})
})
},
...
...
@@ -319,15 +374,53 @@ export default {
// client离开房间
leave
()
{
this
.
rtc
.
leave
()
this
.
$router
.
go
(
-
1
)
},
// 结束会话
overFn
()
{
let
url
=
`/admin/diagnose/endCall/{diagnoseLogId}`
;
this
.
POST
(
url
).
then
(
res
=>
{
let
url
=
`/diagnose/admin/diagnose/endCall`
;
let
params
=
{
diagnoseLogId
:
this
.
diagnoseLogId
};
this
.
POST
(
url
,
params
).
then
(
res
=>
{
if
(
res
.
code
==
"000000"
)
{
this
.
leave
()
}
else
{
this
.
$refs
.
alert
.
init
({
confirmTxt
:
'我知道了'
,
title
:
`操作失败,请稍后重试`
})
.
then
(()
=>
{
})
.
catch
((
err
)
=>
{
})
}
}).
catch
(()
=>
{
this
.
$refs
.
alert
.
init
({
confirmTxt
:
'我知道了'
,
title
:
`操作失败,请稍后重试`
})
.
then
(()
=>
{
})
.
catch
((
err
)
=>
{
})
});
},
// 获取信息失败
getErr
()
{
closeLoading
(
this
)
this
.
$nextTick
(()
=>
{
this
.
$refs
.
alert
.
init
({
confirmTxt
:
'我知道了'
,
title
:
`获取信息失败,请稍后重试`
})
.
then
(()
=>
{
this
.
$router
.
go
(
-
1
)
})
.
catch
((
err
)
=>
{
this
.
$router
.
go
(
-
1
)
})
})
}
},
destroyed
()
{
...
...
@@ -405,11 +498,11 @@ export default {
.main {
margin-top: 24px;
display: flex;
flex: 1;
flex: 1;
.viedo-wrapper {
display: flex;
width: 49%;
height:
90%
;
height:
50vh
;
background: #2D2D2D;
&:first-of-type {
margin-right: 2%;
...
...
@@ -447,6 +540,7 @@ export default {
}
&> div {
height: 100%;
width: 100%;
video {
width: 100%;
height: 100%;
...
...
@@ -489,7 +583,7 @@ export default {
color: #FFFFFF;
line-height: 32px;
text-align: center;
margin:
0
auto 6%;
margin:
15px
auto 6%;
cursor: pointer;
}
}
...
...
写
预览
Markdown
格式
0%
请重试
or
附加一个文件
附加文件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录