index.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <div class="simple-video-player">
  3. <van-popup v-model="show" position="center" :closeable="true">
  4. <div class="pupup-content">
  5. <video
  6. :src="videoSrc"
  7. controls
  8. ref="video"
  9. class="video"
  10. :style="{ height: videoHeight }"
  11. ></video>
  12. <div class="desc" v-if="description">{{ description }}</div>
  13. </div>
  14. </van-popup>
  15. </div>
  16. </template>
  17. <script>
  18. export default {
  19. props: {
  20. videoSrc: {
  21. type: String,
  22. default: '',
  23. },
  24. description: {
  25. type: String,
  26. default: '',
  27. },
  28. },
  29. data() {
  30. return {
  31. show: false,
  32. }
  33. },
  34. computed: {
  35. videoHeight() {
  36. return this.description ? '92vh' : '100vh'
  37. },
  38. },
  39. watch: {
  40. show(nVal) {
  41. this.$nextTick(() => {
  42. nVal ? this.$refs.video.play() : this.$refs.video.pause()
  43. })
  44. },
  45. },
  46. methods: {
  47. open() {
  48. this.show = true
  49. },
  50. },
  51. }
  52. </script>
  53. <style scoped lang="scss">
  54. .simple-video-player {
  55. .pupup-content {
  56. position: relative;
  57. width: 100vw;
  58. height: 100vh;
  59. background: #000;
  60. }
  61. .video {
  62. margin: 0 auto;
  63. height: 92vh;
  64. }
  65. @media screen and (min-width: 768px) {
  66. .desc {
  67. position: absolute;
  68. height: 48px;
  69. left: 0;
  70. bottom: 16px;
  71. padding: 0 32px;
  72. line-height: 24px;
  73. font-size: 14px;
  74. color: #fff;
  75. box-sizing: border-box;
  76. background: rgba(0, 0, 0, 0.5);
  77. text-align: justify;
  78. @include ellipsis(2);
  79. }
  80. }
  81. @media screen and (max-width: 768px) {
  82. .desc {
  83. position: absolute;
  84. height: 10.4vw;
  85. left: 0;
  86. bottom: 4vw;
  87. padding: 0 4vw;
  88. line-height: 5.2vw;
  89. font-size: 3.2vw;
  90. color: #fff;
  91. box-sizing: border-box;
  92. background: rgba(0, 0, 0, 0.5);
  93. text-align: justify;
  94. @include ellipsis(2);
  95. }
  96. }
  97. }
  98. </style>