CommentVideo.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  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">
  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. name: {
  246. textStyle: {
  247. color: '#fff',
  248. backgroundColor: '#91C7AE',
  249. borderRadius: 3,
  250. padding: [5, 10]
  251. }
  252. },
  253. indicator: [
  254. { name: '同步差异化', max: 100},
  255. { name: '融合创新', max: 100},
  256. { name: '合作学习', max: 100},
  257. { name: '科技互动', max: 100},
  258. { name: '教法应用', max: 100},
  259. { name: '教材设计', max: 100}
  260. ],
  261. splitLine: {
  262. lineStyle: {
  263. // 使用深浅的间隔色
  264. color: ['#8A8A8A', '#838B83']
  265. }
  266. },
  267. },
  268. series: [{
  269. name: '预算 vs 开销(Budget vs spending)',
  270. type: 'radar',
  271. itemStyle: {
  272. normal: {
  273. areaStyle: {
  274. type: 'default',
  275. },
  276. lineStyle:{
  277. color:'#63B8FF'
  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: '#91C7AE' // 选择区域颜色
  293. },
  294. }
  295. }
  296. ]
  297. }]
  298. }
  299. radarLeft.setOption(radarLeftOption);
  300. let scoreRightOption = {
  301. tooltip : {
  302. formatter: "{a} {b} : {c}分"
  303. },
  304. series: [
  305. {
  306. name: '最终得分',
  307. type: 'gauge',
  308. radius:'80%',
  309. splitNumber:'5',
  310. detail: {
  311. fontSize:'60',
  312. fontWeight:'bolder',
  313. padding:[0,0,0,0],
  314. color:"#00868B"
  315. },
  316. data: [{ value: this.score }]
  317. }
  318. ]
  319. };
  320. scoreRight.setOption(scoreRightOption);
  321. myChart.on('click', function (params) {
  322. let totalSecond = document.getElementsByClassName('vjs-tech')[0].duration;
  323. //document.getElementsByClassName('vjs-control-bar')[0].style.opacity = 1;
  324. that.$refs.videoPlayer.player.play();
  325. console.log(that.$refs.videoPlayer.player.controls);
  326. that.$refs.videoPlayer.player.currentTime(totalSecond * parseInt(params.value[0]) * 0.01);
  327. });
  328. },
  329. }
  330. </script>
  331. <style>
  332. .video-page {
  333. width: 1200px;
  334. margin: 100px auto;
  335. }
  336. .video-title {
  337. margin-bottom: 20px;
  338. height: 20px;
  339. }
  340. .video-title-h3 {
  341. height: 20px;
  342. font-size: 20px;
  343. line-height: 20px;
  344. border-left: 6px solid #37b1fa;
  345. padding-left: 12px;
  346. }
  347. .video-info {
  348. width: 100%;
  349. display: table;
  350. }
  351. .comment-video-detail-info {
  352. width: 400px;
  353. background: #ffffff;
  354. display: table-cell;
  355. vertical-align: top;
  356. padding: 20px 10px 20px 30px;
  357. position: relative;
  358. border-left: 15px solid rgb(241,242,243);
  359. }
  360. .comment-video-detail-info .ivu-form-item {
  361. margin-bottom: 8px;
  362. }
  363. .comment-video-detail-info .ivu-form .ivu-form-item-label {
  364. font-size: 14px;
  365. color: #999999;
  366. }
  367. .comment-video-detail-info .ivu-form-item-content {
  368. font-size: 14px;
  369. color: #ffffff;
  370. }
  371. .comment-video-src {
  372. display: table-cell;
  373. width: 780px;
  374. box-sizing: border-box;
  375. padding: 20px 20px;
  376. background: #FFFFFF;
  377. }
  378. .comment-video-src .video-js .vjs-big-play-button {
  379. top: 50%;
  380. left: 50%;
  381. margin-left: -40px;
  382. margin-top: -20px;
  383. }
  384. .download-video {
  385. text-align: center;
  386. position: absolute;
  387. width: 100%;
  388. bottom: 20px;
  389. left: 0;
  390. }
  391. .video-other {
  392. margin-top: 20px;
  393. }
  394. .videos-wrap {
  395. margin: 0px -10px 0px -10px;
  396. }
  397. .video-item {
  398. width: 25%;
  399. display: inline-block;
  400. padding: 0px 10px;
  401. margin-top: 20px;
  402. cursor: pointer;
  403. }
  404. .video-item p {
  405. font-size: 16px;
  406. color: #000;
  407. margin-top: 10px;
  408. text-decoration: none;
  409. text-indent: 8px;
  410. }
  411. .title-header {
  412. color: #666;
  413. margin-right: 30px;
  414. display: inline-block;
  415. }
  416. .liveStatus {
  417. color: #33aafe;
  418. float: right;
  419. }
  420. .review-pane {
  421. max-height: 1000px;
  422. background-color: #fff;
  423. overflow-y: auto;
  424. position: relative;
  425. }
  426. .review-list {
  427. overflow: hidden;
  428. font-size: 14px;
  429. margin: 8px 10px;
  430. padding-bottom: 8px;
  431. border-bottom: 1px solid #f6f6f6;
  432. }
  433. .reviewlist-title {
  434. float: left;
  435. /*width: 22%;*/
  436. color: #999;
  437. text-align: right;
  438. padding-right: 5px;
  439. }
  440. .reviewlist-content {
  441. float: left;
  442. color: #444;
  443. /*width: 76%;*/
  444. font-size: 14px;
  445. word-break: break-all;
  446. }
  447. .lastest-comment {
  448. position: absolute;
  449. top: -5px;
  450. right: 20px;
  451. padding: 5px;
  452. color: #666;
  453. z-index: 999;
  454. cursor: pointer;
  455. }
  456. .publish-review {
  457. padding: 10px;
  458. background-color: #f1f2f3;
  459. border: 1px solid #d7d8da;
  460. font-size: 14px;
  461. color: #333;
  462. width: 100%;
  463. height: 100px;
  464. resize: none;
  465. outline: none;
  466. box-sizing: border-box;
  467. }
  468. .submit-review {
  469. margin-top: 8px;
  470. color: #fff;
  471. background-color: #409eff;
  472. border-color: #409eff;
  473. margin-right: 10px;
  474. display: inline-block;
  475. float: right;
  476. cursor: pointer;
  477. width: 45px;
  478. text-align: center;
  479. height: 22px;
  480. line-height: 22px;
  481. border-radius: 2px;
  482. }
  483. .reviewlist-time {
  484. font-size: 12px;
  485. color: #ccc;
  486. }
  487. .average-score {
  488. margin-top: 20px;
  489. color: #666;
  490. font-size: 14px;
  491. }
  492. .average-score span {
  493. color: #fd8f45;
  494. }
  495. #views {
  496. background: #fff;
  497. padding-top: 30px;
  498. }
  499. .echart-title {
  500. background:#fff;
  501. text-align:center;
  502. display:block;
  503. font-size:18px;
  504. font-weight:bolder;
  505. width:840px;
  506. color:#333
  507. }
  508. </style>