index.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <div class="welcome">
  3. <div class="videoBox" v-if="videoShow">
  4. <video
  5. ref="myVideo"
  6. src="../../assets/myData/play.mp4"
  7. autoplay
  8. muted
  9. ></video>
  10. <div class="button" v-if="time" @click="videoShow = false">
  11. <img src="../../assets/myData/btn1.png" alt="" />
  12. </div>
  13. </div>
  14. <div class="imgBox" v-else>
  15. <div class="button" @click.stop="$emit('close')">
  16. <img src="../../assets/myData/btn2.png" alt="" />
  17. </div>
  18. </div>
  19. </div>
  20. </template>
  21. <script>
  22. export default {
  23. data() {
  24. return {
  25. videoShow: true,
  26. time: false,
  27. };
  28. },
  29. methods: {},
  30. mounted() {
  31. // 监听视频播放完毕
  32. this.$refs.myVideo.addEventListener("ended", () => {
  33. this.videoShow = false;
  34. });
  35. setTimeout(() => {
  36. this.time = true;
  37. }, 1000);
  38. },
  39. };
  40. </script>
  41. <style lang="less">
  42. .welcome {
  43. position: fixed;
  44. top: 0;
  45. left: 0;
  46. width: 100%;
  47. height: 100%;
  48. z-index: 9999;
  49. font-size: 0;
  50. transition: all ease 0.3s;
  51. background-color: black;
  52. .videoBox {
  53. position: absolute;
  54. top: 0;
  55. left: 0;
  56. width: 100%;
  57. height: 100%;
  58. video {
  59. position: absolute;
  60. top: 0;
  61. left: 0;
  62. width: 100%;
  63. height: 100%;
  64. }
  65. }
  66. .imgBox {
  67. position: absolute;
  68. top: 0;
  69. left: 0;
  70. width: 100%;
  71. height: 100%;
  72. background-image: url("../../assets/myData/bg.jpg");
  73. background-size: 100% 100%;
  74. }
  75. .button {
  76. position: absolute;
  77. bottom: 100px;
  78. left: 50%;
  79. transform: translateX(-50%);
  80. cursor: pointer;
  81. & > img {
  82. width: 260px;
  83. }
  84. }
  85. }
  86. </style>