修改小程序

This commit is contained in:
2025-10-17 17:29:11 +08:00
parent 434fa135d1
commit 212dffd0da
227 changed files with 12887 additions and 45341 deletions

View File

@@ -1,102 +1,251 @@
// pages/index/index.js
const auth = require('../../utils/auth.js')
const dashboardService = require('../../services/dashboardService.js')
const app = getApp();
Page({
data: {
userInfo: {},
quickActions: [
{ key: 'dashboard', name: '数据看板', icon: '📊', path: '/pages/dashboard/dashboard' },
{ key: 'supervision', name: '监管管理', icon: '🔍', path: '/pages/supervision/supervision' },
{ key: 'approval', name: '审批管理', icon: '✅', path: '/pages/approval/approval' },
{ key: 'personnel', name: '人员管理', icon: '👥', path: '/pages/personnel/personnel' },
{ key: 'epidemic', name: '疫情监控', icon: '🦠', path: '/pages/epidemic/epidemic' },
{ key: 'service', name: '服务管理', icon: '🛠️', path: '/pages/service/service' },
{ key: 'warehouse', name: '仓库管理', icon: '📦', path: '/pages/warehouse/warehouse' },
{ key: 'profile', name: '个人中心', icon: '👤', path: '/pages/profile/profile' }
],
statsData: [
{ key: 'supervision', label: '监管记录', value: '0', trend: 'up', trendText: '+0%' },
{ key: 'approval', label: '待审批', value: '0', trend: 'up', trendText: '+0%' },
{ key: 'personnel', label: '人员总数', value: '0', trend: 'up', trendText: '+0%' },
{ key: 'epidemic', label: '疫情预警', value: '0', trend: 'down', trendText: '-0%' }
],
recentActivities: [
currentTime: '',
// 用户信息
userInfo: {
name: '政府管理',
role: '监管人员'
},
// 智能硬件设备(图一样式:使用图片图标)
hardwareDevices: [
{
id: 1,
icon: '🔍',
title: '监管检查',
desc: '完成养殖场A的例行检查',
time: '2小时前'
name: '项圈仓库',
img: '/images/collar.png',
color: '#1890ff',
type: 'collar'
},
{
id: 2,
icon: '',
title: '审批通过',
desc: '通过养殖许可证申请',
time: '4小时前'
name: '耳标仓库',
img: '/images/ear-tag.png',
color: '#ff7a45',
type: 'eartag'
},
{
id: 3,
icon: '👥',
title: '人员管理',
desc: '新增监管员张三',
time: '6小时前'
name: '脚环仓库',
img: '/images/ankle-ring.png',
color: '#52c41a',
type: 'anklet'
},
{
id: 4,
name: '主机仓库',
img: '/images/host.png',
color: '#faad14',
type: 'host'
}
],
// 其它功能(图一样式:使用图片图标)
otherFunctions: [
{
id: 1,
name: '牲畜身份认证',
img: '/images/identity.png',
color: '#1890ff',
type: 'livestock_auth'
},
{
id: 2,
name: '无害化检验',
img: '/images/epidemic.png',
color: '#ff7a45',
type: 'harmless_check'
},
{
id: 3,
name: '检疫证查询',
img: '/images/quarantine.png',
color: '#52c41a',
type: 'quarantine_query'
},
{
id: 4,
name: '金融保险监管',
img: '/images/finance.png',
color: '#faad14',
type: 'finance_insurance'
},
{
id: 5,
name: '屠宰场监管',
img: '/images/slaughter.png',
color: '#722ed1',
type: 'slaughter_supervision'
},
{
id: 6,
name: '检疫站监管',
img: '/images/epidemic-station.png',
color: '#eb2f96',
type: 'quarantine_supervision'
},
{
id: 7,
name: '无害化防疫',
img: '/images/certificate.png',
color: '#13c2c2',
type: 'harmless_prevention'
},
{
id: 8,
name: '防疫站监管',
img: '/images/station.png',
color: '#1890ff',
type: 'prevention_supervision'
}
]
},
onLoad() {
this.initData()
},
onPullDownRefresh() {
this.loadData()
console.log('首页加载完成');
// 延迟检查登录状态,避免与登录跳转冲突
setTimeout(() => {
wx.stopPullDownRefresh()
}, 1000)
this.checkLoginStatus();
}, 100);
this.updateTime();
this.startTimeUpdate();
},
initData() {
// 获取用户信息
this.setData({
userInfo: auth.getUser() || {}
})
onShow() {
console.log('首页显示');
// 延迟检查登录状态,避免与登录跳转冲突
setTimeout(() => {
this.checkLoginStatus();
}, 100);
this.updateTime();
},
onUnload() {
// 清除定时器
if (this.timeInterval) {
clearInterval(this.timeInterval);
}
},
// 检查登录状态
checkLoginStatus() {
const token = wx.getStorageSync('token');
console.log('首页检查登录状态token:', token);
if (!token) {
console.log('未找到token跳转到登录页');
// 未登录,跳转到登录页
wx.reLaunch({
url: '/pages/login/login'
});
return false;
}
console.log('token验证通过用户已登录');
return true;
},
// 更新时间显示
updateTime() {
const now = new Date();
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
const timeString = `${hours}:${minutes}`;
// 加载数据
this.loadData()
this.setData({
currentTime: timeString
});
},
async loadData() {
try {
// 加载统计数据
const stats = await dashboardService.getStats()
if (stats) {
this.updateStatsData(stats)
}
} catch (error) {
console.error('加载数据失败:', error)
// 开始时间更新定时器
startTimeUpdate() {
this.timeInterval = setInterval(() => {
this.updateTime();
}, 60000); // 每分钟更新一次
},
// 智能硬件设备点击
onHardwareDeviceTap(e) {
const { type } = e.currentTarget.dataset;
console.log('点击硬件设备:', type);
wx.showToast({
title: `进入${type}管理`,
icon: 'none'
});
// 根据不同类型跳转到相应页面
switch (type) {
case 'collar':
// 跳转到项圈管理页面
break;
case 'eartag':
// 跳转到耳标管理页面
break;
case 'anklet':
// 跳转到脚环管理页面
break;
case 'host':
// 跳转到主机管理页面
break;
default:
wx.showToast({
title: '功能开发中',
icon: 'none'
});
}
},
updateStatsData(data) {
const statsData = this.data.statsData.map(stat => {
const newValue = data[stat.key] || stat.value
return {
...stat,
value: newValue
}
})
this.setData({ statsData })
},
handleAction(e) {
const { action } = e.currentTarget.dataset
const actionItem = this.data.quickActions.find(item => item.key === action)
if (actionItem && actionItem.path) {
wx.navigateTo({
url: actionItem.path
})
// 其它功能点击
onOtherFunctionTap(e) {
const { type } = e.currentTarget.dataset;
console.log('点击其它功能:', type);
wx.showToast({
title: `进入${type}`,
icon: 'none'
});
// 根据不同类型跳转到相应页面
switch (type) {
case 'livestock_auth':
// 跳转到牲畜身份认证页面
break;
case 'harmless_check':
// 跳转到无害化检验页面
break;
case 'quarantine_query':
// 跳转到检疫证查询页面
break;
case 'finance_insurance':
// 跳转到金融保险监管页面
break;
case 'slaughter_supervision':
// 跳转到屠宰场监管页面
break;
case 'quarantine_supervision':
// 跳转到检疫站监管页面
break;
case 'harmless_prevention':
// 跳转到无害化防疫页面
break;
case 'prevention_supervision':
// 跳转到防疫站监管页面
break;
default:
wx.showToast({
title: '功能开发中',
icon: 'none'
});
}
},
// 分享功能
onShareAppMessage() {
return {
title: '政府监管系统',
path: '/pages/index/index'
};
}
})

View File

@@ -1,3 +1,5 @@
{
"usingComponents": {}
}
"usingComponents": {},
"navigationBarTitleText": "首页",
"navigationStyle": "custom"
}

View File

@@ -1,75 +1,72 @@
<!--pages/index/index.wxml-->
<view class="home-container">
<!-- 头部欢迎区域 -->
<view class="welcome-section">
<view class="welcome-content">
<view class="user-info">
<view class="avatar">
<image src="/images/avatar.png" class="avatar-img" />
</view>
<view class="user-details">
<view class="username">{{userInfo.name || '管理员'}}</view>
<view class="user-role">{{userInfo.role || '系统管理员'}}</view>
</view>
</view>
<view class="weather-info">
<view class="weather-icon">☀️</view>
<view class="weather-text">晴 25°C</view>
</view>
<view class="container">
<!-- 顶部导航栏 -->
<view class="nav-bar">
<view class="nav-title">首页</view>
<view class="nav-actions">
<view class="nav-icon">⋯</view>
<view class="nav-icon">—</view>
<view class="nav-icon">⊙</view>
</view>
</view>
<!-- 快捷功能区域 -->
<view class="quick-actions">
<view class="section-title">快捷功能</view>
<view class="action-grid">
<view
wx:for="{{quickActions}}"
wx:key="key"
class="action-item"
data-action="{{item.key}}"
bindtap="handleAction"
>
<view class="action-icon">{{item.icon}}</view>
<view class="action-text">{{item.name}}</view>
</view>
<!-- 智能硬件设备区域 -->
<view class="section">
<view class="section-header">
<view class="section-indicator"></view>
<text class="section-title">智能硬件设备</text>
</view>
</view>
<!-- 数据概览区域 -->
<view class="stats-section">
<view class="section-title">数据概览</view>
<view class="stats-grid">
<view
wx:for="{{statsData}}"
wx:key="key"
class="stat-item"
>
<view class="stat-value">{{item.value}}</view>
<view class="stat-label">{{item.label}}</view>
<view class="stat-trend {{item.trend}}">
{{item.trendText}}
</view>
</view>
</view>
</view>
<!-- 最近活动区域 -->
<view class="recent-activities">
<view class="section-title">最近活动</view>
<view class="activity-list">
<view
wx:for="{{recentActivities}}"
<view class="hardware-grid">
<view
class="hardware-item"
wx:for="{{hardwareDevices}}"
wx:key="id"
class="activity-item"
data-type="{{item.type}}"
bindtap="onHardwareDeviceTap"
>
<view class="activity-icon">{{item.icon}}</view>
<view class="activity-content">
<view class="activity-title">{{item.title}}</view>
<view class="activity-desc">{{item.desc}}</view>
<view class="activity-time">{{item.time}}</view>
<view class="hardware-icon" style="background-color: {{item.color}}">
<image class="icon-image" src="{{item.img}}" mode="aspectFit"/>
</view>
<text class="hardware-name">{{item.name}}</text>
</view>
</view>
</view>
</view>
<!-- 其它功能区域 -->
<view class="section">
<view class="section-header">
<view class="section-indicator"></view>
<text class="section-title">其它</text>
</view>
<view class="other-grid">
<view
class="other-item"
wx:for="{{otherFunctions}}"
wx:key="id"
data-type="{{item.type}}"
bindtap="onOtherFunctionTap"
>
<view class="other-icon" style="background-color: {{item.color}}">
<image class="icon-image" src="{{item.img}}" mode="aspectFit"/>
</view>
<text class="other-name">{{item.name}}</text>
</view>
</view>
</view>
</view>
<!-- 底部标签栏 -->
<view class="tab-bar">
<view class="tab-item active">
<image class="tab-icon" src="/images/home-active.png" mode="aspectFit"/>
<text class="tab-text">首页</text>
</view>
<view class="tab-item">
<image class="tab-icon" src="/images/farmers.png" mode="aspectFit"/>
<text class="tab-text">养殖户</text>
</view>
<view class="tab-item">
<image class="tab-icon" src="/images/profile.png" mode="aspectFit"/>
<text class="tab-text">我的</text>
</view>
</view>

View File

@@ -1,187 +1,199 @@
/* pages/index/index.wxss */
.home-container {
.container {
min-height: 100vh;
background: #f6f6f6;
background: #f5f5f5;
padding-bottom: 120rpx; /* 为底部标签栏留出空间 */
}
.welcome-section {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
padding: 40rpx 30rpx 60rpx;
color: #fff;
}
.welcome-content {
/* 顶部导航栏 */
.nav-bar {
background: linear-gradient(135deg, #7CB342 0%, #8BC34A 100%);
height: 88rpx;
display: flex;
align-items: center;
justify-content: space-between;
align-items: center;
padding: 0 30rpx;
color: white;
}
.user-info {
display: flex;
align-items: center;
}
.avatar {
margin-right: 24rpx;
}
.avatar-img {
width: 80rpx;
height: 80rpx;
border-radius: 40rpx;
background: rgba(255, 255, 255, 0.2);
}
.username {
font-size: 36rpx;
font-weight: 600;
margin-bottom: 8rpx;
}
.user-role {
font-size: 24rpx;
opacity: 0.8;
}
.weather-info {
text-align: right;
}
.weather-icon {
.nav-title {
font-size: 32rpx;
margin-bottom: 8rpx;
}
.weather-text {
font-size: 24rpx;
opacity: 0.8;
}
.quick-actions,
.stats-section,
.recent-activities {
padding: 30rpx;
background: #fff;
margin-bottom: 20rpx;
}
.section-title {
font-size: 32rpx;
font-weight: 600;
color: #333;
margin-bottom: 30rpx;
}
.action-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 30rpx;
}
.action-item {
display: flex;
flex-direction: column;
align-items: center;
padding: 30rpx 20rpx;
background: #f8f9fa;
border-radius: 16rpx;
transition: all 0.3s;
}
.action-item:active {
transform: scale(0.95);
background: #e9ecef;
}
.action-icon {
font-size: 48rpx;
margin-bottom: 16rpx;
}
.action-text {
font-size: 24rpx;
color: #666;
text-align: center;
}
.stats-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 20rpx;
}
.stat-item {
padding: 30rpx;
background: #f8f9fa;
border-radius: 16rpx;
text-align: center;
}
.stat-value {
font-size: 48rpx;
font-weight: 600;
color: #1890ff;
margin-bottom: 8rpx;
}
.stat-label {
font-size: 24rpx;
color: #666;
margin-bottom: 8rpx;
}
.stat-trend {
font-size: 20rpx;
font-weight: 500;
}
.stat-trend.up {
color: #52c41a;
}
.stat-trend.down {
color: #ff4d4f;
}
.activity-list {
space-y: 20rpx;
}
.activity-item {
.nav-actions {
display: flex;
align-items: center;
padding: 20rpx 0;
border-bottom: 1rpx solid #f0f0f0;
background: rgba(255, 255, 255, 0.2);
border-radius: 44rpx;
padding: 8rpx 16rpx;
}
.activity-item:last-child {
border-bottom: none;
}
.activity-icon {
font-size: 32rpx;
margin-right: 20rpx;
width: 60rpx;
text-align: center;
}
.activity-content {
flex: 1;
}
.activity-title {
font-size: 28rpx;
color: #333;
margin-bottom: 8rpx;
}
.activity-desc {
.nav-icon {
font-size: 24rpx;
color: #666;
margin: 0 8rpx;
width: 24rpx;
height: 24rpx;
display: flex;
align-items: center;
justify-content: center;
}
/* 区域样式 */
.section {
background: white;
margin: 20rpx 0;
border-radius: 0;
}
.section-header {
display: flex;
align-items: center;
padding: 24rpx 30rpx;
background: #f8f8f8;
border-bottom: 1rpx solid #e8e8e8;
}
.section-indicator {
width: 6rpx;
height: 28rpx;
background: #2c5aa0;
margin-right: 16rpx;
border-radius: 3rpx;
}
.section-title {
font-size: 28rpx;
font-weight: 500;
color: #333;
}
/* 智能硬件设备网格 */
.hardware-grid {
display: flex;
flex-wrap: nowrap;
padding: 30rpx 20rpx;
background: white;
justify-content: space-between;
}
.hardware-item {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
margin: 0 10rpx;
}
.hardware-icon {
width: 120rpx;
height: 120rpx;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 20rpx;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
}
.icon-image {
width: 60rpx;
height: 60rpx;
}
.hardware-name {
font-size: 26rpx;
color: #333;
text-align: center;
line-height: 1.3;
font-weight: 500;
}
/* 其它功能网格 */
.other-grid {
display: flex;
flex-wrap: wrap;
padding: 30rpx;
background: white;
}
.other-item {
width: 25%;
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 40rpx;
}
.other-icon {
width: 100rpx;
height: 100rpx;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 16rpx;
}
.other-name {
font-size: 24rpx;
color: #333;
text-align: center;
line-height: 1.2;
word-break: break-all;
}
.icon-image {
width: 60rpx;
height: 60rpx;
}
/* 底部标签栏 */
.tab-bar {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 120rpx;
background: white;
display: flex;
align-items: center;
justify-content: space-around;
border-top: 1rpx solid #e8e8e8;
padding-bottom: env(safe-area-inset-bottom);
}
.tab-item {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
flex: 1;
height: 100%;
}
.tab-icon {
width: 48rpx;
height: 48rpx;
margin-bottom: 8rpx;
}
.activity-time {
.tab-text {
font-size: 20rpx;
color: #999;
}
}
.tab-item.active .tab-text {
color: #7CB342;
}
/* 点击效果 */
.hardware-item:active,
.other-item:active {
transform: scale(0.95);
transition: transform 0.1s;
}
.tab-item:active {
background: rgba(0, 0, 0, 0.05);
}