course-video.vue 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <div class="video-item-box">
  3. <i @click="playVideo" class="video-play-btn"></i>
  4. <img :src="imgUrl" :alt="videoData.title">
  5. <p>
  6. <span v-if="videoData.title">展现:{{ videoData.title }}</span>
  7. <span v-if="showTitle">用途:{{videoData.purpose}}</span></p>
  8. <!-- 视频播放弹窗 -->
  9. <el-dialog
  10. :title="videoData.title"
  11. :visible.sync="videoDialogFlag"
  12. @close="closeVideoDialog"
  13. class="course-video-dialog course-h5-padding-bottom-10"
  14. center>
  15. <video controls :src="curSource" class="course-video-box"></video>
  16. </el-dialog>
  17. </div>
  18. </template>
  19. <script>
  20. export default {
  21. name: "course-video",
  22. props: {
  23. source: {
  24. type: String,
  25. require: '',
  26. },
  27. videoData: {
  28. type: Object,
  29. default: () => ({})
  30. },
  31. imgUrl: {
  32. type: String,
  33. default: ''
  34. },
  35. showTitle: {
  36. type: Boolean,
  37. default: true
  38. }
  39. },
  40. data() {
  41. return {
  42. videoDialogFlag: false,
  43. curSource: '',
  44. }
  45. },
  46. methods: {
  47. closeVideoDialog() {
  48. this.videoDialogFlag = false;
  49. this.curSource = "";
  50. },
  51. playVideo() {
  52. this.videoDialogFlag = true;
  53. this.curSource = this.source;
  54. }
  55. }
  56. }
  57. </script>
  58. <style lang="scss" scoped>
  59. .video-item-box{
  60. width: 352px;background: rgba(18,107,255,0.12);margin: 0;
  61. border: 1px solid #ffffff;border-radius: 10px;padding: 10px;
  62. box-sizing: border-box;position: relative;justify-content: space-between;
  63. display: flex;align-items: center;
  64. img{width: 330px;height:186px;border-radius: 8px;z-index: 8;}
  65. p{
  66. color: #fdfdfd;font-size: 14px;display: flex;justify-content: space-between;
  67. left: 70px;right: -10px;bottom: -2px;z-index: 11;position: absolute;letter-spacing: 1px;
  68. }
  69. .video-play-btn{
  70. width: 70px;height: 70px;position: absolute;z-index: 10;background-size: cover;background-position: center;
  71. background-image: url("~static/images/client/course/animation-video-img1.png");background-repeat: no-repeat;
  72. right: -15px;bottom: 30px;transition: 0.5s;
  73. }
  74. .video-play-btn:hover{transform: scale(1.1);cursor: pointer;}
  75. }
  76. .video-item-box:before,.video-item-box:after{content: ' ';position: absolute;display: block;background-repeat: no-repeat;background-size: contain;}
  77. .video-item-box:before{width: 357px;height: 99px;background-image: url("~static/images/client/course/animation-video-img2.png");bottom: -30px;right: -44px;z-index: 9;}
  78. .video-item-box:after{width: 95px;height: 160px;background-image: url("~static/images/client/course/animation-video-img3.png");bottom: 20px;right: -30px;z-index: 7;transform: rotateY(180deg);}
  79. @media (max-width: 768px){
  80. .video-item-box{
  81. width: 90%;margin: 0 auto 16px;
  82. img{width: 100%;}
  83. .video-play-btn{width: 30%;height: 30%;top: 50%;left: 50%;transform: translate(-50%,-50%);background-size: contain;}
  84. p{font-size: 14px;left: 10px;right: 10px;bottom: 10px;padding: 6px 12px;
  85. background: #006cf8;border-radius: 0 0 8px 8px;box-sizing: border-box;}
  86. }
  87. .video-item-box:before{display: none;}
  88. .video-item-box:after{display: none;}
  89. .course-h5-padding-bottom-10 {
  90. ::v-deep .el-dialog__body {
  91. padding-bottom: 15px;
  92. }
  93. }
  94. }
  95. </style>