index.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <transition appear name="custom-classes-transition" leave-active-class="animated fadeOut faster">
  3. <div class="open-video">
  4. <div class="vmask"></div>
  5. <video x5-playsinline="true" playsinline="true" webkit-playsinline="true" class="bgvideo" preload autoplay :src="videourl"></video>
  6. <video x5-playsinline="true" playsinline="true" webkit-playsinline="true" class="video" ref="openvideo$" preload autoplay :src="videourl"></video>
  7. <div @click.stop="emit('close')" class="jump">跳過</div>
  8. </div>
  9. </transition>
  10. </template>
  11. <script setup>
  12. import { ref, watch, defineEmits, computed, onMounted, nextTick, defineProps } from "vue";
  13. import * as apis from "@/apis/index.js";
  14. const openvideo$ = ref(null);
  15. const videourl = ref(null);
  16. const emit = defineEmits(["close"]);
  17. onMounted(() => {
  18. nextTick(async () => {
  19. let res = await apis.get_video();
  20. if (!res.data) {
  21. return emit("close");
  22. }
  23. videourl.value = res.data.videoUrl;
  24. openvideo$.value.addEventListener("ended", () => {
  25. emit("close");
  26. });
  27. document.addEventListener(
  28. "WeixinJSBridgeReady",
  29. () => {
  30. openvideo$.value.play();
  31. },
  32. false
  33. );
  34. });
  35. });
  36. </script>
  37. <style lang="scss" scoped>
  38. .open-video {
  39. position: fixed;
  40. width: 100%;
  41. height: 100%;
  42. top: 0;
  43. left: 0;
  44. right: 0;
  45. bottom: 0;
  46. display: table;
  47. table-layout: fixed;
  48. .bgvideo {
  49. position: absolute;
  50. left: 0;
  51. top: 0;
  52. bottom: 0;
  53. right: 0;
  54. z-index: -2;
  55. height: 100%;
  56. z-index: 0;
  57. width: auto;
  58. object-fit: fill;
  59. // filter: blur(10px);
  60. }
  61. .vmask {
  62. position: absolute;
  63. left: 0;
  64. top: 0;
  65. bottom: 0;
  66. right: 0;
  67. display: inline-block;
  68. z-index: -1;
  69. backdrop-filter: blur(10px);
  70. }
  71. .video {
  72. width: 100%;
  73. height: 100%;
  74. display: table-cell;
  75. text-align: center;
  76. vertical-align: middle;
  77. }
  78. .jump {
  79. position: absolute;
  80. right: 15px;
  81. top: 20px;
  82. width: 56px;
  83. height: 28px;
  84. background: rgba(0, 0, 0, 0.5);
  85. border-radius: 16px;
  86. text-align: center;
  87. line-height: 28px;
  88. z-index: 999;
  89. }
  90. }
  91. </style>