CommentVideo.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439
  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. that.$refs.videoPlayer.player.currentTime(totalSecond * parseInt(params.value[0]) * 0.01);
  232. });
  233. },
  234. }
  235. </script>
  236. <style>
  237. .video-page {
  238. width: 1200px;
  239. margin: 100px auto;
  240. }
  241. .video-title {
  242. margin-bottom: 20px;
  243. height: 20px;
  244. }
  245. .video-title-h3 {
  246. height: 20px;
  247. font-size: 20px;
  248. line-height: 20px;
  249. border-left: 6px solid #37b1fa;
  250. padding-left: 12px;
  251. }
  252. .video-info {
  253. width: 100%;
  254. display: table;
  255. }
  256. .comment-video-detail-info {
  257. width: 400px;
  258. background: #ffffff;
  259. display: table-cell;
  260. vertical-align: top;
  261. padding: 20px 10px 20px 30px;
  262. position: relative;
  263. border-left: 15px solid rgb(241,242,243);
  264. }
  265. .comment-video-detail-info .ivu-form-item {
  266. margin-bottom: 8px;
  267. }
  268. .comment-video-detail-info .ivu-form .ivu-form-item-label {
  269. font-size: 14px;
  270. color: #999999;
  271. }
  272. .comment-video-detail-info .ivu-form-item-content {
  273. font-size: 14px;
  274. color: #ffffff;
  275. }
  276. .comment-video-src {
  277. display: table-cell;
  278. width: 780px;
  279. box-sizing: border-box;
  280. padding: 20px 20px;
  281. background: #FFFFFF;
  282. }
  283. .comment-video-src .video-js .vjs-big-play-button {
  284. top: 50%;
  285. left: 50%;
  286. margin-left: -40px;
  287. margin-top: -20px;
  288. }
  289. .download-video {
  290. text-align: center;
  291. position: absolute;
  292. width: 100%;
  293. bottom: 20px;
  294. left: 0;
  295. }
  296. .video-other {
  297. margin-top: 20px;
  298. }
  299. .videos-wrap {
  300. margin: 0px -10px 0px -10px;
  301. }
  302. .video-item {
  303. width: 25%;
  304. display: inline-block;
  305. padding: 0px 10px;
  306. margin-top: 20px;
  307. cursor: pointer;
  308. }
  309. .video-item p {
  310. font-size: 16px;
  311. color: #000;
  312. margin-top: 10px;
  313. text-decoration: none;
  314. text-indent: 8px;
  315. }
  316. .title-header {
  317. color: #666;
  318. margin-right: 30px;
  319. display: inline-block;
  320. }
  321. .liveStatus {
  322. color: #33aafe;
  323. float: right;
  324. }
  325. .review-pane {
  326. height: 700px;
  327. background-color: #fff;
  328. overflow-y: auto;
  329. position: relative;
  330. }
  331. .review-list {
  332. overflow: hidden;
  333. font-size: 14px;
  334. margin: 8px 10px;
  335. padding-bottom: 8px;
  336. border-bottom: 1px solid #f6f6f6;
  337. }
  338. .reviewlist-title {
  339. float: left;
  340. /*width: 22%;*/
  341. color: #999;
  342. text-align: right;
  343. padding-right: 5px;
  344. }
  345. .reviewlist-content {
  346. float: left;
  347. color: #444;
  348. /*width: 76%;*/
  349. font-size: 14px;
  350. word-break: break-all;
  351. }
  352. .lastest-comment {
  353. position: absolute;
  354. top: -5px;
  355. right: 20px;
  356. padding: 5px;
  357. color: #666;
  358. z-index: 999;
  359. cursor: pointer;
  360. }
  361. .publish-review {
  362. padding: 10px;
  363. background-color: #f1f2f3;
  364. border: 1px solid #d7d8da;
  365. font-size: 14px;
  366. color: #333;
  367. width: 100%;
  368. height: 100px;
  369. resize: none;
  370. outline: none;
  371. box-sizing: border-box;
  372. }
  373. .submit-review {
  374. margin-top: 8px;
  375. color: #fff;
  376. background-color: #409eff;
  377. border-color: #409eff;
  378. margin-right: 10px;
  379. display: inline-block;
  380. float: right;
  381. cursor: pointer;
  382. width: 45px;
  383. text-align: center;
  384. height: 22px;
  385. line-height: 22px;
  386. border-radius: 2px;
  387. }
  388. .reviewlist-time {
  389. font-size: 12px;
  390. color: #ccc;
  391. }
  392. .average-score {
  393. margin-top: 20px;
  394. color: #666;
  395. font-size: 14px;
  396. }
  397. .average-score span {
  398. color: #fd8f45;
  399. }
  400. #views {
  401. background: #fff;
  402. padding-top: 30px;
  403. }
  404. </style>