2022-08-30 10:36:30 +08:00
|
|
|
|
<template>
|
2023-08-01 15:50:13 +08:00
|
|
|
|
<div ref="fullPageRef" v-loading="loading" class="fullPage">
|
2022-10-13 17:42:32 +08:00
|
|
|
|
<div class="indicator">
|
|
|
|
|
|
<div
|
2024-03-01 17:29:36 +08:00
|
|
|
|
v-for="idx in 7"
|
|
|
|
|
|
:id="idx.toString()"
|
|
|
|
|
|
:key="idx"
|
|
|
|
|
|
:class="`${indicatorActiveIndex === idx ? 'active' : ''}`"
|
|
|
|
|
|
class="point"
|
|
|
|
|
|
@click="handleIndicatorClick(idx)"
|
2022-10-13 17:42:32 +08:00
|
|
|
|
></div>
|
|
|
|
|
|
</div>
|
2022-10-01 09:12:01 +08:00
|
|
|
|
<div
|
2024-03-01 17:29:36 +08:00
|
|
|
|
ref="fullPageContainerRef"
|
|
|
|
|
|
:data-index="state.fullpage.current"
|
|
|
|
|
|
class="fullPageContainer"
|
|
|
|
|
|
@mousewheel="mouseWheelHandle"
|
2022-10-01 09:12:01 +08:00
|
|
|
|
>
|
|
|
|
|
|
<!-- @DOMMouseScroll="mouseWheelHandle" -->
|
|
|
|
|
|
<div
|
2024-03-01 17:29:36 +08:00
|
|
|
|
v-for="(item, $index) in state.boxList"
|
|
|
|
|
|
:key="$index"
|
|
|
|
|
|
:style="`z-index: ${item.zIndex};`"
|
|
|
|
|
|
class="section"
|
2022-09-20 17:31:39 +08:00
|
|
|
|
>
|
2022-10-13 17:42:32 +08:00
|
|
|
|
<!-- v-if="`index${state.fullpage.current}` == item.title" -->
|
|
|
|
|
|
<component
|
2024-03-01 17:29:36 +08:00
|
|
|
|
:is="item.comp"
|
|
|
|
|
|
v-if="Math.abs(state.fullpage.current - ($index + 1)) <= 1"
|
|
|
|
|
|
:map-index="mapIndex"
|
|
|
|
|
|
@changeMapIndex="mapIndex = $event"
|
2022-10-13 17:42:32 +08:00
|
|
|
|
></component>
|
2022-10-01 09:12:01 +08:00
|
|
|
|
</div>
|
2022-09-20 17:31:39 +08:00
|
|
|
|
</div>
|
2022-08-30 10:36:30 +08:00
|
|
|
|
</div>
|
2022-09-20 17:31:39 +08:00
|
|
|
|
<!-- <div class="home">
|
|
|
|
|
|
<transition-group
|
|
|
|
|
|
:enter-active-class="state.animate.in"
|
|
|
|
|
|
:leave-active-class="state.animate.out"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div
|
|
|
|
|
|
v-for="(item, $index) in state.boxList"
|
|
|
|
|
|
class="box"
|
|
|
|
|
|
:key="$index"
|
|
|
|
|
|
:style="`z-index: ${item.zIndex};`"
|
|
|
|
|
|
v-show="state.showBox === $index"
|
|
|
|
|
|
>
|
|
|
|
|
|
<component :is="item.comp"></component>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</transition-group>
|
|
|
|
|
|
</div>-->
|
2022-08-30 10:36:30 +08:00
|
|
|
|
</template>
|
2022-09-20 17:31:39 +08:00
|
|
|
|
|
2022-10-19 00:22:39 +08:00
|
|
|
|
<script setup>
|
2024-03-01 17:29:36 +08:00
|
|
|
|
import {computed, onMounted, reactive, ref, shallowRef} from "vue";
|
2023-08-01 15:50:13 +08:00
|
|
|
|
import index0 from "./comp/index0.vue";
|
2022-09-20 17:31:39 +08:00
|
|
|
|
import index1 from "./comp/index1.vue";
|
|
|
|
|
|
import index8 from "./comp/index8.vue";
|
2024-03-01 17:29:36 +08:00
|
|
|
|
import index9 from "@/views/website/home/comp/index9.vue";
|
2022-09-20 17:31:39 +08:00
|
|
|
|
|
2022-10-19 00:22:39 +08:00
|
|
|
|
const loading = ref(true);
|
2022-09-20 17:31:39 +08:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
loading.value = false;
|
2022-10-01 09:12:01 +08:00
|
|
|
|
}, 500);
|
|
|
|
|
|
const fullPageRef = ref();
|
|
|
|
|
|
const fullPageContainerRef = ref();
|
2023-08-01 15:50:13 +08:00
|
|
|
|
const mapIndex = ref(0); // 0-3
|
|
|
|
|
|
const mapRef = ref();
|
2022-10-01 09:12:01 +08:00
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
fullPageContainerRef.value.addEventListener(
|
2024-03-01 17:29:36 +08:00
|
|
|
|
"DOMMouseScroll",
|
|
|
|
|
|
mouseWheelHandle
|
2022-10-01 09:12:01 +08:00
|
|
|
|
);
|
|
|
|
|
|
});
|
|
|
|
|
|
// onUnmounted(() => {
|
|
|
|
|
|
// fullPageContainerRef.value.clearEventListener(
|
|
|
|
|
|
// "DOMMouseScroll",
|
|
|
|
|
|
// mouseWheelHandle
|
|
|
|
|
|
// );
|
|
|
|
|
|
// console.log("cleard");
|
|
|
|
|
|
// });
|
2022-10-13 17:42:32 +08:00
|
|
|
|
const len = computed(() => state.boxList.length);
|
|
|
|
|
|
// const len = ref(6);
|
2023-08-01 15:50:13 +08:00
|
|
|
|
|
2022-10-01 09:12:01 +08:00
|
|
|
|
const next = () => {
|
2022-09-20 17:31:39 +08:00
|
|
|
|
// 往下切换
|
2022-10-01 09:12:01 +08:00
|
|
|
|
// TODO:
|
2022-10-13 17:42:32 +08:00
|
|
|
|
// let len = 6; // 页面的个数
|
|
|
|
|
|
if (state.fullpage.current + 1 <= len.value) {
|
2022-09-20 17:31:39 +08:00
|
|
|
|
// 如果当前页面编号+1 小于总个数,则可以执行向下滑动
|
|
|
|
|
|
state.fullpage.current += 1; // 页面+1
|
|
|
|
|
|
move(state.fullpage.current); // 执行切换
|
|
|
|
|
|
}
|
2022-10-01 09:12:01 +08:00
|
|
|
|
};
|
|
|
|
|
|
const pre = () => {
|
2022-09-20 17:31:39 +08:00
|
|
|
|
// 往上切换
|
|
|
|
|
|
if (state.fullpage.current - 1 > 0) {
|
|
|
|
|
|
// 如果当前页面编号-1 大于0,则可以执行向下滑动
|
|
|
|
|
|
state.fullpage.current -= 1; // 页面+1
|
|
|
|
|
|
move(state.fullpage.current); // 执行切换
|
|
|
|
|
|
}
|
2022-10-01 09:12:01 +08:00
|
|
|
|
};
|
2023-08-01 15:50:13 +08:00
|
|
|
|
|
2022-10-19 00:22:39 +08:00
|
|
|
|
function move(index) {
|
2022-09-20 17:31:39 +08:00
|
|
|
|
state.fullpage.isScrolling = true; // 为了防止滚动多页,需要通过一个变量来控制是否滚动
|
|
|
|
|
|
directToMove(index); //执行滚动
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
//这里的动画是1s执行完,使用setTimeout延迟1s后解锁
|
|
|
|
|
|
state.fullpage.isScrolling = false;
|
|
|
|
|
|
}, 1010);
|
|
|
|
|
|
}
|
2023-08-01 15:50:13 +08:00
|
|
|
|
|
2022-10-19 00:22:39 +08:00
|
|
|
|
function directToMove(index) {
|
2022-10-01 09:12:01 +08:00
|
|
|
|
let height = fullPageRef.value["clientHeight"]; //获取屏幕的宽度
|
|
|
|
|
|
// let scrollPage = proxy.$refs["fullPageContainer"]; // 获取执行tarnsform的元素
|
2022-10-19 00:22:39 +08:00
|
|
|
|
let scrollHeight; // 计算滚动的告诉,是往上滚还往下滚
|
2022-09-20 17:31:39 +08:00
|
|
|
|
scrollHeight = -(index - 1) * height + "px";
|
2022-10-01 09:12:01 +08:00
|
|
|
|
fullPageContainerRef.value.style.transform = `translateY(${scrollHeight})`;
|
2022-09-20 17:31:39 +08:00
|
|
|
|
state.fullpage.current = index;
|
|
|
|
|
|
}
|
2023-08-01 15:50:13 +08:00
|
|
|
|
|
2022-09-20 17:31:39 +08:00
|
|
|
|
function mouseWheelHandle(event) {
|
|
|
|
|
|
// 监听鼠标监听
|
|
|
|
|
|
// 添加冒泡阻止
|
|
|
|
|
|
let evt = event || window.event;
|
|
|
|
|
|
if (evt.stopPropagation) {
|
|
|
|
|
|
evt.stopPropagation();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
evt.returnValue = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (state.fullpage.isScrolling) {
|
|
|
|
|
|
// 判断是否可以滚动
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
let e = event.originalEvent || event;
|
|
|
|
|
|
state.fullpage.deltaY = e.deltaY || e.detail; // Firefox使用detail
|
|
|
|
|
|
if (state.fullpage.deltaY > 0) {
|
|
|
|
|
|
next();
|
|
|
|
|
|
} else if (state.fullpage.deltaY < 0) {
|
|
|
|
|
|
pre();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let state = reactive({
|
|
|
|
|
|
fullpage: {
|
|
|
|
|
|
current: 1, // 当前的页面编号
|
|
|
|
|
|
isScrolling: false, // 是否在滚动,是为了防止滚动多页,需要通过一个变量来控制是否滚动
|
|
|
|
|
|
deltaY: 0, // 返回鼠标滚轮的垂直滚动量,保存的鼠标滚动事件的deleteY,用来判断是往下还是往上滚
|
|
|
|
|
|
},
|
|
|
|
|
|
showBox: 0,
|
|
|
|
|
|
boxList: [
|
2022-10-13 17:42:32 +08:00
|
|
|
|
{
|
|
|
|
|
|
comp: shallowRef(index1),
|
|
|
|
|
|
zIndex: 1,
|
|
|
|
|
|
title: "index1",
|
|
|
|
|
|
},
|
2024-03-01 17:29:36 +08:00
|
|
|
|
{
|
|
|
|
|
|
comp: shallowRef(index9),
|
|
|
|
|
|
zIndex: 1,
|
|
|
|
|
|
title: "index9",
|
|
|
|
|
|
},
|
2022-09-20 17:31:39 +08:00
|
|
|
|
{
|
2023-08-01 15:50:13 +08:00
|
|
|
|
comp: shallowRef(index0),
|
2022-09-20 17:31:39 +08:00
|
|
|
|
zIndex: 1,
|
2023-08-01 15:50:13 +08:00
|
|
|
|
title: "index1",
|
2022-09-20 17:31:39 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2022-10-01 09:12:01 +08:00
|
|
|
|
comp: shallowRef(index8),
|
2022-09-20 17:31:39 +08:00
|
|
|
|
zIndex: 1,
|
|
|
|
|
|
title: "index8",
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
|
|
|
|
|
animate: {
|
|
|
|
|
|
in: "animate__animated animate__fadeInDown",
|
|
|
|
|
|
out: "animate__animated animate__fadeOutDown",
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
2022-10-13 17:42:32 +08:00
|
|
|
|
|
2023-08-01 15:50:13 +08:00
|
|
|
|
const indicatorActiveIndex = computed(() => {
|
|
|
|
|
|
if (state.fullpage.current === 1) {
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
} else if (state.fullpage.current === 2) {
|
2024-03-01 17:29:36 +08:00
|
|
|
|
return 2
|
|
|
|
|
|
} else if (state.fullpage.current === 3) {
|
|
|
|
|
|
return mapIndex.value + 3;
|
2023-08-01 15:50:13 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
return state.fullpage.current + 3;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2022-10-13 17:42:32 +08:00
|
|
|
|
// 点击 indicator 时
|
2022-10-19 00:22:39 +08:00
|
|
|
|
const handleIndicatorClick = (idx) => {
|
2023-08-01 15:50:13 +08:00
|
|
|
|
console.log(idx);
|
|
|
|
|
|
let boxIndex;
|
|
|
|
|
|
let _mapIndex;
|
|
|
|
|
|
if (idx === 1) {
|
|
|
|
|
|
boxIndex = 1;
|
|
|
|
|
|
_mapIndex = null;
|
|
|
|
|
|
} else if (idx <= 5) {
|
|
|
|
|
|
boxIndex = 2;
|
|
|
|
|
|
_mapIndex = idx - 2;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
boxIndex = 3;
|
|
|
|
|
|
_mapIndex = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (boxIndex > state.fullpage.current) {
|
|
|
|
|
|
for (let i = state.fullpage.current; i < boxIndex; i++) {
|
2022-10-13 17:42:32 +08:00
|
|
|
|
next();
|
|
|
|
|
|
}
|
2023-08-01 15:50:13 +08:00
|
|
|
|
} else if (boxIndex < state.fullpage.current) {
|
|
|
|
|
|
for (let i = state.fullpage.current; i > boxIndex; i--) {
|
2022-10-13 17:42:32 +08:00
|
|
|
|
pre();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-08-01 15:50:13 +08:00
|
|
|
|
if (_mapIndex !== null && _mapIndex !== mapIndex.value) {
|
|
|
|
|
|
// mapRef.value?.loadMapByIndex(_mapIndex)
|
|
|
|
|
|
// console.log(mapRef.value.loadMapByIndex)
|
|
|
|
|
|
mapIndex.value = _mapIndex;
|
|
|
|
|
|
}
|
2022-10-13 17:42:32 +08:00
|
|
|
|
};
|
2022-10-01 09:12:01 +08:00
|
|
|
|
</script>
|
2022-09-20 17:31:39 +08:00
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
.fullPage {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
overflow: hidden;
|
2022-10-13 17:42:32 +08:00
|
|
|
|
position: relative;
|
2023-08-01 15:50:13 +08:00
|
|
|
|
|
2022-10-13 17:42:32 +08:00
|
|
|
|
.indicator {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 50%;
|
|
|
|
|
|
right: 20px;
|
|
|
|
|
|
z-index: 999;
|
|
|
|
|
|
transform: translateY(-50%);
|
2023-08-01 15:50:13 +08:00
|
|
|
|
|
2022-10-13 17:42:32 +08:00
|
|
|
|
.point {
|
|
|
|
|
|
transition: all 1s;
|
|
|
|
|
|
width: 12px;
|
|
|
|
|
|
height: 12px;
|
|
|
|
|
|
background-color: #999;
|
|
|
|
|
|
border-radius: 50%;
|
2023-08-01 15:50:13 +08:00
|
|
|
|
|
2022-10-13 17:42:32 +08:00
|
|
|
|
&.active {
|
|
|
|
|
|
background-color: #0054ff;
|
|
|
|
|
|
}
|
2023-08-01 15:50:13 +08:00
|
|
|
|
|
2022-10-13 17:42:32 +08:00
|
|
|
|
&:not(:last-child) {
|
|
|
|
|
|
margin-bottom: 6px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2022-09-20 17:31:39 +08:00
|
|
|
|
}
|
2023-08-01 15:50:13 +08:00
|
|
|
|
|
2022-09-20 17:31:39 +08:00
|
|
|
|
.fullPageContainer {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
transition: all linear 0.5s;
|
|
|
|
|
|
}
|
2023-08-01 15:50:13 +08:00
|
|
|
|
|
2022-09-20 17:31:39 +08:00
|
|
|
|
.section {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
background-position: center center;
|
|
|
|
|
|
background-repeat: no-repeat;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|