index.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. @mixin ellipsis($line: 1) {
  55. overflow: hidden;
  56. text-overflow: ellipsis;
  57. display: -webkit-box;
  58. -webkit-line-clamp: $line;
  59. -webkit-box-orient: vertical;
  60. }
  61. .simple-video-player {
  62. .pupup-content {
  63. position: relative;
  64. width: 100vw;
  65. height: 100vh;
  66. background: #000;
  67. }
  68. .video {
  69. margin: 0 auto;
  70. height: 92vh;
  71. }
  72. @media screen and (min-width: 768px) {
  73. .desc {
  74. position: absolute;
  75. height: 48px;
  76. left: 0;
  77. bottom: 16px;
  78. padding: 0 32px;
  79. line-height: 24px;
  80. font-size: 14px;
  81. color: #fff;
  82. box-sizing: border-box;
  83. background: rgba(0, 0, 0, 0.5);
  84. text-align: justify;
  85. @include ellipsis(2);
  86. }
  87. }
  88. @media screen and (max-width: 768px) {
  89. .desc {
  90. position: absolute;
  91. height: 10.4vw;
  92. left: 0;
  93. bottom: 4vw;
  94. padding: 0 4vw;
  95. line-height: 5.2vw;
  96. font-size: 3.2vw;
  97. color: #fff;
  98. box-sizing: border-box;
  99. background: rgba(0, 0, 0, 0.5);
  100. text-align: justify;
  101. @include ellipsis(2);
  102. }
  103. }
  104. }
  105. </style>