hldy_app/pages/index/index.vue

441 lines
12 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-03-21 17:36:27 +08:00
<view v-if="saveruler.type"
:class="saveruler.type=='日常' ? `title-time-border-yellow`:`title-time-border-pouple`"
:style="{ top: `${clientY}rpx`, left: `${clientX}rpx` }" style="font-size: 30rpx;overflow: hidden;">
<view class="title-time" v-show="saveruler.time" style="margin-top: 5rpx;">
<view class="title-time-time" style="font-size: 30rpx;">
{{saveruler.time}}
</view>
<image class="title-time-button"
:src="saveruler.type=='日常'?`/static/index/yellowbian.png`:`/static/index/puoplebian.png`" />
<view class="title-time-font">
{{saveruler.type}}
</view>
</view>
<view style="margin-top: 20rpx;font-weight: 700;">
{{splitString(saveruler.value)[0]}}
</view>
<view class="down-icons" :style="saveruler.type!='日常'?{backgroundColor:`rgb(212,203,255)`}:{}"
v-show="splitString(saveruler.value)[1]">
<view class="" v-for="(item,index) in splitString(saveruler.value).slice(1)" :key="index">
<view class="icon" :style="saveruler.type!='日常'?{backgroundColor:`rgb(123,97,255)`}:{}">
{{splitString(saveruler.value)[1]}}
</view>
</view>
</view>
</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"
2025-03-21 17:36:27 +08:00
@saveruler="openruler" @changefangkuang="changefangkuang" @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-27 17:32:12 +08:00
const menuIndex = ref<number>(0);
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-21 17:36:27 +08:00
//翻页计时器
const canTrigger = ref(true);
2025-03-07 17:26:02 +08:00
//全局获得x轴和y轴
2025-03-11 17:27:40 +08:00
const getxyrel = (event) => {
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-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-21 17:36:27 +08:00
2025-03-11 17:27:40 +08:00
const clickedItem = fangkuaiValue.value.find(item => {
2025-03-21 17:36:27 +08:00
return translateX >= Math.floor(item.left) && translateX <= Math.floor(item.right) &&
translateY >= Math.floor(item.top) && translateY <= Math.floor(item.bottom);
2025-03-11 17:27:40 +08:00
});
if (clickedItem) {
2025-03-14 17:30:56 +08:00
const { index0, index1 } = clickedItem.dataset;
indexNumber.value.index0 = index0
indexNumber.value.index1 = index1
2025-03-21 17:36:27 +08:00
if (clientX.value > 2050 && canTrigger.value) {
ruler.value?.nextItems();
canTrigger.value = false;
setTimeout(() => {
canTrigger.value = true;
}, 1000);
}
2025-03-14 17:30:56 +08:00
} 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-21 17:36:27 +08:00
const openname = (res : string, fangkuai : any) => {
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-21 17:36:27 +08:00
const changefangkuang = (fangkuang : any) => {
fangkuaiValue.value = fangkuang
console.log("!!!!", fangkuaiValue.value)
}
//移动方块
const saveruler = ref({})
const openruler = (res : string, fangkuai : any) => {
saveruler.value = res
canmove.value = false;
fangkuaiValue.value = fangkuai
}
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;
2025-03-21 17:36:27 +08:00
// fangkuaiValue.value = []
2025-03-12 15:22:01 +08:00
}
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
};
2025-03-21 17:36:27 +08:00
if (savename.value) {
ruler.value?.rulerEnd(savename.value);
} else if (saveruler.value.type) {
ruler.value?.rulerMoveEnd(saveruler.value);
}
2025-03-11 17:27:40 +08:00
savename.value = "";
2025-03-21 17:36:27 +08:00
saveruler.value = {};
2025-03-11 17:27:40 +08:00
}
//节流函数
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-03-21 17:36:27 +08:00
function splitString(str) {
// 使用正则表达式找到所有括号的内容
let result = [];
let remainingStr = str;
// 正则匹配最外层括号(支持全角和半角)
let regex = /([^(]*)[(]([^)]+)[)]/;
while (regex.test(remainingStr)) {
let match = remainingStr.match(regex);
if (match) {
// 添加括号前的部分(去掉空白)
if (match[1].trim()) {
result.push(match[1].trim());
}
// 添加括号内的内容
if (match[2].trim()) {
result.push(match[2].trim());
}
// 更新剩余的字符串
remainingStr = remainingStr.replace(match[0], '').trim();
}
}
// 如果最后还有剩余部分,也加入结果
if (remainingStr.trim()) {
result.push(remainingStr.trim());
}
return result;
}
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-17 17:34:36 +08:00
// font-weight: 700;
2025-03-07 17:26:02 +08:00
z-index: 10;
2025-03-11 17:27:40 +08:00
pointer-events: none;
2025-03-17 17:34:36 +08:00
// color: #016AD1;
background-color: rgb(201, 232, 255);
2025-03-14 17:30:56 +08:00
border-radius: 20rpx;
border: 2rpx solid #fff;
2025-03-17 17:34:36 +08:00
width: 220rpx;
2025-03-14 17:30:56 +08:00
height: 100rpx;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
2025-03-17 17:34:36 +08:00
font-size: 40rpx;
2025-03-14 17:30:56 +08:00
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-03-21 17:36:27 +08:00
.title-time-border-yellow {
width: 255rpx;
height: 189rpx;
margin: 10rpx;
border: 1rpx solid #dae8fa;
background: linear-gradient(to bottom, #fff1db, #ffe2b2);
// width: calc(100% - 20rpx);
// height: calc(100% - 20rpx);
border-radius: 20rpx;
display: flex;
align-items: center;
flex-direction: column;
position: absolute;
z-index: 10;
}
.title-time-border-pouple {
width: 255rpx;
height: 189rpx;
margin: 10rpx;
border: 1rpx solid #dae8fa;
background: linear-gradient(to bottom, #f1eeff, #e3deff);
// width: calc(100% - 20rpx);
// height: calc(100% - 20rpx);
border-radius: 20rpx;
display: flex;
align-items: center;
flex-direction: column;
position: absolute;
z-index: 10;
}
.title-time {
display: flex;
width: 100%;
position: relative;
.title-time-time {
font-size: 32rpx;
margin-left: 27rpx;
margin-top: 12rpx;
}
.title-time-button {
position: absolute;
top: -5rpx;
right: 0rpx;
width: 70rpx;
height: 70rpx;
}
.title-time-font {
position: absolute;
top: 7rpx;
right: 5rpx;
font-size: 23rpx;
color: #fff;
}
}
.down-icons {
margin-top: 20rpx;
width: 100%;
height: 50rpx;
background-color: rgb(255, 216, 126);
display: flex;
justify-content: center;
align-items: center;
.icon {
margin: 0 5rpx;
font-size: 20rpx;
padding: 5rpx 10rpx;
background-color: rgb(255, 138, 0);
color: #fff;
border-radius: 5rpx;
}
}
2025-02-18 17:11:31 +08:00
</style>