course-video.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <div class="video-container">
  3. <div class="video-box">
  4. <span>
  5. <img :src="imgUrl" :alt="title">
  6. <i @click="playVideo"></i>
  7. </span>
  8. <p>{{ title }}</p>
  9. </div>
  10. <!-- 视频播放弹窗 -->
  11. <el-dialog
  12. :title="dialogTitle"
  13. :visible.sync="videoDialogFlag"
  14. @close="closeVideoDialog"
  15. class="course-video-dialog"
  16. center>
  17. <video controls :src="curSource" class="course-video-box"></video>
  18. </el-dialog>
  19. </div>
  20. </template>
  21. <script>
  22. export default {
  23. name: "course-video",
  24. props: {
  25. source: {
  26. type: String,
  27. require: '',
  28. },
  29. title: {
  30. type: String,
  31. default: ''
  32. },
  33. dialogTitle: {
  34. type: String,
  35. default: ''
  36. },
  37. imgUrl: {
  38. type: String,
  39. default: ''
  40. }
  41. },
  42. data() {
  43. return {
  44. videoDialogFlag: false,
  45. curSource: '',
  46. }
  47. },
  48. methods: {
  49. closeVideoDialog() {
  50. this.videoDialogFlag = false;
  51. this.curSource = "";
  52. },
  53. playVideo() {
  54. this.videoDialogFlag = true;
  55. this.curSource = this.source;
  56. }
  57. }
  58. }
  59. </script>
  60. <style lang="scss" scoped>
  61. .video-container {
  62. width: 380px;
  63. height: 280px;
  64. .video-box {
  65. text-align: center;
  66. > span {
  67. position: relative;
  68. display: inline-block;
  69. }
  70. p {
  71. height: 23px;
  72. font-size: 24px;
  73. font-weight: 400;
  74. color: #333333;
  75. }
  76. i:hover {
  77. background-image: url("~static/images/client/course/course-video-icon-a.svg");
  78. background-size: cover;
  79. background-position: bottom;
  80. }
  81. i {
  82. width: 48px;
  83. height: 48px;
  84. cursor: pointer;
  85. background-image: url("~static/images/client/course/course-video-icon.svg");
  86. display: inline-block;
  87. position: absolute;
  88. left: 50%;
  89. margin-left: -24px;
  90. z-index: 5;
  91. top: 50%;
  92. margin-top: -24px;
  93. background-size: cover;
  94. background-position: bottom;
  95. transition: all 0.5s;
  96. }
  97. img {
  98. width: 100%;
  99. }
  100. }
  101. }
  102. </style>