Browse Source

新增下拉菜单页面

dev_230517
zhangzhiyi 2 years ago
parent
commit
6945a158b6
  1. BIN
      src/assets/imgs/drop-down-menu/func-gaowenshajun@2x.png
  2. BIN
      src/assets/imgs/drop-down-menu/func-jiankang@2x.png
  3. BIN
      src/assets/imgs/drop-down-menu/func-jieneng@2x.png
  4. BIN
      src/assets/imgs/drop-down-menu/func-set@2x.png
  5. BIN
      src/assets/imgs/drop-down-menu/func-shuju@2x.png
  6. BIN
      src/assets/imgs/drop-down-menu/func-tongsuo@2x.png
  7. BIN
      src/assets/imgs/drop-down-menu/func-xiping@2x.png
  8. BIN
      src/assets/imgs/drop-down-menu/func-zhenduan@2x.png
  9. BIN
      src/assets/imgs/drop-down-menu/func-ziqingjie@2x.png
  10. BIN
      src/assets/imgs/drop-down-menu/retract@2x.png
  11. 114
      src/view/drop-down-menu/drop-down-menu.vue
  12. 4
      src/view/tabs/device-control.vue
  13. 59
      src/view/tabs/home-screen.vue
  14. 124
      src/view/tabs/tabs.vue

BIN
src/assets/imgs/drop-down-menu/func-gaowenshajun@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

BIN
src/assets/imgs/drop-down-menu/func-jiankang@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

BIN
src/assets/imgs/drop-down-menu/func-jieneng@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

BIN
src/assets/imgs/drop-down-menu/func-set@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

BIN
src/assets/imgs/drop-down-menu/func-shuju@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
src/assets/imgs/drop-down-menu/func-tongsuo@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

BIN
src/assets/imgs/drop-down-menu/func-xiping@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
src/assets/imgs/drop-down-menu/func-zhenduan@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
src/assets/imgs/drop-down-menu/func-ziqingjie@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

BIN
src/assets/imgs/drop-down-menu/retract@2x.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

114
src/view/drop-down-menu/drop-down-menu.vue

@ -0,0 +1,114 @@ @@ -0,0 +1,114 @@
<template>
<div class="drop-down-menu-wrapper">
<div class="content-top">
<!-- 功能容器 -->
<div
class="func-wrapper"
v-for="i in funcList"
:key="i"
>
<img :src="i.img" class="func-img" width="100%">
<span class="func-text">{{ i.text }}</span>
</div>
</div>
<div class="content-btm" @click="pullUp()">
<img src="@/assets/imgs/drop-down-menu/retract@2x.png" width="100%">
</div>
</div>
</template>
<script lang="ts" setup>
import {ref, onMounted} from 'vue';
const funcList = ref<any[]>([]);
const emit = defineEmits(['pullUp'])
onMounted(() => {
funcList.value = [
{
img: '/src/assets/imgs/drop-down-menu/func-xiping@2x.png',
text: '息屏'
}, {
img: '/src/assets/imgs/drop-down-menu/func-tongsuo@2x.png',
text: '童锁'
}, {
img: '/src/assets/imgs/drop-down-menu/func-jiankang@2x.png',
text: '健康'
}, {
img: '/src/assets/imgs/drop-down-menu/func-ziqingjie@2x.png',
text: '自清洁'
}, {
img: '/src/assets/imgs/drop-down-menu/func-gaowenshajun@2x.png',
text: '高温除菌'
}, {
img: '/src/assets/imgs/drop-down-menu/func-shuju@2x.png',
text: '数据中心'
}, {
img: '/src/assets/imgs/drop-down-menu/func-jieneng@2x.png',
text: '节能'
}, {
img: '/src/assets/imgs/drop-down-menu/func-set@2x.png',
text: '设置'
}, {
img: '/src/assets/imgs/drop-down-menu/func-zhenduan@2x.png',
text: '智慧健康诊断'
},
];
})
/** 窗口上弹事件 */
const pullUp = () => {
emit('pullUp');
}
</script>
<style lang="scss" scoped>
.drop-down-menu-wrapper {
width: 100vw;
height: 100vh;
background-color: #0A101A;
overflow: hidden;
.content-top {
padding: 19px 24px;
display: flex;
justify-content: space-between;
flex-wrap: wrap;
.func-wrapper {
width: 210px;
height: 200px;
border-radius: 16px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin: 5px 0;
background: #20252E;
.func-img {
width: 66px;
height: 66px;
}
.func-text {
font-size: 28px;
color: #FFF;
font-family: SourceHanSansCN-Regular, SourceHanSansCN;
font-weight: 400;
margin-top: 42px;
}
}
}
.content-btm {
width: 100vw;
text-align: center;
padding-bottom: 6px;
img {
width: 142px;
}
}
}
</style>

4
src/view/tabs/device-control.vue

@ -6,8 +6,8 @@ @@ -6,8 +6,8 @@
<style lang="scss" scoped>
#device-control-wrapper {
width: 1500px;
height: 1500px;
width: 100vw;
height: 100vh;
background: rgb(5, 154, 200);
}
</style>

59
src/view/tabs/home-screen.vue

