123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <template>
- <div class="welcome">
- <template v-show="!isVideo">
- <img class="bg" :style="{'z-index': isVideo?-1:0,opacity:isVideo?0:1}" :src="require('@/assets/images/bg.jpg')" alt="">
- <div v-if="!isVideo" class="we_title">欢迎访问信息工程大学数字史馆</div>
- <span v-if="!isVideo" class="btn" @click="showVideo">开始预览</span>
- </template>
- <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>
- <span v-if="isVideo" class="btn jump" @click="$bus.$emit('toggleWelcome', false)">跳过</span>
- </div>
- </template>
- <script>
- export default {
- data(){
- return {
- isVideo: false
- }
- },
- methods:{
- autoplay(){
- this.$nextTick(()=> {
- setTimeout(() => {
- this.$refs.welcome.play();
- });
- })
- },
- showVideo(){
- this.isVideo=true
- this.autoplay()
- }
- },
- mounted(){
- this.$nextTick(()=> {
- this.$refs.welcome && this.$refs.welcome.addEventListener('ended',()=>{
- this.$bus.$emit('toggleWelcome', false)
- })
- })
-
- // this.autoplay()
- }
- }
- </script>
- <style lang="less">
- .welcome{
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background-color: #000;
- z-index: 999;
- transition: all ease 0.3s;
- .bg{
- width: 100%;
- height: 100%;
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%,-50%);
-
- }
- .we_title{
- background: none;
- position: absolute;
- top: 35%;
- left: 50%;
- transform: translate(-50%,-50%);
- font-size: 48px;
- color: #FCD67B;
- letter-spacing: 6px;
- font-weight: bold;
- width: 100%;
- text-align: center;
- }
- >video{
- width: 100%;
- }
- .btn{
- position: absolute;
- top: 50%;
- left: 50%;
- transform: translate(-50%,-50%);
- z-index: 9999;
- font-size: 18px;
- color: #FCD67B;
- background-color: #A01C26;
- border-radius: 44px;
- display: inline-block;
- cursor: pointer;
- letter-spacing: 2px;
- padding: 12px 60px;
- }
- .jump{
- transform: none;
- bottom: 47px;
- right: 66px;
- top: auto;
- left: auto;
- }
- }
- </style>
|