CommentVideo.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  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 style="background:#fff;text-align:center;display:block;font-size:18px;font-weight:bolder;width:840px; color:#333">
  21. <!--<Icon type="md-pulse" size="26" color="rgb(102, 205, 170)" style="margin:10px"/>-->
  22. 专家点评分析图
  23. </div>
  24. </div>
  25. <div class="comment-video-detail-info">
  26. <Tabs value="name1">
  27. <TabPane label="观课评论" name="name1">
  28. <div class="review-pane">
  29. <div class="review-list" v-for="(item,index) in commmentList" :key="index">
  30. <span class="reviewlist-title">
  31. {{item.employeeName}} :&nbsp;
  32. </span> <span class="reviewlist-content"><span>{{item.content}}</span> <span class="reviewlist-time">({{item.createTimeTip}})</span> <!----></span>
  33. </div>
  34. </div>
  35. <div style="position: relative; padding-top:40px;">
  36. <div class="lastest-comment" style="display: none;">查看最新评论</div>
  37. <textarea placeholder="发表您的评论" v-model="newComment" maxlength="250" class="publish-review"></textarea>
  38. <span class="submit-review" @click="addComment">提交</span>
  39. </div>
  40. </TabPane>
  41. <TabPane label="专家点评" name="name2">
  42. <div class="review-pane">
  43. <div v-for="(item,index) in expertComments">
  44. <div class="review-list" v-for="(comment,index) in item.contentList" :key="index">
  45. <span class="reviewlist-title">
  46. {{comment.name}} :&nbsp;
  47. </span>
  48. <span class="reviewlist-content">
  49. <span>{{comment.content}}</span>
  50. <span class="reviewlist-time">({{item.time}})</span>
  51. </span>
  52. </div>
  53. </div>
  54. </div>
  55. </TabPane>
  56. </Tabs>
  57. </div>
  58. </div>
  59. </div>
  60. </template>
  61. <script>
  62. import lessonDetails from '@/static/lessonDetails.json'
  63. import "videojs-contrib-hls.js/src/videojs.hlsjs"
  64. export default {
  65. data() {
  66. return {
  67. playerOptions: {
  68. playbackRates: [0.7, 1.0, 1.5, 2.0], //播放速度
  69. autoplay: false, //如果true,浏览器准备好时开始回放。
  70. controls: true, //控制条
  71. preload: 'auto', //视频预加载
  72. muted: false, //默认情况下将会消除任何音频。
  73. loop: false, //导致视频一结束就重新开始。
  74. language: 'zh-CN',
  75. aspectRatio: '16:9', // 将播放器置于流畅模式,并在计算播放器的动态大小时使用该值。值应该代表一个比例 - 用冒号分隔的两个数字(例如"16:9"或"4:3")
  76. fluid: true, // 当true时,Video.js player将拥有流体大小。换句话说,它将按比例缩放以适应其容器。
  77. sources: [{
  78. type: 'application/x-mpegURL',
  79. src: lessonDetails[sessionStorage.getItem('_lesson_rowKey')].data.liveHls
  80. }],
  81. //poster: "http://static.smartisanos.cn/pr/img/video/video_03_cc87ce5bdb.jpg", //你的封面地址
  82. width: document.documentElement.clientWidth,
  83. notSupportedMessage: '此视频暂无法播放,请稍后再试' //允许覆盖Video.js无法播放媒体源时显示的默认信息。
  84. },
  85. routerData: {},
  86. rewardDatas: [],
  87. commmentList: [],
  88. expertComments: [],
  89. newComment: "",
  90. player: {},
  91. rowKey: sessionStorage.getItem('_lesson_rowKey'),
  92. lessonInfo:lessonDetails[sessionStorage.getItem('_lesson_rowKey')].data
  93. }
  94. },
  95. methods: {
  96. //时间转成秒数
  97. transferTime(time) {
  98. var s = '';
  99. var min = time.split(':')[0];
  100. var sec = time.split(':')[1];
  101. s = Number(min * 60) + Number(sec);
  102. return s;
  103. },
  104. //添加评论
  105. addComment() {
  106. let newComment = {
  107. employeeName: "admin",
  108. content: this.newComment,
  109. createTimeTip: new Date().toLocaleDateString() + ' ' + new Date().toLocaleTimeString()
  110. }
  111. if (newComment.content) {
  112. this.commmentList.unshift(newComment);
  113. } else {
  114. this.$Message.warning("评论内容不能为空!");
  115. }
  116. this.newComment = "";
  117. },
  118. //秒数转成时间格式
  119. transferSecond(s) {
  120. var t;
  121. if (s > -1) {
  122. var hour = Math.floor(s / 3600);
  123. var min = Math.floor(s / 60) % 60;
  124. var sec = s % 60;
  125. if (hour < 10) {
  126. t = '0' + hour + ":";
  127. } else {
  128. t = hour + ":";
  129. }
  130. if (min < 10) { t += "0"; }
  131. t += min + ":";
  132. if (sec < 10) { t += "0"; }
  133. t += sec.toFixed(0);
  134. }
  135. return t;
  136. },
  137. onPlayerPlay(player) {
  138. console.log('player play!', player)
  139. },
  140. onPlayerPause(player) {
  141. console.log('player pause!', player)
  142. },
  143. onPlayerPlaying(player) {
  144. let current = this.transferTime(player.controlBar.currentTimeDisplay.formattedTime_);
  145. let totalSecond = document.getElementsByClassName('vjs-tech')[0].duration;
  146. },
  147. playerReadied(player) {
  148. //player.currentTime(120);
  149. },
  150. getPercent(num, total) {
  151. num = parseFloat(num);
  152. total = parseFloat(total);
  153. if (isNaN(num) || isNaN(total)) {
  154. return "-";
  155. }
  156. return total <= 0 ? "0%" : (Math.round(num / total * 10000) / 100.00) + "%";
  157. },
  158. transferArr(arr) {
  159. let newArr = [];
  160. for (let i in arr) {
  161. newArr.push([arr[i].per, arr[i].value, arr[i].contentList]);
  162. }
  163. return newArr;
  164. }
  165. },
  166. mounted() {
  167. let that = this;
  168. this.commmentList = lessonDetails[this.rowKey].commentList;
  169. this.expertComments = lessonDetails[this.rowKey].expertComments;
  170. let myChart = this.$echarts.init(document.getElementById('views'));
  171. let option = {
  172. calculable: true,
  173. xAxis: [
  174. {
  175. type: 'value',
  176. name: "视频进度",
  177. boundaryGap: false,
  178. axisLabel: {
  179. formatter: '{value}%'
  180. }
  181. }
  182. ],
  183. yAxis: [
  184. {
  185. type: 'value',
  186. name: "专家点评数",
  187. nameGap: 30,
  188. minInterval:1,
  189. axisLabel: {
  190. },
  191. splitLine: { // gird 区域中的分割线
  192. show: false, // 是否显示
  193. },
  194. }
  195. ],
  196. series: [
  197. {
  198. name: '评论数',
  199. type: 'line',
  200. smooth: true,
  201. data: that.transferArr(that.expertComments),
  202. itemStyle: {
  203. normal: {
  204. color: '#66CDAA', //改变折线点的颜色
  205. borderWidth: 5
  206. }
  207. },
  208. lineStyle: {
  209. color: '#66CDAA', //改变折线颜色
  210. width: 3,
  211. },
  212. }
  213. ],
  214. tooltip: {
  215. formatter: function (point) {
  216. let totalSecond = document.getElementsByClassName('vjs-tech')[0].duration;
  217. let time = "点评时间 : " + that.transferSecond(point.value[0] * totalSecond * 0.01) + '</br>';
  218. let list = point.value[2];
  219. let str = "评论内容:</br>"
  220. let content = "";
  221. for (let i in list) {
  222. content = content + list[i].name + ' : ' + list[i].content + '</br>';
  223. }
  224. return time + content
  225. }
  226. }
  227. };
  228. myChart.setOption(option);
  229. myChart.on('click', function (params) {
  230. let totalSecond = document.getElementsByClassName('vjs-tech')[0].duration;
  231. //document.getElementsByClassName('vjs-control-bar')[0].style.opacity = 1;
  232. that.$refs.videoPlayer.player.play();
  233. console.log(that.$refs.videoPlayer.player.controls);
  234. that.$refs.videoPlayer.player.currentTime(totalSecond * parseInt(params.value[0]) * 0.01);
  235. });
  236. },
  237. }
  238. </script>
  239. <style>
  240. .video-page {
  241. width: 1200px;
  242. margin: 100px auto;
  243. }
  244. .video-title {
  245. margin-bottom: 20px;
  246. height: 20px;
  247. }
  248. .video-title-h3 {
  249. height: 20px;
  250. font-size: 20px;
  251. line-height: 20px;
  252. border-left: 6px solid #37b1fa;
  253. padding-left: 12px;
  254. }
  255. .video-info {
  256. width: 100%;
  257. display: table;
  258. }
  259. .comment-video-detail-info {
  260. width: 400px;
  261. background: #ffffff;
  262. display: table-cell;
  263. vertical-align: top;
  264. padding: 20px 10px 20px 30px;
  265. position: relative;
  266. border-left: 15px solid rgb(241,242,243);
  267. }
  268. .comment-video-detail-info .ivu-form-item {
  269. margin-bottom: 8px;
  270. }
  271. .comment-video-detail-info .ivu-form .ivu-form-item-label {
  272. font-size: 14px;
  273. color: #999999;
  274. }
  275. .comment-video-detail-info .ivu-form-item-content {
  276. font-size: 14px;
  277. color: #ffffff;
  278. }
  279. .comment-video-src {
  280. display: table-cell;
  281. width: 780px;
  282. box-sizing: border-box;
  283. padding: 20px 20px;
  284. background: #FFFFFF;
  285. }
  286. .comment-video-src .video-js .vjs-big-play-button {
  287. top: 50%;
  288. left: 50%;
  289. margin-left: -40px;
  290. margin-top: -20px;
  291. }
  292. .download-video {
  293. text-align: center;
  294. position: absolute;
  295. width: 100%;
  296. bottom: 20px;
  297. left: 0;
  298. }
  299. .video-other {
  300. margin-top: 20px;
  301. }
  302. .videos-wrap {
  303. margin: 0px -10px 0px -10px;
  304. }
  305. .video-item {
  306. width: 25%;
  307. display: inline-block;
  308. padding: 0px 10px;
  309. margin-top: 20px;
  310. cursor: pointer;
  311. }
  312. .video-item p {
  313. font-size: 16px;
  314. color: #000;
  315. margin-top: 10px;
  316. text-decoration: none;
  317. text-indent: 8px;
  318. }
  319. .title-header {
  320. color: #666;
  321. margin-right: 30px;
  322. display: inline-block;
  323. }
  324. .liveStatus {
  325. color: #33aafe;
  326. float: right;
  327. }
  328. .review-pane {
  329. height: 700px;
  330. background-color: #fff;
  331. overflow-y: auto;
  332. position: relative;
  333. }
  334. .review-list {
  335. overflow: hidden;
  336. font-size: 14px;
  337. margin: 8px 10px;
  338. padding-bottom: 8px;
  339. border-bottom: 1px solid #f6f6f6;
  340. }
  341. .reviewlist-title {
  342. float: left;
  343. /*width: 22%;*/
  344. color: #999;
  345. text-align: right;
  346. padding-right: 5px;
  347. }
  348. .reviewlist-content {
  349. float: left;
  350. color: #444;
  351. /*width: 76%;*/
  352. font-size: 14px;
  353. word-break: break-all;
  354. }
  355. .lastest-comment {
  356. position: absolute;
  357. top: -5px;
  358. right: 20px;
  359. padding: 5px;
  360. color: #666;
  361. z-index: 999;
  362. cursor: pointer;
  363. }
  364. .publish-review {
  365. padding: 10px;
  366. background-color: #f1f2f3;
  367. border: 1px solid #d7d8da;
  368. font-size: 14px;
  369. color: #333;
  370. width: 100%;
  371. height: 100px;
  372. resize: none;
  373. outline: none;
  374. box-sizing: border-box;
  375. }
  376. .submit-review {
  377. margin-top: 8px;
  378. color: #fff;
  379. background-color: #409eff;
  380. border-color: #409eff;
  381. margin-right: 10px;
  382. display: inline-block;
  383. float: right;
  384. cursor: pointer;
  385. width: 45px;
  386. text-align: center;
  387. height: 22px;
  388. line-height: 22px;
  389. border-radius: 2px;
  390. }
  391. .reviewlist-time {
  392. font-size: 12px;
  393. color: #ccc;
  394. }
  395. .average-score {
  396. margin-top: 20px;
  397. color: #666;
  398. font-size: 14px;
  399. }
  400. .average-score span {
  401. color: #fd8f45;
  402. }
  403. #views {
  404. background: #fff;
  405. padding-top: 30px;
  406. }
  407. </style>