修改小程序及大屏

This commit is contained in:
2025-10-23 17:26:47 +08:00
parent 212dffd0da
commit 07bd3ce5da
90 changed files with 3348 additions and 3554 deletions

View File

@@ -1,70 +1,34 @@
// pages/farmer/farmer.js
const app = getApp();
const apiService = require('../../utils/api.js');
Page({
data: {
statusBarHeight: 0,
loading: true,
mode: 'view', // view, edit, add
farmerId: null,
farmerInfo: {},
formData: {},
animalTypes: ['牛羊混养', '肉牛养殖', '奶牛养殖', '羊养殖', '其他'],
animalTypeIndex: 0,
loading: false
},
onLoad: function (options) {
this.checkLoginStatus();
// 搜索和筛选
searchKeyword: '',
selectedStatus: 'all',
selectedArea: 'all',
// 筛选选项
statusOptions: [
{ value: 'all', label: '全部状态' },
{ value: 'normal', label: '正常' },
{ value: 'warning', label: '异常' },
{ value: 'offline', label: '离线' }
],
areaOptions: [
{ value: 'all', label: '全部区域' },
{ value: 'area1', label: '银川市' },
{ value: 'area2', label: '石嘴山市' },
{ value: 'area3', label: '吴忠市' },
{ value: 'area4', label: '固原市' },
{ value: 'area5', label: '中卫市' }
],
// 养殖户列表
farmerList: [],
// 分页
currentPage: 1,
pageSize: 10,
totalCount: 0,
hasMore: true,
// 统计信息
statistics: {
total: 0,
normal: 0,
warning: 0,
offline: 0
// 根据参数确定页面模式
if (options.mode === 'add') {
this.setData({
mode: 'add'
});
this.initFormData();
} else if (options.id) {
this.setData({
mode: 'view',
farmerId: options.id
});
this.loadFarmerInfo(options.id);
}
},
onLoad() {
// 获取状态栏高度
const systemInfo = wx.getSystemInfoSync();
this.setData({
statusBarHeight: systemInfo.statusBarHeight
});
// 检查登录状态
this.checkLoginStatus();
},
onShow() {
// 每次显示页面时刷新数据
this.loadData();
},
// 检查登录状态
checkLoginStatus() {
checkLoginStatus: function() {
const token = wx.getStorageSync('token');
if (!token) {
wx.reLaunch({
@@ -75,268 +39,182 @@ Page({
return true;
},
// 加载数据
async loadData(isRefresh = true) {
if (!this.checkLoginStatus()) return;
if (isRefresh) {
this.setData({
loading: true,
currentPage: 1,
farmerList: [],
hasMore: true
});
}
try {
await this.loadFarmers();
} catch (error) {
console.error('数据加载失败:', error);
// 加载模拟数据作为备用
this.loadMockData();
} finally {
this.setData({ loading: false });
}
},
// 加载养殖户信息
loadFarmerInfo: function(farmerId) {
this.setData({ loading: true });
// 加载养殖户列表
async loadFarmers() {
try {
const params = {
page: this.data.currentPage,
pageSize: this.data.pageSize,
keyword: this.data.searchKeyword,
status: this.data.selectedStatus === 'all' ? '' : this.data.selectedStatus,
area: this.data.selectedArea === 'all' ? '' : this.data.selectedArea
};
const result = await apiService.getFarmers(params);
if (result.code === 200 || result.code === 0) {
const data = result.data || result;
const farmers = data.list || data.farmers || [];
// 处理数据格式
const formattedFarmers = farmers.map(farmer => ({
id: farmer.id,
name: farmer.name || farmer.farmerName,
phone: farmer.phone || farmer.mobile,
area: farmer.area || farmer.region,
farmName: farmer.farmName || farmer.farm_name,
animalCount: farmer.animalCount || farmer.animal_count || 0,
animalType: farmer.animalType || farmer.animal_type,
status: farmer.status || 'normal',
lastCheckTime: farmer.lastCheckTime || farmer.last_check_time,
avatar: farmer.avatar || '/images/avatar.png'
}));
// 更新列表数据
if (this.data.currentPage === 1) {
this.setData({
farmerList: formattedFarmers,
totalCount: data.total || farmers.length
});
} else {
this.setData({
farmerList: [...this.data.farmerList, ...formattedFarmers]
});
}
// 更新分页状态
this.setData({
hasMore: formattedFarmers.length >= this.data.pageSize
});
// 更新统计信息
if (data.statistics) {
this.setData({
statistics: data.statistics
});
} else {
this.calculateStatistics();
}
}
} catch (error) {
console.error('获取养殖户列表失败:', error);
throw error;
}
},
// 加载模拟数据
loadMockData() {
const mockFarmers = [
{
id: 1,
name: '张三',
phone: '138****1234',
area: '银川市',
farmName: '张家养殖场',
animalCount: 120,
animalType: '牛',
status: 'normal',
lastCheckTime: '2024-01-15 10:30',
avatar: '/images/avatar.png'
},
{
id: 2,
name: '李四',
phone: '139****5678',
area: '石嘴山市',
farmName: '李氏牧场',
animalCount: 85,
animalType: '羊',
status: 'warning',
lastCheckTime: '2024-01-14 16:20',
avatar: '/images/avatar.png'
},
{
id: 3,
name: '王五',
phone: '137****9012',
area: '吴忠市',
farmName: '王家农场',
animalCount: 200,
animalType: '牛',
status: 'normal',
lastCheckTime: '2024-01-15 09:15',
avatar: '/images/avatar.png'
}
];
this.setData({
farmerList: mockFarmers,
totalCount: mockFarmers.length,
hasMore: false,
statistics: {
total: 3,
normal: 2,
warning: 1,
offline: 0
}
});
},
// 计算统计信息
calculateStatistics() {
const farmers = this.data.farmerList;
const statistics = {
total: farmers.length,
normal: farmers.filter(f => f.status === 'normal').length,
warning: farmers.filter(f => f.status === 'warning').length,
offline: farmers.filter(f => f.status === 'offline').length
// 模拟数据
const mockFarmer = {
id: farmerId,
name: '张三',
phone: '13800138001',
address: '宁夏银川市兴庆区某某村123号',
farmName: '张三养殖场',
animalCount: 120,
status: 'active',
registerTime: '2023-01-15',
animalType: '牛羊混养',
farmArea: '500',
lastCheckTime: '2024-01-15'
};
setTimeout(() => {
this.setData({
farmerInfo: mockFarmer,
loading: false
});
}, 1000);
},
// 初始化表单数据
initFormData: function() {
this.setData({
formData: {
name: '',
farmName: '',
phone: '',
address: '',
animalCount: '',
animalType: '',
farmArea: ''
}
});
},
// 返回上一页
onBack: function() {
wx.navigateBack();
},
// 编辑模式
onEdit: function() {
const { farmerInfo } = this.data;
this.setData({
mode: 'edit',
formData: {
name: farmerInfo.name,
farmName: farmerInfo.farmName,
phone: farmerInfo.phone,
address: farmerInfo.address,
animalCount: farmerInfo.animalCount.toString(),
animalType: farmerInfo.animalType,
farmArea: farmerInfo.farmArea
},
animalTypeIndex: this.data.animalTypes.indexOf(farmerInfo.animalType)
});
},
// 输入框变化
onInputChange: function(e) {
const field = e.currentTarget.dataset.field;
const value = e.detail.value;
this.setData({
[`formData.${field}`]: value
});
},
// 选择器变化
onPickerChange: function(e) {
const field = e.currentTarget.dataset.field;
const index = e.detail.value;
const value = this.data.animalTypes[index];
this.setData({ statistics });
},
onPullDownRefresh() {
this.loadData(true).finally(() => {
wx.stopPullDownRefresh();
});
},
onReachBottom() {
this.onLoadMore();
},
// 搜索输入
onSearchInput(e) {
this.setData({
searchKeyword: e.detail.value
[`formData.${field}`]: value,
animalTypeIndex: index
});
},
// 执行搜索
onSearch() {
this.loadData(true);
},
// 清空搜索
onClearSearch() {
this.setData({
searchKeyword: ''
});
this.loadData(true);
},
// 状态筛选
onStatusChange(e) {
const status = e.currentTarget.dataset.status;
this.setData({
selectedStatus: status
});
this.loadData(true);
},
// 区域筛选
onAreaChange(e) {
const area = e.currentTarget.dataset.area;
this.setData({
selectedArea: area
});
this.loadData(true);
},
// 养殖户项点击
onFarmerTap(e) {
const { farmer } = e.currentTarget.dataset;
wx.navigateTo({
url: `/pages/farmer/detail/detail?id=${farmer.id}`
});
},
// 添加养殖户
onAddFarmer() {
wx.navigateTo({
url: '/pages/farmer/add/add'
});
},
// 编辑养殖户
onEditFarmer(e) {
e.stopPropagation();
const { farmer } = e.currentTarget.dataset;
wx.navigateTo({
url: `/pages/farmer/edit/edit?id=${farmer.id}`
});
},
// 拨打电话
onCallFarmer(e) {
e.stopPropagation();
const { farmer } = e.currentTarget.dataset;
// 保存数据
onSave: function() {
const { formData, mode } = this.data;
// 验证必填字段
if (!formData.name || !formData.farmName || !formData.phone || !formData.address || !formData.animalCount) {
wx.showToast({
title: '请填写完整信息',
icon: 'none'
});
return;
}
// 验证手机号
const phoneRegex = /^1[3-9]\d{9}$/;
if (!phoneRegex.test(formData.phone)) {
wx.showToast({
title: '请输入正确的手机号',
icon: 'none'
});
return;
}
wx.showLoading({
title: mode === 'add' ? '保存中...' : '更新中...'
});
// 模拟保存
setTimeout(() => {
wx.hideLoading();
wx.showToast({
title: mode === 'add' ? '保存成功' : '更新成功',
icon: 'success'
});
setTimeout(() => {
if (mode === 'add') {
wx.navigateBack();
} else {
// 更新模式,重新加载数据并切换到查看模式
this.loadFarmerInfo(this.data.farmerId);
this.setData({ mode: 'view' });
}
}, 1500);
}, 1000);
},
// 取消编辑
onCancel: function() {
if (this.data.mode === 'add') {
wx.navigateBack();
} else {
this.setData({ mode: 'view' });
}
},
// 删除养殖户
onDelete: function() {
wx.showModal({
title: '拨打电话',
content: `确定要拨打 ${farmer.name} 的电话吗?`,
title: '确认删除',
content: '确定要删除这个养殖户吗?此操作不可恢复。',
confirmText: '删除',
confirmColor: '#F44336',
success: (res) => {
if (res.confirm) {
wx.makePhoneCall({
phoneNumber: farmer.phone.replace(/\*/g, '1') // 替换掩码
wx.showLoading({
title: '删除中...'
});
// 模拟删除
setTimeout(() => {
wx.hideLoading();
wx.showToast({
title: '删除成功',
icon: 'success'
});
setTimeout(() => {
wx.navigateBack();
}, 1500);
}, 1000);
}
}
});
},
// 加载更多
onLoadMore() {
if (!this.data.hasMore || this.data.loading) return;
this.setData({
currentPage: this.data.currentPage + 1
});
this.loadData(false);
},
// 分享页面
onShareAppMessage() {
onShareAppMessage: function() {
return {
title: '政府监管端 - 养殖户管理',
path: '/pages/farmer/farmer'
title: '养殖户详情',
path: `/pages/farmer/farmer?id=${this.data.farmerId}`
};
}
});

View File

@@ -1,139 +1,179 @@
<!--pages/farmer/farmer.wxml-->
<view class="container">
<!-- 状态栏 -->
<view class="status-bar">
<view class="status-left">
<text>17:00</text>
</view>
<view class="status-right">
<text>100%</text>
<view class="battery-icon"></view>
</view>
</view>
<!-- 顶部标题栏 -->
<view class="farmer-container">
<!-- 标题栏 -->
<view class="header">
<view class="header-title">养殖户管理</view>
<view class="header-actions">
<view class="action-btn" bindtap="onMenuTap">
<text class="icon-more">⋯</text>
<view class="header-left">
<view class="back-btn" bindtap="onBack">
<text class="back-icon">←</text>
</view>
<view class="action-btn">
<text class="icon-minus"></text>
</view>
<view class="action-btn">
<text class="icon-circle">●</text>
<text class="title">{{mode === 'add' ? '新增养殖户' : mode === 'edit' ? '编辑养殖户' : '养殖户详情'}}</text>
</view>
<view class="header-right" wx:if="{{mode === 'view'}}">
<view class="action-btn" bindtap="onEdit">
<text class="edit-icon">✏️</text>
</view>
</view>
</view>
<!-- 搜索框 -->
<view class="search-section">
<view class="search-box">
<view class="search-icon">🔍</view>
<input
class="search-input"
placeholder="请输入账号、昵称、真实"
value="{{searchValue}}"
bindinput="onSearchInput"
bindconfirm="onSearch"
/>
</view>
</view>
<!-- 养殖户列表 -->
<view class="farmer-list">
<view
class="farmer-card"
wx:for="{{farmerList}}"
wx:key="id"
data-farmer="{{item}}"
bindtap="viewFarmerDetail"
>
<!-- 养殖户基本信息 -->
<view class="farmer-info">
<view class="farmer-header">
<view class="farmer-name">{{item.name}}</view>
<view class="farmer-status {{item.status === '正常' ? 'status-normal' : item.status === '异常' ? 'status-error' : 'status-pending'}}">
{{item.status}}
</view>
</view>
<view class="farmer-details">
<view class="detail-item">
<text class="detail-label">手机号码:</text>
<text class="detail-value">{{item.phone}}</text>
</view>
<view class="detail-item">
<text class="detail-label">所在地区:</text>
<text class="detail-value">{{item.area}}</text>
</view>
<view class="detail-item">
<text class="detail-label">养殖场名:</text>
<text class="detail-value">{{item.farmName}}</text>
</view>
<view class="detail-item">
<text class="detail-label">牲畜数量:</text>
<text class="detail-value">{{item.animalCount}}头</text>
</view>
<view class="detail-item">
<text class="detail-label">注册时间:</text>
<text class="detail-value">{{item.registerTime}}</text>
</view>
<view class="detail-item">
<text class="detail-label">最近检查:</text>
<text class="detail-value">{{item.lastCheckTime}}</text>
</view>
</view>
<!-- 养殖户详情卡片 -->
<view class="farmer-detail-card" wx:if="{{mode === 'view'}}">
<view class="card-header">
<view class="farmer-avatar">
<text class="avatar-text">{{farmerInfo.name.charAt(0)}}</text>
</view>
<!-- 操作按钮 -->
<view class="farmer-actions">
<view
class="action-btn edit-btn"
data-farmer="{{item}}"
bindtap="editFarmer"
catchtap="true"
>
<text class="action-icon">✏️</text>
<text class="action-text">编辑</text>
</view>
<view
class="action-btn status-btn"
data-farmer="{{item}}"
bindtap="toggleFarmerStatus"
catchtap="true"
>
<text class="action-icon">🔄</text>
<text class="action-text">{{item.status === '正常' ? '标记异常' : '标记正常'}}</text>
</view>
<view
class="action-btn delete-btn"
data-farmer="{{item}}"
bindtap="deleteFarmer"
catchtap="true"
>
<text class="action-icon">🗑️</text>
<text class="action-text">删除</text>
<view class="farmer-basic">
<view class="farmer-name">{{farmerInfo.name}}</view>
<view class="status-tag {{farmerInfo.status}}">
<text>{{farmerInfo.status === 'active' ? '正常' : farmerInfo.status === 'pending' ? '待审核' : '停用'}}</text>
</view>
</view>
</view>
<!-- 空状态 -->
<view class="empty-state" wx:if="{{farmerList.length === 0 && !loading}}">
<text class="empty-text">暂无养殖户数据</text>
</view>
<view class="card-content">
<view class="info-section">
<view class="section-title">基本信息</view>
<view class="info-grid">
<view class="info-item">
<text class="info-label">农场名称</text>
<text class="info-value">{{farmerInfo.farmName}}</text>
</view>
<view class="info-item">
<text class="info-label">联系电话</text>
<text class="info-value">{{farmerInfo.phone}}</text>
</view>
<view class="info-item">
<text class="info-label">农场地址</text>
<text class="info-value">{{farmerInfo.address}}</text>
</view>
<view class="info-item">
<text class="info-label">注册时间</text>
<text class="info-value">{{farmerInfo.registerTime}}</text>
</view>
</view>
</view>
<!-- 加载状态 -->
<view class="loading-state" wx:if="{{loading}}">
<text>加载中...</text>
<view class="info-section">
<view class="section-title">养殖信息</view>
<view class="info-grid">
<view class="info-item">
<text class="info-label">牲畜数量</text>
<text class="info-value highlight">{{farmerInfo.animalCount}}头</text>
</view>
<view class="info-item">
<text class="info-label">养殖类型</text>
<text class="info-value">{{farmerInfo.animalType || '牛羊混养'}}</text>
</view>
<view class="info-item">
<text class="info-label">农场面积</text>
<text class="info-value">{{farmerInfo.farmArea || '500亩'}}</text>
</view>
<view class="info-item">
<text class="info-label">最近检查</text>
<text class="info-value">{{farmerInfo.lastCheckTime || '2024-01-15'}}</text>
</view>
</view>
</view>
</view>
</view>
<!-- 底部新增按钮 -->
<view class="bottom-section">
<view class="add-farmer-btn" bindtap="addFarmer">
新增监管养殖户
<!-- 表单编辑模式 -->
<view class="farmer-form" wx:if="{{mode === 'add' || mode === 'edit'}}">
<view class="form-section">
<view class="section-title">基本信息</view>
<view class="form-group">
<text class="form-label">养殖户姓名 <text class="required">*</text></text>
<input
class="form-input"
placeholder="请输入养殖户姓名"
value="{{formData.name}}"
bindinput="onInputChange"
data-field="name"
/>
</view>
<view class="form-group">
<text class="form-label">农场名称 <text class="required">*</text></text>
<input
class="form-input"
placeholder="请输入农场名称"
value="{{formData.farmName}}"
bindinput="onInputChange"
data-field="farmName"
/>
</view>
<view class="form-group">
<text class="form-label">联系电话 <text class="required">*</text></text>
<input
class="form-input"
placeholder="请输入联系电话"
type="number"
value="{{formData.phone}}"
bindinput="onInputChange"
data-field="phone"
/>
</view>
<view class="form-group">
<text class="form-label">农场地址 <text class="required">*</text></text>
<textarea
class="form-textarea"
placeholder="请输入农场详细地址"
value="{{formData.address}}"
bindinput="onInputChange"
data-field="address"
/>
</view>
</view>
<view class="form-section">
<view class="section-title">养殖信息</view>
<view class="form-group">
<text class="form-label">牲畜数量 <text class="required">*</text></text>
<input
class="form-input"
placeholder="请输入牲畜数量"
type="number"
value="{{formData.animalCount}}"
bindinput="onInputChange"
data-field="animalCount"
/>
</view>
<view class="form-group">
<text class="form-label">养殖类型</text>
<picker
class="form-picker"
bindchange="onPickerChange"
data-field="animalType"
value="{{animalTypeIndex}}"
range="{{animalTypes}}"
>
<view class="picker-content">
<text class="picker-text">{{formData.animalType || '请选择养殖类型'}}</text>
<text class="picker-arrow">></text>
</view>
</picker>
</view>
<view class="form-group">
<text class="form-label">农场面积</text>
<input
class="form-input"
placeholder="请输入农场面积(亩)"
type="digit"
value="{{formData.farmArea}}"
bindinput="onInputChange"
data-field="farmArea"
/>
</view>
</view>
</view>
<!-- 操作按钮 -->
<view class="action-buttons">
<view class="btn-group" wx:if="{{mode === 'view'}}">
<view class="btn btn-secondary" bindtap="onEdit">编辑信息</view>
<view class="btn btn-danger" bindtap="onDelete">删除养殖户</view>
</view>
<view class="btn-group" wx:if="{{mode === 'add' || mode === 'edit'}}">
<view class="btn btn-secondary" bindtap="onCancel">取消</view>
<view class="btn btn-primary" bindtap="onSave">{{mode === 'add' ? '保存' : '更新'}}</view>
</view>
</view>
</view>

View File

@@ -1,53 +1,343 @@
/* pages/farmer/farmer.wxss */
.container {
.farmer-container {
background-color: #f5f7fa;
min-height: 100vh;
background-color: #f5f5f5;
padding-bottom: 120rpx; /* 为底部按钮留出空间 */
}
/* 确保状态栏在顶部 */
.status-bar {
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 1000;
padding: 0;
}
/* 标题栏 */
.header {
margin-top: 60rpx; /* 为状态栏留出空间 */
}
/* 状态栏 */
.status-bar {
background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
padding: 20rpx 30rpx;
display: flex;
align-items: center;
justify-content: space-between;
box-shadow: 0 4rpx 12rpx rgba(76, 175, 80, 0.15);
}
.header-left {
display: flex;
align-items: center;
background-color: #ffffff;
padding: 10rpx 30rpx;
gap: 20rpx;
}
.back-btn {
width: 60rpx;
height: 60rpx;
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
background: rgba(255, 255, 255, 0.2);
border-radius: 50%;
transition: all 0.3s ease;
}
.back-btn:active {
background: rgba(255, 255, 255, 0.3);
transform: scale(0.95);
}
.back-icon {
color: #ffffff;
font-size: 32rpx;
font-weight: bold;
}
.title {
color: #ffffff;
font-size: 36rpx;
font-weight: 600;
}
.header-right {
display: flex;
align-items: center;
}
.action-btn {
width: 60rpx;
height: 60rpx;
display: flex;
align-items: center;
justify-content: center;
background: rgba(255, 255, 255, 0.2);
border-radius: 50%;
transition: all 0.3s ease;
}
.action-btn:active {
background: rgba(255, 255, 255, 0.3);
transform: scale(0.95);
}
.edit-icon {
font-size: 28rpx;
}
/* 养殖户详情卡片 */
.farmer-detail-card {
margin: 30rpx;
background: #ffffff;
border-radius: 16rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
overflow: hidden;
}
.card-header {
background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
padding: 40rpx 30rpx;
display: flex;
align-items: center;
gap: 24rpx;
}
.farmer-avatar {
width: 100rpx;
height: 100rpx;
border-radius: 50%;
background: rgba(255, 255, 255, 0.2);
display: flex;
align-items: center;
justify-content: center;
border: 3rpx solid rgba(255, 255, 255, 0.3);
}
.avatar-text {
color: #ffffff;
font-size: 40rpx;
font-weight: 600;
}
.farmer-basic {
flex: 1;
}
.farmer-name {
color: #ffffff;
font-size: 36rpx;
font-weight: 600;
margin-bottom: 12rpx;
}
.status-tag {
display: inline-flex;
align-items: center;
padding: 8rpx 16rpx;
border-radius: 20rpx;
font-size: 24rpx;
font-weight: 500;
background: rgba(255, 255, 255, 0.2);
color: #ffffff;
border: 1rpx solid rgba(255, 255, 255, 0.3);
}
.card-content {
padding: 30rpx;
}
.info-section {
margin-bottom: 40rpx;
}
.info-section:last-child {
margin-bottom: 0;
}
.section-title {
font-size: 32rpx;
font-weight: 600;
color: #333333;
margin-bottom: 24rpx;
padding-bottom: 12rpx;
border-bottom: 2rpx solid #4CAF50;
}
.status-left {
.info-grid {
display: flex;
flex-direction: column;
gap: 20rpx;
}
.info-item {
display: flex;
align-items: center;
padding: 16rpx 0;
border-bottom: 1rpx solid #f0f0f0;
}
.status-right {
.info-item:last-child {
border-bottom: none;
}
.info-label {
color: #666666;
font-size: 28rpx;
width: 160rpx;
flex-shrink: 0;
}
.info-value {
color: #333333;
font-size: 28rpx;
font-weight: 500;
flex: 1;
}
.info-value.highlight {
color: #4CAF50;
font-weight: 600;
}
/* 表单样式 */
.farmer-form {
padding: 30rpx;
}
.form-section {
background: #ffffff;
border-radius: 16rpx;
padding: 30rpx;
margin-bottom: 30rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
}
.form-group {
margin-bottom: 30rpx;
}
.form-group:last-child {
margin-bottom: 0;
}
.form-label {
display: block;
color: #333333;
font-size: 28rpx;
font-weight: 500;
margin-bottom: 12rpx;
}
.required {
color: #F44336;
}
.form-input,
.form-textarea {
width: 100%;
background: #f8f9fa;
border: 2rpx solid #e8e8e8;
border-radius: 12rpx;
padding: 20rpx;
font-size: 28rpx;
color: #333333;
box-sizing: border-box;
transition: all 0.3s ease;
}
.form-input:focus,
.form-textarea:focus {
border-color: #4CAF50;
background: #ffffff;
box-shadow: 0 0 0 4rpx rgba(76, 175, 80, 0.1);
}
.form-input {
height: 80rpx;
}
.form-textarea {
min-height: 120rpx;
resize: vertical;
}
.form-picker {
width: 100%;
background: #f8f9fa;
border: 2rpx solid #e8e8e8;
border-radius: 12rpx;
transition: all 0.3s ease;
}
.form-picker:active {
border-color: #4CAF50;
background: #ffffff;
}
.picker-content {
display: flex;
align-items: center;
gap: 10rpx;
justify-content: space-between;
padding: 20rpx;
height: 80rpx;
box-sizing: border-box;
}
.battery-icon {
width: 20rpx;
height: 12rpx;
background-color: #333333;
border-radius: 2rpx;
position: relative;
.picker-text {
font-size: 28rpx;
color: #333333;
flex: 1;
}
.picker-arrow {
color: #999999;
font-size: 24rpx;
}
/* 操作按钮 */
.action-buttons {
padding: 30rpx;
background: #ffffff;
border-top: 1rpx solid #e8e8e8;
}
.btn-group {
display: flex;
gap: 20rpx;
}
.btn {
flex: 1;
height: 88rpx;
display: flex;
align-items: center;
justify-content: center;
border-radius: 12rpx;
font-size: 32rpx;
font-weight: 600;
transition: all 0.3s ease;
}
.btn-primary {
background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
color: #ffffff;
box-shadow: 0 4rpx 12rpx rgba(76, 175, 80, 0.25);
}
.btn-primary:active {
transform: translateY(2rpx);
box-shadow: 0 2rpx 8rpx rgba(76, 175, 80, 0.25);
}
.btn-secondary {
background: #f8f9fa;
color: #666666;
border: 2rpx solid #e8e8e8;
}
.btn-secondary:active {
background: #e8e8e8;
transform: translateY(2rpx);
}
.btn-danger {
background: linear-gradient(135deg, #F44336 0%, #d32f2f 100%);
color: #ffffff;
box-shadow: 0 4rpx 12rpx rgba(244, 67, 54, 0.25);
}
.btn-danger:active {
transform: translateY(2rpx);
box-shadow: 0 2rpx 8rpx rgba(244, 67, 54, 0.25);
}
.battery-icon::after {

View File

@@ -2,8 +2,10 @@
Page({
data: {
farmers: [],
allFarmers: [], // 存储所有养殖户数据
loading: false,
searchKeyword: '',
activeTab: 'all', // 当前激活的筛选标签
currentPage: 1,
pageSize: 10,
total: 0
@@ -45,35 +47,83 @@ Page({
address: '宁夏银川市兴庆区',
farmName: '张三养殖场',
animalCount: 120,
status: 'active'
status: 'active',
registerTime: '2023-01-15'
},
{
id: 2,
name: '李四',
phone: '13800138002',
address: '宁夏银川市金凤区',
farmName: '李四牧',
address: '宁夏石嘴山市大武口区',
farmName: '李四牧',
animalCount: 85,
status: 'active'
status: 'pending',
registerTime: '2023-02-20'
},
{
id: 3,
name: '王五',
phone: '13800138003',
address: '宁夏银川市西夏区',
farmName: '王五养殖合作社',
address: '宁夏吴忠市利通区',
farmName: '王五农场',
animalCount: 200,
status: 'inactive'
status: 'inactive',
registerTime: '2023-03-10'
},
{
id: 4,
name: '赵六',
phone: '13800138004',
address: '宁夏固原市原州区',
farmName: '赵六养殖合作社',
animalCount: 150,
status: 'active',
registerTime: '2023-04-05'
}
];
setTimeout(() => {
this.setData({
farmers: mockFarmers,
loading: false,
total: mockFarmers.length
allFarmers: mockFarmers,
loading: false
});
}, 500);
this.filterFarmers();
}, 1000);
},
// 筛选标签切换
onTabChange: function(e) {
const tab = e.currentTarget.dataset.tab;
this.setData({
activeTab: tab
});
this.filterFarmers();
},
// 根据当前标签和搜索关键词筛选养殖户
filterFarmers: function() {
const { allFarmers, activeTab, searchKeyword } = this.data;
let filteredFarmers = [...allFarmers];
// 按状态筛选
if (activeTab !== 'all') {
filteredFarmers = filteredFarmers.filter(farmer => farmer.status === activeTab);
}
// 按搜索关键词筛选
if (searchKeyword.trim()) {
const keyword = searchKeyword.trim().toLowerCase();
filteredFarmers = filteredFarmers.filter(farmer =>
farmer.name.toLowerCase().includes(keyword) ||
farmer.farmName.toLowerCase().includes(keyword) ||
farmer.phone.includes(keyword)
);
}
this.setData({
farmers: filteredFarmers,
total: filteredFarmers.length
});
},
onSearchInput: function(e) {
@@ -83,19 +133,19 @@ Page({
},
onSearch: function() {
this.loadFarmers();
this.filterFarmers();
},
onFarmerTap: function(e) {
const farmerId = e.currentTarget.dataset.id;
wx.navigateTo({
url: `/pages/farmer/detail/detail?id=${farmerId}`
url: `/pages/farmer/farmer?id=${farmerId}`
});
},
onAddFarmer: function() {
wx.navigateTo({
url: '/pages/farmer/add/add'
url: '/pages/farmer/farmer?mode=add'
});
},
@@ -105,14 +155,13 @@ Page({
},
onReachBottom: function() {
// 加载更多数据
if (this.data.farmers.length < this.data.total) {
this.loadMoreFarmers();
}
},
loadMoreFarmers: function() {
// 实现分页加载
// 实际项目中这里会加载更多数据
console.log('加载更多养殖户数据');
},

View File

@@ -1,27 +1,66 @@
<!--pages/farmers/farmers.wxml-->
<view class="container">
<!-- 顶部搜索栏 -->
<view class="search-bar">
<view class="search-input-wrapper">
<input
class="search-input"
placeholder="搜索养殖户姓名或农场名称"
value="{{searchKeyword}}"
bindinput="onSearchInput"
bindconfirm="onSearch"
/>
<view class="search-btn" bindtap="onSearch">
<text class="search-icon">🔍</text>
</view>
<view class="farmers-container">
<!-- 标题栏 -->
<view class="header">
<text class="title">养殖户管理</text>
</view>
<!-- 筛选标签 -->
<view class="filter-tabs">
<view
class="tab-item {{activeTab === 'all' ? 'active' : ''}}"
data-tab="all"
bindtap="onTabChange"
>
<text>全部</text>
</view>
<view class="add-btn" bindtap="onAddFarmer">
<text class="add-icon">+</text>
<text class="add-text">新增</text>
<view
class="tab-item {{activeTab === 'active' ? 'active' : ''}}"
data-tab="active"
bindtap="onTabChange"
>
<text>正常</text>
</view>
<view
class="tab-item {{activeTab === 'pending' ? 'active' : ''}}"
data-tab="pending"
bindtap="onTabChange"
>
<text>待审核</text>
</view>
<view
class="tab-item {{activeTab === 'inactive' ? 'active' : ''}}"
data-tab="inactive"
bindtap="onTabChange"
>
<text>停用</text>
</view>
</view>
<!-- 搜索栏 -->
<view class="search-section">
<view class="search-bar">
<view class="search-input-wrapper">
<input
class="search-input"
placeholder="搜索养殖户姓名或农场名称"
value="{{searchKeyword}}"
bindinput="onSearchInput"
bindconfirm="onSearch"
/>
<view class="search-btn" bindtap="onSearch">
<text class="search-icon">🔍</text>
</view>
</view>
<view class="add-btn" bindtap="onAddFarmer">
<text class="add-icon">+</text>
<text class="add-text">新增</text>
</view>
</view>
</view>
<!-- 养殖户列表 -->
<view class="farmers-list">
<view class="farmer-list">
<view
class="farmer-item"
wx:for="{{farmers}}"
@@ -29,49 +68,54 @@
data-id="{{item.id}}"
bindtap="onFarmerTap"
>
<view class="farmer-avatar">
<text class="avatar-text">{{item.name.charAt(0)}}</text>
</view>
<!-- 养殖户标题 -->
<view class="farmer-title">{{item.name}} - {{item.farmName}}</view>
<!-- 养殖户信息 -->
<view class="farmer-info">
<view class="farmer-header">
<text class="farmer-name">{{item.name}}</text>
<view class="farmer-status {{item.status}}">
<text class="status-text">{{item.status === 'active' ? '正常' : '停用'}}</text>
<view class="info-row">
<text class="info-label">负责人:</text>
<text class="info-value">{{item.name}}</text>
</view>
<view class="info-row">
<text class="info-label">当前状态:</text>
<view class="status-tag {{item.status}}">
<text>{{item.status === 'active' ? '正常' : item.status === 'pending' ? '待审核' : '停用'}}</text>
</view>
</view>
<view class="farmer-details">
<view class="detail-item">
<text class="detail-label">农场</text>
<text class="detail-value">{{item.farmName}}</text>
</view>
<view class="detail-item">
<text class="detail-label">电话:</text>
<text class="detail-value">{{item.phone}}</text>
</view>
<view class="detail-item">
<text class="detail-label">地址:</text>
<text class="detail-value">{{item.address}}</text>
</view>
<view class="detail-item">
<text class="detail-label">牲畜数量:</text>
<text class="detail-value animal-count">{{item.animalCount}}头</text>
</view>
<view class="info-row">
<text class="info-label">联系电话</text>
<text class="info-value">{{item.phone}}</text>
</view>
<view class="info-row">
<text class="info-label">牲畜数量:</text>
<text class="info-value">{{item.animalCount}}头</text>
</view>
<view class="info-row">
<text class="info-label">农场地址:</text>
<text class="info-value">{{item.address}}</text>
</view>
<view class="info-row">
<text class="info-label">注册时间:</text>
<text class="info-value">{{item.registerTime}}</text>
</view>
</view>
<view class="farmer-arrow">
<text class="arrow-icon">></text>
</view>
</view>
</view>
<!-- 加载状态 -->
<view class="loading" wx:if="{{loading}}">
<view class="loading-state" wx:if="{{loading}}">
<text class="loading-text">加载中...</text>
</view>
<!-- 空状态 -->
<view class="empty-state" wx:if="{{!loading && farmers.length === 0}}">
<text class="empty-icon">📋</text>
<image class="empty-icon" src="/images/empty.png" />
<text class="empty-text">暂无养殖户数据</text>
<view class="empty-btn" bindtap="onAddFarmer">
<text>添加养殖户</text>

View File

@@ -1,17 +1,67 @@
/* pages/farmers/farmers.wxss */
.container {
.farmers-container {
background-color: #f5f7fa;
min-height: 100vh;
background-color: #f5f5f5;
padding: 0;
}
/* 搜索栏样式 */
/* 标题栏 */
.header {
background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
padding: 20rpx 30rpx;
box-shadow: 0 4rpx 12rpx rgba(76, 175, 80, 0.15);
}
.title {
color: #ffffff;
font-size: 36rpx;
font-weight: 600;
}
/* 筛选标签 */
.filter-tabs {
display: flex;
background: #ffffff;
padding: 20rpx 30rpx;
border-bottom: 1rpx solid #e8e8e8;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
}
.tab-item {
flex: 1;
text-align: center;
padding: 16rpx 0;
border-radius: 8rpx;
margin: 0 8rpx;
transition: all 0.3s ease;
}
.tab-item text {
font-size: 28rpx;
color: #666666;
font-weight: 500;
}
.tab-item.active {
background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
box-shadow: 0 4rpx 12rpx rgba(76, 175, 80, 0.25);
}
.tab-item.active text {
color: #ffffff;
font-weight: 600;
}
/* 搜索区域 */
.search-section {
background: #ffffff;
padding: 20rpx 30rpx;
border-bottom: 1rpx solid #e8e8e8;
}
.search-bar {
display: flex;
align-items: center;
background-color: #ffffff;
padding: 20rpx 30rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
gap: 20rpx;
}
@@ -19,33 +69,200 @@
flex: 1;
display: flex;
align-items: center;
background-color: #f8f8f8;
border-radius: 25rpx;
background: #f8f9fa;
border-radius: 12rpx;
padding: 0 20rpx;
height: 70rpx;
border: 2rpx solid transparent;
transition: all 0.3s ease;
}
.search-input-wrapper:focus-within {
border-color: #4CAF50;
background: #ffffff;
box-shadow: 0 0 0 4rpx rgba(76, 175, 80, 0.1);
}
.search-input {
flex: 1;
height: 80rpx;
font-size: 28rpx;
color: #333333;
height: 100%;
background: transparent;
}
.search-input::placeholder {
color: #999999;
}
.search-btn {
width: 60rpx;
height: 60rpx;
display: flex;
align-items: center;
justify-content: center;
background-color: #7CB342;
border-radius: 50%;
margin-left: 10rpx;
padding: 8rpx;
border-radius: 8rpx;
background: #4CAF50;
transition: all 0.3s ease;
}
.search-btn:active {
background: #45a049;
transform: scale(0.95);
}
.search-icon {
color: white;
font-size: 28rpx;
color: #ffffff;
}
.add-btn {
display: flex;
align-items: center;
gap: 8rpx;
background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
color: #ffffff;
padding: 20rpx 24rpx;
border-radius: 12rpx;
font-size: 28rpx;
font-weight: 600;
box-shadow: 0 4rpx 12rpx rgba(76, 175, 80, 0.25);
transition: all 0.3s ease;
}
.add-btn:active {
transform: translateY(2rpx);
box-shadow: 0 2rpx 8rpx rgba(76, 175, 80, 0.25);
}
.add-icon {
font-size: 32rpx;
font-weight: bold;
}
/* 养殖户列表 */
.farmer-list {
padding: 20rpx 30rpx;
}
.farmer-item {
background: #ffffff;
border-radius: 16rpx;
margin-bottom: 20rpx;
padding: 30rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
border: 1rpx solid #f0f0f0;
transition: all 0.3s ease;
}
.farmer-item:active {
transform: translateY(2rpx);
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.12);
}
.farmer-title {
font-size: 32rpx;
font-weight: 600;
color: #333333;
margin-bottom: 20rpx;
padding-bottom: 16rpx;
border-bottom: 1rpx solid #f0f0f0;
}
.farmer-info {
display: flex;
flex-direction: column;
gap: 16rpx;
}
.info-row {
display: flex;
align-items: center;
font-size: 28rpx;
}
.info-label {
color: #666666;
width: 160rpx;
flex-shrink: 0;
}
.info-value {
color: #333333;
flex: 1;
font-weight: 500;
}
/* 状态标签 */
.status-tag {
display: inline-flex;
align-items: center;
padding: 8rpx 16rpx;
border-radius: 20rpx;
font-size: 24rpx;
font-weight: 500;
}
.status-tag.active {
background: rgba(76, 175, 80, 0.1);
color: #4CAF50;
}
.status-tag.pending {
background: rgba(255, 193, 7, 0.1);
color: #FFC107;
}
.status-tag.inactive {
background: rgba(244, 67, 54, 0.1);
color: #F44336;
}
/* 加载状态 */
.loading-state {
display: flex;
justify-content: center;
align-items: center;
padding: 80rpx 0;
}
.loading-text {
color: #999999;
font-size: 28rpx;
}
/* 空状态 */
.empty-state {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 120rpx 60rpx;
text-align: center;
}
.empty-icon {
width: 120rpx;
height: 120rpx;
margin-bottom: 30rpx;
opacity: 0.6;
}
.empty-text {
color: #999999;
font-size: 28rpx;
margin-bottom: 40rpx;
}
.empty-btn {
background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
color: #ffffff;
padding: 20rpx 40rpx;
border-radius: 12rpx;
font-size: 28rpx;
font-weight: 600;
box-shadow: 0 4rpx 12rpx rgba(76, 175, 80, 0.25);
transition: all 0.3s ease;
}
.empty-btn:active {
transform: translateY(2rpx);
box-shadow: 0 2rpx 8rpx rgba(76, 175, 80, 0.25);
}
.add-btn {

View File

@@ -3,3 +3,4 @@
"navigationBarTitleText": "首页",
"navigationStyle": "custom"
}

View File

@@ -1,21 +1,18 @@
<!--pages/index/index.wxml-->
<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 class="home-container">
<!-- 标题栏 -->
<view class="header">
<view class="header-left">
<text class="title">首页</text>
</view>
<view class="header-right">
<!-- 可以在这里添加右侧操作按钮 -->
</view>
</view>
<!-- 智能硬件设备区域 -->
<view class="section">
<view class="section-header">
<view class="section-indicator"></view>
<text class="section-title">智能硬件设备</text>
</view>
<view class="section card">
<view class="section-title">智能硬件设备</view>
<view class="hardware-grid">
<view
class="hardware-item"
@@ -32,12 +29,9 @@
</view>
</view>
<!-- 其它功能区域 -->
<view class="section">
<view class="section-header">
<view class="section-indicator"></view>
<text class="section-title">其它</text>
</view>
<!-- 快捷功能区域 -->
<view class="section card">
<view class="section-title">快捷功能</view>
<view class="other-grid">
<view
class="other-item"
@@ -53,20 +47,6 @@
</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,80 +1,73 @@
/* pages/index/index.wxss */
.container {
.home-container {
min-height: 100vh;
background: #f5f5f5;
padding-bottom: 120rpx; /* 为底部标签栏留出空间 */
background: linear-gradient(180deg, #f8fffe 0%, #f0f9ff 100%);
padding-bottom: 120rpx;
}
/* 顶部导航栏 */
.nav-bar {
background: linear-gradient(135deg, #7CB342 0%, #8BC34A 100%);
height: 88rpx;
/* 标题栏 */
.header {
background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
padding: 20rpx 30rpx;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 30rpx;
color: white;
box-shadow: 0 4rpx 12rpx rgba(76, 175, 80, 0.15);
}
.nav-title {
font-size: 32rpx;
font-weight: 500;
}
.nav-actions {
.header-left {
display: flex;
align-items: center;
background: rgba(255, 255, 255, 0.2);
border-radius: 44rpx;
padding: 8rpx 16rpx;
gap: 20rpx;
}
.nav-icon {
font-size: 24rpx;
margin: 0 8rpx;
width: 24rpx;
height: 24rpx;
.title {
color: #ffffff;
font-size: 36rpx;
font-weight: 600;
}
.header-right {
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;
margin: 25rpx 30rpx;
background: #ffffff;
border-radius: 20rpx;
padding: 35rpx 30rpx;
box-shadow: 0 8rpx 25rpx rgba(0, 0, 0, 0.08);
border: 1rpx solid rgba(76, 175, 80, 0.1);
}
.section-title {
font-size: 28rpx;
font-weight: 500;
color: #333;
font-size: 34rpx;
font-weight: 700;
color: #2c3e50;
margin-bottom: 35rpx;
position: relative;
padding-left: 20rpx;
}
.section-title::before {
content: '';
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
width: 6rpx;
height: 28rpx;
background: linear-gradient(135deg, #4CAF50, #45a049);
border-radius: 3rpx;
}
/* 智能硬件设备网格 */
.hardware-grid {
display: flex;
flex-wrap: nowrap;
padding: 30rpx 20rpx;
background: white;
justify-content: space-between;
gap: 25rpx;
}
.hardware-item {
@@ -82,67 +75,118 @@
display: flex;
flex-direction: column;
align-items: center;
margin: 0 10rpx;
padding: 25rpx 15rpx;
border-radius: 16rpx;
background: linear-gradient(145deg, #f8f9fa, #ffffff);
transition: all 0.3s ease;
position: relative;
overflow: hidden;
}
.hardware-item::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(135deg, rgba(76, 175, 80, 0.05), rgba(69, 160, 73, 0.05));
opacity: 0;
transition: opacity 0.3s ease;
}
.hardware-item:active::before {
opacity: 1;
}
.hardware-icon {
width: 120rpx;
height: 120rpx;
border-radius: 50%;
width: 110rpx;
height: 110rpx;
border-radius: 55rpx;
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;
box-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.12);
position: relative;
z-index: 2;
}
.hardware-name {
font-size: 26rpx;
color: #333;
font-size: 28rpx;
color: #2c3e50;
text-align: center;
line-height: 1.3;
font-weight: 500;
line-height: 1.4;
font-weight: 600;
position: relative;
z-index: 2;
}
.icon-image {
width: 56rpx;
height: 56rpx;
}
/* 其它功能网格 */
.other-grid {
display: flex;
flex-wrap: wrap;
padding: 30rpx;
background: white;
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 35rpx 25rpx;
}
.other-item {
width: 25%;
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 40rpx;
padding: 25rpx 15rpx;
border-radius: 16rpx;
background: linear-gradient(145deg, #f8f9fa, #ffffff);
transition: all 0.3s ease;
position: relative;
overflow: hidden;
}
.other-item::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(135deg, rgba(76, 175, 80, 0.05), rgba(69, 160, 73, 0.05));
opacity: 0;
transition: opacity 0.3s ease;
}
.other-item:active::before {
opacity: 1;
}
.other-icon {
width: 100rpx;
height: 100rpx;
border-radius: 50%;
width: 88rpx;
height: 88rpx;
border-radius: 44rpx;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 16rpx;
margin-bottom: 18rpx;
box-shadow: 0 6rpx 16rpx rgba(0, 0, 0, 0.12);
position: relative;
z-index: 2;
}
.other-name {
font-size: 24rpx;
color: #333;
font-size: 26rpx;
color: #2c3e50;
text-align: center;
line-height: 1.2;
word-break: break-all;
line-height: 1.3;
font-weight: 600;
position: relative;
z-index: 2;
}
.icon-image {
width: 60rpx;
height: 60rpx;

View File

@@ -1,7 +1,7 @@
/* pages/login/login.wxss */
.container {
min-height: 100vh;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
display: flex;
align-items: center;
justify-content: center;
@@ -27,150 +27,190 @@
}
.circle-1 {
width: 200rpx;
height: 200rpx;
top: 10%;
left: 10%;
width: 220rpx;
height: 220rpx;
top: 8%;
left: 8%;
animation-delay: 0s;
}
.circle-2 {
width: 150rpx;
height: 150rpx;
top: 60%;
right: 15%;
width: 170rpx;
height: 170rpx;
top: 65%;
right: 12%;
animation-delay: 2s;
}
.circle-3 {
width: 100rpx;
height: 100rpx;
top: 30%;
right: 30%;
width: 120rpx;
height: 120rpx;
top: 25%;
right: 25%;
animation-delay: 4s;
}
@keyframes float {
0%, 100% { transform: translateY(0px); }
50% { transform: translateY(-20px); }
0%, 100% {
transform: translateY(0px) rotate(0deg);
opacity: 0.6;
}
50% {
transform: translateY(-25px) rotate(180deg);
opacity: 0.8;
}
}
/* 登录表单 */
.login-form {
width: 600rpx;
background: rgba(255, 255, 255, 0.95);
border-radius: 20rpx;
padding: 60rpx 40rpx;
box-shadow: 0 20rpx 40rpx rgba(0, 0, 0, 0.1);
backdrop-filter: blur(10px);
width: 640rpx;
background: rgba(255, 255, 255, 0.98);
border-radius: 25rpx;
padding: 70rpx 45rpx;
box-shadow: 0 25rpx 50rpx rgba(0, 0, 0, 0.15);
backdrop-filter: blur(15px);
border: 1rpx solid rgba(255, 255, 255, 0.2);
}
/* 头部区域 */
.header-section {
text-align: center;
margin-bottom: 60rpx;
margin-bottom: 70rpx;
}
.logo {
margin-bottom: 30rpx;
margin-bottom: 35rpx;
}
.logo-img {
width: 120rpx;
height: 120rpx;
width: 140rpx;
height: 140rpx;
border-radius: 70rpx;
box-shadow: 0 8rpx 20rpx rgba(0, 0, 0, 0.1);
}
.title {
font-size: 48rpx;
font-weight: bold;
color: #333;
margin-bottom: 10rpx;
font-size: 52rpx;
font-weight: 800;
color: #2c3e50;
margin-bottom: 15rpx;
text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.05);
}
.subtitle {
font-size: 28rpx;
color: #666;
font-size: 30rpx;
color: #5a6c7d;
font-weight: 500;
}
/* 输入框区域 */
.input-section {
margin-bottom: 40rpx;
margin-bottom: 50rpx;
}
.input-group {
position: relative;
margin-bottom: 30rpx;
background: #f8f9fa;
border-radius: 12rpx;
border: 2rpx solid #e9ecef;
margin-bottom: 35rpx;
background: linear-gradient(145deg, #f8f9fa, #ffffff);
border-radius: 18rpx;
border: 2rpx solid rgba(76, 175, 80, 0.1);
display: flex;
align-items: center;
padding: 0 20rpx;
padding: 0 25rpx;
transition: all 0.3s ease;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
}
.input-group:focus-within {
border-color: #4CAF50;
background: #fff;
box-shadow: 0 0 0 6rpx rgba(76, 175, 80, 0.1);
background: #ffffff;
box-shadow: 0 8rpx 25rpx rgba(76, 175, 80, 0.15);
transform: translateY(-2rpx);
}
.input-icon {
font-size: 32rpx;
margin-right: 20rpx;
color: #666;
font-size: 36rpx;
margin-right: 25rpx;
color: #4CAF50;
text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.1);
}
.input-field {
flex: 1;
height: 88rpx;
font-size: 32rpx;
color: #333;
height: 96rpx;
font-size: 34rpx;
color: #2c3e50;
background: transparent;
border: none;
font-weight: 500;
}
.input-field::placeholder {
color: #999;
color: #95a5a6;
font-weight: 400;
}
.password-toggle {
padding: 10rpx;
font-size: 32rpx;
color: #666;
padding: 12rpx;
font-size: 36rpx;
color: #4CAF50;
transition: all 0.3s ease;
}
.password-toggle:active {
transform: scale(0.9);
}
/* 按钮区域 */
.button-section {
margin-bottom: 40rpx;
margin-bottom: 50rpx;
}
.login-btn {
width: 100%;
height: 88rpx;
border-radius: 12rpx;
font-size: 32rpx;
font-weight: bold;
height: 96rpx;
border-radius: 18rpx;
font-size: 36rpx;
font-weight: 700;
border: none;
transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
position: relative;
overflow: hidden;
}
.login-btn::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
transition: left 0.5s ease;
}
.login-btn.active {
background: linear-gradient(135deg, #4CAF50, #45a049);
color: white;
box-shadow: 0 8rpx 20rpx rgba(76, 175, 80, 0.3);
}
.login-btn.active:active {
transform: translateY(2rpx);
box-shadow: 0 4rpx 8rpx rgba(76, 175, 80, 0.3);
transform: translateY(3rpx);
box-shadow: 0 4rpx 12rpx rgba(76, 175, 80, 0.4);
}
.login-btn.active:active::before {
left: 100%;
}
.login-btn.disabled {
background: #e9ecef;
color: #999;
background: linear-gradient(145deg, #e9ecef, #f8f9fa);
color: #95a5a6;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
}
/* 选项区域 */
@@ -178,7 +218,7 @@
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 40rpx;
margin-bottom: 50rpx;
}
.remember-section {
@@ -189,18 +229,26 @@
.checkbox-label {
display: flex;
align-items: center;
font-size: 28rpx;
color: #666;
font-size: 30rpx;
color: #5a6c7d;
font-weight: 500;
}
.checkbox-text {
margin-left: 10rpx;
margin-left: 12rpx;
}
.forgot-password {
font-size: 28rpx;
font-size: 30rpx;
color: #4CAF50;
text-decoration: underline;
font-weight: 600;
transition: all 0.3s ease;
}
.forgot-password:active {
color: #45a049;
transform: scale(0.95);
}
/* 版本信息 */
@@ -209,6 +257,7 @@
}
.version-text {
font-size: 24rpx;
color: #999;
font-size: 26rpx;
color: #95a5a6;
font-weight: 400;
}

View File

@@ -113,7 +113,7 @@ Page({
onShow() {
// 每次显示页面时刷新数据
this.loadData();
this.loadUserData();
},
// 检查登录状态
@@ -127,7 +127,13 @@ Page({
}
},
// 加载用户数据
// 编辑个人资料
editProfile() {
wx.showToast({
title: '编辑功能开发中',
icon: 'none'
});
},
async loadUserData() {
try {
// 从本地存储获取用户信息

View File

@@ -2,3 +2,4 @@
"usingComponents": {},
"navigationBarTitleText": "我的"
}

View File

@@ -1,93 +1,57 @@
<!--pages/profile/profile.wxml-->
<view class="container">
<!-- 状态栏 -->
<view class="status-bar" style="height: {{statusBarHeight}}px;"></view>
<!-- 用户信息卡片 -->
<view class="user-card">
<view class="profile-container">
<!-- 用户信息头部 -->
<view class="profile-header">
<view class="user-avatar">
<image wx:if="{{userInfo.avatar}}" src="{{userInfo.avatar}}" class="avatar-img" mode="aspectFill" />
<image wx:else src="/images/avatar.png" class="avatar-img" />
</view>
<view class="user-info">
<view class="avatar-container" bindtap="onAvatarTap">
<image wx:if="{{userInfo.avatar}}" class="avatar" src="{{userInfo.avatar}}" mode="aspectFill" />
<view wx:else class="avatar-placeholder">
<text class="avatar-text">{{userInfo.name.charAt(0)}}</text>
</view>
<view class="avatar-badge">📷</view>
</view>
<view class="user-details">
<view class="user-name">{{userInfo.name}}</view>
<view class="user-account">账号: {{userInfo.account}}</view>
<view class="user-department">{{userInfo.department}}</view>
<view class="user-position">{{userInfo.position}}</view>
<view class="last-login">最后登录: {{userInfo.lastLoginTime}}</view>
</view>
<view class="username">{{userInfo.name || '西藏智慧三牧'}}</view>
<view class="user-role">{{userInfo.phone || '18003030830'}}</view>
</view>
</view>
<!-- 统计数据 -->
<view class="stats-section">
<view class="section-title">今日数据</view>
<view class="stats-grid">
<view class="stat-item">
<view class="stat-number">{{statsData.todayCheck}}</view>
<view class="stat-label">今日检查</view>
</view>
<view class="stat-item">
<view class="stat-number">{{statsData.totalFarmers}}</view>
<view class="stat-label">管理养殖户</view>
</view>
<view class="stat-item">
<view class="stat-number">{{statsData.totalAlerts}}</view>
<view class="stat-label">待处理告警</view>
</view>
<view class="stat-item">
<view class="stat-number">{{statsData.completedTasks}}</view>
<view class="stat-label">完成任务</view>
</view>
</view>
</view>
<!-- 快捷操作 -->
<view class="quick-actions-section">
<view class="section-title">快捷操作</view>
<view class="quick-actions">
<view
wx:for="{{quickActions}}"
wx:key="id"
class="quick-action-item"
style="background-color: {{item.color}}20;"
bindtap="onQuickActionTap"
data-id="{{item.id}}"
>
<view class="quick-action-icon" style="color: {{item.color}};">{{item.icon}}</view>
<view class="quick-action-title">{{item.title}}</view>
</view>
<view class="edit-btn" bindtap="editProfile">
<text class="edit-icon">✏️</text>
</view>
</view>
<!-- 功能菜单 -->
<view class="menu-section">
<view class="section-title">功能设置</view>
<view class="menu-list">
<view
wx:for="{{menuItems}}"
wx:key="id"
class="menu-item"
bindtap="onMenuItemTap"
data-id="{{item.id}}"
>
<view class="menu-icon">{{item.icon}}</view>
<view class="menu-content">
<view class="menu-title">{{item.title}}</view>
<view class="menu-desc">{{item.desc}}</view>
</view>
<view wx:if="{{item.arrow}}" class="menu-arrow">></view>
</view>
<view class="menu-item" bindtap="onMenuItemTap" data-id="system">
<view class="menu-icon">⚙️</view>
<view class="menu-text">系统设置</view>
<view class="menu-arrow">></view>
</view>
<view class="menu-item" bindtap="onMenuItemTap" data-id="trade">
<view class="menu-icon">📋</view>
<view class="menu-text">生资交易</view>
<view class="menu-arrow">></view>
</view>
<view class="menu-item" bindtap="onMenuItemTap" data-id="personnel">
<view class="menu-icon">👥</view>
<view class="menu-text">人员管理</view>
<view class="menu-arrow">></view>
</view>
<view class="menu-item" bindtap="onMenuItemTap" data-id="password">
<view class="menu-icon">👤</view>
<view class="menu-text">设置账号密码</view>
<view class="menu-arrow">></view>
</view>
</view>
<!-- 退出登录 -->
<view class="logout-section">
<button class="logout-btn" bindtap="onLogout">退出登录</button>
<button class="logout-btn" bindtap="onLogout">
<text class="logout-icon">🚪</text>
<text class="logout-text">退出登录</text>
</button>
</view>
<!-- 版本信息 -->
<view class="version-info">
<text class="version-text">版本 1.0.0</text>
</view>
</view>

View File

@@ -1,54 +1,150 @@
/* pages/profile/profile.wxss */
.container {
.profile-container {
min-height: 100vh;
background-color: #f5f5f5;
background: #f5f5f5;
padding: 0 0 40rpx 0;
}
.status-bar {
background-color: #2c5aa0;
}
/* 用户信息卡片 */
.user-card {
background: linear-gradient(135deg, #2c5aa0 0%, #4a7bc8 100%);
padding: 40rpx 30rpx 30rpx;
color: white;
}
.user-info {
/* 用户信息头部 */
.profile-header {
background: #4CAF50;
padding: 60rpx 40rpx 40rpx 40rpx;
display: flex;
align-items: center;
position: relative;
}
.avatar-container {
position: relative;
.user-avatar {
margin-right: 30rpx;
}
.avatar {
.avatar-img {
width: 120rpx;
height: 120rpx;
border-radius: 60rpx;
background: rgba(255, 255, 255, 0.2);
border: 4rpx solid rgba(255, 255, 255, 0.3);
}
.avatar-placeholder {
width: 120rpx;
height: 120rpx;
border-radius: 60rpx;
background-color: rgba(255, 255, 255, 0.2);
.user-info {
flex: 1;
}
.username {
font-size: 36rpx;
font-weight: 600;
color: #fff;
margin-bottom: 8rpx;
}
.user-role {
font-size: 28rpx;
color: rgba(255, 255, 255, 0.8);
}
.edit-btn {
position: absolute;
top: 60rpx;
right: 40rpx;
padding: 20rpx;
background: rgba(255, 255, 255, 0.2);
border-radius: 50%;
}
.edit-icon {
font-size: 32rpx;
color: #fff;
}
/* 功能菜单 */
.menu-section {
background: #fff;
margin: 20rpx 0;
border-radius: 16rpx;
overflow: hidden;
}
.menu-item {
display: flex;
align-items: center;
padding: 32rpx 40rpx;
border-bottom: 1rpx solid #f0f0f0;
position: relative;
}
.menu-item:last-child {
border-bottom: none;
}
.menu-item:active {
background: #f8f8f8;
}
.menu-icon {
font-size: 36rpx;
margin-right: 24rpx;
width: 40rpx;
text-align: center;
}
.menu-text {
flex: 1;
font-size: 32rpx;
color: #333;
}
.menu-arrow {
font-size: 28rpx;
color: #999;
}
/* 退出登录 */
.logout-section {
margin: 20rpx 0;
padding: 0 0 40rpx 0;
}
.logout-btn {
width: 100%;
height: 88rpx;
background: #fff;
border: 2rpx solid #ff4d4f;
border-radius: 16rpx;
display: flex;
align-items: center;
justify-content: center;
border: 4rpx solid rgba(255, 255, 255, 0.3);
font-size: 32rpx;
color: #ff4d4f;
font-weight: 500;
margin: 0 0 0 0;
}
.avatar-text {
font-size: 48rpx;
font-weight: bold;
color: white;
.logout-btn:active {
background: #fff2f0;
}
.logout-icon {
font-size: 32rpx;
margin-right: 16rpx;
}
.logout-text {
font-size: 32rpx;
}
/* 版本信息 */
.version-info {
text-align: center;
padding: 40rpx 0;
}
.version-text {
font-size: 24rpx;
color: #999;
}
.avatar-badge {
position: absolute;
bottom: 0;
@@ -178,11 +274,12 @@
/* 功能菜单 */
.menu-section {
background-color: white;
margin: 20rpx;
border-radius: 16rpx;
padding: 30rpx;
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.1);
margin: 25rpx 30rpx;
background: #ffffff;
border-radius: 20rpx;
padding: 35rpx 30rpx;
box-shadow: 0 8rpx 25rpx rgba(0, 0, 0, 0.08);
border: 1rpx solid rgba(76, 175, 80, 0.1);
}
.menu-list {
@@ -192,9 +289,10 @@
.menu-item {
display: flex;
align-items: center;
padding: 24rpx 0;
border-bottom: 1rpx solid #f0f0f0;
transition: background-color 0.3s ease;
padding: 28rpx 0;
border-bottom: 1rpx solid rgba(76, 175, 80, 0.1);
transition: all 0.3s ease;
position: relative;
}
.menu-item:last-child {
@@ -202,17 +300,23 @@
}
.menu-item:active {
background-color: #f8f9fa;
background-color: rgba(76, 175, 80, 0.05);
border-radius: 12rpx;
margin: 0 -15rpx;
padding: 28rpx 15rpx;
}
.menu-icon {
width: 48rpx;
height: 48rpx;
margin-right: 24rpx;
font-size: 36rpx;
width: 52rpx;
height: 52rpx;
margin-right: 28rpx;
font-size: 40rpx;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(145deg, #f8f9fa, #ffffff);
border-radius: 26rpx;
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
}
.menu-content {
@@ -220,9 +324,63 @@
}
.menu-title {
font-size: 30rpx;
color: #333;
margin-bottom: 4rpx;
font-size: 32rpx;
color: #2c3e50;
margin-bottom: 6rpx;
font-weight: 600;
}
.menu-desc {
font-size: 26rpx;
color: #5a6c7d;
font-weight: 400;
}
.menu-arrow {
font-size: 28rpx;
color: #4CAF50;
font-weight: 600;
}
/* 退出登录 */
.logout-section {
margin: 25rpx 30rpx;
padding-bottom: 40rpx;
}
.logout-btn {
width: 100%;
background: linear-gradient(135deg, #f44336 0%, #e57373 100%);
color: white;
border: none;
border-radius: 20rpx;
padding: 35rpx;
font-size: 34rpx;
font-weight: 700;
box-shadow: 0 8rpx 20rpx rgba(244, 67, 54, 0.3);
transition: all 0.3s ease;
position: relative;
overflow: hidden;
}
.logout-btn::before {
content: '';
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
transition: left 0.5s ease;
}
.logout-btn:active {
transform: scale(0.98);
box-shadow: 0 4rpx 12rpx rgba(244, 67, 54, 0.4);
}
.logout-btn:active::before {
left: 100%;
}
.menu-desc {