|
@@ -28,13 +28,30 @@
|
|
|
<div class="loading-wrapper">
|
|
|
<p class="loading-title">正在呼叫,等待对方接通...</p>
|
|
|
<div>
|
|
|
- <!-- <el-button type="danger" circle>
|
|
|
+ <el-button type="danger" circle @click="handsDown('loading')">
|
|
|
<svg-icon icon-class="hang-up" />
|
|
|
- </el-button> -->
|
|
|
+ </el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div v-show="connect" id="student"></div>
|
|
|
+ <div v-show="connect" class="student-parent">
|
|
|
+ <div v-show="roomInfo.video_mode === 1 || remoteStreamType === 1" id="student"></div>
|
|
|
+ <template v-if="remoteStreamType !== 1">
|
|
|
+ <template v-if="roomInfo.video_mode === 1">
|
|
|
+ <el-button type="danger" @click="handsDown">
|
|
|
+ <svg-icon icon-class="hang-up" /> 挂断
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <div class="student-audio">
|
|
|
+ <el-avatar icon="el-icon-user" :src="connectStudent.student_image_url" />
|
|
|
+ <el-button type="danger" circle @click="handsDown">
|
|
|
+ <svg-icon icon-class="hang-up" />
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </template>
|
|
|
+ </div>
|
|
|
<div v-show="isDraw" id="draw-parent">
|
|
|
<div v-show="isDrawSetting" class="draw-setting">
|
|
|
<span class="brush-shape">
|
|
@@ -106,7 +123,7 @@
|
|
|
@mouseout="liveMenuShow = false"
|
|
|
>
|
|
|
<div id="live"></div>
|
|
|
- <div v-show="liveMenuShow" class="live-wrapper">
|
|
|
+ <div :style="{ bottom: liveMenuShow ? '0' : '-40px' }" class="live-wrapper">
|
|
|
<div>
|
|
|
{{ roomInfo.teacher_name }}
|
|
|
</div>
|
|
@@ -122,9 +139,8 @@
|
|
|
<span class="name">{{ item.student_name }}</span>
|
|
|
</div>
|
|
|
<div class="student-list-right">
|
|
|
- <svg-icon icon-class="video" @click="invite(item.room_user_id, 1)" />
|
|
|
- <svg-icon icon-class="voice" @click="invite(item.room_user_id, 2)" />
|
|
|
- <span @click="handsDown(item.room_user_id)"> 下麦 </span>
|
|
|
+ <svg-icon icon-class="video" @click="invite(item, 1)" />
|
|
|
+ <svg-icon icon-class="voice" @click="invite(item, 2)" />
|
|
|
</div>
|
|
|
</li>
|
|
|
</ul>
|
|
@@ -150,7 +166,12 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { GetLiveRoomStudentList, CloseLiveRoom, GetLiveRoomInfo } from '@/api/live';
|
|
|
+import {
|
|
|
+ GetLiveRoomStudentList,
|
|
|
+ CloseLiveRoom,
|
|
|
+ GetLiveRoomInfo,
|
|
|
+ StudentExitLiveRoom
|
|
|
+} from '@/api/live';
|
|
|
import SelectMaterial from '@/components/live/SelectMaterial.vue';
|
|
|
import CompleteList from './CompleteList.vue';
|
|
|
import * as common from './live';
|
|
@@ -166,6 +187,7 @@ export default {
|
|
|
task_id: this.$route.query.task_id,
|
|
|
// 连麦
|
|
|
connect: false,
|
|
|
+ connectStudent: {},
|
|
|
// 等待接通
|
|
|
callLoading: false,
|
|
|
dialogVisible: false,
|
|
@@ -173,6 +195,7 @@ export default {
|
|
|
dialogVisibleComplete: false,
|
|
|
// 定时器
|
|
|
timer: null,
|
|
|
+ remoteStreamType: -1,
|
|
|
rtc: null,
|
|
|
roomData: {
|
|
|
desc: '直播间标题',
|
|
@@ -221,13 +244,21 @@ export default {
|
|
|
watch: {
|
|
|
loadedNumber(newVal) {
|
|
|
if (newVal === 5) {
|
|
|
- this.initSDK();
|
|
|
- this.$loading().close();
|
|
|
+ common.createScript(
|
|
|
+ 'https://class.csslcloud.net/static/SDK/docSDK/drawSdk_3.0.js'
|
|
|
+ ).onload = () => {
|
|
|
+ this.initSDK();
|
|
|
+ this.$loading().close();
|
|
|
+ };
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
- this.downloadWebSDK();
|
|
|
+ this.$loading({
|
|
|
+ text: '加载直播所需SDK中...',
|
|
|
+ background: '#fff'
|
|
|
+ });
|
|
|
+ common.downloadWebSDK(this);
|
|
|
this.getLiveRoomStudentList();
|
|
|
this.getLiveRoomInfo();
|
|
|
},
|
|
@@ -264,60 +295,6 @@ export default {
|
|
|
clearInterval(this.timer);
|
|
|
},
|
|
|
methods: {
|
|
|
- // 加载直播所需 SDK,加载完成后才能初始化
|
|
|
- downloadWebSDK() {
|
|
|
- this.$loading({
|
|
|
- text: '加载直播所需SDK中...',
|
|
|
- background: '#fff'
|
|
|
- });
|
|
|
- let script = this.createScript('https://class.csslcloud.net/static/dist/js/websdk_4.0.js');
|
|
|
- let link = this.createLink('https://class.csslcloud.net/static/SDK/docSDK/draw.css');
|
|
|
-
|
|
|
- link.onload = () => {
|
|
|
- this.loadedNumber += 1;
|
|
|
- };
|
|
|
-
|
|
|
- script.onload = () => {
|
|
|
- let scriptArray = [
|
|
|
- 'https://class.csslcloud.net/static/dist/js/classMode.js',
|
|
|
- 'https://class.csslcloud.net/static/dist/js/classUpdateChat.js',
|
|
|
- 'https://image.csslcloud.net/js/dpc.js'
|
|
|
- ];
|
|
|
- for (let i = 0; i < scriptArray.length; i++) {
|
|
|
- let classMode = this.createScript(scriptArray[i]);
|
|
|
- classMode.onload = () => {
|
|
|
- this.loadedNumber += 1;
|
|
|
- };
|
|
|
- }
|
|
|
- };
|
|
|
-
|
|
|
- let jq = this.createScript('https://class.csslcloud.net/static/js/jquery/jquery.min.js');
|
|
|
- jq.onload = () => {
|
|
|
- let classMode = this.createScript(
|
|
|
- 'https://class.csslcloud.net/static/SDK/docSDK/drawSdk_3.0.js'
|
|
|
- );
|
|
|
- classMode.onload = () => {
|
|
|
- this.loadedNumber += 1;
|
|
|
- };
|
|
|
- };
|
|
|
- },
|
|
|
-
|
|
|
- createScript(url) {
|
|
|
- let script = document.createElement('script');
|
|
|
- script.type = 'text/javascript';
|
|
|
- script.src = url;
|
|
|
- document.getElementsByTagName('body')[0].appendChild(script);
|
|
|
- return script;
|
|
|
- },
|
|
|
-
|
|
|
- createLink(url) {
|
|
|
- let link = document.createElement('link');
|
|
|
- link.rel = 'stylesheet';
|
|
|
- link.href = url;
|
|
|
- document.getElementsByTagName('body')[0].appendChild(link);
|
|
|
- return link;
|
|
|
- },
|
|
|
-
|
|
|
initSDK() {
|
|
|
const { live_room_sys_user_id, room_id, session_id } = this.$route.query;
|
|
|
this.rtc = common.initSDK({
|
|
@@ -326,7 +303,6 @@ export default {
|
|
|
sessionid: session_id
|
|
|
});
|
|
|
common.initListener(this); // 注册监听事件
|
|
|
- window.rtc = this.rtc;
|
|
|
this.getLiveStat();
|
|
|
},
|
|
|
|
|
@@ -388,21 +364,29 @@ export default {
|
|
|
},
|
|
|
|
|
|
// 老师邀请学生上麦
|
|
|
- invite(uid, mode) {
|
|
|
+ invite(student, mode) {
|
|
|
+ if (this.connect || this.callLoading) {
|
|
|
+ this.$message.warning('正在连麦中');
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.callLoading = true;
|
|
|
+ this.connectStudent = student;
|
|
|
GetLiveRoomInfo({ task_id: this.task_id })
|
|
|
.then(({ video_mode }) => {
|
|
|
+ let uid = student.room_user_id;
|
|
|
if (video_mode === mode) {
|
|
|
common.invite(uid);
|
|
|
} else {
|
|
|
common.roomUpdate({
|
|
|
video_mode: mode,
|
|
|
- roomUpdateSuccess: function (data) {
|
|
|
+ roomUpdateSuccess: data => {
|
|
|
console.log(data, '连麦音视频模式更新请求成功!');
|
|
|
+ this.roomInfo.video_mode = mode;
|
|
|
common.invite(uid);
|
|
|
},
|
|
|
- roomUpdateFailed: function (data) {
|
|
|
- console.log(data, '连麦音视频模式更新请求失败! 请稍后再试!');
|
|
|
+ roomUpdateFailed: data => {
|
|
|
+ this.callLoading = false;
|
|
|
+ this.connectStudent = '';
|
|
|
this.$message.error('连麦音视频模式更新请求失败! 请稍后再试!');
|
|
|
}
|
|
|
});
|
|
@@ -410,16 +394,24 @@ export default {
|
|
|
})
|
|
|
.catch(() => {
|
|
|
this.callLoading = false;
|
|
|
+ this.connectStudent = '';
|
|
|
});
|
|
|
},
|
|
|
|
|
|
// 下麦
|
|
|
- handsDown(uid) {
|
|
|
+ handsDown(type) {
|
|
|
common.handsDown({
|
|
|
- uid,
|
|
|
+ uid: this.connectStudent.room_user_id,
|
|
|
success: str => {
|
|
|
+ if (type === 'loading') {
|
|
|
+ common.sendPublishMessage({
|
|
|
+ type: 'handsDown-load',
|
|
|
+ uid: this.connectStudent.room_user_id
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
this.callLoading = false;
|
|
|
- console.log('下麦成功', str);
|
|
|
+ this.connectStudent = '';
|
|
|
this.$message.success('下麦成功');
|
|
|
},
|
|
|
fail: data => {
|
|
@@ -471,6 +463,10 @@ export default {
|
|
|
}, 5000);
|
|
|
},
|
|
|
|
|
|
+ studentExitLiveRoom(room_user_id) {
|
|
|
+ StudentExitLiveRoom({ task_id: this.task_id, room_user_id });
|
|
|
+ },
|
|
|
+
|
|
|
// 弹出框方法
|
|
|
publishStream() {
|
|
|
common.publishStream('main');
|
|
@@ -568,12 +564,45 @@ $live-bc: #3d3938;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- #student {
|
|
|
+ .student-parent {
|
|
|
+ position: relative;
|
|
|
width: 100%;
|
|
|
height: 468px;
|
|
|
- border: 1px solid #ccc;
|
|
|
- position: relative;
|
|
|
- background-color: $live-bc;
|
|
|
+
|
|
|
+ #student {
|
|
|
+ width: 100%;
|
|
|
+ height: 468px;
|
|
|
+ border: 1px solid #ccc;
|
|
|
+ position: relative;
|
|
|
+ background-color: $live-bc;
|
|
|
+ }
|
|
|
+
|
|
|
+ > .el-button {
|
|
|
+ position: absolute;
|
|
|
+ bottom: 40px;
|
|
|
+ left: calc(50% - 44px);
|
|
|
+ }
|
|
|
+
|
|
|
+ .student-audio {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ background-color: #646464;
|
|
|
+ display: flex;
|
|
|
+ flex-direction: column;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+
|
|
|
+ .el-avatar {
|
|
|
+ width: 96px;
|
|
|
+ height: 96px;
|
|
|
+ line-height: 96px;
|
|
|
+ margin-bottom: 24px;
|
|
|
+
|
|
|
+ &--icon {
|
|
|
+ font-size: 36px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
#draw-parent {
|
|
@@ -753,7 +782,6 @@ $live-bc: #3d3938;
|
|
|
|
|
|
.live-wrapper {
|
|
|
position: absolute;
|
|
|
- bottom: 0;
|
|
|
height: 40px;
|
|
|
width: 100%;
|
|
|
background-color: #000;
|
|
@@ -761,9 +789,11 @@ $live-bc: #3d3938;
|
|
|
color: #fff;
|
|
|
line-height: 40px;
|
|
|
padding: 0 16px;
|
|
|
+ transition: all 300ms ease-in 0s;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 学员列表
|
|
|
.student-list {
|
|
|
width: 100%;
|
|
|
padding: 24px 16px;
|
|
@@ -782,7 +812,7 @@ $live-bc: #3d3938;
|
|
|
margin-bottom: 16px;
|
|
|
|
|
|
.student-list-left {
|
|
|
- flex: 7;
|
|
|
+ flex: 8;
|
|
|
|
|
|
.name {
|
|
|
vertical-align: super;
|
|
@@ -791,7 +821,7 @@ $live-bc: #3d3938;
|
|
|
}
|
|
|
|
|
|
.student-list-right {
|
|
|
- flex: 3;
|
|
|
+ flex: 2;
|
|
|
|
|
|
.svg-icon {
|
|
|
font-size: 18px;
|