You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
2.4 KiB
Vue

<template>
<view class="page-container">
<scroll-view scroll-y class="main-scroll" :scroll-top="scrollTop" scroll-with-animation @scroll="onScroll">
<BannerSection />
<view class="content-section">
<!-- 功能导航 -->
<NavSection />
<!-- 生产概览统计 -->
<StatsSection />
<!-- 生产概括 -->
<PlanSection />
<!-- 设备概括 -->
<DeviceSection />
</view>
</scroll-view>
<view v-if="showGoTop" class="go-top-btn" @click="goTop">
<text class="go-top-icon"></text>
</view>
</view>
</template>
<script setup>
import { onMounted, onUnmounted, ref } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { onLocaleChange, offLocaleChange, setNavigationTitle } from '@/locales'
import BannerSection from '@/components/dashboard/BannerSection.vue'
import NavSection from '@/components/dashboard/NavSection.vue'
import StatsSection from '@/components/dashboard/StatsSection.vue'
import PlanSection from '@/components/dashboard/PlanSection.vue'
import DeviceSection from '@/components/dashboard/DeviceSection.vue'
const scrollTop = ref(0)
const currentScrollTop = ref(0)
const showGoTop = ref(false)
function onScroll(e) {
const top = Number(e?.detail?.scrollTop || 0)
currentScrollTop.value = top
showGoTop.value = top > 600
}
function goTop() {
scrollTop.value = currentScrollTop.value + 1
setTimeout(() => {
scrollTop.value = 0
}, 0)
}
const updatePageTitle = () => setNavigationTitle('nav.home')
onShow(() => {
updatePageTitle()
})
onLocaleChange(updatePageTitle)
onUnmounted(() => {
offLocaleChange(updatePageTitle)
})
</script>
<style lang="scss" scoped>
.page-container {
display: flex;
flex-direction: column;
height: 100vh;
background-color: #f0f2f5;
}
.main-scroll {
flex: 1;
height: 100%;
}
.content-section {
padding: 0 24rpx 24rpx;
margin-top: -40rpx;
position: relative;
z-index: 5;
}
.go-top-btn {
position: fixed;
bottom: 140rpx;
right: 30rpx;
width: 88rpx;
height: 88rpx;
background: linear-gradient(135deg, #1a3a5c 0%, #2d5a87 100%);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 8rpx 24rpx rgba(26, 58, 92, 0.3);
z-index: 999;
&:active {
transform: scale(0.95);
}
}
.go-top-icon {
font-size: 44rpx;
color: #ffffff;
font-weight: bold;
}
</style>