管灌系统农户端微信小程序(嘉峪关应用)
更新项目配置,提升监测页面功能,新增注肥泵状态管理和故障清除功能;优化样式以增强用户体验和可视化效果。
6个文件已修改
1个文件已添加
643 ■■■■■ 已修改文件
images/custompump.svg 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/stationMonitor/stationMonitor.js 495 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/stationMonitor/stationMonitor.wxml 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pages/stationMonitor/stationMonitor.wxss 83 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
project.config.json 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
project.private.config.json 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
utils/projectConfig.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
images/custompump.svg
New file
@@ -0,0 +1 @@
<svg t="1755829084511" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5891" width="200" height="200"><path d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zM289.4 276.1l90.5 90.5-45.3 45.3-90.5-90.5 45.3-45.3zM480 224h64v128h-64V224zM288 736h64V568c0-88.4 71.6-160 160-160s160 71.6 160 160v168h64v64H288v-64z m385.4-324.1l-45.3-45.3 90.5-90.5 45.3 45.3-90.5 90.5z" fill="#2c2c2c" p-id="5892"></path></svg>
pages/stationMonitor/stationMonitor.js
@@ -1,6 +1,7 @@
// pages/stationMonitor/stationMonitor.js
const {
  get
  get,
  post
} = require('../../api/request.js');
Page({
@@ -951,24 +952,207 @@
    if (!this.data.currentFertilizerStation) return;
    // 更新搅拌状态
    // 如果用户开启搅拌,调用启动接口
    if (enabled) {
      this.startStirring();
    } else {
      // 关闭搅拌时调用停止接口
      this.stopStirring();
    }
  },
  /**
   * 启动搅拌
   */
  startStirring() {
    const currentStation = this.data.currentFertilizerStation;
    if (!currentStation) return;
    console.log('开始调用启动搅拌接口');
    // 显示loading状态
    wx.showLoading({
      title: '启动搅拌中...',
      mask: true
    });
    // 调用启动搅拌接口
    post({
      url: '/wx/mqttStir/start',
      data: {
        manureId: currentStation.manureId || currentStation.id,
        operator: getApp().globalData.operator
      },
      isShowLoding: false // 我们自己控制loading状态
    })
      .then(response => {
        console.log('启动搅拌接口返回:', response);
        // 隐藏loading
        wx.hideLoading();
        if (response.success && response.code === '0001') {
          // 接口调用成功,更新搅拌状态
          this.updateMixingStatus(true);
          // 显示成功提示
          wx.showToast({
            title: '搅拌启动成功',
            icon: 'success',
            duration: 2000
          });
        } else {
          // 接口调用失败,重置开关状态
          console.error('启动搅拌失败:', response.msg);
          this.resetMixingSwitch();
          wx.showToast({
            title: response.msg || '启动搅拌失败',
            icon: 'error',
            duration: 2000
          });
        }
      })
      .catch(error => {
        console.error('调用启动搅拌接口失败:', error);
        // 隐藏loading
        wx.hideLoading();
        // 接口调用失败,重置开关状态
        this.resetMixingSwitch();
        // 显示错误提示
        wx.showToast({
          title: '启动搅拌失败,请重试',
          icon: 'error',
          duration: 2000
        });
      });
  },
  /**
   * 更新搅拌状态
   */
  updateMixingStatus(enabled) {
    const currentStation = {
      ...this.data.currentFertilizerStation
    };
    currentStation.mixingEnabled = enabled;
    
    // 更新具体的搅拌运行状态(这里假设只控制第一个搅拌器)
    currentStation.mixingEnabled = enabled;
    currentStation.stirRunning1 = enabled ? 1 : 0;
    this.setData({
      currentFertilizerStation: currentStation
    });
    // 显示操作结果
    wx.showToast({
      title: enabled ? '搅拌已开启' : '搅拌已关闭',
      icon: 'success'
    console.log('搅拌状态已更新:', enabled ? '开启' : '关闭');
  },
  /**
   * 重置搅拌开关状态(接口调用失败时使用)
   */
  resetMixingSwitch() {
    const currentStation = {
      ...this.data.currentFertilizerStation
    };
    // 重置为关闭状态
    currentStation.mixingEnabled = false;
    currentStation.stirRunning1 = 0;
    this.setData({
      currentFertilizerStation: currentStation
    });
    console.log('搅拌开关状态已重置为关闭');
  },
  /**
   * 停止搅拌
   */
  stopStirring() {
    const currentStation = this.data.currentFertilizerStation;
    if (!currentStation) return;
    console.log('开始调用停止搅拌接口');
    // 显示loading状态
    wx.showLoading({
      title: '停止搅拌中...',
      mask: true
    });
    // 调用停止搅拌接口
    post({
      url: '/wx/mqttStir/stop',
      data: {
        manureId: currentStation.manureId || currentStation.id,
        operator: getApp().globalData.operator
      },
      isShowLoding: false // 我们自己控制loading状态
    })
      .then(response => {
        console.log('停止搅拌接口返回:', response);
        // 隐藏loading
        wx.hideLoading();
        if (response.success && response.code === '0001') {
          // 接口调用成功,更新搅拌状态
          this.updateMixingStatus(false);
          // 显示成功提示
          wx.showToast({
            title: '搅拌停止成功',
            icon: 'success',
            duration: 2000
          });
        } else {
          // 接口调用失败,保持开启状态
          console.error('停止搅拌失败:', response.msg);
          this.keepMixingSwitchOn();
          wx.showToast({
            title: response.msg || '停止搅拌失败',
            icon: 'error',
            duration: 2000
          });
        }
      })
      .catch(error => {
        console.error('调用停止搅拌接口失败:', error);
        // 隐藏loading
        wx.hideLoading();
        // 接口调用失败,保持开启状态
        this.keepMixingSwitchOn();
        // 显示错误提示
        wx.showToast({
          title: '停止搅拌失败,请重试',
          icon: 'error',
          duration: 2000
        });
      });
  },
  /**
   * 保持搅拌开关为开启状态(停止失败时使用)
   */
  keepMixingSwitchOn() {
    const currentStation = {
      ...this.data.currentFertilizerStation
    };
    // 保持为开启状态
    currentStation.mixingEnabled = true;
    currentStation.stirRunning1 = 1;
    this.setData({
      currentFertilizerStation: currentStation
    });
    console.log('搅拌开关状态保持为开启');
  },
  /**
@@ -980,24 +1164,207 @@
    if (!this.data.currentFertilizerStation) return;
    // 更新注肥状态
    // 如果用户开启注肥,调用启动接口
    if (enabled) {
      this.startInjecting();
    } else {
      // 关闭注肥时调用停止接口
      this.stopInjecting();
    }
  },
  /**
   * 启动注肥
   */
  startInjecting() {
    const currentStation = this.data.currentFertilizerStation;
    if (!currentStation) return;
    console.log('开始调用启动注肥接口');
    // 显示loading状态
    wx.showLoading({
      title: '启动注肥中...',
      mask: true
    });
    // 调用启动注肥接口
    post({
      url: '/wx/mqttInject/start',
      data: {
        manureId: currentStation.manureId || currentStation.id,
        operator: getApp().globalData.operator
      },
      isShowLoding: false // 我们自己控制loading状态
    })
      .then(response => {
        console.log('启动注肥接口返回:', response);
        // 隐藏loading
        wx.hideLoading();
        if (response.success && response.code === '0001') {
          // 接口调用成功,更新注肥状态
          this.updateInjectingStatus(true);
          // 显示成功提示
          wx.showToast({
            title: '注肥启动成功',
            icon: 'success',
            duration: 2000
          });
        } else {
          // 接口调用失败,重置开关状态
          console.error('启动注肥失败:', response.msg);
          this.resetInjectingSwitch();
          wx.showToast({
            title: response.msg || '启动注肥失败',
            icon: 'error',
            duration: 2000
          });
        }
      })
      .catch(error => {
        console.error('调用启动注肥接口失败:', error);
        // 隐藏loading
        wx.hideLoading();
        // 接口调用失败,重置开关状态
        this.resetInjectingSwitch();
        // 显示错误提示
        wx.showToast({
          title: '启动注肥失败,请重试',
          icon: 'error',
          duration: 2000
        });
      });
  },
  /**
   * 更新注肥状态
   */
  updateInjectingStatus(enabled) {
    const currentStation = {
      ...this.data.currentFertilizerStation
    };
    currentStation.fertilizingEnabled = enabled;
    
    // 更新注肥运行状态
    currentStation.fertilizingEnabled = enabled;
    currentStation.injectRunning = enabled ? 1 : 0;
    this.setData({
      currentFertilizerStation: currentStation
    });
    // 显示操作结果
    wx.showToast({
      title: enabled ? '注肥已开启' : '注肥已关闭',
      icon: 'success'
    console.log('注肥状态已更新:', enabled ? '开启' : '关闭');
  },
  /**
   * 重置注肥开关状态(接口调用失败时使用)
   */
  resetInjectingSwitch() {
    const currentStation = {
      ...this.data.currentFertilizerStation
    };
    // 重置为关闭状态
    currentStation.fertilizingEnabled = false;
    currentStation.injectRunning = 0;
    this.setData({
      currentFertilizerStation: currentStation
    });
    console.log('注肥开关状态已重置为关闭');
  },
  /**
   * 停止注肥
   */
  stopInjecting() {
    const currentStation = this.data.currentFertilizerStation;
    if (!currentStation) return;
    console.log('开始调用停止注肥接口');
    // 显示loading状态
    wx.showLoading({
      title: '停止注肥中...',
      mask: true
    });
    // 调用停止注肥接口
    post({
      url: '/wx/mqttInject/stop',
      data: {
        manureId: currentStation.manureId || currentStation.id,
        operator: getApp().globalData.operator
      },
      isShowLoding: false // 我们自己控制loading状态
    })
      .then(response => {
        console.log('停止注肥接口返回:', response);
        // 隐藏loading
        wx.hideLoading();
        if (response.success && response.code === '0001') {
          // 接口调用成功,更新注肥状态
          this.updateInjectingStatus(false);
          // 显示成功提示
          wx.showToast({
            title: '注肥停止成功',
            icon: 'success',
            duration: 2000
          });
        } else {
          // 接口调用失败,保持开启状态
          console.error('停止注肥失败:', response.msg);
          this.keepInjectingSwitchOn();
          wx.showToast({
            title: response.msg || '停止注肥失败',
            icon: 'error',
            duration: 2000
          });
        }
      })
      .catch(error => {
        console.error('调用停止注肥接口失败:', error);
        // 隐藏loading
        wx.hideLoading();
        // 接口调用失败,保持开启状态
        this.keepInjectingSwitchOn();
        // 显示错误提示
        wx.showToast({
          title: '停止注肥失败,请重试',
          icon: 'error',
          duration: 2000
        });
      });
  },
  /**
   * 保持注肥开关为开启状态(停止失败时使用)
   */
  keepInjectingSwitchOn() {
    const currentStation = {
      ...this.data.currentFertilizerStation
    };
    // 保持为开启状态
    currentStation.fertilizingEnabled = true;
    currentStation.injectRunning = 1;
    this.setData({
      currentFertilizerStation: currentStation
    });
    console.log('注肥开关状态保持为开启');
  },
@@ -1045,12 +1412,14 @@
        const updatedItem = {
          ...item,
          isLoadingUrl: isLoading,
          urlError: hasError
          urlError: hasError,
          onLine:false
        };
        console.log(`摄像头 ${cameraId} 状态更新:`, {
          name: updatedItem.name,
          isLoadingUrl: updatedItem.isLoadingUrl,
          urlError: updatedItem.urlError
          urlError: updatedItem.urlError,
          onLine:false
        });
        return updatedItem;
      }
@@ -1105,11 +1474,11 @@
      this.updateCameraUrlLoadingState(camera.id, false, true);
      
      // 显示错误提示
      wx.showToast({
        title: '视频播放出错',
        icon: 'error',
        duration: 2000
      });
      // wx.showToast({
      //   title: '视频播放出错',
      //   icon: 'error',
      //   duration: 2000
      // });
    } else {
      console.error('未找到对应的摄像头:', cameraId);
    }
@@ -1191,5 +1560,87 @@
    console.log('播放状态更新完成');
  },
  /**
   * 清除故障
   */
  clearAlarm() {
    const currentStation = this.data.currentFertilizerStation;
    if (!currentStation) return;
    console.log('开始调用清除故障接口');
    // 显示loading状态
    wx.showLoading({
      title: '清除故障中...',
      mask: true
    });
    // 调用清除故障接口
    post({
      url: '/wx/mqttFault/clear',
      data: {
        manureId: currentStation.manureId || currentStation.id,
        operator: getApp().globalData.operator
      },
      isShowLoding: false // 我们自己控制loading状态
    })
      .then(response => {
        console.log('消除报警接口返回:', response);
        // 隐藏loading
        wx.hideLoading();
        if (response.success && response.code === '0001') {
          // 接口调用成功,更新报警状态
          this.updateAlarmStatus(0);
          // 显示成功提示
          wx.showToast({
            title: '故障清除成功',
            icon: 'success',
            duration: 2000
          });
        } else {
          // 接口调用失败
          console.error('清除故障失败:', response.msg);
          wx.showToast({
            title: response.msg || '清除故障失败',
            icon: 'error',
            duration: 2000
          });
        }
      })
      .catch(error => {
        console.error('调用清除故障接口失败:', error);
        // 隐藏loading
        wx.hideLoading();
        // 显示错误提示
        wx.showToast({
          title: '清除故障失败,请重试',
          icon: 'error',
          duration: 2000
        });
      });
  },
  /**
   * 更新报警状态
   */
  updateAlarmStatus(alarmStatus) {
    const currentStation = {
      ...this.data.currentFertilizerStation
    };
    currentStation.alarm = alarmStatus;
    this.setData({
      currentFertilizerStation: currentStation
    });
    console.log('报警状态已更新:', alarmStatus === 1 ? '报警' : '正常');
  },
})
pages/stationMonitor/stationMonitor.wxml
@@ -355,6 +355,25 @@
        <view class="monitoring-data">
          <text class="section-title">监测数据</text>
          <view class="data-grid">
            <!-- 注肥泵状态 -->
            <view class="data-item pump-status custom-pump-row">
              <view class="data-icon">
                <image src="/images/custompump.svg" />
              </view>
              <view class="data-content">
                <text class="data-label">注肥泵状态</text>
                <text class="data-value {{currentFertilizerStation.alarm === 1 ? 'alarm' : 'normal'}}">
                  {{currentFertilizerStation.alarm === 1 ? '报警' : '正常'}}
                </text>
              </view>
              <button wx:if="{{currentFertilizerStation.alarm === 1}}"
                      class="clear-fault-btn"
                      bind:tap="clearAlarm"
                      size="mini">
                清除报警
              </button>
            </view>
            <!-- 肥料流量 -->
            <view class="data-item waste-flow">
              <view class="data-icon">
