StartUp.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <div class="start-up">
  3. <button
  4. v-show="!isBeginVideo"
  5. v-click-audio
  6. class="begin"
  7. :style="{
  8. left: beginBtnPos.x + 'px',
  9. top: beginBtnPos.y + 'px',
  10. }"
  11. @click="onClickBeginVideo"
  12. >
  13. <img
  14. class=""
  15. src="@/assets/images/btn-begin.png"
  16. alt=""
  17. draggable="false"
  18. >
  19. </button>
  20. <video
  21. ref="startup-video"
  22. v-click-audio
  23. src="@/assets/videos/startup-video.mp4"
  24. @play="onVideoPlay"
  25. @ended="onStartupOver"
  26. @click="onClickVideo"
  27. />
  28. <!-- <transition name="fade-in">
  29. <button
  30. v-show="isShowSkip"
  31. v-click-audio
  32. class="skip"
  33. @click="onStartupOver"
  34. >
  35. 跳&emsp;过
  36. </button>
  37. </transition> -->
  38. </div>
  39. </template>
  40. <script>
  41. import useWindowSizeAdaptor from '@/useFunctions/useWindowSizeAdaptor.js'
  42. import { onMounted, reactive, ref } from "vue"
  43. export default {
  44. name: 'StartUp',
  45. emits: ['begin', 'over'],
  46. setup() {
  47. const { windowSizeWhenDesign, unit } = useWindowSizeAdaptor()
  48. const beginBtnPos = ref({})
  49. // const beginBtnPos = reactive( utils.mapPosFromDraftToWindow({
  50. // x: 1850,
  51. // y: 630,
  52. // }, 'contain'))
  53. function computebeginBtnPos() {
  54. beginBtnPos.value = utils.mapPosFromDraftToWindow({
  55. x: 1850,
  56. y: 630,
  57. }, 'contain')
  58. console.log('更新屏幕', beginBtnPos.value)
  59. }
  60. onMounted(() => {
  61. beginBtnPos.value = utils.mapPosFromDraftToWindow({
  62. x: 1850,
  63. y: 630,
  64. }, 'contain')
  65. window.addEventListener('resize', computebeginBtnPos)
  66. })
  67. return {
  68. windowSizeWhenDesign,
  69. unit,
  70. beginBtnPos
  71. }
  72. },
  73. data() {
  74. return {
  75. isBeginVideo: false,
  76. isShowSkip: false,
  77. }
  78. },
  79. methods: {
  80. onClickBeginVideo() {
  81. this.isBeginVideo = true
  82. this.$refs['startup-video'].play()
  83. this.$emit('begin')
  84. },
  85. onVideoPlay() {
  86. this.isShowSkip = true
  87. // setTimeout(() => {
  88. // this.isShowSkip = true
  89. // }, 3000)
  90. },
  91. onStartupOver() {
  92. this.$emit('over')
  93. },
  94. onClickVideo() {
  95. if (this.isShowSkip) {
  96. this.onStartupOver()
  97. }
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="less" scoped>
  103. .start-up {
  104. position: absolute;
  105. left: 0;
  106. top: 0;
  107. width: 100%;
  108. height: 100%;
  109. background-color: #000;
  110. z-index: 10;
  111. >button.begin {
  112. position: absolute;
  113. right: 5vh;
  114. bottom: 5vh;
  115. z-index: 1;
  116. // left: calc(1850 / v-bind('windowSizeWhenDesign') * v-bind('unit'));
  117. // top: calc(630 / v-bind('windowSizeWhenDesign') * v-bind('unit'));
  118. width: calc(40 / v-bind('windowSizeWhenDesign') * v-bind('unit'));
  119. height: fit-content;
  120. >img {
  121. width: 100%;
  122. }
  123. &:hover {
  124. transform: scale(1.1);
  125. }
  126. }
  127. >video {
  128. position: absolute;
  129. left: 0;
  130. top: 0;
  131. width: 100%;
  132. height: 100%;
  133. }
  134. // >.skip {
  135. // position: absolute;
  136. // top: 70px;
  137. // right: 42px;
  138. // height: 36px;
  139. // width: 120px;
  140. // background-image: url(@/assets/images/btn-skip.png);
  141. // background-size: cover;
  142. // background-repeat: no-repeat;
  143. // background-position: center center;
  144. // font-size: 18px;
  145. // font-family: FZShaoEr-M11-Regular, FZShaoEr-M11;
  146. // font-weight: 400;
  147. // color: #D11414;
  148. // &:hover {
  149. // transform: scale(1.1);
  150. // }
  151. // }
  152. }
  153. </style>