CounterFireGames/src/views/HomeView.vue
2024-06-24 11:27:51 +08:00

192 lines
4.7 KiB
Vue

<template>
<div class="map-container">
<swiper
:direction="'vertical'"
:slidesPerView="1"
:mousewheel="true"
:speed="400"
:pagination="{
clickable: true,
}"
:modules="modules"
ref="mySwiper"
class="mySwiper"
@swiper="onSwiper"
>
<swiper-slide><Banner></Banner></swiper-slide>
<swiper-slide><WhatCounterFire></WhatCounterFire></swiper-slide>
<swiper-slide
><HeroWeaponChipSelector></HeroWeaponChipSelector
></swiper-slide>
<swiper-slide> <GameFeatures></GameFeatures></swiper-slide>
<swiper-slide> <GameVideo></GameVideo></swiper-slide>
<swiper-slide>
<HomeFooter @goToSlide="goToSlide"></HomeFooter
></swiper-slide>
</swiper>
<div class="please" v-if="!isLandscape && isMobileDevice">
<div class="content">
<div class="logo">
<img src="../assets/img/planet/planetGuide_logo.png" alt="" />
</div>
<div>
<div class="phone-logo">
<img src="../assets/img/planet/planetGuide_phoneIcon.png" alt="" />
</div>
<div class="please-text">
Please rotate to horizontal to experience COUNTER FIRE
</div>
</div>
</div>
</div>
</div>
</template>
<script setup>
import { ref, reactive, onMounted, onUnmounted } from "vue";
import { Swiper, SwiperSlide } from "swiper/vue";
import Banner from "../components/home/banner.vue";
import WhatCounterFire from "../components/home/WhatCounterFire.vue";
import HeroWeaponChipSelector from "../components/home/HeroWeaponChipSelector.vue";
import GameFeatures from "../components/home/GameFeatures.vue";
import HomeFooter from "../components/home/HomeFooter.vue";
import GameVideo from "../components/home/GameVideo.vue";
import { Pagination, Navigation, Mousewheel } from "swiper/modules";
import "swiper/css";
import "swiper/css/autoplay";
import "swiper/css/effect-fade";
const modules = [Mousewheel];
const mySwiper = ref(null);
const swiperInstance = ref();
// 嫌麻烦,直接引入了所有 Swiper 样式,包括所有模块样式
// import 'swiper/css/bundle'
const onSlideChange = () => {};
const isLandscape = ref(false);
// 检测是否为移动设备
const isMobileDevice =
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
navigator.userAgent
);
// 更新横屏或竖屏状态
const updateOrientation = () => {
const orientation = window.orientation;
isLandscape.value = orientation === 90 || orientation === -90;
};
function goToSlide(position) {
if (swiperInstance.value) {
swiperInstance.value.slideTo(position);
}
}
function onSwiper(swiper) {
swiperInstance.value = swiper;
}
const resetSwiper = () => {
mySwiper.value.slideTo(0);
};
onMounted(() => {
// mySwiper.value = document.querySelector('.mySwiper').swiper;
if (isMobileDevice) {
// 如果是移动设备,则添加事件监听器
window.addEventListener("orientationchange", updateOrientation);
// 初始化时进行一次检测
updateOrientation();
}
// console.log(isLandscape.value, "-=-=-");
});
onUnmounted(() => {
if (isMobileDevice) {
// 如果是移动设备,则移除事件监听器
window.removeEventListener("orientationchange", updateOrientation);
}
});
</script>
<style lang="scss" scoped>
.map-container {
width: 100%;
height: 100%;
overflow: hidden;
.please {
position: fixed;
z-index: 8888;
background-color: black;
left: 0;
bottom: 0;
top: 0;
width: 100%;
height: 100vh;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
background: url("../assets/img/planet/planetGuide-bg.png") no-repeat;
background-size: 100% 100%;
.content {
display: flex;
flex-direction: column;
height: 60vh;
justify-content: space-between;
align-items: center;
}
.logo {
width: 853px;
height: 248px;
img {
width: 100%;
}
}
.phone-logo {
width: 226px;
height: 226px;
margin: 0 auto;
img {
width: 100%;
}
}
.please-text {
font-size: 22px;
width: 80%;
font-family: "Poppins";
font-weight: 400;
margin: 0 auto;
margin-top: 80px;
text-align: center;
color: #d8d8d8;
}
}
.swiper {
width: 100%;
height: 100%;
}
.swiper-slide {
text-align: center;
font-size: 18px;
background: #fff;
/* Center slide text vertically */
display: flex;
justify-content: center;
align-items: center;
}
.swiper-slide img {
display: block;
width: 100%;
height: 100%;
object-fit: cover;
}
}
</style>