@@ -451,11 +470,11 @@
            <!-- 错误状态 -->
            <view wx:elif="{{item.urlError}}" class="video-error">
              <image class="error-icon" src="/images/error.svg" />
              <text class="error-text">获取播放地址失败</text>
              <button class="retry-btn" bind:tap="retryGetHlsUrl" data-camera="{{item}}">
              <text class="error-text">设备离线</text>
              <!-- <button class="retry-btn" bind:tap="retryGetHlsUrl" data-camera="{{item}}">
                <image class="retry-icon" src="/images/refresh.svg" />
                <text>重试</text>
              </button>
              </button> -->
            </view>
            <!-- 正常播放状态 -->
pages/stationMonitor/stationMonitor.wxss
@@ -48,7 +48,7 @@
  position: sticky;
  /* 使用sticky定位 */
  top: 0;
  z-index: 9999;
  z-index: 999;
  background-color: #fff;
  /* 确保背景色 */
  /* 减小tabs高度 */
@@ -1001,12 +1001,91 @@
  transform: scale(0.98);
}
/* 水肥机数据项样式 */
/* 注肥泵状态行样式 */
.monitoring-data .data-item.pump-status {
  border-left-color: #1890ff;
  background: linear-gradient(135deg, #e6f7ff 0%, #ffffff 100%);
}
/* 注肥泵状态行 - 重新设计为两模块布局 */
.fertilizer-info-card .monitoring-data .data-grid .data-item.pump-status {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 20rpx !important;
  gap: 16rpx !important;
}
/* 左侧模块:图标+标签+状态值 */
.fertilizer-info-card .monitoring-data .data-grid .data-item.pump-status .data-content {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  flex: 1;
  /* 关闭 gap,改用 margin 控制,兼容性更好 */
  gap: 0 !important;
  min-width: 0;
}
/* 只作用于注肥泵状态行:用 margin 控制 label 与 value 的间距,避免 gap 兼容性问题 */
.fertilizer-info-card .monitoring-data .data-grid .data-item.pump-status.custom-pump-row .data-label {
  display: block !important;
  margin-bottom: 0 !important;
  line-height: 1 !important;
}
.fertilizer-info-card .monitoring-data .data-grid .data-item.pump-status.custom-pump-row .data-value {
  display: block !important;
  margin-top: -10rpx !important;
  line-height: 1 !important;
}
/* 左侧模块中的状态值样式 */
.fertilizer-info-card .monitoring-data .data-grid .data-item.pump-status .data-value {
  font-size: 36rpx !important;
  font-weight: 700 !important;
  line-height: 1.2 !important;
  margin: 0 !important;
}
/* 状态值样式 */
.data-value.normal {
  color: #52c41a;
}
.data-value.alarm {
  color: #ff4d4f;
}
/* 右侧模块:清除报警按钮 - 独立模块在右边居中 */
.fertilizer-info-card .monitoring-data .data-grid .data-item.pump-status .clear-fault-btn {
  background: linear-gradient(135deg, #ff4d4f 0%, #ff7875 100%) !important;
  color: white !important;
  border: none !important;
  border-radius: 20rpx !important;
  padding: 12rpx 20rpx !important;
  font-size: 24rpx !important;
  font-weight: 500 !important;
  box-shadow: 0 4rpx 12rpx rgba(255, 77, 79, 0.3) !important;
  transition: all 0.3s ease !important;
  white-space: nowrap !important;
  line-height: 1.2 !important;
  height: 50rpx !important;
  min-height: 44rpx !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  margin: 0 !important;
  align-self: center !important;
}
/* 清除故障按钮激活状态 - 只针对注肥泵状态行 */
.fertilizer-info-card .monitoring-data .data-grid .data-item.pump-status .clear-fault-btn:active {
  transform: scale(0.95) !important;
  box-shadow: 0 1rpx 4rpx rgba(255, 77, 79, 0.4) !important;
}
.monitoring-data .data-item.waste-flow {
  border-left-color: #52c41a;
  background: linear-gradient(135deg, #f6ffed 0%, #ffffff 100%);
project.config.json
@@ -1,6 +1,6 @@
{
  "compileType": "miniprogram",
  "libVersion": "trial",
  "libVersion": "3.9.1",
  "packOptions": {
    "ignore": [],
    "include": []
@@ -18,12 +18,24 @@
      "disablePlugins": [],
      "outputPath": ""
    },
    "condition": true
    "condition": true,
    "compileWorklet": false,
    "uglifyFileName": false,
    "uploadWithSourceMap": true,
    "packNpmManually": false,
    "minifyWXSS": true,
    "minifyWXML": true,
    "localPlugins": false,
    "disableUseStrict": false,
    "useCompilerPlugins": false,
    "swc": false,
    "disableSWC": true
  },
  "condition": {},
  "editorSetting": {
    "tabIndent": "auto",
    "tabSize": 2
  },
  "appid": "wxbc2b6a00dd904ead"
  "appid": "wxbc2b6a00dd904ead",
  "simulatorPluginLibVersion": {}
}
project.private.config.json
@@ -3,7 +3,22 @@
  "projectname": "irrigate_user",
  "setting": {
    "compileHotReLoad": true,
    "urlCheck": true
    "urlCheck": true,
    "coverView": true,
    "lazyloadPlaceholderEnable": false,
    "skylineRenderEnable": false,
    "preloadBackgroundData": false,
    "autoAudits": false,
    "useApiHook": true,
    "useApiHostProcess": true,
    "showShadowRootInWxmlPanel": true,
    "useStaticServer": false,
    "useLanDebug": false,
    "showES6CompileOption": false,
    "checkInvalidKey": true,
    "ignoreDevUnusedFiles": true,
    "bigPackageSizeSupport": false
  },
  "libVersion": "3.9.1"
  "libVersion": "3.9.1",
  "condition": {}
}
utils/projectConfig.js
@@ -3,7 +3,7 @@
const SERVER_INFO = {
  URL_233: 'https://wanzheng.dayuyanjiuyuan.top/',
  URL_55: 'https://irrigate.dayuyanjiuyuan.top/',
  URL_166: 'https://wanzheng.dayuyanjiuyuan.top/frp/',
  URL_166: 'https://wanzheng.dayuyanjiuyuan.top/frp/',//测试环境
  URL_121: 'https://shifanqu1.dayuyanjiuyuan.top/',
  // URL_121: 'https://wanzheng.dayuyanjiuyuan.top/frp/',
  URL_87: 'http://192.168.10.87:54321/'