From 832a41e2688553219b540ca772faeaba16a02088 Mon Sep 17 00:00:00 2001
From: zuoxiao <zuoxiao>
Date: 星期五, 22 八月 2025 14:44:23 +0800
Subject: [PATCH] 更新项目配置,提升监测页面功能,新增注肥泵状态管理和故障清除功能;优化样式以增强用户体验和可视化效果。
---
pages/waterIntake/waterIntake.js | 270 ++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 244 insertions(+), 26 deletions(-)
diff --git a/pages/waterIntake/waterIntake.js b/pages/waterIntake/waterIntake.js
index 22ec85b..0ef769c 100644
--- a/pages/waterIntake/waterIntake.js
+++ b/pages/waterIntake/waterIntake.js
@@ -40,6 +40,27 @@
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
@@ -77,11 +98,7 @@
choseItem: event.currentTarget.dataset.item,
allWaterPoints: []
})
- // console.log(intakeId);
- // wx.navigateTo({
- // url: '/pages/openCard/openCard?intakeId='+intakeId,
- // })
-
+ // 娉ㄦ剰锛歩nitDialogData鐨勮皟鐢ㄧЩ鍒颁簡confirmDialog鏂规硶涓�
},
//寮�娉甸�氫俊
/**
@@ -100,8 +117,8 @@
});
const app = getApp();
const data = {
- intakeId: intakeId, //鍙栨按鍙D
- // vcId: vcId, //铏氭嫙鍗D
+ intakeId: this.data.choseItem.intakeId, //鍙栨按鍙D
+ // vcId: app.globalData.vcId, //铏氭嫙鍗D
operator: app.globalData.clientId, //鎿嶄綔鍛�
forceOpen: !!isforce // 浣跨敤閫昏緫闈炴搷浣滅 !! 鏉ョ‘淇� isForce 鏄竷灏斿��
};
@@ -110,7 +127,6 @@
data: data,
timeout: 180000
}).then(response => {
-
// 澶勭悊鎴愬姛鍝嶅簲
console.log('璇锋眰鎴愬姛:', response);
// 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢�
@@ -119,7 +135,6 @@
wx.reLaunch({
url: '/pages/home/home?param=true' // 棣栭〉鐨勮矾寰勶紝鏍规嵁瀹為檯鎯呭喌濉啓
});
-
}).catch(error => {
// 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢�
wx.hideLoading();
@@ -130,10 +145,18 @@
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
+ errorData: error.msg,
+ errorDialogTitle: "寮�闃�閿欒"
})
}
});
@@ -208,14 +231,28 @@
isRefreshing_all: false
});
if (data.success && data.code === "0001") {
- if (!data.content) {
+ let waterPoints = [];
+
+ // 鍏煎鏂版棫涓ょ鏁版嵁缁撴瀯
+ if (data.content) {
+ // 鏂版暟鎹粨鏋勶細content鐩存帴鍖呭惈鍙栨按鍙d俊鎭�
+ 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: [data.content]
+ allWaterPoints: waterPoints
});
}
@@ -284,9 +321,9 @@
},
confirmDialog() {
this.setData({
- showConfirm: false
+ showConfirm: false
})
- this.postOpenValva(this.data.choseItem.intakeId);
+ this.initDialogData();
},
closeDialog() {
this.setData({
@@ -476,15 +513,15 @@
mask: true // 鏄惁鏄剧ず閫忔槑钂欏眰锛岄槻姝㈣Е鎽哥┛閫忥紝榛樿涓� false
});
const data = {
- intakeId: this.data.intakeId, //鍙栨按鍙D
- // vcId: this.data.vcId, //铏氭嫙鍗D
+ intakeId: this.data.choseItem.intakeId, //鍙栨按鍙D
minutes: this.data.postMinutes, //鍒嗛挓
operator: app.globalData.clientId, //鎿嶄綔鍛�
plannedOpenTime: this.data.openTime
};
post({
url: "wx/valve/planed_open_timed_close",
- data: data
+ data: data,
+ timeout: 180000
}).then(response => {
// 澶勭悊鎴愬姛鍝嶅簲
console.log('璇锋眰鎴愬姛:', response);
@@ -499,10 +536,20 @@
wx.hideLoading();
// 澶勭悊閿欒鍝嶅簲
console.error('璇锋眰澶辫触:', error);
- this.setData({
- showErrorDialog: true,
- errorData: error.msg
- })
+ if (error.code === "ECONNABORTED" || error.message?.includes('timeout')) {
+ // 澶勭悊瓒呮椂閿欒
+ this.setData({
+ showErrorDialog: true,
+ errorData: "閫氫俊瓒呮椂锛岃绋嶅悗鍐嶈瘯",
+ errorDialogTitle: "寮�闃�閿欒"
+ })
+ } else {
+ this.setData({
+ showErrorDialog: true,
+ errorData: error.msg,
+ errorDialogTitle: "寮�闃�閿欒"
+ })
+ }
});
},
//瀹氭椂鍏抽榾寮忓紑闃�
@@ -513,14 +560,14 @@
mask: true // 鏄惁鏄剧ず閫忔槑钂欏眰锛岄槻姝㈣Е鎽哥┛閫忥紝榛樿涓� false
});
const data = {
- intakeId: this.data.intakeId, //鍙栨按鍙D
- // vcId: this.data.vcId, //铏氭嫙鍗D
+ intakeId: this.data.choseItem.intakeId, //鍙栨按鍙D
minutes: this.data.postMinutes, //鍒嗛挓
operator: app.globalData.clientId //鎿嶄綔鍛�
};
post({
url: "wx/valve/timed_close",
- data: data
+ data: data,
+ timeout: 180000
}).then(response => {
// 澶勭悊鎴愬姛鍝嶅簲
console.log('璇锋眰鎴愬姛:', response);
@@ -535,10 +582,181 @@
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({
- showErrorDialog: true,
- errorData: error.msg
+ 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: '姝e湪閫氫俊璇风◢鍊�...', // 鍔犺浇鎻愮ず鏂囧瓧
+ mask: true // 鏄惁鏄剧ず閫忔槑钂欏眰锛岄槻姝㈣Е鎽哥┛閫忥紝榛樿涓� false
+ });
+ const data = {
+ intakeId: this.data.choseItem.intakeId, //鍙栨按鍙D
+ 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: '姝e湪寮�闃�璇风◢鍊�...', // 鍔犺浇鎻愮ず鏂囧瓧
+ mask: true // 鏄惁鏄剧ず閫忔槑钂欏眰锛岄槻姝㈣Е鎽哥┛閫忥紝榛樿涓� false
+ });
+ const data = {
+ intakeId: this.data.choseItem.intakeId, //鍙栨按鍙D
+ 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: "寮�闃�閿欒"
+ })
+ }
});
},
})
\ No newline at end of file
--
Gitblit v1.8.0