@ -1,12 +1,63 @@ @@ -1,12 +1,63 @@
<template>
<div id="home-screen-wrapper"></div>
<div id="home-screen-wrapper">
<div class="ceshi">
<img id="imgs" src="" width="100%">
</div>
</div>
</template>
<script lang="ts" setup></script>
<script lang="ts" setup>
import { time } from 'console';
import { ref, onMounted } from 'vue';
const aniImgs: any = ref([]);
const timer: any = ref();
const imgs: any = ref();
const index = ref(0)
onMounted(() => {
imgs.value = document.getElementById('imgs');
// for (let i = 0; i <= 79; i++) {
// aniImgs.value.push(`/src/assets/imgs/home-screen/-_000${i < 10? '0' + i: i}`);
// }
run();
console.log(aniImgs.value);
})
const run = () => {
//
if (timer.value) {
clearInterval(timer.value);
timer.value = null;
}
change();
timer.value = setInterval(() => {
index.value++;
if (index.value > 79) {
index.value = 0;
}
change();
}, 1000 / 24);
}
const change = () => {
if (imgs.value) {
imgs.value.src = `/src/assets/imgs/home-screen/切图-关机时循环_000${index.value < 10? '0' + index.value: index.value}.png`;
}
}
</script>
<style lang="scss" scoped>
#home-screen-wrapper {
width: 1500px;
height: 1500px;
width: 100vh;
height: 100vh;
background: rgb(15, 188, 102);
.ceshi {
width: 100vw;
}
#imgs {
width: 100%;
}
}</style>

124
src/view/tabs/tabs.vue

@ -1,29 +1,37 @@ @@ -1,29 +1,37 @@
<template>
<div id="tabs-wrapper">
<div class="swiper">
<div class="swiper-wrapper">
<div class="swiper-slide">
<div class="swiper-item">
<FixedTime class="swiper-slide"></FixedTime>
</div>
</div>
<div class="swiper-slide">
<div class="swiper-item">
<HomeScreen class="swiper-slide"></HomeScreen>
</div>
</div>
<div class="swiper-slide">
<div class="swiper-item">
<DeviceControl class="swiper-slide"></DeviceControl>
</div>
</div>
<div class="swiper-slide">
<div class="swiper-item">
<Scene class="swiper-slide"></Scene>
</div>
</div>
<!-- 下拉 -->
<div
class="drop-down-menu"
@touchstart="dropDownMenuStart($event)"
@touchmove="dropDownMenuMove($event)"
@touchend="dropDownMenuEnd($event)">
</div>
<DropDownMenu id="menu" v-show="showMenu" ref="menu" @pull-up="pullUp()"></DropDownMenu>
<div class="swiper">
<div class="swiper-wrapper">
<div class="swiper-slide">
<div class="swiper-item">
<FixedTime class="swiper-slide"></FixedTime>
</div>
</div>
<div class="swiper-slide">
<div class="swiper-item">
<HomeScreen class="swiper-slide"></HomeScreen>
</div>
</div>
<div class="swiper-slide">
<div class="swiper-item">
<DeviceControl class="swiper-slide"></DeviceControl>
</div>
</div>
<div class="swiper-slide">
<div class="swiper-item">
<Scene class="swiper-slide"></Scene>
</div>
</div>
</div>
</div>
</div>
</template>
@ -39,13 +47,19 @@ import FixedTime from './fixed-time.vue'; @@ -39,13 +47,19 @@ import FixedTime from './fixed-time.vue';
import HomeScreen from './home-screen.vue';
import DeviceControl from './device-control.vue';
import Scene from './scene.vue';
import DropDownMenu from '../drop-down-menu/drop-down-menu.vue';
import "swiper/swiper-bundle.css";
let mySwiper: Swiper; // swiper
const touchStart = ref(0);
const touchDis = ref(0);
/** 是否展示菜单 */
const showMenu = ref(false);
const menuDom: any = ref();
onMounted(() => {
initSwiper();
menuDom.value = document.getElementById('menu') as HTMLElement | null;
})
/** 初始化swiper */
@ -60,9 +74,73 @@ const initSwiper = () => { @@ -60,9 +74,73 @@ const initSwiper = () => {
effect: "fade", //
});
}
/** 下拉菜单开始 */
const dropDownMenuStart = (event: any) => {
touchStart.value = 0;
touchDis.value = 0;
touchStart.value = event.targetTouches[0].pageY;
}
/** 下拉菜单移动 */
const dropDownMenuMove = (event: any) => {
//
let touchPos = event.targetTouches[0].pageY;
touchDis.value = touchPos - touchStart.value;
if (document.documentElement.scrollTop === 0 && touchDis.value > 0) {
showMenu.value = true;
if (menuDom.value) {
const top = (-(window.innerHeight) + touchDis.value) > 0? 0: (-(window.innerHeight) + touchDis.value);
menuDom.value.style.top = `${top}px`;
}
} else {
showMenu.value = false;
}
}
/** 下拉菜单结束 */
const dropDownMenuEnd = (event: any) => {
if (touchDis.value > 0) {
if (menuDom.value) {
menuDom.value.style.transition = `${(window.innerHeight - touchDis.value) / (window.innerHeight)}s`;
menuDom.value.style.top = '0';
}
}
}
/** 点击收起菜单 */
const pullUp = () => {
if (menuDom.value && (menuDom.value.style.top === '0px' || menuDom.value.style.top === '0')) {
menuDom.value.style.top = '-100vh';
menuDom.value.style.transition = '0.5s';
// 0.5s
setTimeout(() => {
showMenu.value = false;
menuDom.value.style.transition = '0s';
}, 500);
}
}
</script>
<style lang="scss" scoped>
#tabs-wrapper {
width: 100vw;
height: 100vh;
position: relative;
.drop-down-menu {
width: 100vw;
height: 40px;
position: fixed;
top: 0;
left: 0;
z-index: 999;
}
#menu {
position: absolute;
top: -100vh;
z-index: 999;
}
}
</style>
Loading…
Cancel
Save