index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <div class="welcome">
  3. <template v-show="!isVideo">
  4. <img class="bg" :style="{'z-index': isVideo?-1:0,opacity:isVideo?0:1}" :src="require('@/assets/images/bg.jpg')" alt="">
  5. <div v-if="!isVideo" class="we_title">欢迎访问信息工程大学数字史馆</div>
  6. <span v-if="!isVideo" class="btn" @click="showVideo">开始预览</span>
  7. </template>
  8. <video @click="autoplay" ref="welcome" :style="{opacity:isVideo?1:0}" preload="auto" :poster="require('@/assets/images/videopost.jpg')" :src="require('@/assets/video/welcome.mp4')"></video>
  9. <span v-if="isVideo" class="btn jump" @click="$bus.$emit('toggleWelcome', false)">跳过</span>
  10. </div>
  11. </template>
  12. <script>
  13. export default {
  14. data(){
  15. return {
  16. isVideo: false
  17. }
  18. },
  19. methods:{
  20. autoplay(){
  21. this.$nextTick(()=> {
  22. setTimeout(() => {
  23. this.$refs.welcome.play();
  24. });
  25. })
  26. },
  27. showVideo(){
  28. this.isVideo=true
  29. this.autoplay()
  30. }
  31. },
  32. mounted(){
  33. this.$nextTick(()=> {
  34. this.$refs.welcome && this.$refs.welcome.addEventListener('ended',()=>{
  35. this.$bus.$emit('toggleWelcome', false)
  36. })
  37. })
  38. // this.autoplay()
  39. }
  40. }
  41. </script>
  42. <style lang="less">
  43. .welcome{
  44. position: fixed;
  45. top: 0;
  46. left: 0;
  47. width: 100%;
  48. height: 100%;
  49. background-color: #000;
  50. z-index: 999;
  51. transition: all ease 0.3s;
  52. .bg{
  53. width: 100%;
  54. height: 100%;
  55. position: absolute;
  56. top: 50%;
  57. left: 50%;
  58. transform: translate(-50%,-50%);
  59. }
  60. .we_title{
  61. background: none;
  62. position: absolute;
  63. top: 35%;
  64. left: 50%;
  65. transform: translate(-50%,-50%);
  66. font-size: 48px;
  67. color: #FCD67B;
  68. letter-spacing: 6px;
  69. font-weight: bold;
  70. width: 100%;
  71. text-align: center;
  72. }
  73. >video{
  74. width: 100%;
  75. }
  76. .btn{
  77. position: absolute;
  78. top: 50%;
  79. left: 50%;
  80. transform: translate(-50%,-50%);
  81. z-index: 9999;
  82. font-size: 18px;
  83. color: #FCD67B;
  84. background-color: #A01C26;
  85. border-radius: 44px;
  86. display: inline-block;
  87. cursor: pointer;
  88. letter-spacing: 2px;
  89. padding: 12px 60px;
  90. }
  91. .jump{
  92. transform: none;
  93. bottom: 47px;
  94. right: 66px;
  95. top: auto;
  96. left: auto;
  97. }
  98. }
  99. </style>