index.vue 30 KB

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