audit.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694
  1. <template>
  2. <div class="group">
  3. <!--顶部-->
  4. <div class="group-top">
  5. <div class="live-title">
  6. <div class="live-title-name">
  7. {{ roomInfo.cs_item_name }} {{ roomInfo.task_name }}
  8. </div>
  9. <div>
  10. <el-button @click="exitRoom">
  11. 退出房间
  12. </el-button>
  13. </div>
  14. </div>
  15. <div class="live-course-name">
  16. {{ roomInfo.course_name }}
  17. </div>
  18. <div class="live-teacher">
  19. <span class="live-teacher-name"> <svg-icon icon-class="person" />{{ roomInfo.teacher_name }} </span>
  20. <span><svg-icon icon-class="people" />{{ roomInfo.student_count }}</span>
  21. </div>
  22. </div>
  23. <!-- 主容器 -->
  24. <div class="group-container">
  25. <!-- 左侧 -->
  26. <div class="group-container-left">
  27. <div class="group-discussion">
  28. <!-- 有流列表 -->
  29. <div v-for="(item, i) in streamList" :key="item.id()" class="group-wrapper">
  30. <div :id="`group-${i}`" class="group-box" />
  31. <div class="live-wrapper-stream">
  32. {{ searchStudentName(item.id()) }}
  33. <svg-icon :icon-class="item.hasAudio() ? 'mike-on-grey' : ''" />
  34. <svg-icon v-if="isMobile(item.id())" icon-class="mobile" />
  35. </div>
  36. </div>
  37. <!-- 无流列表 -->
  38. <div v-for="item in noStreamList" :key="item.student_id" class="group-box student-info">
  39. <el-avatar icon="el-icon-user" :src="item.student_image_url" :size="80" />
  40. <span class="student_name">{{ item.student_name }}</span>
  41. </div>
  42. </div>
  43. <div class="audit-list">
  44. <svg-icon icon-class="arrow-left-white" @click="listMove('left')" />
  45. <div ref="avatar" class="audit-list-container">
  46. <div ref="list" class="avatar-list" :style="{ 'margin-left': marginLeft + 'px' }">
  47. <el-avatar
  48. v-for="item in audience_list"
  49. :key="item.student_id"
  50. :size="32"
  51. :src="item.student_image_url"
  52. />
  53. </div>
  54. </div>
  55. <svg-icon icon-class="arrow-right-white" @click="listMove('right')" />
  56. </div>
  57. <div class="button-group">
  58. <div class="button-group-left" />
  59. <div class="button-group-right" />
  60. </div>
  61. <div class="group-container-left-chat">
  62. <div class="chat-top">
  63. <span>聊天</span>
  64. </div>
  65. <div class="chat-window">
  66. <ul ref="chat" class="chat-window-ul">
  67. <li v-for="(item, i) in chatList" :key="i">
  68. <div class="msg-normal">
  69. <span>{{ item.username }}: </span>
  70. <span>{{ item.msg }}</span>
  71. </div>
  72. </li>
  73. </ul>
  74. </div>
  75. <div class="chat-speak">
  76. <el-input v-model="msg" placeholder="输入发言" maxlength="400" disabled @keydown.enter.native="sendMsg">
  77. <el-button slot="append" disabled @click="sendMsg">
  78. 发送
  79. </el-button>
  80. </el-input>
  81. </div>
  82. </div>
  83. </div>
  84. <!-- 右侧 -->
  85. <div class="group-container-right">
  86. <div class="live-teacher-lens" @mouseover="liveMenuShow = true" @mouseout="liveMenuShow = false">
  87. <div class="live-container">
  88. <div v-show="is_teacher_in_group" id="live" />
  89. <el-image v-show="!is_teacher_in_group" :src="roomInfo.teacher_image_url" fit="contain" />
  90. </div>
  91. <div :style="{ bottom: liveMenuShow ? '0' : '-40px' }" class="live-wrapper">
  92. <div>
  93. {{ roomInfo.teacher_name }}
  94. </div>
  95. <div />
  96. </div>
  97. </div>
  98. <div class="student-list">
  99. <div class="student-list-title">
  100. 小组成员
  101. </div>
  102. <ul>
  103. <li v-for="item in student_list" :key="item.room_user_id">
  104. <div class="student-list-left">
  105. <el-avatar icon="el-icon-user" size="small" :src="item.student_image_url" />
  106. <span class="name">{{ item.student_name }}</span>
  107. </div>
  108. </li>
  109. </ul>
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. </template>
  115. <script>
  116. import {
  117. StudentExitLiveRoom,
  118. GetLiveRoomInfo,
  119. GetGroupStatus,
  120. GetMyGroupInfo_Student,
  121. CreateEnterLiveRoomSession
  122. } from '@/api/live';
  123. import * as common from './audit';
  124. export default {
  125. data() {
  126. return {
  127. task_id: this.$route.query.task_id,
  128. room_user_id: '',
  129. session_id: '',
  130. live_room_sys_user_id: '',
  131. room_id: '',
  132. hasVideo: false,
  133. hasAudio: false,
  134. // 定时器
  135. timer: null,
  136. rtc: null,
  137. streamList: [],
  138. roomData: {
  139. desc: '直播间标题',
  140. name: '姓名',
  141. user: {
  142. id: '',
  143. name: '',
  144. role: 'talker',
  145. rommid: ''
  146. },
  147. max_users: 1,
  148. allow_chat: true,
  149. allow_audio: true,
  150. allow_speak: true
  151. },
  152. roomInfo: {
  153. room_id: '',
  154. video_mode: 1,
  155. task_name: '',
  156. cs_item_name: '',
  157. course_name: '',
  158. teacher_name: '',
  159. student_count: 0,
  160. teacher_image_url: ''
  161. },
  162. loadedNumber: 0,
  163. speakData: {},
  164. roomContext: {},
  165. msg: '',
  166. chatList: [],
  167. // 直播间学员列表
  168. student_list: [],
  169. // 直播状态
  170. liveStat: false,
  171. liveMenuShow: false,
  172. is_teacher_in_group: false,
  173. // 无远程流学员列表
  174. noStreamList: [],
  175. // 旁听学员列表
  176. audience_list: [],
  177. marginLeft: 0
  178. };
  179. },
  180. watch: {
  181. loadedNumber(newVal) {
  182. if (newVal === 5) {
  183. common.createScript('https://class.csslcloud.net/static/SDK/docSDK/drawSdk_3.0.js').onload = () => {
  184. this.rtc = common.initSDK({
  185. userid: this.live_room_sys_user_id,
  186. roomid: this.room_id,
  187. sessionid: this.session_id
  188. });
  189. common.initListener(this); // 注册监听事件
  190. this.getLiveStat();
  191. this.$loading().close();
  192. };
  193. }
  194. },
  195. streamList(newVal) {
  196. let list = this.student_list.filter(item => {
  197. if (item.is_self === 'false') {
  198. let isNoStream = true;
  199. for (let i = 0; i < newVal.length; i++) {
  200. if (newVal[i].id().split('-')[0] === item.room_user_id) isNoStream = false;
  201. }
  202. return isNoStream;
  203. }
  204. return false;
  205. });
  206. this.noStreamList = list;
  207. if (newVal.length > 0) {
  208. this.$nextTick(() => {
  209. newVal[newVal.length - 1].show(`group-${newVal.length - 1}`);
  210. });
  211. }
  212. },
  213. // 聊天列表滚动
  214. chatList() {
  215. common.chatRoll(this);
  216. }
  217. },
  218. created() {
  219. this.getLiveRoomInfo();
  220. this.getMyGroupInfo_Student();
  221. },
  222. mounted() {
  223. this.getGroupStatus();
  224. },
  225. beforeDestroy() {
  226. clearInterval(this.timer);
  227. StudentExitLiveRoom({ task_id: this.task_id, room_user_id: this.room_user_id });
  228. common.handsDown({
  229. uid: this.room_user_id,
  230. success: str => {
  231. console.log('下麦成功', str);
  232. },
  233. fail: data => {
  234. console.log('下麦失败', data);
  235. common.closeVideo('picture');
  236. }
  237. });
  238. this.streamList.forEach(item => {
  239. common.unSubscribeStream(item);
  240. });
  241. },
  242. methods: {
  243. getLiveRoomInfo() {
  244. GetLiveRoomInfo({ task_id: this.task_id }).then(
  245. ({
  246. room_id,
  247. video_mode,
  248. task_name,
  249. cs_item_name,
  250. course_name,
  251. teacher_name,
  252. student_count,
  253. teacher_image_url
  254. }) => {
  255. this.roomInfo = {
  256. room_id,
  257. video_mode,
  258. task_name,
  259. cs_item_name,
  260. course_name,
  261. teacher_name,
  262. student_count,
  263. teacher_image_url
  264. };
  265. }
  266. );
  267. },
  268. exitRoom() {
  269. StudentExitLiveRoom({ task_id: this.task_id, room_user_id: this.room_user_id }).then(() => {
  270. this.$router.push('/');
  271. });
  272. },
  273. getLiveStat() {
  274. common.getLiveStat({
  275. success: data => {
  276. this.liveStat = data.started;
  277. },
  278. fail: str => {
  279. this.liveStat = false;
  280. console.log('直播关闭状态或查询直播失败', str);
  281. }
  282. });
  283. },
  284. // 发消息
  285. sendMsg() {
  286. common.sendMsg(this.msg);
  287. this.msg = '';
  288. },
  289. // 分组讨论
  290. getGroupStatus() {
  291. this.timer = setInterval(() => {
  292. GetGroupStatus({ task_id: this.task_id }).then(
  293. ({ is_enable_group, is_has_group_message, group_message_text }) => {
  294. if (is_enable_group === 'false') {
  295. clearInterval(this.timer);
  296. CreateEnterLiveRoomSession({
  297. task_id: this.task_id
  298. }).then(({ live_room_sys_user_id, room_id, session_id, room_user_id }) => {
  299. this.$router.push({
  300. path: `/live/student`,
  301. query: {
  302. live_room_sys_user_id,
  303. room_id,
  304. session_id,
  305. task_id: this.task_id,
  306. room_user_id
  307. }
  308. });
  309. });
  310. }
  311. if (is_has_group_message === 'true') {
  312. this.$alert(group_message_text, '群消息', {
  313. confirmButtonText: '确认'
  314. });
  315. }
  316. }
  317. );
  318. }, 5000);
  319. },
  320. searchStudentName(id) {
  321. let uid = id.split('-')[0];
  322. if (uid) {
  323. let student = this.student_list.find(item => item.room_user_id === uid);
  324. return student ? student.student_name : '';
  325. }
  326. return '';
  327. },
  328. isMobile(id) {
  329. let uid = id.split('-')[0];
  330. if (uid) {
  331. let student = this.student_list.find(item => item.room_user_id === uid);
  332. return student ? student.is_mobile === 'true' : false;
  333. }
  334. return false;
  335. },
  336. listMove(direction) {
  337. let w = this.$refs.list.clientWidth - this.$refs.avatar.clientWidth;
  338. if (w > 60) {
  339. let left = Number(this.$refs.list.style['margin-left'].slice(0, -2));
  340. let width = direction === 'right' ? left - 60 : left + 60;
  341. if (Math.abs(width) > w) width = -w;
  342. this.marginLeft = width > 0 ? 0 : width;
  343. }
  344. },
  345. getMyGroupInfo_Student() {
  346. GetMyGroupInfo_Student({
  347. task_id: this.task_id
  348. }).then(({ live_room_sys_user_id, room_id, student_list, audience_list }) => {
  349. console.log(audience_list);
  350. let data = audience_list.find(el => el.is_self === 'true');
  351. this.session_id = data.session_id;
  352. this.room_user_id = data.room_user_id;
  353. this.live_room_sys_user_id = live_room_sys_user_id;
  354. this.room_id = room_id;
  355. this.student_list = student_list;
  356. this.noStreamList = student_list.filter(item => item.is_self === 'false');
  357. this.audience_list = audience_list;
  358. common.downloadWebSDK(this);
  359. });
  360. }
  361. }
  362. };
  363. </script>
  364. <style lang="scss" scoped>
  365. @import '~@/styles/mixin';
  366. $live-bc: #3d3938;
  367. .group {
  368. @include container;
  369. // 顶部
  370. &-top {
  371. padding: 24px 32px;
  372. background-color: #fff;
  373. border-top-left-radius: 8px;
  374. border-top-right-radius: 8px;
  375. .live-title {
  376. display: flex;
  377. justify-content: space-between;
  378. &-name {
  379. font-size: 22px;
  380. }
  381. .el-button {
  382. padding: 7px 12px;
  383. border-radius: 4px;
  384. }
  385. }
  386. .live-course-name {
  387. font-size: 14px;
  388. line-height: 30px;
  389. color: #737373;
  390. }
  391. .live-teacher {
  392. margin-top: 12px;
  393. .svg-icon {
  394. margin-right: 8px;
  395. }
  396. &-name {
  397. margin-right: 60px;
  398. }
  399. }
  400. }
  401. // 主容器
  402. &-container {
  403. display: flex;
  404. justify-content: left;
  405. &-left {
  406. width: 832px;
  407. background-color: #fff;
  408. border-radius: 8px;
  409. // 分组讨论
  410. .group-discussion {
  411. display: grid;
  412. grid-template-rows: 144px;
  413. grid-template-columns: 1fr 1fr 1fr;
  414. gap: 8px;
  415. width: 100%;
  416. height: 404px;
  417. padding: 24px;
  418. overflow-y: auto;
  419. background-color: $live-bc;
  420. .group-box {
  421. width: 100%;
  422. height: 144px;
  423. &.student-info {
  424. display: flex;
  425. flex-direction: column;
  426. align-items: center;
  427. justify-content: space-between;
  428. border: 2px solid #625c5b;
  429. .el-avatar {
  430. margin-top: 12px;
  431. }
  432. .student_name {
  433. height: 28px;
  434. color: #fff;
  435. }
  436. }
  437. }
  438. .group-wrapper {
  439. position: relative;
  440. %live-wrapper-stream,
  441. .live-wrapper-stream {
  442. position: absolute;
  443. top: 112px;
  444. width: calc(100% - 16px);
  445. height: 32px;
  446. padding: 0 15px;
  447. margin: 0 8px;
  448. line-height: 32px;
  449. color: #fff;
  450. text-align: center;
  451. background-color: rgba(0, 0, 0, 70%);
  452. transition: all 300ms ease-in 0s;
  453. > .svg-icon {
  454. margin-left: 12px;
  455. }
  456. }
  457. .local-stream {
  458. @extend %live-wrapper-stream;
  459. display: flex;
  460. > div:first-child {
  461. flex: 6;
  462. }
  463. > div:last-child {
  464. flex: 4;
  465. text-align: right;
  466. .svg-icon {
  467. margin-right: 18px;
  468. cursor: pointer;
  469. }
  470. }
  471. }
  472. }
  473. }
  474. // 旁听列表
  475. .audit-list {
  476. display: flex;
  477. align-items: center;
  478. width: 100%;
  479. height: 64px;
  480. padding: 16px 24px;
  481. background-color: #5a5a5a;
  482. &-container {
  483. width: 100%;
  484. height: 100%;
  485. margin: 0 24px;
  486. overflow: hidden;
  487. .avatar-list {
  488. display: inline-block;
  489. white-space: nowrap;
  490. .el-avatar {
  491. margin-left: 8px;
  492. }
  493. }
  494. }
  495. .svg-icon {
  496. cursor: pointer;
  497. }
  498. }
  499. .button-group {
  500. display: flex;
  501. justify-content: space-between;
  502. height: 48px;
  503. padding: 0 15px;
  504. background-color: #4d4d4d;
  505. border-bottom-left-radius: 5px;
  506. .svg-icon {
  507. font-size: 20px;
  508. }
  509. &-left {
  510. > span {
  511. display: inline-block;
  512. height: 100%;
  513. padding: 14px 16px;
  514. cursor: pointer;
  515. &:active,
  516. &:hover {
  517. background-color: #3d3d3d;
  518. }
  519. }
  520. }
  521. }
  522. // 聊天窗口
  523. &-chat {
  524. display: flex;
  525. flex-direction: column;
  526. justify-content: space-between;
  527. height: 278px;
  528. border: 1px solid #ccc;
  529. border-bottom-left-radius: 8px;
  530. .chat-top {
  531. display: flex;
  532. justify-content: space-between;
  533. padding: 15px 15px 10px;
  534. color: #959595;
  535. border-bottom: 1px solid #e6e6e6;
  536. label {
  537. cursor: pointer;
  538. }
  539. .allow-chat {
  540. margin-right: 12px;
  541. }
  542. }
  543. .chat-window {
  544. position: relative;
  545. width: 100%;
  546. height: 100%;
  547. overflow: hidden;
  548. &-ul {
  549. position: absolute;
  550. top: 0;
  551. left: 0;
  552. width: 100%;
  553. height: 100%;
  554. overflow: auto;
  555. .msg-normal {
  556. padding: 7px 16px;
  557. }
  558. }
  559. }
  560. .chat-speak {
  561. padding: 16px;
  562. }
  563. }
  564. }
  565. &-right {
  566. height: 794px;
  567. padding: 8px;
  568. background-color: #2c2c2c;
  569. border-end-end-radius: 8px;
  570. .live-teacher-lens {
  571. position: relative;
  572. overflow: hidden;
  573. .live-container {
  574. width: 352px;
  575. height: 198px;
  576. background-color: $live-bc;
  577. #live {
  578. width: 100%;
  579. height: 100%;
  580. }
  581. .el-image {
  582. width: 100%;
  583. height: 100%;
  584. }
  585. }
  586. .live-wrapper {
  587. position: absolute;
  588. width: 100%;
  589. height: 40px;
  590. padding: 0 16px;
  591. line-height: 40px;
  592. color: #fff;
  593. background-color: rgba(0, 0, 0, 70%);
  594. transition: all 300ms ease-in 0s;
  595. }
  596. }
  597. .student-list {
  598. width: 100%;
  599. height: calc(100% - 200px);
  600. padding: 24px 16px;
  601. margin-top: 2px;
  602. font-size: 14px;
  603. color: #fff;
  604. background-color: #2c2c2c;
  605. &-title {
  606. margin-bottom: 16px;
  607. }
  608. ul {
  609. height: calc(100% - 20px);
  610. overflow-x: auto;
  611. }
  612. li {
  613. display: flex;
  614. margin-bottom: 16px;
  615. .student-list-left {
  616. .name {
  617. margin-left: 8px;
  618. vertical-align: super;
  619. }
  620. }
  621. }
  622. }
  623. }
  624. }
  625. }
  626. </style>