From 86a5b87fe5d8f62ae03346f0f316e0a33d9e06e4 Mon Sep 17 00:00:00 2001
From: zuoxiao <zuoxiao>
Date: 星期一, 31 三月 2025 20:52:44 +0800
Subject: [PATCH] 添加时间选择器
---
pages/waterIntake/waterIntake.js | 104 +++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 95 insertions(+), 9 deletions(-)
diff --git a/pages/waterIntake/waterIntake.js b/pages/waterIntake/waterIntake.js
index 22ec85b..5ac5cb2 100644
--- a/pages/waterIntake/waterIntake.js
+++ b/pages/waterIntake/waterIntake.js
@@ -40,6 +40,29 @@
openTimeText: "",
openTime: "",
irrigateProfile: [], //鑾峰彇鎵�閫夌亴婧夋柟寮忕殑璇︾粏鏁版嵁
+ dialog_mode: true,
+ dialog_time: false,
+ dialog_water: false,
+ group_time: false, //鏄惁鏄剧ず閫夋嫨鍒嗛挓鎴栧皬鏃剁殑鍗曢�夋
+ openTime: "", //璁″垝寮�娉电殑寮�濮嬫椂闂�
+ openTimeText: "",
+ isShowOpenTime: "false",
+ isOpenTiming: false, //鏄惁鏄鍒掑紑闃�鏃堕棿鏍峰紡鐨勫紑闃�
+ postMinutes: 0, //瀹氱亴婧夋椂闀跨殑鏃堕棿
+ showForceConfirm: false,
+ showErrorDialog: false, //閿欒鎻愮ず
+ errorData: "",
+ confirmBtn: {
+ content: '纭'
+ },
+ radioValue: "0", //寮�闃�鏂瑰紡閫変腑鐨勭被鍨�
+ costiomTime: "", //鑷畾涔夌亴婧夋椂闂�
+ waterAmount: 0, //瀹氶噺寮�闃�鐨勬按閲�
+ costiomWater: "", //杈撳叆鐨勮嚜瀹氫箟姘撮噺
+ isWXRefreshing: false,
+ irrigateProfile: [], //鑾峰彇鎵�閫夌亴婧夋柟寮忕殑璇︾粏鏁版嵁
+ datetimeVisible: false,
+
},
// 鍒囨崲 Tabs
@@ -73,10 +96,13 @@
choseCard(event) {
//鏄剧ず浜屾纭寮圭獥
this.setData({
- showConfirm: true,
+ // showConfirm: true,
choseItem: event.currentTarget.dataset.item,
allWaterPoints: []
+
})
+ this.initDialogData();
+
// console.log(intakeId);
// wx.navigateTo({
// url: '/pages/openCard/openCard?intakeId='+intakeId,
@@ -100,8 +126,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 鏄竷灏斿��
};
@@ -283,10 +309,14 @@
this.getcommonWaterPoints();
},
confirmDialog() {
+ // this.setData({
+ // showConfirm: false
+ // })
+ // this.postOpenValva(this.data.choseItem.intakeId);
this.setData({
- showConfirm: false
+ showConfirm: false
})
- this.postOpenValva(this.data.choseItem.intakeId);
+ this.initDialogData();
},
closeDialog() {
this.setData({
@@ -476,8 +506,8 @@
mask: true // 鏄惁鏄剧ず閫忔槑钂欏眰锛岄槻姝㈣Е鎽哥┛閫忥紝榛樿涓� false
});
const data = {
- intakeId: this.data.intakeId, //鍙栨按鍙D
- // vcId: this.data.vcId, //铏氭嫙鍗D
+ intakeId: this.data.choseItem.intakeId, //鍙栨按鍙D
+ // vcId: app.globalData.vcId, //铏氭嫙鍗D
minutes: this.data.postMinutes, //鍒嗛挓
operator: app.globalData.clientId, //鎿嶄綔鍛�
plannedOpenTime: this.data.openTime
@@ -513,8 +543,8 @@
mask: true // 鏄惁鏄剧ず閫忔槑钂欏眰锛岄槻姝㈣Е鎽哥┛閫忥紝榛樿涓� false
});
const data = {
- intakeId: this.data.intakeId, //鍙栨按鍙D
- // vcId: this.data.vcId, //铏氭嫙鍗D
+ intakeId: this.data.choseItem.intakeId, //鍙栨按鍙D
+ // vcId: app.globalData.vcId, //铏氭嫙鍗D
minutes: this.data.postMinutes, //鍒嗛挓
operator: app.globalData.clientId //鎿嶄綔鍛�
};
@@ -541,4 +571,60 @@
})
});
},
+ // 閫氳繃灏忔椂杞崲鎴愬垎閽�
+ 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"
+ })
+ },
})
\ No newline at end of file
--
Gitblit v1.8.0