CommentVideo.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. <template>
  2. <div class="video-page">
  3. <!--<div class="video-title">
  4. <h3 class="video-title-h3">12月03日直播</h3>
  5. </div>-->
  6. <div class="video-info">
  7. <div class="comment-video-src">
  8. <div>
  9. <p style=" font-size: 14px; margin-bottom: 20px;"><span class="title-header">标题 : <span class="title-content">{{lessonInfo.name}} 《 {{lessonInfo.parentProjectName}} 》</span></span> <span class="title-header">主讲人 : {{lessonInfo.speaker}}<span class="title-content"></span></span> <span class="liveStatus">播放成功</span></p>
  10. </div>
  11. <video-player class="video-player-box" style="width:800px;"
  12. ref="videoPlayer"
  13. :options="playerOptions"
  14. :playsinline="true"
  15. @playing="onPlayerPlaying($event)"
  16. @ready="playerReadied">
  17. </video-player>
  18. <!--<p class="average-score">作品当前平均分 : <span>未评</span></p>-->
  19. <div id="views" style="width:840px; height:350px;"></div>
  20. <div class="echart-title">专家点评分析图</div>
  21. <div style="width:400px;float:left;margin-left:20px">
  22. <div id="radarLeft" style="width:400px; height:350px;margin-top:20px;"></div>
  23. <div class="echart-title" style="margin-top:20px;width:400px;">课堂评价</div>
  24. </div>
  25. <div style="width:400px;float:left">
  26. <div id="scoreRight" style="width:400px; height:350px;margin-top:20px;"></div>
  27. <div class="echart-title" style="margin-top:20px;width:400px;">课堂得分</div>
  28. </div>
  29. </div>
  30. <div class="comment-video-detail-info">
  31. <Tabs value="name1">
  32. <TabPane label="观课评论" name="name1">
  33. <div class="review-pane">
  34. <div class="review-list" v-for="(item,index) in commmentList" :key="index">
  35. <span class="reviewlist-title">
  36. {{item.employeeName}} :&nbsp;
  37. </span> <span class="reviewlist-content"><span>{{item.content}}</span> <span class="reviewlist-time">({{item.createTimeTip}})</span> <!----></span>
  38. </div>
  39. </div>
  40. <div style="position: relative; padding-top:40px;">
  41. <div class="lastest-comment" style="display: none;">查看最新评论</div>
  42. <textarea placeholder="发表您的评论" v-model="newComment" maxlength="250" class="publish-review"></textarea>
  43. <span class="submit-review" @click="addComment">提交</span>
  44. </div>
  45. </TabPane>
  46. <TabPane label="专家点评" name="name2">
  47. <div class="review-pane">
  48. <div v-for="(item,index) in expertComments">
  49. <div class="review-list" v-for="(comment,index) in item.contentList" :key="index">
  50. <span class="reviewlist-title">
  51. {{comment.name}} :&nbsp;
  52. </span>
  53. <span class="reviewlist-content">
  54. <span>{{comment.content}}</span>
  55. <span class="reviewlist-time">({{item.time}})</span>
  56. </span>
  57. </div>
  58. </div>
  59. </div>
  60. </TabPane>
  61. </Tabs>
  62. </div>
  63. </div>
  64. </div>
  65. </template>
  66. <script>
  67. import lessonDetails from '@/static/lessonDetails.json'
  68. import "videojs-contrib-hls.js/src/videojs.hlsjs"
  69. export default {
  70. data() {
  71. return {
  72. playerOptions: {
  73. playbackRates: [0.7, 1.0, 1.5, 2.0], //播放速度
  74. autoplay: false, //如果true,浏览器准备好时开始回放。
  75. controls: true, //控制条
  76. preload: 'auto', //视频预加载
  77. muted: false, //默认情况下将会消除任何音频。
  78. loop: false, //导致视频一结束就重新开始。
  79. language: 'zh-CN',
  80. aspectRatio: '16:9', // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
  81. fluid: true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
  82. sources: [{
  83. type: 'application/x-mpegURL',
  84. src: lessonDetails[sessionStorage.getItem('_lesson_rowKey')].data.liveHls
  85. }],
  86. //poster: "http://static.smartisanos.cn/pr/img/video/video_03_cc87ce5bdb.jpg", //你的封面地址
  87. width: document.documentElement.clientWidth,
  88. notSupportedMessage: '此视频暂无法播放,请稍后再试' //允许覆盖Video.js无法播放媒体源时显示的默认信息。
  89. },
  90. routerData: {},
  91. rewardDatas: [],
  92. commmentList: [],
  93. expertComments: [],
  94. newComment: "",
  95. player: {},
  96. rowKey: sessionStorage.getItem('_lesson_rowKey'),
  97. lessonInfo: lessonDetails[sessionStorage.getItem('_lesson_rowKey')].data,
  98. scoreList: [],
  99. score:0
  100. }
  101. },
  102. methods: {
  103. //时间转成秒数
  104. transferTime(time) {
  105. var s = '';
  106. var min = time.split(':')[0];
  107. var sec = time.split(':')[1];
  108. s = Number(min * 60) + Number(sec);
  109. return s;
  110. },
  111. //添加评论
  112. addComment() {
  113. let newComment = {
  114. employeeName: "admin",
  115. content: this.newComment,
  116. createTimeTip: new Date().toLocaleDateString() + ' ' + new Date().toLocaleTimeString()
  117. }
  118. if (newComment.content) {
  119. this.commmentList.unshift(newComment);
  120. } else {
  121. this.$Message.warning("评论内容不能为空!");
  122. }
  123. this.newComment = "";
  124. },
  125. //秒数转成时间格式
  126. transferSecond(s) {
  127. var t;
  128. if (s > -1) {
  129. var hour = Math.floor(s / 3600);
  130. var min = Math.floor(s / 60) % 60;
  131. var sec = s % 60;
  132. if (hour < 10) {
  133. t = '0' + hour + ":";
  134. } else {
  135. t = hour + ":";
  136. }
  137. if (min < 10) { t += "0"; }
  138. t += min + ":";
  139. if (sec < 10) { t += "0"; }
  140. t += sec.toFixed(0);
  141. }
  142. return t;
  143. },
  144. onPlayerPlay(player) {
  145. console.log('player play!', player)
  146. },
  147. onPlayerPause(player) {
  148. console.log('player pause!', player)
  149. },
  150. onPlayerPlaying(player) {
  151. let current = this.transferTime(player.controlBar.currentTimeDisplay.formattedTime_);
  152. let totalSecond = document.getElementsByClassName('vjs-tech')[0].duration;
  153. },
  154. playerReadied(player) {
  155. //player.currentTime(120);
  156. },
  157. getPercent(num, total) {
  158. num = parseFloat(num);
  159. total = parseFloat(total);
  160. if (isNaN(num) || isNaN(total)) {
  161. return "-";
  162. }
  163. return total <= 0 ? "0%" : (Math.round(num / total * 10000) / 100.00) + "%";
  164. },
  165. transferArr(arr) {
  166. let newArr = [];
  167. for (let i in arr) {
  168. newArr.push([arr[i].per, arr[i].value, arr[i].contentList]);
  169. }
  170. return newArr;
  171. }
  172. },
  173. mounted() {
  174. let that = this;
  175. let scoreList = lessonDetails[this.rowKey].score
  176. this.commmentList = lessonDetails[this.rowKey].commentList;
  177. this.expertComments = lessonDetails[this.rowKey].expertComments;
  178. this.scoreList = scoreList;
  179. this.score = (scoreList.reduce((acc, val) => acc + val, 0) / scoreList.length).toFixed(0)
  180. let myChart = this.$echarts.init(document.getElementById('views'));
  181. let radarLeft = this.$echarts.init(document.getElementById('radarLeft'));
  182. let scoreRight = this.$echarts.init(document.getElementById('scoreRight'));
  183. let option = {
  184. calculable: true,
  185. xAxis: [
  186. {
  187. type: 'value',
  188. name: "视频进度",
  189. boundaryGap: false,
  190. axisLabel: {
  191. formatter: '{value}%'
  192. }
  193. }
  194. ],
  195. yAxis: [
  196. {
  197. type: 'value',
  198. name: "专家点评数",
  199. nameGap: 30,
  200. minInterval:1,
  201. axisLabel: {
  202. },
  203. splitLine: { // gird 区域中的分割线
  204. show: false, // 是否显示
  205. },
  206. }
  207. ],
  208. series: [
  209. {
  210. name: '评论数',
  211. type: 'line',
  212. smooth: true,
  213. data: that.transferArr(that.expertComments),
  214. itemStyle: {
  215. normal: {
  216. color: '#66CDAA', //改变折线点的颜色
  217. borderWidth: 5
  218. }
  219. },
  220. lineStyle: {
  221. color: '#66CDAA', //改变折线颜色
  222. width: 3,
  223. },
  224. }
  225. ],
  226. tooltip: {
  227. formatter: function (point) {
  228. let totalSecond = document.getElementsByClassName('vjs-tech')[0].duration;
  229. let time = "点评时间 : " + that.transferSecond(point.value[0] * totalSecond * 0.01) + '</br>';
  230. let list = point.value[2];
  231. let str = "评论内容:</br>"
  232. let content = "";
  233. for (let i in list) {
  234. content = content + list[i].name + ' : ' + list[i].content + '</br>';
  235. }
  236. return time + content
  237. }
  238. }
  239. };
  240. myChart.setOption(option);
  241. let radarLeftOption = {
  242. tooltip: {},
  243. radar: {
  244. shape: 'circle',
  245. radius:'55%',
  246. name: {
  247. textStyle: {
  248. color: '#fff',
  249. backgroundColor: '#33CC8F',
  250. borderRadius: 3,
  251. padding: [5, 10]
  252. }
  253. },
  254. indicator: [
  255. { name: '同步差异化', max: 100},
  256. { name: '融合创新', max: 100},
  257. { name: '合作学习', max: 100},
  258. { name: '科技互动', max: 100},
  259. { name: '教法应用', max: 100},
  260. { name: '教材设计', max: 100}
  261. ],
  262. splitLine: {
  263. lineStyle: {
  264. // 使用深浅的间隔色
  265. color: ['#8A8A8A', '#838B83']
  266. }
  267. },
  268. },
  269. series: [{
  270. type: 'radar',
  271. itemStyle: {
  272. normal: {
  273. areaStyle: {
  274. type: 'default',
  275. },
  276. lineStyle:{
  277. color:'#44BB44'
  278. }
  279. }
  280. },
  281. areaStyle: {
  282. normal: {
  283. opacity:0.9
  284. }
  285. },
  286. data : [
  287. {
  288. value: this.scoreList,
  289. name: '课堂评价分数',
  290. areaStyle: {
  291. normal: {
  292. color: '#33CC8F' // 选择区域颜色
  293. },
  294. }
  295. }
  296. ]
  297. }]
  298. }
  299. let scoreRightOption = {
  300. tooltip : {
  301. formatter: "{a}{b} : {c}分"
  302. },
  303. series: [
  304. {
  305. name: '最终得分',
  306. type: 'gauge',
  307. radius:'70%',
  308. splitNumber:'5',
  309. detail: {
  310. fontSize:'50',
  311. fontWeight:'bolder',
  312. padding:[100,0,0,0],
  313. color:"#44BB44"
  314. },
  315. axisLine: { // 坐标轴线
  316. lineStyle: { // 属性lineStyle控制线条样式
  317. color: [[0.2, '#FF6600'], [0.4, '#FFCC00'], [0.6, '#D5D52B'], [0.8, '#33cc99'], [1, '#00cc33']]
  318. }
  319. },
  320. data: [{ value: this.score }]
  321. }
  322. ]
  323. };
  324. window.addEventListener("scroll", function () {
  325. radarLeft.setOption(radarLeftOption);
  326. scoreRight.setOption(scoreRightOption);
  327. });
  328. myChart.on('click', function (params) {
  329. let totalSecond = document.getElementsByClassName('vjs-tech')[0].duration;
  330. //document.getElementsByClassName('vjs-control-bar')[0].style.opacity = 1;
  331. that.$refs.videoPlayer.player.play();
  332. console.log(that.$refs.videoPlayer.player.controls);
  333. that.$refs.videoPlayer.player.currentTime(totalSecond * parseInt(params.value[0]) * 0.01);
  334. });
  335. },
  336. }
  337. </script>
  338. <style>
  339. .video-page {
  340. width: 1200px;
  341. margin: 100px auto;
  342. }
  343. .video-title {
  344. margin-bottom: 20px;
  345. height: 20px;
  346. }
  347. .video-title-h3 {
  348. height: 20px;
  349. font-size: 20px;
  350. line-height: 20px;
  351. border-left: 6px solid #37b1fa;
  352. padding-left: 12px;
  353. }
  354. .video-info {
  355. width: 100%;
  356. display: table;
  357. }
  358. .comment-video-detail-info {
  359. width: 400px;
  360. background: #ffffff;
  361. display: table-cell;
  362. vertical-align: top;
  363. padding: 20px 10px 20px 30px;
  364. position: relative;
  365. border-left: 15px solid rgb(241,242,243);
  366. }
  367. .comment-video-detail-info .ivu-form-item {
  368. margin-bottom: 8px;
  369. }
  370. .comment-video-detail-info .ivu-form .ivu-form-item-label {
  371. font-size: 14px;
  372. color: #999999;
  373. }
  374. .comment-video-detail-info .ivu-form-item-content {
  375. font-size: 14px;
  376. color: #ffffff;
  377. }
  378. .comment-video-src {
  379. display: table-cell;
  380. width: 780px;
  381. box-sizing: border-box;
  382. padding: 20px 20px;
  383. background: #FFFFFF;
  384. }
  385. .comment-video-src .video-js .vjs-big-play-button {
  386. top: 50%;
  387. left: 50%;
  388. margin-left: -40px;
  389. margin-top: -20px;
  390. }
  391. .download-video {
  392. text-align: center;
  393. position: absolute;
  394. width: 100%;
  395. bottom: 20px;
  396. left: 0;
  397. }
  398. .video-other {
  399. margin-top: 20px;
  400. }
  401. .videos-wrap {
  402. margin: 0px -10px 0px -10px;
  403. }
  404. .video-item {
  405. width: 25%;
  406. display: inline-block;
  407. padding: 0px 10px;
  408. margin-top: 20px;
  409. cursor: pointer;
  410. }
  411. .video-item p {
  412. font-size: 16px;
  413. color: #000;
  414. margin-top: 10px;
  415. text-decoration: none;
  416. text-indent: 8px;
  417. }
  418. .title-header {
  419. color: #666;
  420. margin-right: 30px;
  421. display: inline-block;
  422. }
  423. .liveStatus {
  424. color: #33aafe;
  425. float: right;
  426. }
  427. .review-pane {
  428. height: 700px;
  429. background-color: #fff;
  430. overflow-y: auto;
  431. position: relative;
  432. }
  433. .review-list {
  434. overflow: hidden;
  435. font-size: 14px;
  436. margin: 8px 10px;
  437. padding-bottom: 8px;
  438. border-bottom: 1px solid #f6f6f6;
  439. }
  440. .reviewlist-title {
  441. float: left;
  442. /*width: 22%;*/
  443. color: #999;
  444. text-align: right;
  445. padding-right: 5px;
  446. }
  447. .reviewlist-content {
  448. float: left;
  449. color: #444;
  450. /*width: 76%;*/
  451. font-size: 14px;
  452. word-break: break-all;
  453. }
  454. .lastest-comment {
  455. position: absolute;
  456. top: -5px;
  457. right: 20px;
  458. padding: 5px;
  459. color: #666;
  460. z-index: 999;
  461. cursor: pointer;
  462. }
  463. .publish-review {
  464. padding: 10px;
  465. background-color: #f1f2f3;
  466. border: 1px solid #d7d8da;
  467. font-size: 14px;
  468. color: #333;
  469. width: 100%;
  470. height: 100px;
  471. resize: none;
  472. outline: none;
  473. box-sizing: border-box;
  474. }
  475. .submit-review {
  476. margin-top: 8px;
  477. color: #fff;
  478. background-color: #409eff;
  479. border-color: #409eff;
  480. margin-right: 10px;
  481. display: inline-block;
  482. float: right;
  483. cursor: pointer;
  484. width: 45px;
  485. text-align: center;
  486. height: 22px;
  487. line-height: 22px;
  488. border-radius: 2px;
  489. }
  490. .reviewlist-time {
  491. font-size: 12px;
  492. color: #ccc;
  493. }
  494. .average-score {
  495. margin-top: 20px;
  496. color: #666;
  497. font-size: 14px;
  498. }
  499. .average-score span {
  500. color: #fd8f45;
  501. }
  502. #views {
  503. background: #fff;
  504. padding-top: 30px;
  505. }
  506. .echart-title {
  507. background:#fff;
  508. text-align:center;
  509. display:block;
  510. font-size:18px;
  511. font-weight:bolder;
  512. width:840px;
  513. color:#333
  514. }
  515. </style>