首页地图

This commit is contained in:
cxc
2022-10-01 09:12:01 +08:00
parent 25ed1387a7
commit e8fb69f0e3
56 changed files with 4910 additions and 941 deletions

View File

@ -1,26 +1,22 @@
<template>
<div v-loading="loading" class="fullPage" ref="fullPage">
<div class="fullPageContainer" ref="fullPageContainer">
<!-- <div
<div v-loading="loading" class="fullPage" ref="fullPageRef">
<div
class="fullPageContainer"
:data-index="state.fullpage.current"
ref="fullPageContainerRef"
@mousewheel="mouseWheelHandle"
>
<!-- @DOMMouseScroll="mouseWheelHandle" -->
<div
v-for="(item, $index) in state.boxList"
class="section"
:key="$index"
:style="`z-index: ${item.zIndex};`"
>
<component :is="item.comp"></component>
</div> -->
<!-- <div class="section"><index1></index1></div>
<div class="section"><index2 /></div>
<div class="section"><index3 /></div>
<div class="section"><index4 /></div>
<div class="section"><index5 /></div>
<div class="section"><index6 /></div>
<div class="section"><index7 /></div>
<div class="section"><index8 /></div>-->
</div>
</div>
</div>
<!-- <div class="home">
<transition-group
:enter-active-class="state.animate.in"
@ -40,88 +36,7 @@
</template>
<script setup lang="ts">
import { ref } from "vue";
const loading = ref<boolean>(true);
// let state = reactive({
// fullpage: {
// current: 1, // 当前的页面编号
// isScrolling: false, // 是否在滚动,是为了防止滚动多页,需要通过一个变量来控制是否滚动
// deltaY: 0, // 返回鼠标滚轮的垂直滚动量保存的鼠标滚动事件的deleteY,用来判断是往下还是往上滚
// },
// showBox: 0,
// boxList: [
// {
// comp: index1,
// zIndex: 1,
// title: "index1",
// },
// {
// comp: index2,
// zIndex: 1,
// title: "index2",
// },
// {
// comp: index3,
// zIndex: 1,
// title: "index3",
// },
// {
// comp: index4,
// zIndex: 1,
// title: "index4",
// },
// {
// comp: index5,
// zIndex: 1,
// title: "index5",
// },
// {
// comp: index6,
// zIndex: 1,
// title: "index6",
// },
// {
// comp: index7,
// zIndex: 1,
// title: "index7",
// },
// {
// comp: index8,
// zIndex: 1,
// title: "index8",
// },
// ],
// animate: {
// in: "animate__animated animate__fadeInDown",
// out: "animate__animated animate__fadeOutDown",
// },
// });
// const 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();
// }
// };
</script>
<!-- <script setup lang="ts">
import { reactive, onMounted, getCurrentInstance, ref } from "vue";
const { proxy } = getCurrentInstance();
import { reactive, onMounted, ref, shallowRef, onUnmounted } from "vue";
import index1 from "./comp/index1.vue";
import index2 from "./comp/index2.vue";
import index3 from "./comp/index3.vue";
@ -131,30 +46,44 @@ import index6 from "./comp/index6.vue";
import index7 from "./comp/index7.vue";
import index8 from "./comp/index8.vue";
const loading = ref(true);
const loading = ref<boolean>(true);
setTimeout(() => {
loading.value = false;
}, 1000);
onMounted(() => {});
function next() {
}, 500);
const fullPageRef = ref();
const fullPageContainerRef = ref();
onMounted(() => {
fullPageContainerRef.value.addEventListener(
"DOMMouseScroll",
mouseWheelHandle
);
});
// onUnmounted(() => {
// fullPageContainerRef.value.clearEventListener(
// "DOMMouseScroll",
// mouseWheelHandle
// );
// console.log("cleard");
// });
const next = () => {
// 往下切换
let len = 8; // 页面的个数
// TODO:
let len = 7; // 页面的个数
if (state.fullpage.current + 1 <= len) {
// 如果当前页面编号+1 小于总个数,则可以执行向下滑动
state.fullpage.current += 1; // 页面+1
move(state.fullpage.current); // 执行切换
}
}
function pre() {
};
const pre = () => {
// 往上切换
if (state.fullpage.current - 1 > 0) {
// 如果当前页面编号-1 大于0则可以执行向下滑动
state.fullpage.current -= 1; // 页面+1
move(state.fullpage.current); // 执行切换
}
}
function move(index) {
};
function move(index: number) {
state.fullpage.isScrolling = true; // 为了防止滚动多页,需要通过一个变量来控制是否滚动
directToMove(index); //执行滚动
setTimeout(() => {
@ -162,12 +91,12 @@ function move(index) {
state.fullpage.isScrolling = false;
}, 1010);
}
function directToMove(index) {
let height = proxy.$refs["fullPage"]["clientHeight"]; //获取屏幕的宽度
let scrollPage = proxy.$refs["fullPageContainer"]; // 获取执行tarnsform的元素
let scrollHeight; // 计算滚动的告诉,是往上滚还往下滚
function directToMove(index: number) {
let height = fullPageRef.value["clientHeight"]; //获取屏幕的宽度
// let scrollPage = proxy.$refs["fullPageContainer"]; // 获取执行tarnsform的元素
let scrollHeight: string; // 计算滚动的告诉,是往上滚还往下滚
scrollHeight = -(index - 1) * height + "px";
scrollPage.style.transform = `translateY(${scrollHeight})`;
fullPageContainerRef.value.style.transform = `translateY(${scrollHeight})`;
state.fullpage.current = index;
}
function mouseWheelHandle(event) {
@ -200,43 +129,43 @@ let state = reactive({
},
showBox: 0,
boxList: [
// {
// comp: shallowRef(index1),
// zIndex: 1,
// title: "index1",
// },
// {
// comp: shallowRef(index2),
// zIndex: 1,
// title: "index2",
// },
{
comp: index1,
zIndex: 1,
title: "index1",
},
{
comp: index2,
zIndex: 1,
title: "index2",
},
{
comp: index3,
comp: shallowRef(index3),
zIndex: 1,
title: "index3",
},
{
comp: index4,
comp: shallowRef(index4),
zIndex: 1,
title: "index4",
},
{
comp: index5,
comp: shallowRef(index5),
zIndex: 1,
title: "index5",
},
{
comp: index6,
comp: shallowRef(index6),
zIndex: 1,
title: "index6",
},
{
comp: index7,
comp: shallowRef(index7),
zIndex: 1,
title: "index7",
},
{
comp: index8,
comp: shallowRef(index8),
zIndex: 1,
title: "index8",
},
@ -246,7 +175,7 @@ let state = reactive({
out: "animate__animated animate__fadeOutDown",
},
});
</script> -->
</script>
<style lang="scss" scoped>
.fullPage {