|  |  | 
 |  |  | Page({ | 
 |  |  |   data: { | 
 |  |  |     currentTab: 0, // 当前显示的表格,默认为第一个表格 | 
 |  |  |     searchQuery:"", | 
 |  |  |     searchQuery: "", | 
 |  |  |     commonWaterPoints: [], // 常用取水口数据 | 
 |  |  |     allWaterPoints: [], // 所有取水口数据 | 
 |  |  |     searchData: [{ | 
 |  |  |       intakeNum: "1111111" | 
 |  |  |     }, { | 
 |  |  |       intakeNum: "2222222" | 
 |  |  |     }], | 
 |  |  |     isRefreshing_all: false, | 
 |  |  |     isRefreshing_common: false, | 
 |  |  |     showConfirm: false, | 
 |  |  |     waterIntakeName: "", | 
 |  |  |     choseItem: null, | 
 |  |  |     errorData: '', //错误内容 | 
 |  |  |     showErrorDialog: false, | 
 |  |  |     confirmBtn: { | 
 |  |  |       content: '确认' | 
 |  |  |     }, | 
 |  |  |     showForceConfirm: false, | 
 |  |  |     forceIntakeId: "", //强制开阀的取水口id | 
 |  |  |     inputValue: "", | 
 |  |  |     //以下为开阀弹窗相关 | 
 |  |  |     isShowOpenTime: "false", | 
 |  |  |     isOpenTiming: false, //是否是计划开阀时间样式的开阀 | 
 |  |  |     postMinutes: 0, //定灌溉时长的时间 | 
 |  |  |     showForceConfirm: false, | 
 |  |  |     showErrorDialog: false, //错误提示 | 
 |  |  |     showDialog: false, | 
 |  |  |     dialog_mode: false, | 
 |  |  |     dialog_time: false, | 
 |  |  |     dialog_water: false, | 
 |  |  |     openTimeText: "", | 
 |  |  |     openTime: "", | 
 |  |  |     irrigateProfile: [], //获取所选灌溉方式的详细数据 | 
 |  |  |     dialog_mode: true, | 
 |  |  |     dialog_time: false, | 
 |  |  |     dialog_water: false, | 
 |  |  |     group_time: false, //是否显示选择分钟或小时的单选框 | 
 |  |  |     openTime: "", //计划开泵的开始时间 | 
 |  |  |     openTimeText: "", | 
 |  |  |     isShowOpenTime: "false", | 
 |  |  |     showForceConfirm: false, | 
 |  |  |     showErrorDialog: false, //错误提示 | 
 |  |  |     errorData: "", | 
 |  |  |     confirmBtn: { | 
 |  |  |       content: '确认' | 
 |  |  |     }, | 
 |  |  |     radioValue: "0", //开阀方式选中的类型 | 
 |  |  |     costiomTime: "", //自定义灌溉时间 | 
 |  |  |     waterAmount: 0, //定量开阀的水量 | 
 |  |  |     costiomWater: "", //输入的自定义水量 | 
 |  |  |     isWXRefreshing: false, | 
 |  |  |     irrigateProfile: [], //获取所选灌溉方式的详细数据 | 
 |  |  |     datetimeVisible: false, | 
 |  |  |   | 
 |  |  |   }, | 
 |  |  |  | 
 |  |  |   // 切换 Tabs | 
 |  |  | 
 |  |  |       currentTab: tab | 
 |  |  |     }); | 
 |  |  |   }, | 
 |  |  |   onInput(e){ | 
 |  |  |   onInput(e) { | 
 |  |  |     this.setData({ | 
 |  |  |       searchQuery: e.detail.value // 将输入框的值存储到 inputValue | 
 |  |  |     }); | 
 |  |  | 
 |  |  |   onSearch: function () { | 
 |  |  |     const query = this.data.searchQuery; | 
 |  |  |     if (query) { | 
 |  |  |      this.getallWaterPoints(query) | 
 |  |  |       this.getallWaterPoints(query) | 
 |  |  |       // 在这里进行搜索操作,更新 allWaterPoints 数据 | 
 |  |  |     } else { | 
 |  |  |       this.getallWaterPoints(query) | 
 |  |  |       this.setData({ | 
 |  |  |         allWaterPoints: [] | 
 |  |  |       }) | 
 |  |  |     } | 
 |  |  |   }, | 
 |  |  |  | 
 |  |  | 
 |  |  |    * @param {} event  | 
 |  |  |    */ | 
 |  |  |   choseCard(event) { | 
 |  |  |    const intakeId= event.currentTarget.dataset.item.intakeId; | 
 |  |  |    console.log(intakeId); | 
 |  |  |     wx.navigateTo({ | 
 |  |  |       url: '/pages/openCard/openCard?intakeId='+intakeId, | 
 |  |  |     //显示二次确认弹窗 | 
 |  |  |     this.setData({ | 
 |  |  |       showConfirm: true, | 
 |  |  |       choseItem: event.currentTarget.dataset.item, | 
 |  |  |       allWaterPoints: [] | 
 |  |  |     }) | 
 |  |  |     // 注意:initDialogData的调用移到了confirmDialog方法中 | 
 |  |  |   }, | 
 |  |  |  | 
 |  |  |   //开泵通信 | 
 |  |  |   /** | 
 |  |  |    *  | 
 |  |  |    * @param {*} intakeId 取水口id | 
 |  |  |    * @param {*} isforce 是否强制开阀 | 
 |  |  |    */ | 
 |  |  |   postOpenValva(intakeId, isforce) { | 
 |  |  |     this.setData({ | 
 |  |  |       inputValue: "" | 
 |  |  |     }) | 
 |  |  |     console.log("intakeId:" + intakeId + "   isforce:" + isforce) | 
 |  |  |     wx.showLoading({ | 
 |  |  |       title: '正在开阀请稍候...', // 加载提示文字 | 
 |  |  |       mask: true // 是否显示透明蒙层,防止触摸穿透,默认为 false | 
 |  |  |     }); | 
 |  |  |     const app = getApp(); | 
 |  |  |     const data = { | 
 |  |  |       intakeId: this.data.choseItem.intakeId, //取水口ID | 
 |  |  |     //   vcId:  app.globalData.vcId, //虚拟卡ID | 
 |  |  |       operator: app.globalData.clientId, //操作员 | 
 |  |  |       forceOpen: !!isforce // 使用逻辑非操作符 !! 来确保 isForce 是布尔值   | 
 |  |  |     }; | 
 |  |  |     post({ | 
 |  |  |       url: "wx/valve/open_wx", | 
 |  |  |       data: data, | 
 |  |  |       timeout: 180000 | 
 |  |  |     }).then(response => { | 
 |  |  |       // 处理成功响应 | 
 |  |  |       console.log('请求成功:', response); | 
 |  |  |       // 加载完成后隐藏加载动画 | 
 |  |  |       wx.hideLoading(); | 
 |  |  |       //完成后回到首页 | 
 |  |  |       wx.reLaunch({ | 
 |  |  |         url: '/pages/home/home?param=true' // 首页的路径,根据实际情况填写 | 
 |  |  |       }); | 
 |  |  |     }).catch(error => { | 
 |  |  |       // 加载完成后隐藏加载动画 | 
 |  |  |       wx.hideLoading(); | 
 |  |  |       // 处理错误响应 | 
 |  |  |       console.error('请求失败:', error); | 
 |  |  |       if (error.code === "10005") { | 
 |  |  |         this.setData({ | 
 |  |  |           forceIntakeId: intakeId, | 
 |  |  |           showForceConfirm: true | 
 |  |  |         }) | 
 |  |  |       } else if (error.code === "ECONNABORTED" || error.message?.includes('timeout')) { | 
 |  |  |         // 处理超时错误 | 
 |  |  |         this.setData({ | 
 |  |  |           showErrorDialog: true, | 
 |  |  |           errorData: "通信超时,请稍后再试", | 
 |  |  |           errorDialogTitle: "开阀错误" | 
 |  |  |         }) | 
 |  |  |       } else { | 
 |  |  |         this.setData({ | 
 |  |  |           showErrorDialog: true, | 
 |  |  |           errorData: error.msg, | 
 |  |  |           errorDialogTitle: "开阀错误" | 
 |  |  |         }) | 
 |  |  |       } | 
 |  |  |     }); | 
 |  |  |   }, | 
 |  |  |  | 
 |  |  |   /** | 
 |  |  |    * 生命周期函数--监听页面加载 | 
 |  |  | 
 |  |  |    * 生命周期函数--监听页面初次渲染完成 | 
 |  |  |    */ | 
 |  |  |   onReady() { | 
 |  |  |     this.getallWaterPoints(); | 
 |  |  |     this.getcommonWaterPoints(); | 
 |  |  |   }, | 
 |  |  |  | 
 |  |  | 
 |  |  |  | 
 |  |  |   }, | 
 |  |  |  | 
 |  |  |   /** | 
 |  |  |    * 页面相关事件处理函数--监听用户下拉动作 | 
 |  |  |    */ | 
 |  |  |   onPullDownRefresh() { | 
 |  |  |  | 
 |  |  |   }, | 
 |  |  |  | 
 |  |  |  | 
 |  |  |   /** | 
 |  |  |    * 页面上拉触底事件的处理函数 | 
 |  |  | 
 |  |  |    */ | 
 |  |  |   onShareAppMessage() { | 
 |  |  |  | 
 |  |  |   } | 
 |  |  |   , | 
 |  |  |   }, | 
 |  |  |   /** | 
 |  |  |    * 获取所有取水口 | 
 |  |  |    *在所有取水口搜索 | 
 |  |  |    */ | 
 |  |  |   getallWaterPoints: function (intakeNum) { | 
 |  |  |     let params = { url: 'rtu/get_online_intakes' }; | 
 |  |  |     let params = { | 
 |  |  |       url: 'wx/intake/all_intakes' | 
 |  |  |     }; | 
 |  |  |     if (intakeNum) { | 
 |  |  |       params.data = { intakeNum: intakeNum }; | 
 |  |  |       params.data = { | 
 |  |  |         intakeNum: intakeNum | 
 |  |  |       }; | 
 |  |  |     } | 
 |  |  |    | 
 |  |  |     get(params) | 
 |  |  |       .then((data) => { | 
 |  |  |         if(data.success&&data.code==="0001"){ | 
 |  |  |         this.setData({ | 
 |  |  |           isRefreshing_all: false | 
 |  |  |         }); | 
 |  |  |         if (data.success && data.code === "0001") { | 
 |  |  |           let waterPoints = []; | 
 |  |  |            | 
 |  |  |           // 兼容新旧两种数据结构 | 
 |  |  |           if (data.content) { | 
 |  |  |             // 新数据结构:content直接包含取水口信息 | 
 |  |  |             if (data.content.intakeId) { | 
 |  |  |               waterPoints = [data.content]; | 
 |  |  |             } | 
 |  |  |             // 旧数据结构:content包含obj数组 | 
 |  |  |             else if (data.content.obj && Array.isArray(data.content.obj) && data.content.obj.length > 0) { | 
 |  |  |               waterPoints = data.content.obj; | 
 |  |  |             } | 
 |  |  |           } | 
 |  |  |            | 
 |  |  |           if (waterPoints.length === 0) { | 
 |  |  |             wx.showToast({ | 
 |  |  |               title: '没有搜索到取水口', | 
 |  |  |               icon: 'error', | 
 |  |  |             }) | 
 |  |  |           } else { | 
 |  |  |             this.setData({ | 
 |  |  |               allWaterPoints: waterPoints | 
 |  |  |             }); | 
 |  |  |           } | 
 |  |  |  | 
 |  |  |         } else { | 
 |  |  |           wx.showToast({ | 
 |  |  |             title: data.msg, | 
 |  |  |           }) | 
 |  |  |         } | 
 |  |  |         console.log('Failed to add item:'); | 
 |  |  |       }) | 
 |  |  |       .catch((error) => { | 
 |  |  |         this.setData({ | 
 |  |  |           isRefreshing_all: false | 
 |  |  |         }); | 
 |  |  |         wx.showToast({ | 
 |  |  |           title: error.msg, | 
 |  |  |           icon: 'error', | 
 |  |  |           duration: 3000 // 提示的持续时间,单位毫秒 | 
 |  |  |         }) | 
 |  |  |         console.error('Failed to add item:', error); | 
 |  |  |       }); | 
 |  |  |   }, | 
 |  |  |   //获取常用取水口 | 
 |  |  |   getcommonWaterPoints() { | 
 |  |  |     get({ | 
 |  |  |         url: 'wx/intake/used_intakes', | 
 |  |  |         data: { | 
 |  |  |           operatorId: getApp().globalData.clientId | 
 |  |  |         } | 
 |  |  |       }) | 
 |  |  |       .then((data) => { | 
 |  |  |         this.setData({ | 
 |  |  |           isRefreshing_common: false | 
 |  |  |         }); | 
 |  |  |         if (data.success && data.code === "0001") { | 
 |  |  |           this.setData({ | 
 |  |  |             allWaterPoints:  data.content.obj | 
 |  |  |             commonWaterPoints: data.content | 
 |  |  |           }); | 
 |  |  |         }else{ | 
 |  |  |         } else { | 
 |  |  |           wx.showToast({ | 
 |  |  |             title: data.msg, | 
 |  |  |           }) | 
 |  |  |         } | 
 |  |  |         console.log('Failed to add item:'); | 
 |  |  |       }) | 
 |  |  |       .catch((error) => { | 
 |  |  |         this.setData({ | 
 |  |  |           isRefreshing_common: false | 
 |  |  |         }); | 
 |  |  |         wx.showToast({ | 
 |  |  |           title: error.msg, | 
 |  |  |           icon: 'error', | 
 |  |  |           duration: 3000 // 提示的持续时间,单位毫秒 | 
 |  |  |         }) | 
 |  |  |         console.error('Failed to add item:', error); | 
 |  |  |       }); | 
 |  |  |   }, | 
 |  |  |   /** | 
 |  |  |    * 页面相关事件处理函数--监听用户下拉动作 | 
 |  |  |    */ | 
 |  |  |   onPullDownRefresh_all() { | 
 |  |  |     this.getallWaterPoints(); | 
 |  |  |   }, | 
 |  |  |   onPullDownRefresh_common() { | 
 |  |  |     this.getcommonWaterPoints(); | 
 |  |  |   }, | 
 |  |  |   confirmDialog() { | 
 |  |  |     this.setData({ | 
 |  |  |         showConfirm: false | 
 |  |  |     }) | 
 |  |  |     this.initDialogData(); | 
 |  |  |   }, | 
 |  |  |   closeDialog() { | 
 |  |  |     this.setData({ | 
 |  |  |       showConfirm: false | 
 |  |  |     }) | 
 |  |  |   }, | 
 |  |  |   closeErrorDialog() { | 
 |  |  |     this.setData({ | 
 |  |  |       showErrorDialog: false | 
 |  |  |     }) | 
 |  |  |   }, | 
 |  |  |   cancelDialog() { | 
 |  |  |     this.setData({ | 
 |  |  |       showForceConfirm: false | 
 |  |  |     }); | 
 |  |  |   }, | 
 |  |  |   //强制开阀 | 
 |  |  |   confirmForceDialog() { | 
 |  |  |     this.postOpenValva(this.data.forceIntakeId, true); | 
 |  |  |   }, | 
 |  |  |   closeSearch() { | 
 |  |  |     this.setData({ | 
 |  |  |       allWaterPoints: [], | 
 |  |  |       inputValue: "" | 
 |  |  |     }) | 
 |  |  |   }, | 
 |  |  |  | 
 |  |  |   //以下为定时定量相关代码 | 
 |  |  |   //初始化所有开泵的参数 | 
 |  |  |   initDialogData() { | 
 |  |  |     this.setData({ | 
 |  |  |       isShowOpenTime: "false", | 
 |  |  |       isOpenTiming: false, //是否是计划开阀时间样式的开阀 | 
 |  |  |       postMinutes: 0, //定灌溉时长的时间 | 
 |  |  |       showForceConfirm: false, | 
 |  |  |       showErrorDialog: false, //错误提示 | 
 |  |  |       showDialog: true, | 
 |  |  |       dialog_mode: true, | 
 |  |  |       dialog_time: false, | 
 |  |  |       dialog_water: false, | 
 |  |  |       openTimeText: "", | 
 |  |  |       openTime: "" | 
 |  |  |     }) | 
 |  |  |   }, | 
 |  |  |   handleClost() { | 
 |  |  |     this.setData({ | 
 |  |  |       showDialog: false | 
 |  |  |     }) | 
 |  |  |   }, | 
 |  |  |   handleSetDuration() { | 
 |  |  |     this.getIrrigateProfileData(1); | 
 |  |  |   }, | 
 |  |  |   //获取常用用水时长及用水量 | 
 |  |  |   getIrrigateProfileData(type) { | 
 |  |  |     get({ | 
 |  |  |         url: 'wx/valve/irrigate_profile', | 
 |  |  |         data: { | 
 |  |  |           type: type | 
 |  |  |         } | 
 |  |  |       }) | 
 |  |  |       .then((data) => { | 
 |  |  |         if (data.success && data.code === "0001") { | 
 |  |  |           const items = data.content.obj.map(item => { | 
 |  |  |             return { | 
 |  |  |               defaultValue: item.defaultValue, | 
 |  |  |               unit: item.unit, | 
 |  |  |               unitText: item.unit === "1" ? "小时" : item.unit === "2" ? "分钟" : "立方米" | 
 |  |  |             }; | 
 |  |  |           }); | 
 |  |  |           this.setData({ | 
 |  |  |             dialog_mode: false, | 
 |  |  |             dialog_time: type === 1, | 
 |  |  |             dialog_water: type === 2, | 
 |  |  |             irrigateProfile: items | 
 |  |  |           }); | 
 |  |  |         } else { | 
 |  |  |           wx.showToast({ | 
 |  |  |             title: data.msg, | 
 |  |  |           }) | 
 |  |  | 
 |  |  |         console.error('Failed to add item:', error); | 
 |  |  |       }); | 
 |  |  |   }, | 
 |  |  |   getcommonWaterPoints(){ | 
 |  |  |   handleSetWaterVolume() { | 
 |  |  |     this.getIrrigateProfileData(2); | 
 |  |  |   }, | 
 |  |  |   dialogBack() { | 
 |  |  |     this.setData({ | 
 |  |  |       dialog_time: false, | 
 |  |  |       dialog_water: false, | 
 |  |  |       dialog_mode: true, | 
 |  |  |       group_time: false, | 
 |  |  |       activeIndex: -1 | 
 |  |  |     }) | 
 |  |  |   }, | 
 |  |  |   //选择时间后的处理 | 
 |  |  |   handleTimeWrapperTap(e) { | 
 |  |  |     const index = e.currentTarget.dataset.index; | 
 |  |  |     console.log(index) | 
 |  |  |     if (index !== undefined) { | 
 |  |  |       let minutes; | 
 |  |  |       if (this.data.irrigateProfile[index].unit === "1") { | 
 |  |  |         minutes = this.hourToMinutes(this.data.irrigateProfile[index].defaultValue) | 
 |  |  |       } else { | 
 |  |  |         minutes = this.data.irrigateProfile[index].defaultValue; | 
 |  |  |       } | 
 |  |  |       this.setData({ | 
 |  |  |         activeIndex: parseInt(index), | 
 |  |  |         postMinutes: minutes, | 
 |  |  |         costiomTime: "", | 
 |  |  |         group_time: false, | 
 |  |  |       }); | 
 |  |  |     } | 
 |  |  |   }, | 
 |  |  |   onTimeInputChange(data) { | 
 |  |  |     console.log(data.detail.value) | 
 |  |  |     if (data.detail.value !== "") { | 
 |  |  |       this.setData({ | 
 |  |  |         group_time: true, | 
 |  |  |         activeIndex: -1, | 
 |  |  |         postMinutes: parseInt(data.detail.value) | 
 |  |  |       }) | 
 |  |  |     } else { | 
 |  |  |       this.setData({ | 
 |  |  |         group_time: false, | 
 |  |  |         postMinutes: 0, | 
 |  |  |       }) | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     get({url:'rtu/used_intakes', data: { | 
 |  |  |       operator: getApp().globalData.sessionId | 
 |  |  |     }}) | 
 |  |  |     .then((data) => { | 
 |  |  |       if(data.success&&data.code==="0001"){ | 
 |  |  |   }, | 
 |  |  |   //定灌溉时长自定义输入时间时修改时间单位0:分钟,1:小时 | 
 |  |  |   onGroupOpenTimeTypeChange(event) { | 
 |  |  |     let value = event.detail.value; | 
 |  |  |     if (value === "1") { | 
 |  |  |       this.setData({ | 
 |  |  |         postMinutes: this.hourToMinutes(this.data.postMinutes) | 
 |  |  |       }) | 
 |  |  |     } else { | 
 |  |  |       this.setData({ | 
 |  |  |         postMinutes: this.minutesToHours(this.data.postMinutes) | 
 |  |  |       }) | 
 |  |  |     } | 
 |  |  |   }, | 
 |  |  |   onGroupOpenTimeChange(event) { | 
 |  |  |     const { | 
 |  |  |       value | 
 |  |  |     } = event.detail; | 
 |  |  |     console.log('onGroupOpenTimeChange:' + value); | 
 |  |  |     if (value == 1) { | 
 |  |  |       this.showPicker(); | 
 |  |  |       this.setData({ | 
 |  |  |         isOpenTiming: true, | 
 |  |  |         radioValue: value, | 
 |  |  |         dateStartTime: new Date().getTime() | 
 |  |  |       }) | 
 |  |  |     } else { | 
 |  |  |       this.setData({ | 
 |  |  |         isShowOpenTime: false, | 
 |  |  |         isOpenTiming: false, | 
 |  |  |         radioValue: value, | 
 |  |  |       }) | 
 |  |  |     } | 
 |  |  |   }, | 
 |  |  |   //定时开泵按钮 | 
 |  |  |   btnOpenOnTime() { | 
 |  |  |     if (this.data.postMinutes > 0) { | 
 |  |  |       if (this.data.isOpenTiming) { | 
 |  |  |         this.timeClosePlaned(); | 
 |  |  |       } else { | 
 |  |  |         this.timeClose(); | 
 |  |  |       } | 
 |  |  |     } else { | 
 |  |  |       wx.showToast({ | 
 |  |  |         icon: 'error', | 
 |  |  |         title: '请选择或输入灌溉时间!', | 
 |  |  |       }) | 
 |  |  |     } | 
 |  |  |   }, | 
 |  |  |   //定时关阀式计划开阀 | 
 |  |  |   timeClosePlaned() { | 
 |  |  |     const app = getApp(); | 
 |  |  |     wx.showLoading({ | 
 |  |  |       title: '正在通信请稍候...', // 加载提示文字 | 
 |  |  |       mask: true // 是否显示透明蒙层,防止触摸穿透,默认为 false | 
 |  |  |     }); | 
 |  |  |     const data = { | 
 |  |  |       intakeId: this.data.choseItem.intakeId, //取水口ID | 
 |  |  |       minutes: this.data.postMinutes, //分钟 | 
 |  |  |       operator: app.globalData.clientId, //操作员 | 
 |  |  |       plannedOpenTime: this.data.openTime | 
 |  |  |     }; | 
 |  |  |     post({ | 
 |  |  |       url: "wx/valve/planed_open_timed_close", | 
 |  |  |       data: data, | 
 |  |  |       timeout: 180000 | 
 |  |  |     }).then(response => { | 
 |  |  |       // 处理成功响应 | 
 |  |  |       console.log('请求成功:', response); | 
 |  |  |       // 加载完成后隐藏加载动画 | 
 |  |  |       wx.hideLoading(); | 
 |  |  |       //完成后回到首页 | 
 |  |  |       wx.reLaunch({ | 
 |  |  |         url: '/pages/home/home?param=2' // 首页的路径,根据实际情况填写 | 
 |  |  |       }); | 
 |  |  |     }).catch(error => { | 
 |  |  |       // 加载完成后隐藏加载动画 | 
 |  |  |       wx.hideLoading(); | 
 |  |  |       // 处理错误响应 | 
 |  |  |       console.error('请求失败:', error); | 
 |  |  |       if (error.code === "ECONNABORTED" || error.message?.includes('timeout')) { | 
 |  |  |         // 处理超时错误 | 
 |  |  |         this.setData({ | 
 |  |  |           commonWaterPoints:  data.content | 
 |  |  |         }); | 
 |  |  |       }else{ | 
 |  |  |         wx.showToast({ | 
 |  |  |           title: data.msg, | 
 |  |  |           showErrorDialog: true, | 
 |  |  |           errorData: "通信超时,请稍后再试", | 
 |  |  |           errorDialogTitle: "开阀错误" | 
 |  |  |         }) | 
 |  |  |       } else { | 
 |  |  |         this.setData({ | 
 |  |  |           showErrorDialog: true, | 
 |  |  |           errorData: error.msg, | 
 |  |  |           errorDialogTitle: "开阀错误" | 
 |  |  |         }) | 
 |  |  |       } | 
 |  |  |       console.log('Failed to add item:'); | 
 |  |  |     }) | 
 |  |  |     .catch((error) => { | 
 |  |  |       console.error('Failed to add item:', error); | 
 |  |  |     }); | 
 |  |  |   } | 
 |  |  |   }, | 
 |  |  |   //定时关阀式开阀 | 
 |  |  |   timeClose() { | 
 |  |  |     const app = getApp(); | 
 |  |  |     wx.showLoading({ | 
 |  |  |       title: '正在开阀请稍候...', // 加载提示文字 | 
 |  |  |       mask: true // 是否显示透明蒙层,防止触摸穿透,默认为 false | 
 |  |  |     }); | 
 |  |  |     const data = { | 
 |  |  |       intakeId: this.data.choseItem.intakeId, //取水口ID | 
 |  |  |       minutes: this.data.postMinutes, //分钟 | 
 |  |  |       operator: app.globalData.clientId //操作员 | 
 |  |  |     }; | 
 |  |  |     post({ | 
 |  |  |       url: "wx/valve/timed_close", | 
 |  |  |       data: data, | 
 |  |  |       timeout: 180000 | 
 |  |  |     }).then(response => { | 
 |  |  |       // 处理成功响应 | 
 |  |  |       console.log('请求成功:', response); | 
 |  |  |       // 加载完成后隐藏加载动画 | 
 |  |  |       wx.hideLoading(); | 
 |  |  |       //完成后回到首页 | 
 |  |  |       wx.reLaunch({ | 
 |  |  |         url: '/pages/home/home?param=1' // 首页的路径,根据实际情况填写 | 
 |  |  |       }); | 
 |  |  |     }).catch(error => { | 
 |  |  |       // 加载完成后隐藏加载动画 | 
 |  |  |       wx.hideLoading(); | 
 |  |  |       // 处理错误响应 | 
 |  |  |       console.error('请求失败:', error); | 
 |  |  |       if (error.code === "ECONNABORTED" || error.message?.includes('timeout')) { | 
 |  |  |         // 处理超时错误 | 
 |  |  |         this.setData({ | 
 |  |  |           showErrorDialog: true, | 
 |  |  |           errorData: "通信超时,请稍后再试", | 
 |  |  |           errorDialogTitle: "开阀错误" | 
 |  |  |         }) | 
 |  |  |       } else { | 
 |  |  |         this.setData({ | 
 |  |  |           showErrorDialog: true, | 
 |  |  |           errorData: error.msg, | 
 |  |  |           errorDialogTitle: "开阀错误" | 
 |  |  |         }) | 
 |  |  |       } | 
 |  |  |     }); | 
 |  |  |   }, | 
 |  |  |     // 通过小时转换成分钟 | 
 |  |  |     hourToMinutes(hours) { | 
 |  |  |         // 检查输入是否合法 | 
 |  |  |         if (isNaN(hours) || hours < 0) { | 
 |  |  |           console.error('请输入有效的小时数'); | 
 |  |  |           return null; | 
 |  |  |         } | 
 |  |  |         // 将小时转换为分钟 | 
 |  |  |         const minutes = hours * 60; | 
 |  |  |         return minutes; | 
 |  |  |       }, | 
 |  |  |       minutesToHours(minutes) { | 
 |  |  |         // 检查输入是否合法 | 
 |  |  |         if (isNaN(minutes) || hours < 0) { | 
 |  |  |           console.error('请输入有效的小时数'); | 
 |  |  |           return null; | 
 |  |  |         } | 
 |  |  |         // 将小时转换为分钟 | 
 |  |  |         const hours = minutes / 60; | 
 |  |  |         return hours; | 
 |  |  |       }, | 
 |  |  |         // 选择水量后的处理 | 
 |  |  |   handleWaterWrapperTap(e) { | 
 |  |  |     const index = e.currentTarget.dataset.index; | 
 |  |  |     console.log(index) | 
 |  |  |     if (index !== undefined) { | 
 |  |  |       this.data.waterAmount = parseInt(this.data.irrigateProfile[index].defaultValue) | 
 |  |  |       this.setData({ | 
 |  |  |         activeIndex: parseInt(index), | 
 |  |  |         costiomWater: "" | 
 |  |  |       }); | 
 |  |  |     } | 
 |  |  |   }, //显示时间选择器 | 
 |  |  |   showPicker(e) { | 
 |  |  |     this.setData({ | 
 |  |  |       datetime: new Date().getTime(), | 
 |  |  |       datetimeVisible: true, | 
 |  |  |       isShowOpenTime: true | 
 |  |  |     }); | 
 |  |  |   }, | 
 |  |  |   onConfirm(e) { | 
 |  |  |     const { | 
 |  |  |       value | 
 |  |  |     } = e?.detail; | 
 |  |  |     console.log(value); | 
 |  |  |     this.setData({ | 
 |  |  |       openTime: value, | 
 |  |  |       openTimeText: "计划开阀时间:" + value | 
 |  |  |     }) | 
 |  |  |   },  hidePicker() { | 
 |  |  |     this.setData({ | 
 |  |  |       isShowOpenTime: false, | 
 |  |  |       isOpenTiming: false, | 
 |  |  |       radioValue: "0" | 
 |  |  |     }) | 
 |  |  |   }, // 定量开泵按钮 | 
 |  |  |   btnOpenOnWater() { | 
 |  |  |     if (this.data.waterAmount > 0) { | 
 |  |  |       if (this.data.isOpenTiming) { | 
 |  |  |         this.quantifyOpenTime(); | 
 |  |  |       } else { | 
 |  |  |         this.quantifyOpen(); | 
 |  |  |       } | 
 |  |  |     } else { | 
 |  |  |       wx.showToast({ | 
 |  |  |         icon: 'error', | 
 |  |  |         title: '请选择或输入灌溉时间!', | 
 |  |  |       }) | 
 |  |  |     } | 
 |  |  |   },//定量开阀式计划开阀 | 
 |  |  |   quantifyOpenTime() { | 
 |  |  |     const app = getApp(); | 
 |  |  |     wx.showLoading({ | 
 |  |  |       title: '正在通信请稍候...', // 加载提示文字 | 
 |  |  |       mask: true // 是否显示透明蒙层,防止触摸穿透,默认为 false | 
 |  |  |     }); | 
 |  |  |     const data = { | 
 |  |  |       intakeId: this.data.choseItem.intakeId, //取水口ID | 
 |  |  |       waterAmount: this.data.waterAmount, //水量 | 
 |  |  |       operator: app.globalData.clientId, //操作员 | 
 |  |  |       plannedOpenTime: this.data.openTime | 
 |  |  |     }; | 
 |  |  |     post({ | 
 |  |  |       url: "wx/valve/planed_open_quantify_close", | 
 |  |  |       data: data, | 
 |  |  |       timeout: 180000 | 
 |  |  |     }).then(response => { | 
 |  |  |       // 处理成功响应 | 
 |  |  |       console.log('请求成功:', response); | 
 |  |  |       // 加载完成后隐藏加载动画 | 
 |  |  |       wx.hideLoading(); | 
 |  |  |       //完成后回到首页 | 
 |  |  |       wx.reLaunch({ | 
 |  |  |         url: '/pages/home/home?param=2' // 首页的路径,根据实际情况填写 | 
 |  |  |       }); | 
 |  |  |     }).catch(error => { | 
 |  |  |       // 加载完成后隐藏加载动画 | 
 |  |  |       wx.hideLoading(); | 
 |  |  |       // 处理错误响应 | 
 |  |  |       console.error('请求失败:', error); | 
 |  |  |       if (error.code === "ECONNABORTED" || error.message?.includes('timeout')) { | 
 |  |  |         // 处理超时错误 | 
 |  |  |         this.setData({ | 
 |  |  |           showErrorDialog: true, | 
 |  |  |           errorData: "通信超时,请稍后再试", | 
 |  |  |           errorDialogTitle: "开阀错误" | 
 |  |  |         }) | 
 |  |  |       } else { | 
 |  |  |         this.setData({ | 
 |  |  |           showErrorDialog: true, | 
 |  |  |           errorData: error.msg, | 
 |  |  |           errorDialogTitle: "开阀错误" | 
 |  |  |         }) | 
 |  |  |       } | 
 |  |  |     }); | 
 |  |  |   },//定量开阀 | 
 |  |  |   quantifyOpen() { | 
 |  |  |     const app = getApp(); | 
 |  |  |     wx.showLoading({ | 
 |  |  |       title: '正在开阀请稍候...', // 加载提示文字 | 
 |  |  |       mask: true // 是否显示透明蒙层,防止触摸穿透,默认为 false | 
 |  |  |     }); | 
 |  |  |     const data = { | 
 |  |  |       intakeId: this.data.choseItem.intakeId, //取水口ID | 
 |  |  |       waterAmount: this.data.waterAmount, //水量 | 
 |  |  |       operator: app.globalData.clientId //操作员 | 
 |  |  |     }; | 
 |  |  |     post({ | 
 |  |  |       url: "wx/valve/quantify_close", | 
 |  |  |       data: data, | 
 |  |  |       timeout: 180000 | 
 |  |  |     }).then(response => { | 
 |  |  |       // 处理成功响应 | 
 |  |  |       console.log('请求成功:', response); | 
 |  |  |       // 加载完成后隐藏加载动画 | 
 |  |  |       wx.hideLoading(); | 
 |  |  |       //完成后回到首页 | 
 |  |  |       wx.reLaunch({ | 
 |  |  |         url: '/pages/home/home?param=1' // 首页的路径,根据实际情况填写 | 
 |  |  |       }); | 
 |  |  |     }).catch(error => { | 
 |  |  |       // 加载完成后隐藏加载动画 | 
 |  |  |       wx.hideLoading(); | 
 |  |  |       // 处理错误响应 | 
 |  |  |       console.error('请求失败:', error); | 
 |  |  |       if (error.code === "ECONNABORTED" || error.message?.includes('timeout')) { | 
 |  |  |         // 处理超时错误 | 
 |  |  |         this.setData({ | 
 |  |  |           showErrorDialog: true, | 
 |  |  |           errorData: "通信超时,请稍后再试", | 
 |  |  |           errorDialogTitle: "开阀错误" | 
 |  |  |         }) | 
 |  |  |       } else { | 
 |  |  |         this.setData({ | 
 |  |  |           showErrorDialog: true, | 
 |  |  |           errorData: error.msg, | 
 |  |  |           errorDialogTitle: "开阀错误" | 
 |  |  |         }) | 
 |  |  |       } | 
 |  |  |     }); | 
 |  |  |   }, | 
 |  |  | }) |