239 lines
4.8 KiB
Vue
239 lines
4.8 KiB
Vue
<template>
|
||
<view class="container" :style="containerStyle">
|
||
<view class="content">
|
||
<view class="menu-grid">
|
||
<view class="menu-item" @click="goToForm">
|
||
<view class="menu-icon">
|
||
<u-icon name="edit-pen" size="60" color="#2979ff"></u-icon>
|
||
</view>
|
||
<text class="menu-title">信息填报</text>
|
||
<text class="menu-desc">登记户主及家庭成员信息</text>
|
||
</view>
|
||
|
||
<view class="menu-item" @click="goToQuery">
|
||
<view class="menu-icon">
|
||
<u-icon name="search" size="60" color="#19be6b"></u-icon>
|
||
</view>
|
||
<text class="menu-title">结果查询</text>
|
||
<text class="menu-desc">查看已提交的记录</text>
|
||
</view>
|
||
</view>
|
||
|
||
<view class="quick-stats">
|
||
<view class="stats-title">总体统计</view>
|
||
<view class="stats-content">
|
||
<view class="stats-item">
|
||
<text class="stats-number">{{ stats.total }}</text>
|
||
<text class="stats-label">总记录数</text>
|
||
</view>
|
||
<view class="stats-item">
|
||
<text class="stats-number">{{ stats.submitted }}</text>
|
||
<text class="stats-label">已提交</text>
|
||
</view>
|
||
<view class="stats-item">
|
||
<text class="stats-number">{{ stats.draft }}</text>
|
||
<text class="stats-label">暂存</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view class="quick-stats1">
|
||
<view class="stats-title">乡镇统计</view>
|
||
<view class="stats-content">
|
||
<view class="stats-item">
|
||
<text class="stats-number">{{ stats.xhTown }}</text>
|
||
<text class="stats-label">星海镇</text>
|
||
</view>
|
||
<view class="stats-item">
|
||
<text class="stats-number">{{ stats.cxTown }}</text>
|
||
<text class="stats-label">长兴街道</text>
|
||
</view>
|
||
<view class="stats-item">
|
||
<text class="stats-number">{{ stats.csTown }}</text>
|
||
<text class="stats-label">长胜街道</text>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import {
|
||
householdApi
|
||
} from '../../utils/api'
|
||
|
||
export default {
|
||
data() {
|
||
return {
|
||
stats: {
|
||
total: 0,
|
||
submitted: 0,
|
||
draft: 0
|
||
},
|
||
containerStyle: {
|
||
height: '100vh'
|
||
}
|
||
}
|
||
},
|
||
onLoad() {
|
||
this.calculateHeight()
|
||
this.loadStats()
|
||
},
|
||
onShow() {
|
||
// 每次显示页面时刷新统计数据
|
||
this.loadStats()
|
||
},
|
||
onReady() {
|
||
this.calculateHeight()
|
||
// 监听子页面的刷新通知
|
||
uni.$on('refreshStats', () => {
|
||
this.loadStats()
|
||
})
|
||
},
|
||
onUnload() {
|
||
// 移除事件监听
|
||
uni.$off('refreshStats')
|
||
},
|
||
methods: {
|
||
calculateHeight() {
|
||
// 获取系统信息
|
||
const systemInfo = uni.getSystemInfoSync()
|
||
const statusBarHeight = systemInfo.statusBarHeight || 0
|
||
const windowHeight = systemInfo.windowHeight
|
||
|
||
// 计算内容区域高度(屏幕高度 - 顶部高度 - 底部tabbar高度)
|
||
// 微信小程序tabbar高度约为50px
|
||
const tabbarHeight = 50
|
||
const contentHeight = windowHeight - statusBarHeight - tabbarHeight
|
||
|
||
// 设置容器样式
|
||
this.containerStyle = {
|
||
height: contentHeight + 'px'
|
||
}
|
||
},
|
||
|
||
async loadStats() {
|
||
try {
|
||
const response = await householdApi.getUserStats();
|
||
if (response) {
|
||
this.stats = response
|
||
}
|
||
} catch (error) {
|
||
uni.showToast({
|
||
title: error.data.msg,
|
||
icon: 'none'
|
||
})
|
||
}
|
||
},
|
||
|
||
goToForm() {
|
||
uni.navigateTo({
|
||
url: '/packageForm/pages/householdForm'
|
||
})
|
||
},
|
||
|
||
goToQuery() {
|
||
uni.navigateTo({
|
||
url: '/packageQuery/pages/query'
|
||
})
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style scoped>
|
||
.container {
|
||
display: flex;
|
||
flex-direction: column;
|
||
}
|
||
|
||
.content {
|
||
flex: 1;
|
||
padding: 32rpx;
|
||
overflow-y: auto;
|
||
}
|
||
|
||
.menu-grid {
|
||
display: flex;
|
||
gap: 32rpx;
|
||
margin-bottom: 48rpx;
|
||
}
|
||
|
||
.menu-item {
|
||
flex: 1;
|
||
background: #fff;
|
||
border-radius: 24rpx;
|
||
padding: 48rpx 32rpx;
|
||
text-align: center;
|
||
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.1);
|
||
transition: all 0.3s;
|
||
}
|
||
|
||
.menu-item:active {
|
||
transform: scale(0.98);
|
||
}
|
||
|
||
.menu-icon {
|
||
margin-bottom: 24rpx;
|
||
}
|
||
|
||
.menu-title {
|
||
display: block;
|
||
font-size: 32rpx;
|
||
font-weight: bold;
|
||
color: #333;
|
||
margin-bottom: 12rpx;
|
||
}
|
||
|
||
.menu-desc {
|
||
display: block;
|
||
font-size: 24rpx;
|
||
color: #666;
|
||
}
|
||
|
||
.quick-stats {
|
||
background: #fff;
|
||
border-radius: 24rpx;
|
||
padding: 32rpx;
|
||
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.1);
|
||
}
|
||
|
||
.quick-stats1 {
|
||
margin-top: 5%;
|
||
background: #fff;
|
||
border-radius: 24rpx;
|
||
padding: 32rpx;
|
||
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.1);
|
||
}
|
||
|
||
.stats-title {
|
||
font-size: 32rpx;
|
||
font-weight: bold;
|
||
color: #333;
|
||
margin-bottom: 32rpx;
|
||
text-align: center;
|
||
}
|
||
|
||
.stats-content {
|
||
display: flex;
|
||
justify-content: space-around;
|
||
}
|
||
|
||
.stats-item {
|
||
text-align: center;
|
||
}
|
||
|
||
.stats-number {
|
||
display: block;
|
||
font-size: 48rpx;
|
||
font-weight: bold;
|
||
color: #2979ff;
|
||
margin-bottom: 8rpx;
|
||
}
|
||
|
||
.stats-label {
|
||
display: block;
|
||
font-size: 24rpx;
|
||
color: #666;
|
||
}
|
||
</style> |