index.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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: -1;
  55. height: 100%;
  56. width: auto;
  57. object-fit: fill;
  58. // filter: blur(10px);
  59. }
  60. .vmask {
  61. position: absolute;
  62. left: 0;
  63. top: 0;
  64. bottom: 0;
  65. right: 0;
  66. display: inline-block;
  67. z-index: 0;
  68. backdrop-filter: blur(10px);
  69. }
  70. .video {
  71. width: 100%;
  72. height: 100%;
  73. display: table-cell;
  74. text-align: center;
  75. vertical-align: middle;
  76. position: relative;
  77. z-index: 9;
  78. }
  79. .jump {
  80. position: absolute;
  81. right: 15px;
  82. top: 20px;
  83. width: 56px;
  84. height: 28px;
  85. background: rgba(0, 0, 0, 0.5);
  86. border-radius: 16px;
  87. text-align: center;
  88. line-height: 28px;
  89. z-index: 999;
  90. }
  91. }
  92. </style>