From 25ebc714977470b5ed02b0ec7f30ea0615ebd89f Mon Sep 17 00:00:00 2001
From: zuoxiao <zuoxiao>
Date: 星期五, 14 三月 2025 16:48:09 +0800
Subject: [PATCH] 更新应用配置,添加AppID并修改页面路由;优化取水口界面,增加定时开阀功能和相关参数设置;修复首页反馈图标及提示信息。

---
 pages/waterIntake/waterIntake.js |  259 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 250 insertions(+), 9 deletions(-)

diff --git a/pages/waterIntake/waterIntake.js b/pages/waterIntake/waterIntake.js
index 0be2824..7059ee3 100644
--- a/pages/waterIntake/waterIntake.js
+++ b/pages/waterIntake/waterIntake.js
@@ -26,7 +26,20 @@
     },
     showForceConfirm: false,
     forceIntakeId: "", //寮哄埗寮�闃�鐨勫彇姘村彛id
-    inputValue:""
+    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: [], //鑾峰彇鎵�閫夌亴婧夋柟寮忕殑璇︾粏鏁版嵁
   },
 
   // 鍒囨崲 Tabs
@@ -78,7 +91,7 @@
    */
   postOpenValva(intakeId, isforce) {
     this.setData({
-      inputValue:""
+      inputValue: ""
     })
     console.log("intakeId:" + intakeId + "   isforce:" + isforce)
     wx.showLoading({
@@ -200,12 +213,12 @@
               title: '娌℃湁鎼滅储鍒板彇姘村彛',
               icon: 'error',
             })
-          }else{
+          } else {
             this.setData({
-              allWaterPoints:[data.content]
+              allWaterPoints: [data.content]
             });
           }
-        
+
         } else {
           wx.showToast({
             title: data.msg,
@@ -294,10 +307,238 @@
   confirmForceDialog() {
     this.postOpenValva(this.data.forceIntakeId, true);
   },
-  closeSearch(){
+  closeSearch() {
     this.setData({
-      allWaterPoints:[],
-      inputValue:""
+      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.log('Failed to add item:');
+      })
+      .catch((error) => {
+        console.error('Failed to add item:', error);
+      });
+  },
+  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,
+      })
+    }
+
+  },
+  //瀹氱亴婧夋椂闀胯嚜瀹氫箟杈撳叆鏃堕棿鏃朵慨鏀规椂闂村崟浣�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: '姝e湪閫氫俊璇风◢鍊�...', // 鍔犺浇鎻愮ず鏂囧瓧
+      mask: true // 鏄惁鏄剧ず閫忔槑钂欏眰锛岄槻姝㈣Е鎽哥┛閫忥紝榛樿涓� false
+    });
+    const data = {
+      intakeId: this.data.intakeId, //鍙栨按鍙D
+      // vcId: this.data.vcId, //铏氭嫙鍗D
+      minutes: this.data.postMinutes, //鍒嗛挓
+      operator: app.globalData.clientId, //鎿嶄綔鍛�
+      plannedOpenTime: this.data.openTime
+    };
+    post({
+      url: "wx/valve/planed_open_timed_close",
+      data: data
+    }).then(response => {
+      // 澶勭悊鎴愬姛鍝嶅簲
+      console.log('璇锋眰鎴愬姛:', response);
+      // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢�
+      wx.hideLoading();
+      //瀹屾垚鍚庡洖鍒伴椤�
+      wx.reLaunch({
+        url: '/pages/home/home?param=2' // 棣栭〉鐨勮矾寰勶紝鏍规嵁瀹為檯鎯呭喌濉啓
+      });
+    }).catch(error => {
+      // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢�
+      wx.hideLoading();
+      // 澶勭悊閿欒鍝嶅簲
+      console.error('璇锋眰澶辫触:', error);
+      this.setData({
+        showErrorDialog: true,
+        errorData: error.msg
+      })
+    });
+  },
+  //瀹氭椂鍏抽榾寮忓紑闃�
+  timeClose() {
+    const app = getApp();
+    wx.showLoading({
+      title: '姝e湪寮�闃�璇风◢鍊�...', // 鍔犺浇鎻愮ず鏂囧瓧
+      mask: true // 鏄惁鏄剧ず閫忔槑钂欏眰锛岄槻姝㈣Е鎽哥┛閫忥紝榛樿涓� false
+    });
+    const data = {
+      intakeId: this.data.intakeId, //鍙栨按鍙D
+      // vcId: this.data.vcId, //铏氭嫙鍗D
+      minutes: this.data.postMinutes, //鍒嗛挓
+      operator: app.globalData.clientId //鎿嶄綔鍛�
+    };
+    post({
+      url: "wx/valve/timed_close",
+      data: data
+    }).then(response => {
+      // 澶勭悊鎴愬姛鍝嶅簲
+      console.log('璇锋眰鎴愬姛:', response);
+      // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢�
+      wx.hideLoading();
+      //瀹屾垚鍚庡洖鍒伴椤�
+      wx.reLaunch({
+        url: '/pages/home/home?param=1' // 棣栭〉鐨勮矾寰勶紝鏍规嵁瀹為檯鎯呭喌濉啓
+      });
+    }).catch(error => {
+      // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢�
+      wx.hideLoading();
+      // 澶勭悊閿欒鍝嶅簲
+      console.error('璇锋眰澶辫触:', error);
+      this.setData({
+        showErrorDialog: true,
+        errorData: error.msg
+      })
+    });
+  },
 })
\ No newline at end of file

--
Gitblit v1.8.0