CommentVideo.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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">创新实验室(学科教室)课例20190508直播</span></span> <span class="title-header">主讲人 : 林燕<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: 'https://teammodelstorage.blob.core.chinacloudapi.cn/teammodelcontest/20190517/demo/2019.m3u8'
  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. }
  92. },
  93. methods: {
  94. //时间转成秒数
  95. transferTime(time) {
  96. var s = '';
  97. var min = time.split(':')[0];
  98. var sec = time.split(':')[1];
  99. s = Number(min * 60) + Number(sec);
  100. return s;
  101. },
  102. //添加评论
  103. addComment() {
  104. let newComment = {
  105. employeeName: "admin",
  106. content: this.newComment,
  107. createTimeTip: new Date().toLocaleDateString() + ' ' + new Date().toLocaleTimeString()
  108. }
  109. if (newComment.content) {
  110. this.commmentList.unshift(newComment);
  111. } else {
  112. this.$Message.warning("评论内容不能为空!");
  113. }
  114. this.newComment = "";
  115. },
  116. //秒数转成时间格式
  117. transferSecond(s) {
  118. var t;
  119. if (s > -1) {
  120. var hour = Math.floor(s / 3600);
  121. var min = Math.floor(s / 60) % 60;
  122. var sec = s % 60;
  123. if (hour < 10) {
  124. t = '0' + hour + ":";
  125. } else {
  126. t = hour + ":";
  127. }
  128. if (min < 10) { t += "0"; }
  129. t += min + ":";
  130. if (sec < 10) { t += "0"; }
  131. t += sec.toFixed(0);
  132. }
  133. return t;
  134. },
  135. onPlayerPlay(player) {
  136. console.log('player play!', player)
  137. },
  138. onPlayerPause(player) {
  139. console.log('player pause!', player)
  140. },
  141. onPlayerPlaying(player) {
  142. let current = this.transferTime(player.controlBar.currentTimeDisplay.formattedTime_);
  143. let totalSecond = document.getElementsByClassName('vjs-tech')[0].duration;
  144. },
  145. playerReadied(player) {
  146. player.currentTime(120);
  147. },
  148. getPercent(num, total) {
  149. num = parseFloat(num);
  150. total = parseFloat(total);
  151. if (isNaN(num) || isNaN(total)) {
  152. return "-";
  153. }
  154. return total <= 0 ? "0%" : (Math.round(num / total * 10000) / 100.00) + "%";
  155. },
  156. transferArr(arr) {
  157. let newArr = [];
  158. for (let i in arr) {
  159. newArr.push([arr[i].per, arr[i].value, arr[i].contentList]);
  160. }
  161. return newArr;
  162. }
  163. },
  164. mounted() {
  165. let that = this;
  166. this.commmentList = lessonDetails.commentList;
  167. this.expertComments = lessonDetails.expertComments;
  168. let myChart = this.$echarts.init(document.getElementById('views'));
  169. let option = {
  170. calculable: true,
  171. xAxis: [
  172. {
  173. type: 'value',
  174. name: "视频进度",
  175. boundaryGap: false,
  176. axisLabel: {
  177. formatter: '{value}%'
  178. }
  179. }
  180. ],
  181. yAxis: [
  182. {
  183. type: 'value',
  184. name: "专家点评数",
  185. nameGap: 30,
  186. minInterval:1,
  187. axisLabel: {
  188. },
  189. splitLine: { // gird 区域中的分割线
  190. show: false, // 是否显示
  191. },
  192. }
  193. ],
  194. series: [
  195. {
  196. name: '评论数',
  197. type: 'line',
  198. smooth: true,
  199. data: that.transferArr(that.expertComments),
  200. itemStyle: {
  201. normal: {
  202. color: '#66CDAA', //改变折线点的颜色
  203. borderWidth: 5
  204. }
  205. },
  206. lineStyle: {
  207. color: '#66CDAA', //改变折线颜色
  208. width: 3,
  209. },
  210. }
  211. ],
  212. tooltip: {
  213. formatter: function (point) {
  214. let totalSecond = document.getElementsByClassName('vjs-tech')[0].duration;
  215. let time = "点评时间 : " + that.transferSecond(point.value[0] * totalSecond * 0.01) + '</br>';
  216. let list = point.value[2];
  217. let str = "评论内容:</br>"
  218. let content = "";
  219. for (let i in list) {
  220. content = content + list[i].name + ' : ' + list[i].content + '</br>';
  221. }
  222. return time + content
  223. }
  224. }
  225. };
  226. myChart.setOption(option);
  227. myChart.on('click', function (params) {
  228. let totalSecond = document.getElementsByClassName('vjs-tech')[0].duration;
  229. that.$refs.videoPlayer.player.currentTime(totalSecond * parseInt(params.value[0]) * 0.01);
  230. });
  231. },
  232. }
  233. </script>
  234. <style>
  235. .video-page {
  236. width: 1200px;
  237. margin: 100px auto;
  238. }
  239. .video-title {
  240. margin-bottom: 20px;
  241. height: 20px;
  242. }
  243. .video-title-h3 {
  244. height: 20px;
  245. font-size: 20px;
  246. line-height: 20px;
  247. border-left: 6px solid #37b1fa;
  248. padding-left: 12px;
  249. }
  250. .video-info {
  251. width: 100%;
  252. display: table;
  253. }
  254. .comment-video-detail-info {
  255. width: 400px;
  256. background: #ffffff;
  257. display: table-cell;
  258. vertical-align: top;
  259. padding: 20px 10px 20px 30px;
  260. position: relative;
  261. border-left: 15px solid rgb(241,242,243);
  262. }
  263. .comment-video-detail-info .ivu-form-item {
  264. margin-bottom: 8px;
  265. }
  266. .comment-video-detail-info .ivu-form .ivu-form-item-label {
  267. font-size: 14px;
  268. color: #999999;
  269. }
  270. .comment-video-detail-info .ivu-form-item-content {
  271. font-size: 14px;
  272. color: #ffffff;
  273. }
  274. .comment-video-src {
  275. display: table-cell;
  276. width: 780px;
  277. box-sizing: border-box;
  278. padding: 20px 20px;
  279. background: #FFFFFF;
  280. }
  281. .comment-video-src .video-js .vjs-big-play-button {
  282. top: 50%;
  283. left: 50%;
  284. margin-left: -40px;
  285. margin-top: -20px;
  286. }
  287. .download-video {
  288. text-align: center;
  289. position: absolute;
  290. width: 100%;
  291. bottom: 20px;
  292. left: 0;
  293. }
  294. .video-other {
  295. margin-top: 20px;
  296. }
  297. .videos-wrap {
  298. margin: 0px -10px 0px -10px;
  299. }
  300. .video-item {
  301. width: 25%;
  302. display: inline-block;
  303. padding: 0px 10px;
  304. margin-top: 20px;
  305. cursor: pointer;
  306. }
  307. .video-item p {
  308. font-size: 16px;
  309. color: #000;
  310. margin-top: 10px;
  311. text-decoration: none;
  312. text-indent: 8px;
  313. }
  314. .title-header {
  315. color: #666;
  316. margin-right: 30px;
  317. display: inline-block;
  318. }
  319. .liveStatus {
  320. color: #33aafe;
  321. float: right;
  322. }
  323. .review-pane {
  324. height: 700px;
  325. background-color: #fff;
  326. overflow-y: auto;
  327. position: relative;
  328. }
  329. .review-list {
  330. overflow: hidden;
  331. font-size: 14px;
  332. margin: 8px 10px;
  333. padding-bottom: 8px;
  334. border-bottom: 1px solid #f6f6f6;
  335. }
  336. .reviewlist-title {
  337. float: left;
  338. /*width: 22%;*/
  339. color: #999;
  340. text-align: right;
  341. padding-right: 5px;
  342. }
  343. .reviewlist-content {
  344. float: left;
  345. color: #444;
  346. /*width: 76%;*/
  347. font-size: 14px;
  348. word-break: break-all;
  349. }
  350. .lastest-comment {
  351. position: absolute;
  352. top: -5px;
  353. right: 20px;
  354. padding: 5px;
  355. color: #666;
  356. z-index: 999;
  357. cursor: pointer;
  358. }
  359. .publish-review {
  360. padding: 10px;
  361. background-color: #f1f2f3;
  362. border: 1px solid #d7d8da;
  363. font-size: 14px;
  364. color: #333;
  365. width: 100%;
  366. height: 100px;
  367. resize: none;
  368. outline: none;
  369. box-sizing: border-box;
  370. }
  371. .submit-review {
  372. margin-top: 8px;
  373. color: #fff;
  374. background-color: #409eff;
  375. border-color: #409eff;
  376. margin-right: 10px;
  377. display: inline-block;
  378. float: right;
  379. cursor: pointer;
  380. width: 45px;
  381. text-align: center;
  382. height: 22px;
  383. line-height: 22px;
  384. border-radius: 2px;
  385. }
  386. .reviewlist-time {
  387. font-size: 12px;
  388. color: #ccc;
  389. }
  390. .average-score {
  391. margin-top: 20px;
  392. color: #666;
  393. font-size: 14px;
  394. }
  395. .average-score span {
  396. color: #fd8f45;
  397. }
  398. #views {
  399. background: #fff;
  400. padding-top: 30px;
  401. }
  402. </style>