index.vue 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177
  1. <template>
  2. <div class="live">
  3. <!--顶部-->
  4. <div class="live-top">
  5. <div class="live-title">
  6. <div class="live-title-name">{{ roomInfo.cs_item_name }} {{ roomInfo.task_name }}</div>
  7. <div>
  8. <el-button v-if="!liveStat" @click="startLive">开启直播</el-button>
  9. <el-button v-if="liveStat" icon="el-icon-switch-button" @click="closeLiveRoom">
  10. 结束直播
  11. </el-button>
  12. <el-button v-if="liveStat" @click="reconnection">重连</el-button>
  13. <el-button @click="setDevice(true)">设置设备</el-button>
  14. </div>
  15. </div>
  16. <div class="live-course-name">{{ roomInfo.course_name }}</div>
  17. <div class="live-teacher">
  18. <span class="live-teacher-name">
  19. <svg-icon icon-class="person" />{{ roomInfo.teacher_name }}
  20. </span>
  21. <span><svg-icon icon-class="people" />{{ roomInfo.student_count }}</span>
  22. </div>
  23. </div>
  24. <!-- 主容器 -->
  25. <div class="live-container">
  26. <!-- 左侧 -->
  27. <div class="live-container-left">
  28. <div v-show="callLoading" class="loading">
  29. <div class="loading-wrapper">
  30. <el-avatar icon="el-icon-user" :src="connectStudent.student_image_url" />
  31. <p class="loading-title">
  32. 正在呼叫【{{ connectStudent.student_name }}】,等待对方接通...
  33. </p>
  34. <div>
  35. <el-button type="danger" circle @click="handsDown">
  36. <svg-icon icon-class="hang-up" />
  37. </el-button>
  38. </div>
  39. </div>
  40. </div>
  41. <div v-show="connect" class="student-parent">
  42. <div v-show="roomInfo.video_mode === 1 || remoteStreamType === 1" id="student"></div>
  43. <template v-if="remoteStreamType !== 1">
  44. <template v-if="roomInfo.video_mode === 1">
  45. <el-button type="danger" @click="handsDown">
  46. <svg-icon icon-class="hang-up" /> 挂断
  47. </el-button>
  48. </template>
  49. <template v-else>
  50. <div class="student-audio">
  51. <el-avatar icon="el-icon-user" :src="connectStudent.student_image_url" />
  52. <span class="connect-name">{{ connectStudent.student_name }}</span>
  53. <el-button type="danger" circle @click="handsDown">
  54. <svg-icon icon-class="hang-up" />
  55. </el-button>
  56. </div>
  57. </template>
  58. </template>
  59. </div>
  60. <div v-show="isDraw" id="draw-parent">
  61. <!-- 画笔设置 -->
  62. <div v-show="isDrawSetting" class="draw-setting">
  63. <span class="brush-shape" @click="drawChange('type', 2)">
  64. <svg-icon icon-class="brush-shape" />
  65. </span>
  66. <!-- 画笔颜色 -->
  67. <span
  68. v-for="item in drawColorList"
  69. :key="item"
  70. :class="['draw-color', item === curColor ? 'current' : '']"
  71. :style="{ 'background-color': item }"
  72. @click="drawChange('color', item)"
  73. />
  74. <span
  75. v-for="item in drawThicknessList"
  76. :key="item"
  77. class="draw-thickness"
  78. @click="drawChange('thickNess', item)"
  79. >
  80. <span :style="{ width: item * 2 + 'px', height: item * 2 + 'px' }"></span>
  81. </span>
  82. <span class="eraser" @click="drawChange('type', 9)">
  83. <svg-icon icon-class="back" />
  84. </span>
  85. <span class="eraser" @click="drawChange('type', 10)">
  86. <svg-icon icon-class="eraser" />
  87. </span>
  88. <span class="brush-clear" @click="drawChange('type', 0)">
  89. <svg-icon icon-class="clear" />
  90. </span>
  91. </div>
  92. </div>
  93. <div class="button-group">
  94. <div class="button-group-left">
  95. <span class="icon-button" @click="publishShareStream">
  96. <svg-icon icon-class="share" />
  97. </span>
  98. <span class="icon-button" @click="showDrawSetting">
  99. <svg-icon icon-class="draw" />
  100. </span>
  101. <span class="icon-button" @click="startGroup">
  102. <svg-icon icon-class="group" />
  103. </span>
  104. <span class="icon-button" @click="dialogVisible = true">
  105. <svg-icon icon-class="push" />
  106. </span>
  107. </div>
  108. <div class="button-group-right"></div>
  109. </div>
  110. <div class="live-container-left-chat">
  111. <div class="chat-top">
  112. <span>聊天</span>
  113. <label @click="chatBans">
  114. <input v-model="roomData.allow_chat" type="checkbox" class="allow-chat" />
  115. <span>禁言</span>
  116. </label>
  117. </div>
  118. <div class="chat-window">
  119. <ul ref="chat" class="chat-window-ul">
  120. <li v-for="(item, i) in chatList" :key="i">
  121. <div class="msg-normal">
  122. <span>{{ item.username }}: </span>
  123. <span>{{ item.msg }}</span>
  124. </div>
  125. </li>
  126. </ul>
  127. </div>
  128. <div class="chat-speak">
  129. <el-input
  130. v-model="msg"
  131. placeholder="输入发言"
  132. maxlength="400"
  133. @keydown.enter.native="sendMsg"
  134. >
  135. <el-button slot="append" @click="sendMsg">发送</el-button>
  136. </el-input>
  137. </div>
  138. </div>
  139. </div>
  140. <!-- 右侧 -->
  141. <div class="live-container-right">
  142. <div
  143. class="live-teacher-lens"
  144. @mouseover="liveMenuShow = true"
  145. @mouseout="liveMenuShow = false"
  146. >
  147. <div id="live"></div>
  148. <div :style="{ bottom: liveMenuShow ? '0' : '-40px' }" class="live-wrapper">
  149. <div>
  150. {{ roomInfo.teacher_name }}
  151. </div>
  152. <div class="live-wrapper-right">
  153. <svg-icon
  154. :icon-class="hasVideo ? 'camera-on' : 'camera-off'"
  155. @click="playOrPauseVideo"
  156. />
  157. <svg-icon :icon-class="hasAudio ? 'mike-on' : 'mike-off'" @click="playOrPauseAudio" />
  158. <span :style="{ color: netStatusColor }">{{ netStatus }}</span>
  159. </div>
  160. </div>
  161. </div>
  162. <div class="student-list">
  163. <div class="student-list-title">学生列表</div>
  164. <ul>
  165. <li v-for="item in student_list" :key="item.room_user_id">
  166. <div class="student-list-left">
  167. <el-avatar icon="el-icon-user" size="small" :src="item.student_image_url" />
  168. <span class="name">{{ item.student_name }}</span>
  169. </div>
  170. <div class="student-list-right">
  171. <svg-icon
  172. v-if="item.connection_mode === 1 && item.connection_status !== 0"
  173. icon-class="hang-up"
  174. @click="handsDown(item.room_user_id)"
  175. />
  176. <svg-icon v-else icon-class="video" @click="invite(item, 1)" />
  177. <svg-icon
  178. v-if="item.connection_mode === 2 && item.connection_status !== 0"
  179. icon-class="hang-up"
  180. @click="handsDown(item.room_user_id)"
  181. />
  182. <svg-icon v-else icon-class="voice" @click="invite(item, 2)" />
  183. </div>
  184. </li>
  185. </ul>
  186. </div>
  187. </div>
  188. </div>
  189. <!-- 推送资料 -->
  190. <select-material
  191. :dialog-visible="dialogVisible"
  192. :task-id="task_id"
  193. @dialogClose="dialogClose"
  194. @dialogPush="dialogPush"
  195. />
  196. <!-- 教师查看当前完成列表 -->
  197. <complete-list
  198. :task-id="task_id"
  199. :dialog-visible-complete="dialogVisibleComplete"
  200. @dialogCompleteClose="dialogCompleteClose"
  201. />
  202. <select-device
  203. :dialog-visible-device="dialogVisibleDevice"
  204. :device="device"
  205. @dialogDeviceClose="dialogDeviceClose"
  206. />
  207. <el-dialog
  208. title="分组讨论组数"
  209. top="30vh"
  210. width="300px"
  211. class="dialog-group"
  212. :visible.sync="dialogVisibleGroup"
  213. :close-on-click-modal="false"
  214. >
  215. <el-select v-model="group_count">
  216. <el-option v-for="i in groupNumList" :key="i" :label="i" :value="i" />
  217. </el-select>
  218. <span slot="footer">
  219. <el-button size="small" @click="closeGroup">取 消</el-button>
  220. <el-button size="small" type="primary" @click="dialogGroup">确 定</el-button>
  221. </span>
  222. </el-dialog>
  223. </div>
  224. </template>
  225. <script>
  226. import {
  227. GetLiveRoomStudentList,
  228. CloseLiveRoom,
  229. GetLiveRoomInfo,
  230. StudentExitLiveRoom,
  231. StartGroup,
  232. GetGroupStatus,
  233. DealStudentConnection,
  234. GetStudentInfo_Connection
  235. } from '@/api/live';
  236. import { app } from '@/store/mutation-types';
  237. import SelectMaterial from '@/components/live/SelectMaterial.vue';
  238. import CompleteList from './CompleteList.vue';
  239. import SelectDevice from '../SelectDevice.vue';
  240. import * as common from './live';
  241. export default {
  242. components: {
  243. SelectMaterial,
  244. CompleteList,
  245. SelectDevice
  246. },
  247. data() {
  248. return {
  249. task_id: this.$route.query.task_id,
  250. // 连麦
  251. connect: false,
  252. // 连线学员信息
  253. connectStudent: {},
  254. // 等待接通
  255. callLoading: false,
  256. dialogVisible: false,
  257. // 学员完成
  258. dialogVisibleComplete: false,
  259. // 定时器
  260. timer: null,
  261. remoteStreamType: -1,
  262. rtc: null,
  263. roomData: {
  264. desc: '直播间标题',
  265. name: '姓名',
  266. user: {
  267. id: '',
  268. name: '',
  269. role: 'talker',
  270. rommid: ''
  271. },
  272. max_users: 1,
  273. allow_chat: true,
  274. allow_audio: true,
  275. allow_speak: true
  276. },
  277. roomInfo: {
  278. room_id: '',
  279. video_mode: 1,
  280. task_name: '',
  281. cs_item_name: '',
  282. course_name: '',
  283. teacher_name: '',
  284. student_count: 0,
  285. student_connection_info: {}
  286. },
  287. loadedNumber: 0,
  288. speakData: {},
  289. roomContext: {},
  290. msg: '',
  291. chatList: [],
  292. isDrawSetting: false,
  293. curColor: '#343434',
  294. drawColorList: ['#FF4747', '#343434', '#628EFF', '#FFCA0E'],
  295. drawThicknessList: ['1', '3', '5'],
  296. // 直播间学员列表
  297. student_list: [],
  298. // 直播状态
  299. liveStat: false,
  300. liveMenuShow: false,
  301. // 分组讨论
  302. groupNumList: [],
  303. group_count: 1,
  304. // 网络整体情况
  305. netStatus: 0,
  306. dialogVisibleGroup: false,
  307. dialogVisibleDevice: false,
  308. isRecreate: false,
  309. device: {
  310. video: [],
  311. audio: []
  312. },
  313. // 本地视频流画面、声音
  314. hasVideo: false,
  315. hasAudio: false
  316. };
  317. },
  318. computed: {
  319. // 画板模式
  320. isDraw() {
  321. return !this.connect && !this.callLoading;
  322. },
  323. netStatusColor() {
  324. if (this.netStatus >= 1000) {
  325. return '#f00';
  326. }
  327. if (this.netStatus >= 500) {
  328. return '#d6e91a';
  329. }
  330. if (this.netStatus >= 200) {
  331. return '#6aee4c';
  332. }
  333. return '#38d514';
  334. },
  335. connectUid() {
  336. return 'room_user_id' in this.connectStudent ? this.connectStudent.room_user_id : '';
  337. }
  338. },
  339. watch: {
  340. loadedNumber(newVal) {
  341. if (newVal === 5) {
  342. common.createScript(
  343. 'https://class.csslcloud.net/static/SDK/docSDK/drawSdk_3.0.js'
  344. ).onload = () => {
  345. this.initSDK();
  346. this.$loading().close();
  347. };
  348. }
  349. },
  350. // 聊天列表滚动
  351. chatList() {
  352. common.chatRoll(this);
  353. }
  354. },
  355. created() {
  356. GetGroupStatus({ task_id: this.task_id }).then(({ is_enable_group }) => {
  357. if (is_enable_group === 'true') {
  358. this.$router.push({
  359. path: '/live/teacher/group',
  360. query: {
  361. task_id: this.task_id
  362. }
  363. });
  364. } else {
  365. this.$loading({
  366. text: '加载直播所需SDK中...',
  367. background: '#fff'
  368. });
  369. common.downloadWebSDK(this);
  370. this.getLiveRoomStudentList();
  371. this.getLiveRoomInfo();
  372. }
  373. });
  374. },
  375. mounted() {
  376. document.addEventListener(
  377. 'click',
  378. e => {
  379. let target = e.target;
  380. let isHasClass = false;
  381. do {
  382. if (target === null) {
  383. break;
  384. }
  385. if (target.className === 'draw-setting') {
  386. isHasClass = true;
  387. }
  388. target = target.parentElement;
  389. } while (!isHasClass);
  390. if (!isHasClass) {
  391. this.isDrawSetting = false;
  392. }
  393. },
  394. true
  395. );
  396. this.getLiveRoomStudentListPolling();
  397. },
  398. beforeDestroy() {
  399. clearInterval(this.timer);
  400. common.closeVideo('main');
  401. },
  402. methods: {
  403. initSDK() {
  404. const { live_room_sys_user_id, room_id, session_id } = this.$route.query;
  405. this.rtc = common.initSDK({
  406. userid: live_room_sys_user_id,
  407. roomid: room_id,
  408. sessionid: session_id
  409. });
  410. common.initListener(this); // 注册监听事件
  411. this.getLiveStat();
  412. },
  413. getLiveRoomInfo() {
  414. GetLiveRoomInfo({ task_id: this.task_id }).then(
  415. ({
  416. room_id,
  417. video_mode,
  418. task_name,
  419. cs_item_name,
  420. course_name,
  421. teacher_name,
  422. student_count,
  423. student_connection_info
  424. }) => {
  425. this.roomInfo = {
  426. room_id,
  427. video_mode,
  428. task_name,
  429. cs_item_name,
  430. course_name,
  431. teacher_name,
  432. student_count,
  433. student_connection_info
  434. };
  435. this.connectStudent = student_connection_info;
  436. if (student_connection_info.connection_status === 1) {
  437. this.callLoading = true;
  438. }
  439. if (student_connection_info.connection_status === 2) {
  440. this.connect = true;
  441. }
  442. }
  443. );
  444. },
  445. closeLiveRoom() {
  446. CloseLiveRoom({ task_id: this.task_id }).then(() => {
  447. this.$router.push('/');
  448. this.$message.success('关闭直播成功');
  449. });
  450. },
  451. startLive() {
  452. common.startLive();
  453. },
  454. getLiveStat() {
  455. common.getLiveStat({
  456. success: data => {
  457. this.liveStat = data.started;
  458. },
  459. fail: str => {
  460. this.liveStat = false;
  461. console.log('直播关闭状态或查询直播失败', str);
  462. }
  463. });
  464. },
  465. // 推送桌面共享
  466. publishShareStream() {
  467. common.publishShareStream();
  468. },
  469. // 关闭桌面共享
  470. unPubShareStream() {
  471. common.unPubShareStream();
  472. },
  473. reconnection() {
  474. common.reconnection();
  475. },
  476. // 老师邀请学生上麦
  477. invite(student, mode) {
  478. if (this.connect || this.callLoading) {
  479. this.$message.warning('正在连麦中');
  480. return;
  481. }
  482. this.callLoading = true;
  483. this.connectStudent = student;
  484. GetLiveRoomInfo({ task_id: this.task_id })
  485. .then(({ video_mode }) => {
  486. let uid = student.room_user_id;
  487. this.roomInfo.video_mode = mode;
  488. if (video_mode === mode) {
  489. this.inviteStudent(uid, student, mode);
  490. } else {
  491. common.roomUpdate({
  492. video_mode: mode,
  493. roomUpdateSuccess: data => {
  494. console.log(data, '连麦音视频模式更新请求成功!');
  495. this.inviteStudent(uid, student, mode);
  496. },
  497. roomUpdateFailed: data => {
  498. this.callLoading = false;
  499. this.$message.error('连麦音视频模式更新请求失败! 请稍后再试!');
  500. }
  501. });
  502. }
  503. })
  504. .catch(() => {
  505. this.callLoading = false;
  506. });
  507. },
  508. inviteStudent(uid, connectStudent, mode) {
  509. common.invite({
  510. uid,
  511. success: str => {
  512. console.log('邀请上麦成功', str);
  513. this.dealStudentConnection(uid, 1, mode);
  514. common.sendPublishMessage({
  515. type: 'inviteImage',
  516. connectStudent
  517. });
  518. },
  519. fail: data => {
  520. console.log('邀请上麦失败:', data);
  521. this.callLoading = false;
  522. this.$message.error(`邀请上麦失败:${data.errorMsg}`);
  523. }
  524. });
  525. },
  526. dealStudentConnection(room_user_id, deal_mode, connection_mode) {
  527. DealStudentConnection({
  528. task_id: this.task_id,
  529. room_user_id,
  530. deal_mode,
  531. connection_mode
  532. }).then(() => {
  533. this.getLiveRoomStudentList();
  534. });
  535. },
  536. handsDown(uid) {
  537. let connectUid = typeof uid === 'string' ? uid : this.connectUid;
  538. if (connectUid.length === 0) {
  539. GetStudentInfo_Connection({ task_id: this.task_id }).then(({ room_user_id }) =>
  540. this.handsDown_Live(room_user_id)
  541. );
  542. } else {
  543. this.handsDown_Live(connectUid);
  544. }
  545. },
  546. // 下麦
  547. handsDown_Live(uid) {
  548. common.handsDown({
  549. uid,
  550. success: str => {
  551. if (this.callLoading) {
  552. common.sendPublishMessage({
  553. type: 'handsDown-load',
  554. uid
  555. });
  556. }
  557. this.dealStudentConnection(uid, 0, this.connectStudent.connection_mode);
  558. this.callLoading = false;
  559. this.connect = false;
  560. common.updateMcResult('', 0);
  561. this.$message.success('下麦成功');
  562. this.connectStudent = {};
  563. },
  564. fail: data => {
  565. this.callLoading = false;
  566. this.connect = false;
  567. console.log('下麦失败', data);
  568. this.$message.warning(`下麦失败:${data.errorMsg}`);
  569. }
  570. });
  571. },
  572. // 本地流视频开启、关闭
  573. playOrPauseVideo() {
  574. if (this.device.video.length === 0) {
  575. return this.$message.warning('无视频设备');
  576. }
  577. if (this.hasVideo) {
  578. common.pauseVideo({
  579. streamName: 'main',
  580. success: () => {
  581. this.$message.success('关闭本地流视频画面成功');
  582. this.hasVideo = false;
  583. },
  584. fail: str => {
  585. this.$message.warning(str);
  586. }
  587. });
  588. } else {
  589. common.playVideo({
  590. streamName: 'main',
  591. success: () => {
  592. this.$message.success('开启本地流视频画面成功');
  593. this.hasVideo = true;
  594. },
  595. fail: str => {
  596. this.$message.warning(str);
  597. }
  598. });
  599. }
  600. },
  601. // 本地流音频开启、关闭
  602. playOrPauseAudio() {
  603. if (this.device.audio.length === 0) {
  604. return this.$message.warning('无音频设备');
  605. }
  606. if (this.hasAudio) {
  607. common.pauseAudio({
  608. streamName: 'main',
  609. success: () => {
  610. this.$message.success('关闭本地流声音成功');
  611. this.hasAudio = false;
  612. },
  613. fail: str => {
  614. this.$message.warning(str);
  615. }
  616. });
  617. } else {
  618. common.playAudio({
  619. streamName: 'main',
  620. success: () => {
  621. this.$message.success('开启本地流声音成功');
  622. this.hasAudio = true;
  623. },
  624. fail: str => {
  625. this.$message.warning(str);
  626. }
  627. });
  628. }
  629. },
  630. // 发消息
  631. sendMsg() {
  632. common.sendMsg(this.msg);
  633. this.msg = '';
  634. },
  635. chatBans() {
  636. common.roomUpdate({
  637. allow_chat: !this.roomData.allow_chat,
  638. roomUpdateSuccess(data) {
  639. console.log(data, '房间模板配置更新请求成功!');
  640. },
  641. roomUpdateFailed(data) {
  642. console.log(data, '房间模板配置更新请求失败! 请稍后再试!');
  643. }
  644. });
  645. },
  646. // 画笔变更
  647. drawChange(action, value) {
  648. if (action === 'color') {
  649. common.drawChange(action, parseInt(Number(value.replace('#', '0x')), 10));
  650. this.curColor = value;
  651. } else {
  652. common.drawChange(action, value);
  653. }
  654. this.isDrawSetting = false;
  655. },
  656. // 设置音视频设备
  657. setDevice(isRecreate) {
  658. this.isRecreate = isRecreate;
  659. this.dialogVisibleDevice = true;
  660. },
  661. getNetPoint() {
  662. common.getNetPoint();
  663. },
  664. dialogDeviceClose(device) {
  665. this.$store.commit(`app/${app.SET_DEVICE}`, device);
  666. this.dialogVisibleDevice = false;
  667. if (this.isRecreate) {
  668. common.closeVideoTeacher({
  669. streamName: 'main',
  670. success: () => {
  671. common.createLocalStream(this);
  672. },
  673. fail: str => {
  674. console.log(str);
  675. }
  676. });
  677. } else {
  678. common.createLocalStream(this);
  679. }
  680. },
  681. showDrawSetting() {
  682. this.isDrawSetting = !this.isDrawSetting;
  683. },
  684. getLiveRoomStudentList() {
  685. GetLiveRoomStudentList({ task_id: this.task_id }).then(({ student_list }) => {
  686. this.student_list = student_list;
  687. });
  688. },
  689. getLiveRoomStudentListPolling() {
  690. this.timer = setInterval(() => {
  691. this.getLiveRoomStudentList();
  692. }, 5000);
  693. },
  694. studentExitLiveRoom(room_user_id) {
  695. StudentExitLiveRoom({ task_id: this.task_id, room_user_id });
  696. },
  697. publishStream() {
  698. common.publishStream('main');
  699. },
  700. // 分组讨论
  701. startGroup() {
  702. for (let i = 1; i <= this.student_list.length; i++) {
  703. this.groupNumList.push(i);
  704. }
  705. this.dialogVisibleGroup = true;
  706. },
  707. // 弹出框方法
  708. dialogGroup() {
  709. // 开始分组讨论
  710. StartGroup({ task_id: this.task_id, group_count: this.group_count }).then(() => {
  711. this.$message.success('开启分组讨论成功');
  712. this.$router.push({
  713. path: '/live/teacher/group',
  714. query: {
  715. task_id: this.task_id
  716. }
  717. });
  718. });
  719. },
  720. closeGroup() {
  721. this.dialogVisibleGroup = false;
  722. this.groupNumList = [];
  723. this.group_count = 1;
  724. },
  725. dialogClose() {
  726. this.dialogVisible = false;
  727. },
  728. dialogPush() {
  729. this.dialogVisible = false;
  730. this.dialogVisibleComplete = true;
  731. },
  732. dialogCompleteClose() {
  733. this.dialogVisibleComplete = false;
  734. }
  735. }
  736. };
  737. </script>
  738. <style lang="scss">
  739. @import '~@/styles/mixin.scss';
  740. $live-bc: #3d3938;
  741. .live {
  742. @include container;
  743. @include dialog;
  744. .dialog-group .el-dialog__body {
  745. height: 65px;
  746. }
  747. // 顶部
  748. &-top {
  749. background-color: #fff;
  750. padding: 24px 32px;
  751. border-top-left-radius: 8px;
  752. border-top-right-radius: 8px;
  753. .live-title {
  754. display: flex;
  755. justify-content: space-between;
  756. &-name {
  757. font-size: 22px;
  758. }
  759. .el-button {
  760. border-radius: 4px;
  761. padding: 7px 12px;
  762. }
  763. }
  764. .live-course-name {
  765. font-size: 14px;
  766. color: #737373;
  767. line-height: 30px;
  768. }
  769. .live-teacher {
  770. margin-top: 12px;
  771. .svg-icon {
  772. margin-right: 8px;
  773. }
  774. &-name {
  775. margin-right: 60px;
  776. }
  777. }
  778. }
  779. // 主容器
  780. &-container {
  781. display: flex;
  782. justify-content: left;
  783. &-left {
  784. width: 832px;
  785. background-color: #fff;
  786. border-radius: 8px;
  787. .loading {
  788. position: relative;
  789. width: 100%;
  790. height: 468px;
  791. color: #fff;
  792. background-color: #646464;
  793. display: flex;
  794. justify-content: center;
  795. align-items: center;
  796. &-wrapper {
  797. text-align: center;
  798. > .el-avatar {
  799. width: 96px;
  800. height: 96px;
  801. line-height: 96px;
  802. margin-bottom: 24px;
  803. > &--icon {
  804. font-size: 36px;
  805. }
  806. }
  807. .loading-title {
  808. margin-bottom: 24px;
  809. }
  810. }
  811. }
  812. .student-parent {
  813. position: relative;
  814. width: 100%;
  815. height: 468px;
  816. #student {
  817. width: 100%;
  818. height: 468px;
  819. position: relative;
  820. background-color: $live-bc;
  821. }
  822. > .el-button {
  823. position: absolute;
  824. bottom: 40px;
  825. left: calc(50% - 44px);
  826. }
  827. .student-audio {
  828. width: 100%;
  829. height: 100%;
  830. background-color: #646464;
  831. display: flex;
  832. flex-direction: column;
  833. justify-content: center;
  834. align-items: center;
  835. .connect-name {
  836. color: #fff;
  837. margin: 24px 0;
  838. }
  839. > .el-avatar {
  840. width: 96px;
  841. height: 96px;
  842. line-height: 96px;
  843. > &--icon {
  844. font-size: 36px;
  845. }
  846. }
  847. }
  848. }
  849. #draw-parent {
  850. width: 100%;
  851. height: 468px;
  852. position: relative;
  853. background-color: $live-bc;
  854. overflow: hidden;
  855. // 设置屏幕画笔
  856. .draw-setting {
  857. position: absolute;
  858. bottom: 13px;
  859. left: 22px;
  860. z-index: 9999;
  861. background-color: #a0a0a0;
  862. padding: 6px;
  863. border-radius: 40px;
  864. height: 40px;
  865. line-height: 28px;
  866. & > span {
  867. display: inline-block;
  868. text-align: center;
  869. margin-right: 10px;
  870. }
  871. & > span.brush-shape {
  872. width: 28px;
  873. height: 28px;
  874. border-radius: 50%;
  875. background-color: #fff;
  876. cursor: pointer;
  877. }
  878. .draw-color {
  879. position: relative;
  880. top: 5px;
  881. height: 18px;
  882. width: 18px;
  883. border-radius: 50%;
  884. cursor: pointer;
  885. }
  886. .current::after {
  887. content: '';
  888. position: absolute;
  889. bottom: -7px;
  890. left: 7px;
  891. width: 4px;
  892. height: 4px;
  893. border-radius: 50%;
  894. background-color: #292929;
  895. }
  896. .draw-thickness {
  897. height: 18px;
  898. width: 18px;
  899. cursor: pointer;
  900. display: inline-flex;
  901. flex-direction: column;
  902. justify-content: center;
  903. vertical-align: middle;
  904. align-items: center;
  905. span {
  906. border-radius: 50%;
  907. background-color: #000;
  908. }
  909. }
  910. & > .brush-clear {
  911. width: 28px;
  912. height: 28px;
  913. border-radius: 50%;
  914. background-color: #666;
  915. cursor: pointer;
  916. margin-right: 0;
  917. }
  918. & > .eraser {
  919. @extend .brush-clear;
  920. margin-right: 12px;
  921. }
  922. }
  923. }
  924. .button-group {
  925. display: flex;
  926. justify-content: space-between;
  927. height: 48px;
  928. background-color: #4d4d4d;
  929. padding: 0 15px;
  930. border-bottom-left-radius: 5px;
  931. .svg-icon {
  932. font-size: 20px;
  933. }
  934. &-left {
  935. .stop-group {
  936. color: #fff;
  937. }
  938. > .icon-button {
  939. display: inline-block;
  940. height: 100%;
  941. padding: 14px 16px;
  942. cursor: pointer;
  943. &:active,
  944. &:hover {
  945. background-color: #3d3d3d;
  946. }
  947. }
  948. }
  949. }
  950. // 聊天窗口
  951. &-chat {
  952. height: 278px;
  953. border: 1px solid #ccc;
  954. border-bottom-left-radius: 8px;
  955. display: flex;
  956. flex-direction: column;
  957. justify-content: space-between;
  958. .chat-top {
  959. display: flex;
  960. justify-content: space-between;
  961. padding: 15px 15px 10px;
  962. border-bottom: 1px solid #e6e6e6;
  963. color: #959595;
  964. label {
  965. cursor: pointer;
  966. }
  967. .allow-chat {
  968. margin-right: 12px;
  969. }
  970. }
  971. .chat-window {
  972. position: relative;
  973. width: 100%;
  974. height: 100%;
  975. overflow: hidden;
  976. &-ul {
  977. position: absolute;
  978. top: 0;
  979. left: 0;
  980. width: 100%;
  981. height: 100%;
  982. overflow: auto;
  983. .msg-normal {
  984. padding: 7px 16px;
  985. }
  986. }
  987. }
  988. .chat-speak {
  989. padding: 16px;
  990. }
  991. }
  992. }
  993. &-right {
  994. height: 794px;
  995. padding: 8px;
  996. background-color: #2c2c2c;
  997. border-end-end-radius: 8px;
  998. .live-teacher-lens {
  999. position: relative;
  1000. overflow: hidden;
  1001. #live {
  1002. width: 352px;
  1003. height: 198px;
  1004. background-color: $live-bc;
  1005. }
  1006. .live-wrapper {
  1007. display: flex;
  1008. position: absolute;
  1009. height: 40px;
  1010. width: 100%;
  1011. background-color: #000;
  1012. opacity: 0.7;
  1013. color: #fff;
  1014. line-height: 40px;
  1015. padding: 0 16px;
  1016. transition: all 300ms ease-in 0s;
  1017. > div:first-child {
  1018. flex: 6;
  1019. }
  1020. &-right {
  1021. flex: 4;
  1022. text-align: right;
  1023. .svg-icon {
  1024. cursor: pointer;
  1025. margin-right: 18px;
  1026. }
  1027. }
  1028. }
  1029. }
  1030. // 学员列表
  1031. .student-list {
  1032. width: 100%;
  1033. padding: 24px 16px;
  1034. margin-top: 2px;
  1035. height: calc(100% - 200px);
  1036. background-color: #2c2c2c;
  1037. font-size: 14px;
  1038. color: #fff;
  1039. &-title {
  1040. margin-bottom: 16px;
  1041. }
  1042. ul {
  1043. height: calc(100% - 18px);
  1044. overflow: auto;
  1045. }
  1046. li {
  1047. display: flex;
  1048. margin-bottom: 16px;
  1049. .student-list-left {
  1050. flex: 8;
  1051. .name {
  1052. vertical-align: super;
  1053. margin-left: 8px;
  1054. }
  1055. }
  1056. .student-list-right {
  1057. flex: 2;
  1058. .svg-icon {
  1059. font-size: 18px;
  1060. cursor: pointer;
  1061. margin-top: 7px;
  1062. margin-right: 8px;
  1063. }
  1064. }
  1065. }
  1066. }
  1067. }
  1068. }
  1069. }
  1070. </style>