Opening.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <Teleport to="body">
  3. <view class="video-viewer" v-if="isShowVideo">
  4. <video
  5. :playsinline="isMo"
  6. :src="isMo ? 'https://eurs3.4dkankan.com/showcase/hklongxiang/video/opening-new.mp4' : 'https://eurs3.4dkankan.com/showcase/hklongxiang/video/opening-new.mp4'"
  7. autoplay
  8. controls
  9. @play="onVideoPlaying"
  10. @ended="onVideoEnd"
  11. ></video>
  12. <div v-if="showStepper" class="step-in" @click="closeVideo">跳過</div>
  13. <div class="mo_b"></div>
  14. </view>
  15. </Teleport>
  16. </template>
  17. <script setup>
  18. import { ref, onMounted, inject } from "vue";
  19. const isShowVideo = ref(true);
  20. const showStepper = ref(false);
  21. const isMo = inject("isMo");
  22. var showTimer;
  23. const emits = defineEmits(["done", "show-step"]);
  24. const isWeixinBrowser = () => {
  25. var ua = navigator.userAgent.toLowerCase();
  26. return /micromessenger/.test(ua) ? true : false;
  27. };
  28. const closeVideo = () => {
  29. isShowVideo.value = false;
  30. emits("done");
  31. };
  32. onMounted(() => {
  33. if (isWeixinBrowser()) {
  34. closeVideo();
  35. }
  36. // closeVideo()
  37. });
  38. const onVideoPlaying = () => {
  39. showTimer && clearTimeout(showTimer);
  40. showTimer = setTimeout(() => {
  41. showStepper.value = true;
  42. emits("show-step");
  43. }, 3000);
  44. };
  45. const onVideoEnd = () => {
  46. emits("done");
  47. closeVideo();
  48. };
  49. </script>
  50. <style lang="scss">
  51. .video-viewer {
  52. position: fixed;
  53. top: 0;
  54. left: 0;
  55. z-index: 1000000;
  56. width: 100%;
  57. height: 100%;
  58. background: rgba(0, 0, 0, 1);
  59. .step-in {
  60. background: rgba(0, 0, 0, 0.6);
  61. position: absolute;
  62. right: 30px;
  63. top: 30px;
  64. padding: 10px 30px;
  65. border-radius: 20px;
  66. cursor: pointer;
  67. z-index: 1000000;
  68. color: white;
  69. }
  70. video {
  71. width: 100%;
  72. height: 100%;
  73. top: 0;
  74. left: 0;
  75. object-fit: fill;
  76. }
  77. }
  78. .isMo {
  79. .video-viewer {
  80. .mo_b {
  81. background: rgba(0, 0, 0, 0.8);
  82. filter: blur(2px);
  83. position: absolute;
  84. width: 100%;
  85. height: 100%;
  86. z-index: 1;
  87. display: block;
  88. top: 0;
  89. left: 0;
  90. }
  91. video {
  92. object-fit: scale-down;
  93. z-index: 1001;
  94. position: absolute;
  95. }
  96. }
  97. .step-in {
  98. bottom: 80px;
  99. top: initial;
  100. color: white;
  101. background: rgba(0, 0, 0, 1);
  102. transform: translateX(-50%);
  103. left: 50%;
  104. display: inline-block;
  105. text-align: center;
  106. position: fixed;
  107. padding: 10px;
  108. width: 60px;
  109. z-index: 10000;
  110. }
  111. }
  112. </style>