hldy_app/pages/index/index.vue

282 lines
7.5 KiB
Vue
Raw Normal View History

2025-02-18 17:11:31 +08:00
<template>
2025-03-07 17:26:02 +08:00
<view :class="darkFans?`darkbackgroundContainer`:`backgroundContainer`" @touchmove="getxy" @touchend="cleanall">
2025-03-14 17:30:56 +08:00
<view class="move-font" v-show="savename && clientX" :style="{ top: `${clientY}rpx`, left: `${clientX}rpx` }">
2025-03-07 17:26:02 +08:00
{{savename}}
</view>
2025-02-18 17:11:31 +08:00
<view class="left-container">
2025-03-05 17:29:32 +08:00
<view class="left-head">
2025-02-18 17:11:31 +08:00
<image class="left-head-img" src="/static/index/oldman.png" />
2025-02-19 17:33:12 +08:00
<text :class="darkFans?`left-head-font-dark`:`left-head-font`">
2025-02-18 17:11:31 +08:00
王金凤
</text>
</view>
<view class="left-img-container">
<view v-for="(item,index) in iconList" :key="index" class="blue-circle-pos">
<view class="blue-circle" v-show="index === menuIndex">
<image class="blue-circle-size" :src="`/static/index/ray.png`" />
</view>
2025-02-19 17:33:12 +08:00
<image class="left-img" :src="index === menuIndex ? item.targetUrl : item.url"
@click="changeMenu(index)" />
2025-02-28 17:27:27 +08:00
</view>
</view>
2025-02-18 17:11:31 +08:00
</view>
2025-03-11 17:27:40 +08:00
<!-- 主页 -->
2025-03-05 17:29:32 +08:00
<rightItemsfirst :isshow="menuIndexshow" :darkFans="darkFans" v-show="!menuIndex" @darkchange="darkchange" />
2025-03-11 17:27:40 +08:00
<!-- 超凶表格 -->
2025-03-14 17:30:56 +08:00
<rightItemssecond ref="ruler" :liang="indexNumber" :isshow="menuIndexshowsecond" :canmove="canmove"
:darkFans="darkFans" v-show="menuIndex==1" @darkchange="darkchange" @savename="openname"
@cleanname="closename" />
2025-02-18 17:11:31 +08:00
</view>
</template>
<script setup lang="ts">
2025-03-05 17:29:32 +08:00
import { ref, onMounted } from 'vue';
import type { Link } from "./index";
import rightItemsfirst from "../../component/rightItemsindex/index.vue"
import rightItemssecond from "../../component/rightItemssecond/index.vue"
import { onShow } from '@dcloudio/uni-app';
2025-02-18 17:11:31 +08:00
// 初始化左侧菜单列表
const iconList = ref<Link[]>([
{ url: '/static/index/lefticon/index.png', targetUrl: '/static/index/lefticontarget/blueindex.png' },
{ url: '/static/index/lefticon/nurse.png', targetUrl: '/static/index/lefticontarget/bluenurse.png' },
2025-03-14 17:30:56 +08:00
{ url: '/static/index/lefticon/doctor.png', targetUrl: '/static/index/lefticontarget/bluedoctor.png' },
2025-02-25 17:23:40 +08:00
{ url: '/static/index/lefticon/give.png', targetUrl: '/static/index/lefticontarget/givedark.png' },
2025-02-18 17:11:31 +08:00
{ url: '/static/index/lefticon/wifi.png', targetUrl: '/static/index/lefticontarget/bluewifi.png' },
{ url: '/static/index/lefticon/back.png', targetUrl: '/static/index/lefticontarget/blueback.png' }
]);
// 当前选中的菜单索引
2025-03-07 17:26:02 +08:00
const menuIndex = ref<number>(1);
2025-03-05 17:29:32 +08:00
const menuIndexshow = ref<boolean>(false);
const menuIndexshowsecond = ref<boolean>(false);
2025-02-18 17:11:31 +08:00
// 暗黑模式
const darkFans = ref<boolean>(false);
// 当前选中的菜单索引
const roomTar = ref<number[]>([]);
2025-02-19 17:33:12 +08:00
//滑块按钮
const firstcurrentIndex = ref<number>(0);
2025-02-20 17:21:36 +08:00
const firstcurrentIndexup = ref<number>(0);
2025-02-27 17:15:17 +08:00
const secondcurrentIndexup = ref<number>(0);
2025-02-19 17:33:12 +08:00
const secondcurrentIndex = ref<number>(0);
const thirdcurrentIndex = ref<number>(0);
2025-03-05 17:29:32 +08:00
// 暗黑模式改变
2025-03-14 17:30:56 +08:00
const darkchange = (res : boolean) => {
2025-03-05 17:29:32 +08:00
darkFans.value = res
}
2025-02-18 17:11:31 +08:00
// 变更菜单
const changeMenu = (index : number) => {
2025-03-14 17:30:56 +08:00
if (index === 3) {
2025-03-05 17:29:32 +08:00
menuIndexshow.value = false;
menuIndexshowsecond.value = false;
uni.navigateTo({
2025-03-14 17:30:56 +08:00
url: `/pages/somethingmove/index?darkFans=${darkFans.value}`,
animationType: 'slide-in-right',
animationDuration: 400// 设置动画时长为300毫秒, // 动画持续时间,单位为毫秒
2025-03-05 17:29:32 +08:00
});
return
2025-02-18 17:11:31 +08:00
}
2025-03-05 17:29:32 +08:00
menuIndex.value = index;
menuIndexshow.value = false
menuIndexshowsecond.value = false
2025-03-14 17:30:56 +08:00
setTimeout(() => {
2025-03-05 17:29:32 +08:00
switch (index) {
2025-03-14 17:30:56 +08:00
case 0:
menuIndexshow.value = true
break;
case 1:
menuIndexshowsecond.value = true
break;
default:
2025-03-05 17:29:32 +08:00
}
2025-03-14 17:30:56 +08:00
}, 50)
2025-02-27 17:15:17 +08:00
};
2025-03-07 17:26:02 +08:00
const clientX = ref(0);
const clientY = ref(0);
const savename = ref("")
const canmove = ref(true)
2025-03-11 17:27:40 +08:00
const indexNumber = ref({
2025-03-14 17:30:56 +08:00
index0: 999,
index1: 999,
2025-03-11 17:27:40 +08:00
})
2025-03-07 17:26:02 +08:00
//全局获得x轴和y轴
2025-03-11 17:27:40 +08:00
const getxyrel = (event) => {
2025-03-12 15:22:01 +08:00
// event.stopPropagation();
// event.preventDefault();
2025-03-07 17:26:02 +08:00
const touch = event.touches[0];
2025-03-14 17:30:56 +08:00
clientX.value = 2 * (Math.floor(touch.clientX) - 100);
clientY.value = 2 * (Math.floor(touch.clientY) - 55);
2025-03-12 15:22:01 +08:00
// console.log("?????",clientX.value,clientY.value)
2025-03-11 17:27:40 +08:00
// 遍历数组,找到点击区域所在的对象
2025-03-14 17:30:56 +08:00
const translateX = Math.floor(touch.clientX) - 50;
const translateY = Math.floor(touch.clientY) - 25;
2025-03-11 17:27:40 +08:00
const clickedItem = fangkuaiValue.value.find(item => {
2025-03-14 17:30:56 +08:00
return translateX >= item.left && translateX <= item.right &&
translateY >= item.top && translateY <= item.bottom;
2025-03-11 17:27:40 +08:00
});
// 如果找到,则输出该对象的 index0 和 index1
if (clickedItem) {
2025-03-14 17:30:56 +08:00
const { index0, index1 } = clickedItem.dataset;
indexNumber.value.index0 = index0
indexNumber.value.index1 = index1
} else {
2025-03-11 17:27:40 +08:00
indexNumber.value.index0 = 999
indexNumber.value.index1 = 999
}
2025-03-07 17:26:02 +08:00
}
2025-03-11 17:27:40 +08:00
//节流
const getxy = throttle(getxyrel, 10);
2025-03-14 17:30:56 +08:00
2025-03-11 17:27:40 +08:00
const fangkuaiValue = ref([])
//所有适合的方块
2025-03-14 17:30:56 +08:00
const openname = (res : string, fangkuai : Object) => {
2025-03-07 17:26:02 +08:00
savename.value = res;
canmove.value = false;
2025-03-11 17:27:40 +08:00
fangkuaiValue.value = fangkuai
2025-03-07 17:26:02 +08:00
}
2025-03-12 15:22:01 +08:00
//解决拖动bug
2025-03-14 17:30:56 +08:00
const closename = () => {
2025-03-12 15:22:01 +08:00
savename.value = "";
canmove.value = true;
fangkuaiValue.value = []
}
2025-03-11 17:27:40 +08:00
const ruler = ref(null)
//结束、禁止滑动
2025-03-14 17:30:56 +08:00
const cleanall = () => {
2025-03-07 17:26:02 +08:00
clientX.value = 9999;
clientY.value = 9999;
canmove.value = true;
2025-03-11 17:27:40 +08:00
indexNumber.value = {
2025-03-14 17:30:56 +08:00
index0: 999,
index1: 999,
2025-03-11 17:27:40 +08:00
};
ruler.value?.rulerEnd(savename.value);
savename.value = "";
}
//节流函数
function throttle(fn, delay) {
2025-03-14 17:30:56 +08:00
let lastExecutionTime = 0;
return function (...args) {
const now = Date.now();
if (now - lastExecutionTime >= delay) {
lastExecutionTime = now;
fn.apply(this, args);
}
};
2025-03-07 17:26:02 +08:00
}
2025-02-18 17:11:31 +08:00
// 生命周期钩子
2025-03-05 17:29:32 +08:00
onShow(() => {
//首次加载和跳转回来需要重新做个动画
2025-03-14 17:30:56 +08:00
setTimeout(() => {
2025-03-05 17:29:32 +08:00
changeMenu(menuIndex.value)
2025-03-14 17:30:56 +08:00
}, 50)
2025-02-18 17:11:31 +08:00
});
</script>
<style lang="less" scoped>
.backgroundContainer {
display: flex;
position: relative;
width: 100%;
height: 100vh;
2025-02-27 17:15:17 +08:00
background-image: url('/static/index/lightbgcnew.png');
2025-02-18 17:11:31 +08:00
background-size: cover;
background-position: center center;
overflow: hidden;
2025-03-07 17:26:02 +08:00
z-index: 12;
2025-02-18 17:11:31 +08:00
}
2025-02-19 17:33:12 +08:00
2025-02-18 17:11:31 +08:00
//暗黑模式
2025-02-19 17:33:12 +08:00
.darkbackgroundContainer {
2025-02-18 17:11:31 +08:00
display: flex;
position: relative;
width: 100%;
height: 100vh;
background-image: url('/static/index/background.png');
background-size: cover;
background-position: center center;
overflow: hidden;
2025-03-07 17:26:02 +08:00
z-index: 11;
}
2025-03-14 17:30:56 +08:00
.move-font {
2025-03-07 17:26:02 +08:00
position: absolute;
2025-03-14 17:30:56 +08:00
// font-size: 45rpx;
2025-03-07 17:26:02 +08:00
font-weight: 700;
z-index: 10;
2025-03-11 17:27:40 +08:00
pointer-events: none;
2025-03-14 17:30:56 +08:00
color: #016AD1;
background-color: #fff;
border-radius: 20rpx;
border: 2rpx solid #fff;
width: 300rpx;
height: 100rpx;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
font-size: 45rpx;
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.1);
2025-02-18 17:11:31 +08:00
}
2025-03-14 17:30:56 +08:00
2025-03-05 17:29:32 +08:00
.left-container {
width: 235rpx;
height: 100%;
2025-03-14 17:30:56 +08:00
2025-03-05 17:29:32 +08:00
.blue-circle-pos {
2025-02-20 17:21:36 +08:00
position: relative;
2025-03-14 17:30:56 +08:00
2025-03-05 17:29:32 +08:00
.blue-circle {
2025-02-20 17:21:36 +08:00
position: absolute;
2025-03-05 17:29:32 +08:00
top: -50rpx;
left: -68rpx;
2025-03-14 17:30:56 +08:00
2025-03-05 17:29:32 +08:00
.blue-circle-size {
width: 170rpx;
height: 250rpx;
2025-03-04 17:29:52 +08:00
}
}
2025-03-05 17:29:32 +08:00
}
2025-03-14 17:30:56 +08:00
2025-03-05 17:29:32 +08:00
.left-head {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
2025-03-14 17:30:56 +08:00
2025-03-05 17:29:32 +08:00
.left-head-img {
width: 150rpx;
height: 150rpx;
margin-top: 60rpx;
2025-03-04 17:29:52 +08:00
}
2025-03-14 17:30:56 +08:00
2025-03-05 17:29:32 +08:00
.left-head-font {
font-weight: 700;
font-size: 40rpx;
2025-03-04 17:29:52 +08:00
}
2025-03-14 17:30:56 +08:00
2025-03-05 17:29:32 +08:00
.left-head-font-dark {
font-weight: 700;
font-size: 40rpx;
background: linear-gradient(to right, #EBF4FF, #ADC4E0);
-webkit-background-clip: text;
color: transparent;
2025-03-04 17:29:52 +08:00
}
2025-03-05 17:29:32 +08:00
}
2025-03-14 17:30:56 +08:00
2025-03-05 17:29:32 +08:00
.left-img-container {
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
// margin-top: 30rpx;
2025-03-14 17:30:56 +08:00
2025-03-05 17:29:32 +08:00
.left-img {
width: 93rpx;
height: 93rpx;
margin: 50rpx 0;
z-index: 100;
2025-03-04 17:29:52 +08:00
}
2025-03-05 17:29:32 +08:00
}
}
2025-02-18 17:11:31 +08:00
</style>