audit.vue 17 KB

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