From aec1b6ec73897b5e5f3a85f2985447726a399ed0 Mon Sep 17 00:00:00 2001 From: zuoxiao <zuoxiao> Date: 星期六, 19 四月 2025 15:56:48 +0800 Subject: [PATCH] 更新灌溉计划页面,添加灌溉计划列表刷新标记,优化项目选择器和时间选择器的逻辑;更新样式以提升用户体验,确保在切换标签时只加载必要的数据。 --- pages/irrigation/irrigation.js | 136 ++- pages/groupDetail/groupDetail.js | 5 pages/home/home.js | 149 +++ pages/home/home.json | 2 pages/valveList/valveList.wxss | 83 ++ pages/valveList/valveList.wxml | 73 + images/time.svg | 1 pages/createIrrigation/createIrrigation.wxml | 6 pages/createIrrigation/createIrrigation.wxss | 21 app.js | 3 api/config.js | 4 pages/valveList/valveList.js | 210 +++++ pages/irrigation/irrigation.wxml | 2 pages/irrigationDetail/irrigationDetail.js | 131 +++ pages/waterIntake/waterIntake.json | 2 pages/createIrrigation/createIrrigation.js | 906 +++++++++++++------------ pages/home/home.wxml | 44 utils/projectConfig.js | 17 pages/home/home.wxss | 274 +++++-- pages/irrigationDetail/irrigationDetail.wxss | 42 + pages/irrigationDetail/irrigationDetail.wxml | 11 21 files changed, 1,480 insertions(+), 642 deletions(-) diff --git a/api/config.js b/api/config.js index a176cb6..f3763c3 100644 --- a/api/config.js +++ b/api/config.js @@ -7,7 +7,9 @@ JYG: 'https://irrigate.dayuyanjiuyuan.top/', // 鍢夊唱鍏抽」鐩� MQ: 'https://shifanqu1.dayuyanjiuyuan.top/', // 姘戝嫟椤圭洰 TEST: 'https://no253541tf71.vicp.fun/', // test椤圭洰 - SCHOOL: 'https://school.dayuyanjiuyuan.top/' // 瀛︽牎椤圭洰 + SCHOOL: 'https://school.dayuyanjiuyuan.top/', // 瀛︽牎椤圭洰 + JC:'https://shifanqu1.dayuyanjiuyuan.top/', + GSCLT:'https://irrigate.dayuyanjiuyuan.top/'//鐢樿們鍐滅闄㈠磾榫欏ぉ // TEST:'http://192.168.40.182:8087/'// test椤圭洰 // MQ: 'https://no253541tf71.vicp.fun/' // 姘戝嫟椤圭洰 // TEST: 'http://192.168.40.166:54321/' diff --git a/app.js b/app.js index c3f142d..877f2c8 100644 --- a/app.js +++ b/app.js @@ -25,6 +25,7 @@ operator:"2025030416200600006", clientId:"", AppID:"wxbc2b6a00dd904ead", - vcId:"" + vcId:"", + needRefreshIrrigationList: false // 鐢ㄤ簬鏍囪鏄惁闇�瑕佸埛鏂扮亴婧夎鍒掑垪琛� } }) diff --git a/images/time.svg b/images/time.svg new file mode 100644 index 0000000..0c174dc --- /dev/null +++ b/images/time.svg @@ -0,0 +1 @@ +<?xml version="1.0" encoding="UTF-8"?><svg width="24" height="24" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M24 44C35.0457 44 44 35.0457 44 24C44 12.9543 35.0457 4 24 4C12.9543 4 4 12.9543 4 24C4 35.0457 12.9543 44 24 44Z" fill="none" stroke="#1890FF" stroke-width="4" stroke-linejoin="round"/><path d="M24.0084 12.0001L24.0072 24.0089L32.4866 32.4883" stroke="#1890FF" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/></svg> \ No newline at end of file diff --git a/pages/createIrrigation/createIrrigation.js b/pages/createIrrigation/createIrrigation.js index 6a77e38..6915e8f 100644 --- a/pages/createIrrigation/createIrrigation.js +++ b/pages/createIrrigation/createIrrigation.js @@ -1,450 +1,488 @@ const app = getApp(); -const { get, post } = require('../../api/request'); +const { + get, + post +} = require('../../api/request'); const dayjs = require('dayjs'); Page({ - /** - * 椤甸潰鐨勫垵濮嬫暟鎹� - */ - data: { - // 琛ㄥ崟鏁版嵁 - planCode: '', // 璁″垝缂栧彿 - startTime: '', // 鐏屾簤寮�濮嬫椂闂� - pickerValue: '', // 鏃堕棿閫夋嫨鍣ㄧ殑鍊� - timePickerVisible: false, // 鏃堕棿閫夋嫨鍣ㄦ槸鍚﹀彲瑙� - timeInfoVisible: false, // 鏃堕棿鎻愮ず寮圭獥鏄惁鍙 - // 椤圭洰閫夋嫨鍣ㄧ浉鍏� - projectPickerVisible: false, - projectPickerValue: [], - selectedProject: null, - projectOptions: [], - totalDuration: 0, // 娣诲姞鎬荤亴婧夋椂闂� - // 椤圭洰鍒楄〃 - projectList: [], - // 鏃堕棿閫夋嫨鍣ㄩ�夐」 - timeOptions: [], - // 杞亴缁勫垪琛ㄥ埛鏂扮姸鎬� - isRefreshing: false - }, + /** + * 椤甸潰鐨勫垵濮嬫暟鎹� + */ + data: { + // 琛ㄥ崟鏁版嵁 + planCode: '', // 璁″垝缂栧彿 + startTime: '', // 鐏屾簤寮�濮嬫椂闂� + pickerValue: '', // 鏃堕棿閫夋嫨鍣ㄧ殑鍊� + timePickerVisible: false, // 鏃堕棿閫夋嫨鍣ㄦ槸鍚﹀彲瑙� + timeInfoVisible: false, // 鏃堕棿鎻愮ず寮圭獥鏄惁鍙 + // 椤圭洰閫夋嫨鍣ㄧ浉鍏� + projectPickerVisible: false, + projectPickerValue: [], + selectedProject: null, + projectOptions: [], + totalDuration: 0, // 娣诲姞鎬荤亴婧夋椂闂� + // 椤圭洰鍒楄〃 + projectList: [], + // 鏃堕棿閫夋嫨鍣ㄩ�夐」 + timeOptions: [], + // 杞亴缁勫垪琛ㄥ埛鏂扮姸鎬� + isRefreshing: false + }, - /** - * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 - */ - onLoad: function (options) { - // 鐢熸垚璁″垝缂栧彿 - this.generatePlanCode(); - // 璁剧疆鏃堕棿閫夋嫨鍣ㄧ殑鍒濆鍊� - const now = dayjs(); - this.setData({ - pickerValue: now.add(8.5, 'hour').format('YYYY-MM-DD HH:mm') - }); - // 鑾峰彇椤圭洰鍒楄〃 - this.fetchProjects(); - }, + /** + * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇 + */ + onLoad: function (options) { + // 鐢熸垚璁″垝缂栧彿 + this.generatePlanCode(); + // 璁剧疆鏃堕棿閫夋嫨鍣ㄧ殑鍒濆鍊� + const now = dayjs(); + this.setData({ + pickerValue: now.add(8.5, 'hour').format('YYYY-MM-DD HH:mm') + }); + // 鑾峰彇椤圭洰鍒楄〃 + this.fetchProjects(); + }, - /** - * 鐢熸垚璁″垝缂栧彿 - */ - generatePlanCode: function () { - const now = dayjs(); - const dateStr = now.format('YYYYMMDD'); - const randomNum = Math.floor(Math.random() * 10000).toString().padStart(4, '0'); - const planCode = `${dateStr}${randomNum}`; - this.setData({ planCode }); - }, + /** + * 鐢熸垚璁″垝缂栧彿 + */ + generatePlanCode: function () { + const now = dayjs(); + const dateStr = now.format('YYYY-MM-DD'); + const randomNum = Math.floor(Math.random() * 10000).toString().padStart(4, '0'); + const planCode = `${dateStr}${-randomNum}`; + this.setData({ + planCode + }); + }, - /** - * 鑾峰彇椤圭洰鍒楄〃 - */ - fetchProjects: function () { - return get({ - url: '/wx/irrigation/getSimpleProjects', - isShowLoding: true - }).then(res => { - if (res.success) { - const projectList = res.content.map(project => ({ - id: project.projectId, - name: project.projectName, - groupCount: project.groupCount, - groups: [] - })); - - const projectOptions = projectList.map(project => ({ - label: project.name, - value: project.id - })); - - this.setData({ - projectList, - projectOptions - }); - } else { - wx.showToast({ - title: res.msg || '鑾峰彇椤圭洰鍒楄〃澶辫触', - icon: 'none' - }); - return Promise.reject(new Error(res.msg || '鑾峰彇椤圭洰鍒楄〃澶辫触')); - } - }).catch(err => { - console.error('鑾峰彇椤圭洰鍒楄〃澶辫触锛�', err); - wx.showToast({ - title: '鑾峰彇椤圭洰鍒楄〃澶辫触', - icon: 'none' - }); - return Promise.reject(err); - }); - }, - - /** - * 鑾峰彇杞亴缁勫垪琛� - */ - fetchGroups: function (projectId) { - return get({ - url: '/wx/irrigation/getSimpleGroups', - data: { - projectId: projectId, - }, - isShowLoding: true - }).then(res => { - if (res.success) { - console.log('杞亴缁勬暟鎹細', res.content.obj); - - // 鏇存柊閫変腑椤圭洰鐨勮疆鐏岀粍淇℃伅 - const projectList = this.data.projectList.map(project => { - if (project.id === projectId) { - return { - ...project, - groups: res.content.obj.map(group => ({ - id: group.groupId, - name: group.groupCode, - duration: group.defaultDuration || 0, - selected: false, - intakeCount: group.intakeCount - })) - }; - } - return project; - }); - - // 鏇存柊閫変腑鐨勯」鐩� - const selectedProject = projectList.find(project => project.id === projectId); - console.log('鏇存柊鍚庣殑閫変腑椤圭洰锛�', selectedProject); - - this.setData({ - projectList, - selectedProject - }, () => { - // 璁$畻鎬绘椂闂� - this.calculateTotalDuration(); - }); - } else { - wx.showToast({ - title: res.msg || '鑾峰彇杞亴缁勫垪琛ㄥけ璐�', - icon: 'none' - }); - return Promise.reject(new Error(res.msg || '鑾峰彇杞亴缁勫垪琛ㄥけ璐�')); - } - }).catch(err => { - console.error('鑾峰彇杞亴缁勫垪琛ㄥけ璐ワ細', err); - wx.showToast({ - title: '鑾峰彇杞亴缁勫垪琛ㄥけ璐�', - icon: 'none' - }); - return Promise.reject(err); - }); - }, - - /** - * 鏄剧ず鏃堕棿閫夋嫨鍣� - */ - showTimePicker: function () { - // 濡傛灉娌℃湁閫夋嫨鏃堕棿锛屼娇鐢ㄥ綋鍓嶆椂闂� - if (!this.data.pickerValue) { - const now = dayjs(); - this.setData({ - pickerValue: now.format('YYYY-MM-DD HH:mm') - }); - } - - this.setData({ - timePickerVisible: true - }); - }, - - /** - * 鏃堕棿閫夋嫨鍣ㄧ‘璁ゅ洖璋� - */ - onTimePickerConfirm: function (e) { - const { value } = e.detail; - this.setData({ - timePickerVisible: false, - startTime: value - }); - }, - - /** - * 鏃堕棿閫夋嫨鍣ㄥ彇娑堝洖璋� - */ - onTimePickerCancel: function () { - this.setData({ - timePickerVisible: false - }); - }, - - /** - * 鍒囨崲椤圭洰灞曞紑/鎶樺彔鐘舵�� - */ - toggleProject: function (e) { - const index = e.currentTarget.dataset.index; - const currentValue = this.data.projectList[index].expanded; - - // 鍒涘缓鏂扮殑椤圭洰鍒楄〃锛屽厛灏嗘墍鏈夐」鐩涓烘姌鍙犵姸鎬� - const newProjectList = this.data.projectList.map((item, idx) => { - return { - ...item, - expanded: false - }; - }); - - // 濡傛灉褰撳墠鐐瑰嚮鐨勯」鐩凡缁忔槸灞曞紑鐘舵�侊紝鍒欎繚鎸佹墍鏈夐」鐩姌鍙� - // 鍚﹀垯锛屽皢褰撳墠鐐瑰嚮鐨勯」鐩涓哄睍寮�鐘舵�� - if (!currentValue) { - newProjectList[index].expanded = true; - } - - this.setData({ - projectList: newProjectList - }); - }, - - /** - * 鍒囨崲杞亴缁勯�変腑鐘舵�� - */ - toggleGroupSelection: function (e) { - const projectIndex = e.currentTarget.dataset.projectIndex; - const groupIndex = e.currentTarget.dataset.groupIndex; - const key = `projectList[${projectIndex}].groups[${groupIndex}].selected`; - const currentValue = this.data.projectList[projectIndex].groups[groupIndex].selected; - - this.setData({ - [key]: !currentValue - }); - - // 鏇存柊椤圭洰鎬绘椂闀� - this.updateProjectTotalDuration(projectIndex); - }, - - /** - * 澶勭悊鏃堕暱杈撳叆 - */ - onDurationInput: function (e) { - const { groupIndex } = e.currentTarget.dataset; - const duration = parseInt(e.detail.value) || 0; - - const selectedProject = { ...this.data.selectedProject }; - selectedProject.groups[groupIndex].duration = duration; - - this.setData({ - selectedProject - }, () => { - // 杈撳叆鏃堕暱鍚庨噸鏂拌绠楁�绘椂闂� - this.calculateTotalDuration(); - }); - }, - - /** - * 璁$畻骞舵洿鏂伴」鐩�绘椂闀� - */ - updateProjectTotalDuration: function (projectIndex) { - const project = this.data.projectList[projectIndex]; - let totalDuration = 0; - - // 璁$畻鎵�鏈夐�変腑鐨勮疆鐏岀粍鐨勬椂闀挎�诲拰 - project.groups.forEach(group => { - if (group.selected) { - totalDuration += parseInt(group.duration) || 0; - } - }); - - // 鏇存柊椤圭洰鎬绘椂闀� - const totalDurationKey = `projectList[${projectIndex}].totalDuration`; - this.setData({ - [totalDurationKey]: totalDuration - }); - }, - - /** - * 闃绘浜嬩欢鍐掓场 - */ - stopPropagation: function (e) { - if (e && e.stopPropagation) { - e.stopPropagation(); - } - return false; - }, - - /** - * 璺宠浆鍒拌疆鐏岀粍璇︽儏椤� - */ - navigateToGroupDetail: function (e) { - const { groupIndex } = e.currentTarget.dataset; - // TODO: 瀹炵幇璺宠浆閫昏緫 - }, - - /** - * 纭鎸夐挳鐐瑰嚮浜嬩欢 - */ - onConfirm: function () { - const { planCode, startTime, selectedProject } = this.data; - - if (!planCode) { - wx.showToast({ - title: '璇疯緭鍏ヨ鍒掔紪鍙�', - icon: 'none' - }); - return; - } - - if (!selectedProject) { - wx.showToast({ - title: '璇烽�夋嫨椤圭洰', - icon: 'none' - }); - return; - } - - // 鏋勫缓涓婃姤鏁版嵁 - const schedules = selectedProject.groups.map(group => ({ - groupId: group.id, - duration: parseInt(group.duration) || 0 + /** + * 鑾峰彇椤圭洰鍒楄〃 + */ + fetchProjects: function (isShowDiaolog) { + return get({ + url: '/wx/irrigation/getSimpleProjects', + isShowLoding: true + }).then(res => { + if (res.success) { + const projectList = res.content.map(project => ({ + id: project.projectId, + name: project.projectName, + groupCount: project.groupCount, + groups: [] })); - const requestData = { - projectId: selectedProject.id, - planName: planCode, - startupMode: startTime ? 2 : 1, - operatorId: app.globalData.clientId, - schedules: schedules - }; + const projectOptions = projectList.map(project => ({ + label: project.name, + value: project.id + })); - // 濡傛灉鏈夊紑濮嬫椂闂达紝娣诲姞鍒拌姹傛暟鎹腑 - if (startTime) { - requestData.planStartTime = startTime; - } - - // 鍙戦�佽姹� - post({ - url: '/wx/plan/createPlan', - data: requestData, - isShowLoding: true - }).then(res => { - if (res.success) { - wx.showToast({ - title: '鍒涘缓鎴愬姛', - icon: 'success' - }); - // 杩斿洖涓婁竴椤� - setTimeout(() => { - wx.navigateBack(); - }, 1500); - } else { - wx.showToast({ - title: res.msg || '鍒涘缓澶辫触', - icon: 'none' - }); - } - }).catch(err => { - console.error('鍒涘缓璁″垝澶辫触锛�', err); - wx.showToast({ - title: '鍒涘缓澶辫触', - icon: 'none' - }); - }); - }, - - // 鏄剧ず椤圭洰閫夋嫨鍣� - showProjectPicker() { this.setData({ + projectList, + projectOptions + }); + if (isShowDiaolog) { + this.setData({ projectPickerVisible: true - }); - }, - - // 椤圭洰閫夋嫨鍣ㄧ‘璁� - onProjectPickerConfirm(e) { - const { value } = e.detail; - console.log('閫夋嫨鐨勯」鐩甀D锛�', value[0]); // 娣诲姞鏃ュ織鏌ョ湅鏁版嵁 - const selectedProject = this.data.projectList.find(project => project.id === value[0]); - console.log('鎵惧埌鐨勯」鐩細', selectedProject); // 娣诲姞鏃ュ織鏌ョ湅鏁版嵁 - - this.setData({ - projectPickerVisible: false, - selectedProject: selectedProject, - projectPickerValue: value - }, () => { - // 閫夋嫨椤圭洰鍚庤幏鍙栬疆鐏岀粍鍒楄〃 - if (selectedProject) { - this.fetchGroups(selectedProject.id); - } - }); - }, - - // 椤圭洰閫夋嫨鍣ㄥ彇娑� - onProjectPickerCancel() { - this.setData({ - projectPickerVisible: false - }); - }, - - /** - * 璁$畻鎬荤亴婧夋椂闂� - */ - calculateTotalDuration: function () { - if (!this.data.selectedProject) return; - - const totalDuration = this.data.selectedProject.groups.reduce((sum, group) => { - return sum + (parseInt(group.duration) || 0); - }, 0); - - this.setData({ - totalDuration - }); - }, - - /** - * 杞亴缁勫垪琛ㄤ笅鎷夊埛鏂� - */ - onGroupListRefresh: function () { - if (!this.data.selectedProject) { - this.setData({ isRefreshing: false }); - return; + }); } - - this.setData({ isRefreshing: true }); - - this.fetchGroups(this.data.selectedProject.id) - .then(() => { - this.setData({ isRefreshing: false }); - }) - .catch(() => { - this.setData({ isRefreshing: false }); - }); - }, - - /** - * 鏄剧ず鏃堕棿鎻愮ず寮圭獥 - */ - showTimeInfo: function () { - this.setData({ - timeInfoVisible: true + } else { + wx.showToast({ + title: res.msg || '鑾峰彇椤圭洰鍒楄〃澶辫触', + icon: 'none' }); - }, + return Promise.reject(new Error(res.msg || '鑾峰彇椤圭洰鍒楄〃澶辫触')); + } + }).catch(err => { + console.error('鑾峰彇椤圭洰鍒楄〃澶辫触锛�', err); + wx.showToast({ + title: '鑾峰彇椤圭洰鍒楄〃澶辫触', + icon: 'none' + }); + return Promise.reject(err); + }); + }, - /** - * 鍏抽棴鏃堕棿鎻愮ず寮圭獥 - */ - onTimeInfoConfirm: function () { - this.setData({ - timeInfoVisible: false + /** + * 鑾峰彇杞亴缁勫垪琛� + */ + fetchGroups: function (projectId) { + return get({ + url: '/wx/irrigation/getSimpleGroups', + data: { + projectId: projectId, + }, + isShowLoding: true + }).then(res => { + if (res.success) { + console.log('杞亴缁勬暟鎹細', res.content); + + // 鏇存柊閫変腑椤圭洰鐨勮疆鐏岀粍淇℃伅 + const projectList = this.data.projectList.map(project => { + if (project.id === projectId) { + return { + ...project, + groups: res.content.map(group => ({ + id: group.groupId, + name: group.groupCode, + duration: group.defaultDuration || 0, + selected: false, + intakeCount: group.intakeCount + })) + }; + } + return project; }); - }, -}); \ No newline at end of file + + // 鏇存柊閫変腑鐨勯」鐩� + const selectedProject = projectList.find(project => project.id === projectId); + console.log('鏇存柊鍚庣殑閫変腑椤圭洰锛�', selectedProject); + + this.setData({ + projectList, + selectedProject + }, () => { + // 璁$畻鎬绘椂闂� + this.calculateTotalDuration(); + }); + } else { + wx.showToast({ + title: res.msg || '鑾峰彇杞亴缁勫垪琛ㄥけ璐�', + icon: 'none' + }); + return Promise.reject(new Error(res.msg || '鑾峰彇杞亴缁勫垪琛ㄥけ璐�')); + } + }).catch(err => { + console.error('鑾峰彇杞亴缁勫垪琛ㄥけ璐ワ細', err); + wx.showToast({ + title: '鑾峰彇杞亴缁勫垪琛ㄥけ璐�', + icon: 'none' + }); + return Promise.reject(err); + }); + }, + + /** + * 鏄剧ず鏃堕棿閫夋嫨鍣� + */ + showTimePicker: function () { + // 濡傛灉娌℃湁閫夋嫨鏃堕棿锛屼娇鐢ㄥ綋鍓嶆椂闂� + if (!this.data.pickerValue) { + const now = dayjs(); + this.setData({ + pickerValue: now.format('YYYY-MM-DD HH:mm') + }); + } + + this.setData({ + timePickerVisible: true + }); + }, + + /** + * 鏃堕棿閫夋嫨鍣ㄧ‘璁ゅ洖璋� + */ + onTimePickerConfirm: function (e) { + const { + value + } = e.detail; + this.setData({ + timePickerVisible: false, + startTime: value + }); + }, + + /** + * 鏃堕棿閫夋嫨鍣ㄥ彇娑堝洖璋� + */ + onTimePickerCancel: function () { + this.setData({ + timePickerVisible: false + }); + }, + + /** + * 鍒囨崲椤圭洰灞曞紑/鎶樺彔鐘舵�� + */ + toggleProject: function (e) { + const index = e.currentTarget.dataset.index; + const currentValue = this.data.projectList[index].expanded; + + // 鍒涘缓鏂扮殑椤圭洰鍒楄〃锛屽厛灏嗘墍鏈夐」鐩涓烘姌鍙犵姸鎬� + const newProjectList = this.data.projectList.map((item, idx) => { + return { + ...item, + expanded: false + }; + }); + + // 濡傛灉褰撳墠鐐瑰嚮鐨勯」鐩凡缁忔槸灞曞紑鐘舵�侊紝鍒欎繚鎸佹墍鏈夐」鐩姌鍙� + // 鍚﹀垯锛屽皢褰撳墠鐐瑰嚮鐨勯」鐩涓哄睍寮�鐘舵�� + if (!currentValue) { + newProjectList[index].expanded = true; + } + + this.setData({ + projectList: newProjectList + }); + }, + + /** + * 鍒囨崲杞亴缁勯�変腑鐘舵�� + */ + toggleGroupSelection: function (e) { + const projectIndex = e.currentTarget.dataset.projectIndex; + const groupIndex = e.currentTarget.dataset.groupIndex; + const key = `projectList[${projectIndex}].groups[${groupIndex}].selected`; + const currentValue = this.data.projectList[projectIndex].groups[groupIndex].selected; + + this.setData({ + [key]: !currentValue + }); + + // 鏇存柊椤圭洰鎬绘椂闀� + this.updateProjectTotalDuration(projectIndex); + }, + + /** + * 澶勭悊鏃堕暱杈撳叆 + */ + onDurationInput: function (e) { + const { + groupIndex + } = e.currentTarget.dataset; + const duration = parseInt(e.detail.value) || 0; + + const selectedProject = { + ...this.data.selectedProject + }; + selectedProject.groups[groupIndex].duration = duration; + + this.setData({ + selectedProject + }, () => { + // 杈撳叆鏃堕暱鍚庨噸鏂拌绠楁�绘椂闂� + this.calculateTotalDuration(); + }); + }, + + /** + * 璁$畻骞舵洿鏂伴」鐩�绘椂闀� + */ + updateProjectTotalDuration: function (projectIndex) { + const project = this.data.projectList[projectIndex]; + let totalDuration = 0; + + // 璁$畻鎵�鏈夐�変腑鐨勮疆鐏岀粍鐨勬椂闀挎�诲拰 + project.groups.forEach(group => { + if (group.selected) { + totalDuration += parseInt(group.duration) || 0; + } + }); + + // 鏇存柊椤圭洰鎬绘椂闀� + const totalDurationKey = `projectList[${projectIndex}].totalDuration`; + this.setData({ + [totalDurationKey]: totalDuration + }); + }, + + /** + * 闃绘浜嬩欢鍐掓场 + */ + stopPropagation: function (e) { + if (e && e.stopPropagation) { + e.stopPropagation(); + } + return false; + }, + + /** + * 璺宠浆鍒拌疆鐏岀粍璇︽儏椤� + */ + navigateToGroupDetail: function (e) { + const { + groupIndex + } = e.currentTarget.dataset; + // TODO: 瀹炵幇璺宠浆閫昏緫 + }, + + /** + * 纭鎸夐挳鐐瑰嚮浜嬩欢 + */ + onConfirm: function () { + const { + planCode, + startTime, + selectedProject + } = this.data; + + if (!planCode) { + wx.showToast({ + title: '璇疯緭鍏ヨ鍒掔紪鍙�', + icon: 'none' + }); + return; + } + + if (!selectedProject) { + wx.showToast({ + title: '璇烽�夋嫨椤圭洰', + icon: 'none' + }); + return; + } + + // 鏋勫缓涓婃姤鏁版嵁 + const schedules = selectedProject.groups.map(group => ({ + groupId: group.id, + duration: parseInt(group.duration) || 0 + })); + + const requestData = { + projectId: selectedProject.id, + planName: planCode, + startupMode: startTime ? 2 : 1, + operatorId: app.globalData.clientId, + schedules: schedules + }; + + // 濡傛灉鏈夊紑濮嬫椂闂达紝娣诲姞鍒拌姹傛暟鎹腑 + if (startTime) { + requestData.planStartTime = startTime; + } + + // 鍙戦�佽姹� + post({ + url: '/wx/plan/createPlan', + data: requestData, + isShowLoding: true + }).then(res => { + if (res.success) { + wx.showToast({ + title: '鍒涘缓鎴愬姛', + icon: 'success' + }); + // 杩斿洖涓婁竴椤碉紝骞朵紶閫掑弬鏁版寚绀洪渶瑕佸埛鏂板垪琛ㄥ苟鍒囨崲鍒板綋鍓嶈鍒掑垪琛� + setTimeout(() => { + // 浣跨敤鍏ㄥ眬鍙橀噺鏍囪闇�瑕佸埛鏂� + const app = getApp(); + app.globalData.needRefreshIrrigationList = true; + + // 鐩存帴杩斿洖涓婁竴椤� + wx.navigateBack({ + delta: 1 + }); + }, 1500); + } else { + wx.showToast({ + title: res.msg || '鍒涘缓澶辫触', + icon: 'none' + }); + } + }).catch(err => { + console.error('鍒涘缓璁″垝澶辫触锛�', err); + wx.showToast({ + title: '鍒涘缓澶辫触', + icon: 'none' + }); + }); + }, + + // 鏄剧ず椤圭洰閫夋嫨鍣� + showProjectPicker() { + this.fetchProjects(true) + + }, + + // 椤圭洰閫夋嫨鍣ㄧ‘璁� + onProjectPickerConfirm(e) { + const { + value + } = e.detail; + console.log('閫夋嫨鐨勯」鐩甀D锛�', value[0]); // 娣诲姞鏃ュ織鏌ョ湅鏁版嵁 + const selectedProject = this.data.projectList.find(project => project.id === value[0]); + console.log('鎵惧埌鐨勯」鐩細', selectedProject); // 娣诲姞鏃ュ織鏌ョ湅鏁版嵁 + + this.setData({ + projectPickerVisible: false, + selectedProject: selectedProject, + projectPickerValue: value + }, () => { + // 閫夋嫨椤圭洰鍚庤幏鍙栬疆鐏岀粍鍒楄〃 + if (selectedProject) { + this.fetchGroups(selectedProject.id); + } + }); + }, + + // 椤圭洰閫夋嫨鍣ㄥ彇娑� + onProjectPickerCancel() { + this.setData({ + projectPickerVisible: false + }); + }, + + /** + * 璁$畻鎬荤亴婧夋椂闂� + */ + calculateTotalDuration: function () { + if (!this.data.selectedProject) return; + + const totalDuration = this.data.selectedProject.groups.reduce((sum, group) => { + return sum + (parseInt(group.duration) || 0); + }, 0); + + this.setData({ + totalDuration + }); + }, + + /** + * 杞亴缁勫垪琛ㄤ笅鎷夊埛鏂� + */ + onGroupListRefresh: function () { + if (!this.data.selectedProject) { + this.setData({ + isRefreshing: false + }); + return; + } + + this.setData({ + isRefreshing: true + }); + + this.fetchGroups(this.data.selectedProject.id) + .then(() => { + this.setData({ + isRefreshing: false + }); + }) + .catch(() => { + this.setData({ + isRefreshing: false + }); + }); + }, + + /** + * 鏄剧ず鏃堕棿鎻愮ず寮圭獥 + */ + showTimeInfo: function () { + this.setData({ + timeInfoVisible: true + }); + }, + + /** + * 鍏抽棴鏃堕棿鎻愮ず寮圭獥 + */ + onTimeInfoConfirm: function () { + this.setData({ + timeInfoVisible: false + }); + }, +}); \ No newline at end of file diff --git a/pages/createIrrigation/createIrrigation.wxml b/pages/createIrrigation/createIrrigation.wxml index a6087f4..5963560 100644 --- a/pages/createIrrigation/createIrrigation.wxml +++ b/pages/createIrrigation/createIrrigation.wxml @@ -65,7 +65,11 @@ <block wx:for="{{selectedProject.groups}}" wx:key="id" wx:for-item="group" wx:for-index="groupIndex"> <view class="group-item {{group.selected ? 'selected' : ''}}" bindtap="navigateToGroupDetail" data-group-index="{{groupIndex}}"> <view class="group-info"> - <view class="group-name">{{group.name || '鏈懡鍚嶈疆鐏岀粍'}} (鍏眥{group.intakeCount}}涓彇姘村彛)</view> + <text class="group-index">{{groupIndex + 1}}.</text> + <view class="group-name"> + <text class="group-name-text">{{group.name || '鏈懡鍚嶈疆鐏岀粍'}}</text> + <text class="group-intake-count">(鍏眥{group.intakeCount}}涓彇姘村彛)</text> + </view> </view> <view class="group-duration"> <input diff --git a/pages/createIrrigation/createIrrigation.wxss b/pages/createIrrigation/createIrrigation.wxss index b4df43e..3ea92a9 100644 --- a/pages/createIrrigation/createIrrigation.wxss +++ b/pages/createIrrigation/createIrrigation.wxss @@ -257,16 +257,33 @@ flex-wrap: wrap; } +.group-index { + color: #1890FF; + margin-right: 8rpx; + font-size: 26rpx; +} + .group-name { + display: flex; + align-items: center; font-size: 26rpx; color: #666; position: relative; - padding-left: 10rpx; - background-color: rgba(24, 144, 255, 0.1); padding: 4rpx 20rpx; + background-color: rgba(24, 144, 255, 0.1); border-radius: 10rpx; } +.group-name-text { + color: #333; + margin-right: 8rpx; +} + +.group-intake-count { + color: #999; + font-size: 24rpx; +} + .group-hint { font-size: 22rpx; color: #1890FF; diff --git a/pages/groupDetail/groupDetail.js b/pages/groupDetail/groupDetail.js index f663689..3a75ef0 100644 --- a/pages/groupDetail/groupDetail.js +++ b/pages/groupDetail/groupDetail.js @@ -34,11 +34,6 @@ console.log('璁剧疆鍚庣殑鏁版嵁:', this.data); - // 璁剧疆瀵艰埅鏍忔爣棰� - wx.setNavigationBarTitle({ - title: this.data.groupName || '杞亴缁勮鎯�' - }); - this.loadWaterOutletData(); } }, diff --git a/pages/home/home.js b/pages/home/home.js index afb394f..02da0b4 100644 --- a/pages/home/home.js +++ b/pages/home/home.js @@ -58,14 +58,14 @@ }) } }, - calculateScrollViewHeight: function () { - wx.createSelectorQuery().selectAll('.list-item').boundingClientRect((rects) => { - let totalHeight = rects.reduce((sum, rect) => sum + rect.height, 0); - this.setData({ - scrollViewHeight: totalHeight, - }); - }).exec(); - }, + // calculateScrollViewHeight: function () { + // wx.createSelectorQuery().selectAll('.list-item').boundingClientRect((rects) => { + // let totalHeight = rects.reduce((sum, rect) => sum + rect.height, 0); + // this.setData({ + // scrollViewHeight: totalHeight, + // }); + // }).exec(); + // }, startPullDownRefresh() { if (getApp().globalData.isLoggedIn) { if (!this.data.isWXRefreshing) { @@ -340,13 +340,17 @@ }) }, openValveList() { - // wx.navigateTo({ - // url: '/pages/valveList/valveList', - // }) - wx.showToast({ - title: '鏆傛湭寮�鏀�', - icon: 'none' - }) + const app = getApp(); + if (app.globalData.isLoggedIn) { + wx.navigateTo({ + url: '/pages/valveList/valveList', + }) + } else { + wx.showToast({ + title: '璇峰厛鐧诲綍', + icon: 'error' + }) + } }, feedBack() { wx.showToast({ @@ -538,11 +542,8 @@ isRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚 isWXRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚 }); + this.updateDisplayText(); - // 鎴愬姛鑾峰彇鏁版嵁鍚庡埛鏂癠I楂樺害 - setTimeout(() => { - this.calculateScrollViewHeight(); - }, 200); }).catch(err => { console.error('鑾峰彇鍒楄〃鏁版嵁澶辫触:', err); // 閿欒鍥炶皟 @@ -1235,13 +1236,6 @@ console.log('continueInitPage: 浠庨〉闈㈡暟鎹腑妫�娴嬪埌isFromLogin=true'); fromLogin = true; } - - // 鍒ゆ柇鏈湴鏄惁淇濆瓨sessionId - // 浣跨敤 wx.nextTick 绛夊緟椤甸潰娓叉煋瀹屾垚 - wx.nextTick(() => { - this.calculateScrollViewHeight(); - }); - // 褰撳紑闃�鎴愬姛鍚庤皟鐢ㄥ埛鏂� if (options && options.param) { console.log("寮�闃�鎴愬姛鍙傛暟:", options.param); @@ -1498,4 +1492,107 @@ showInfoDialog: false }) }, + //寮哄埗鍒犻櫎 + onDelete(e) { + const item = e.currentTarget.dataset.item; + const that = this; + + if (this.data.useTestData) { + // 娴嬭瘯鏁版嵁妯″紡涓嬶紝妯℃嫙鍒犻櫎鎿嶄綔 + wx.showLoading({ + title: '姝e湪寮哄埗鍒犻櫎璇风◢鍊�...', + mask: true + }); + + // 妯℃嫙璇锋眰寤惰繜 + setTimeout(() => { + wx.hideLoading(); + + // 浠庡垪琛ㄤ腑绉婚櫎琚垹闄ょ殑椤� + const updatedList = this.data.listData.filter(listItem => + listItem.orderNo !== item.orderNo + ); + + this.setData({ + listData: updatedList + }); + + wx.showToast({ + title: '鍒犻櫎鎴愬姛', + icon: 'success', + duration: 2000 + }); + }, 1500); + return; + } + + wx.showLoading({ + title: '姝e湪寮哄埗鍒犻櫎璇风◢鍊�...', // 鍔犺浇鎻愮ず鏂囧瓧 + mask: true // 鏄惁鏄剧ず閫忔槑钂欏眰锛岄槻姝㈣Е鎽哥┛閫忥紝榛樿涓� false + }); + const data = { + vcNum: item.vcNum, //鍙栨按鍙D + rtuAddr: item.rtuAddr, //闃�鎺у櫒鍦板潃 + }; + post({ + url: "wx/valve/deleteUnclosed", + data: data, + timeout: 180000 + }).then(response => { + // 澶勭悊鎴愬姛鍝嶅簲 + console.log('璇锋眰鎴愬姛:', response); + // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢� + wx.hideLoading(); + //閲嶆柊鑾峰彇鍒楄〃鍒锋柊鏁版嵁 + this.getOpenList(); + }).catch(error => { + // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢� + wx.hideLoading(); + // 澶勭悊閿欒鍝嶅簲 + console.error('璇锋眰澶辫触:', error); + }); + }, + //淇敼鎸夐挳鏂囧瓧 + updateDisplayText() { + const updatedList = this.data.listData.map(item => { + let displayText = ''; + if (item.planned) { + displayText = '鍙栨秷'; + } else { + displayText = "鍏抽榾" + } + let deleteText = "鍒犻櫎" + let time; + if (!item.dt) { + time = "鏆傛棤" + } else { + time = this.extractTime(item.dt) + } + if (item.waterInstant===null) { + item.waterInstant = "鏆傛棤" + } + + return { + ...item, + displayText, + deleteText, + time + }; // 淇濈暀鎵�鏈夊叾浠栧瓧娈碉紝骞舵坊鍔� displayText 瀛楁 + }); + // 鏇存柊鍒楄〃鏁版嵁 + this.setData({ + listData: updatedList + }); + }, + //澶勭悊鏃堕棿鍘绘帀骞存湀鏃� + extractTime(datetimeString) { + const formattedDate = datetimeString.replace(" ", "T"); + const date = new Date(formattedDate); + // 鑾峰彇灏忔椂銆佸垎閽熷拰绉� + const hours = date.getHours().toString().padStart(2, '0'); + const minutes = date.getMinutes().toString().padStart(2, '0'); + const seconds = date.getSeconds().toString().padStart(2, '0'); + return `${hours}:${minutes}:${seconds}`; + }, + }) \ No newline at end of file diff --git a/pages/home/home.json b/pages/home/home.json index eefd2a2..f5ba849 100644 --- a/pages/home/home.json +++ b/pages/home/home.json @@ -2,7 +2,7 @@ "component": true, "usingComponents": { "t-avatar": "tdesign-miniprogram/avatar/avatar", - "t-switch": "tdesign-miniprogram/switch/switch", + "t-swipe-cell": "tdesign-miniprogram/swipe-cell/swipe-cell", "t-dialog": "tdesign-miniprogram/dialog/dialog" }, "navigationBarTitleText": "澶х鑺傛按", diff --git a/pages/home/home.wxml b/pages/home/home.wxml index 513fc93..eab6ee6 100644 --- a/pages/home/home.wxml +++ b/pages/home/home.wxml @@ -47,7 +47,6 @@ </view> <text class="refresh-button" bind:tap="startPullDownRefresh">鍒锋柊</text> </view> - <view class="divider"></view> <!-- refresher-enabled="true" refresher-threshold="50" --> <scroll-view class="scroll-view" scroll-x="false" scroll-y="true" refresher-enabled="{{isRefreshing==false?true:false}}" refresher-threshold="50" bindrefresherrefresh="onPullDownRefresh" refresher-triggered="{{isWXRefreshing}}"> <view wx:if="{{isRefreshing}}" class="refresh-view"> @@ -56,16 +55,29 @@ <view class="dot"></view> </view> <view class="scroll-bg"> - <view wx:if="{{listData.length > 0}}" class="list-item" wx:for="{{listData}}" wx:key="index"> - <view class="item-left"> - <!-- <image class="item-img" src="/images/pipeline.svg" /> --> - <text>{{item.intakeNum}}</text> - <image class="item-img" src="{{item.isOnLine ? '/images/wifi_no.svg' : '/images/wifi_off.svg'}}" /> - </view> - <view> - <!-- <t-switch class="switch" data-item="{{item}}" bindchange="handleChange" value="{{true}}" label="{{['寮�', '鍏�']}}" slot="note" /> --> - <text class="item-button" bind:tap="handleChange" data-item="{{item}}">鍏抽榾</text> - </view> + <view wx:if="{{listData.length > 0}}" wx:for="{{listData}}" wx:key="index"> + <t-swipe-cell> + <view class="swipe-cell"> + <view class="list-item"> + <view class="item-left"> + <view class="left-intake-name"> + <image class="item-img-left" src="/images/valve.svg" /> + <text class="water-intake-name">{{item.intakeNum}}</text> + <image class="item-img" src="{{item.isOnLine ? '/images/wifi_no.svg' : '/images/wifi_off.svg'}}" /> + </view> + <view class="left-time"> + <image class="item-img" src="/images/time.svg" /> + <text class="flow-time">{{item.time}}</text> + <text class="flow-rate">鐬椂娴侀噺锛歿{item.waterInstant}} m鲁/h</text> + </view> + </view> + <view class="item-right"> + <text class="item-button" bind:tap="handleChange" data-item="{{item}}">鍏抽榾</text> + </view> + </view> + </view> + <view slot="right" class="delete-btn" bind:tap="onDelete" data-item="{{item}}">{{item.deleteText}}</view> + </t-swipe-cell> </view> </view> <view wx:if="{{listData.length === 0}}" class="noMore-View-home"> @@ -104,6 +116,14 @@ <radio value="SCHOOL" checked="{{selectedProject === 'SCHOOL'}}" color="#1890FF" /> <text>瀛︽牎椤圭洰</text> </label> + <label class="project-radio {{selectedProject === 'JC' ? 'project-radio-selected' : ''}}"> + <radio value="JC" checked="{{selectedProject === 'JC'}}" color="#1890FF" /> + <text>閲戞槍椤圭洰</text> + </label> + <label class="project-radio {{selectedProject === 'GSCLT' ? 'project-radio-selected' : ''}}"> + <radio value="GSCLT" checked="{{selectedProject === 'GSCLT'}}" color="#1890FF" /> + <text>鐢樿們鍐滅闄�-宕�</text> + </label> </radio-group> </view> <view class="project-modal-footer"> @@ -117,7 +137,7 @@ <scroll-view slot="content" type="list" scroll-y class="long-content"> <view class="content-container"> <text class="content-container"> - 1.缃戠粶绛変笉鍙姉鍔涘洜绱犲彲鑳藉鑷磋澶囩姸鎬佹樉绀哄欢杩熸垨閿欒銆� + 1.缃戠粶绛変笉鍙姉鍔涘洜绱犲彲鑳藉鑷磋澶囩姸鎬佹樉绀哄欢杩熸垨閿欒銆傦紙褰撹繘琛屼簡寮�闃�鎴栧叧闃�鎿嶄綔鍚庝細鏈変竴瀹氬欢鏃舵墠鍙‘璁ゆ槸鍚︽搷浣滄垚鍔燂級 2.褰撴彁绀烘偍鎿嶄綔澶辫触鍚庢偍鍙◢鍚庡皾璇曢噸鏂版搷浣溿�� 3.鍦ㄥ畾鏃舵垨瀹氶噺寮�闃�鐨勯绾﹀紡寮�闃�鍚庯紝鍙湁闃�闂ㄥ埌杈剧害瀹氱殑鏃堕棿鎴愬姛寮�闃�鍚庢湭鍏抽榾璁板綍鎵嶄細鏄剧ず銆� 4.鎴戜滑璇氭寶鍦伴個璇锋偍閫氳繃鎰忚鍙嶉娓犻亾鎻愬嚭瀹濊吹鐨勫缓璁垨鎰忚銆� diff --git a/pages/home/home.wxss b/pages/home/home.wxss index 113d5c7..286f2f7 100644 --- a/pages/home/home.wxss +++ b/pages/home/home.wxss @@ -143,22 +143,168 @@ /* 鍏佽鍨傜洿婊氬姩 */ z-index: 0; /* 纭繚 scroll-view 鍦ㄥご閮ㄥ拰 center-wrapper 涔嬩笅 */ + background-color: #f5f5f5; + margin-top: 0; + padding-top: 0; + box-sizing: border-box; } +.scroll-bg { + padding: 20rpx 0; + box-sizing: border-box; + padding-top: 0; + width: 100%; +} +/* 纭繚鎵�鏈夊惈瀹藉害鐨勫厓绱犱娇鐢ㄧ浉鍚岀殑璁$畻鏂瑰紡 */ +.bottom-title, +.scroll-bg > view { + width: calc(100% - 40rpx); + margin-left: 20rpx; + margin-right: 20rpx; + box-sizing: border-box; +} + +.scroll-bg > view { + margin-bottom: 20rpx; + border-radius: 12rpx; + overflow: hidden; + box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05); +} + +t-swipe-cell { + display: block; + width: 100%; + border-radius: 12rpx; + overflow: hidden; +} + +.swipe-cell { + display: flex; + justify-content: space-between; + background-color: #fff; + width: 100%; + height: 100%; + border-radius: 12rpx; + overflow: hidden; +} .list-item { background-color: #fff; - margin-bottom: 2rpx; display: flex; - justify-content: space-between; align-items: center; - padding-left: 30rpx; - padding-right: 30rpx; - padding-top: 30rpx; - padding-bottom: 30rpx; + padding: 30rpx; + width: 100%; + box-sizing: border-box; +} + +.item-left { + display: flex; + flex-direction: column; + flex: 1; + width: 100%; +} + +.left-intake-name { + width: 100%; + display: flex; + align-items: center; + margin-bottom: 20rpx; + padding-left: 4rpx; +} + +.item-img-left { + width: 40rpx; + height: 40rpx; + flex-shrink: 0; +} + +.item-img { + width: 40rpx; + height: 40rpx; + flex-shrink: 0; +} + +.left-intake-name .item-img { + margin-left: 8rpx; +} + +.water-intake-name { + font-size: 42rpx !important; + margin-left: 16rpx; + margin-right: 15rpx; + white-space: nowrap; /* 闃叉鏂囨湰鎹㈣ */ + font-weight: 500; + color: #333; + flex-shrink: 0; +} + +.left-time { + width: 100%; + display: flex; + align-items: center; + color: #666; + flex-wrap: nowrap; + overflow: hidden; + padding-right: 10rpx; + padding-left: 4rpx; +} + +.flow-time { + font-size: 28rpx !important; + margin-left: 16rpx; + margin-right: 2rpx; + white-space: nowrap; + color: #666; + display: inline-block; +} + +.flow-rate { + font-size: 28rpx !important; + margin-left: 6rpx; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + flex: 1; + color: #666; +} + +.item-right { + display: flex; + align-items: center; margin-left: 20rpx; - margin-right: 20rpx; +} + +.item-button { + display: flex; + height: 70rpx; + padding: 0 40rpx; + background-color: #1890FF; + color: white; + border: none; + border-radius: 35rpx; + font-size: 30rpx !important; + align-items: center; + justify-content: center; + white-space: nowrap; /* 纭繚鏂囧瓧涓嶆崲琛� */ + box-shadow: 0 4rpx 8rpx rgba(24, 144, 255, 0.2); + transition: all 0.3s; +} + +.item-button:active { + background-color: #1378d8; + transform: scale(0.98); +} + +.delete-btn { + display: flex; + align-items: center; + justify-content: center; + width: 140rpx; + height: 100%; + color: white; + background-color: #e34d59; + font-size: 30rpx; } .list-item text { @@ -174,34 +320,40 @@ } .bottom-title { - border-radius: 5px 5px 0 0; + border-radius: 12rpx 12rpx 0 0; background-color: #fff; display: flex; align-items: center; /* 鍨傜洿鏂瑰悜灞呬腑 */ justify-content: space-between; /* 瀛愬厓绱犲湪涓昏酱涓婄殑瀵归綈鏂瑰紡 */ - padding: 10px; + padding: 30rpx; /* 瀹瑰櫒鐨勫唴杈硅窛 */ + width: calc(100% - 40rpx); margin-left: 20rpx; margin-right: 20rpx; margin-top: 20rpx; + margin-bottom: 0; + box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.03); + position: relative; + box-sizing: border-box; + border-bottom: 1rpx solid #e7e7e7; } .bottom-title-text { margin-right: 10rpx; /* 缁欐枃鏈拰鍥炬爣涔嬮棿娣诲姞涓�浜涢棿璺� */ - font-size: 35rpx; + font-size: 34rpx; /* 瀛椾綋澶у皬 */ color: #333; /* 瀛椾綋棰滆壊 */ - } - + font-weight: 500; +} .refresh-button { margin-left: auto; /* 灏嗘寜閽帹鍒板鍣ㄧ殑鏈�鍙充晶 */ - font-size: 30rpx; + font-size: 28rpx; /* 鎸夐挳鏂囧瓧鐨勫瓧浣撳ぇ灏� */ color: #fff; /* 鎸夐挳鏂囧瓧棰滆壊 */ @@ -209,37 +361,37 @@ /* 鎸夐挳鑳屾櫙棰滆壊 */ border: none; /* 鍘绘帀鎸夐挳杈规 */ - border-radius: 5px; + border-radius: 30rpx; /* 鎸夐挳鍦嗚 */ - padding-left: 25rpx; - padding-right: 25rpx; - padding-top: 15rpx; + padding: 15rpx 30rpx; display: flex; align-items: center; justify-content: center; - padding-bottom: 15rpx; + box-shadow: 0 4rpx 8rpx rgba(24, 144, 255, 0.2); + transition: all 0.3s; } .refresh-button:active { - background-color: #7c7c7c; - /* Change to a darker color when pressed */ + background-color: #1378d8; + transform: scale(0.98); } .refresh-view { text-align: center; - padding: 30rpx; + padding: 40rpx; display: flex; justify-content: center; align-items: center; } .dot { - width: 20rpx; - height: 20rpx; - background-color: #333; + width: 16rpx; + height: 16rpx; + background-color: #1890FF; border-radius: 50%; - margin: 0 5px; + margin: 0 8rpx; animation: blink 1.4s infinite both; + opacity: 0.7; } .dot:nth-child(2) { @@ -251,15 +403,17 @@ } @keyframes blink { - - 0%, - 80%, - 100% { - opacity: 0; + 0% { + opacity: 0.2; + transform: scale(0.8); } - - 40% { + 50% { opacity: 1; + transform: scale(1.2); + } + 100% { + opacity: 0.2; + transform: scale(0.8); } } @@ -267,23 +421,9 @@ --td-switch-checked-color: #1890FF; } - -.item-left { - display: flex; - align-items: center; -} - -.item-left text { - font-size: 40rpx; +/* 淇敼閫夋嫨鍣紝浣垮叾涓嶄細褰卞搷flow-time */ +.item-left .water-intake-name { min-width: 150rpx; -} - -.item-img { - width: 40rpx; - /* 鏍规嵁闇�瑕佽皟鏁村浘鏍囧ぇ灏� */ - height: 40rpx; - /* 鏍规嵁闇�瑕佽皟鏁村浘鏍囧ぇ灏� */ - margin-left: 20rpx; } .dialog { @@ -294,39 +434,23 @@ .noMore-View-home { display: flex; flex-direction: column; - /* 纭繚瀛愬厓绱犵旱鍚戞帓鍒� */ - justify-content: center; - /* 鍨傜洿灞呬腑 */ - align-items: center; - /* 姘村钩灞呬腑 */ - height: 100%; - /* 璁╁鍣ㄩ珮搴﹀崰婊$埗鍏冪礌 */ -} - -.item-button { - display: flex; - height: 80rpx; - padding: 0 60rpx; - background-color: #1890FF; - color: white; - border: none; - border-radius: 20rpx; - font-size: 30rpx; align-items: center; justify-content: center; + margin-top: 80rpx; + padding: 40rpx; } -.item-button:active { - background-color: #7c7c7c; - /* Change to a darker color when pressed */ +.noMore-img { + width: 200rpx; + height: 200rpx; + margin-bottom: 20rpx; + opacity: 0.7; } -.divider { - width: 100%; - margin-top: 2rpx; - /* background-color: #e0e0e0; */ +.noMore-text { + font-size: 32rpx; + color: #999; } - .error-dialog { --td-dialog-title-color: red; @@ -628,7 +752,7 @@ } .long-content { - height: 450rpx; + height: 500rpx; margin-top: 16rpx; font-size: 32rpx; color: #888; diff --git a/pages/irrigation/irrigation.js b/pages/irrigation/irrigation.js index 18aac0c..e30bf8d 100644 --- a/pages/irrigation/irrigation.js +++ b/pages/irrigation/irrigation.js @@ -51,44 +51,42 @@ /** * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず */ - // onShow: function () { - // // 璁剧疆椤甸潰涓哄姞杞戒腑鐘舵�� - // wx.showLoading({ - // title: '鍔犺浇涓�', - // mask: true - // }); + onShow: function () { + // 妫�鏌ュ叏灞�鍙橀噺锛屽垽鏂槸鍚﹂渶瑕佸埛鏂板垪琛ㄥ苟鍒囨崲鍒板綋鍓嶈鍒� + const app = getApp(); - // // 鍏堝姞杞藉綋鍓嶉〉闈㈡墍闇�鐨勬暟鎹� - // const currentTab = this.data.currentTab; - // if (currentTab === 0) { - // // 褰撳墠鏍囩鏄�"褰撳墠鐏屾簤璁″垝"锛屽姞杞借繖涓� - // this.loadIrrigationData() - // .then(() => { - // wx.hideLoading(); - // }) - // .catch(() => { - // wx.hideLoading(); - // }); - // } else { - // // 褰撳墠鏍囩鏄�"鍘嗗彶璁″垝" - // // 鍙姞杞界涓�椤垫暟鎹紝淇濈暀鍒嗛〉鐘舵�� - // if (this.data.completedList.length === 0) { - // // 濡傛灉鍘嗗彶鍒楄〃涓虹┖锛岄噸缃垎椤电姸鎬� - // this.setData({ - // pageCurr: 1, - // hasMoreData: true - // }); - // } + // 鍒锋柊鎵�鏈夋暟鎹紙褰撳墠璁″垝鍜屽巻鍙茶鍒掞級锛岀‘淇濇暟鎹渶鏂� + wx.showLoading({ + title: '鍒锋柊鏁版嵁涓�', + mask: true + }); + + // 鍚屾椂鑾峰彇褰撳墠璁″垝鍜屽巻鍙茶鍒掓暟鎹� + Promise.all([ + this.loadIrrigationData(), + this.loadCompletedIrrigationData(true) // 浼犲叆true琛ㄧず鏄噸鏂板姞杞界涓�椤� + ]).then(() => { + wx.hideLoading(); - // this.loadCompletedIrrigationData() - // .then(() => { - // wx.hideLoading(); - // }) - // .catch(() => { - // wx.hideLoading(); - // }); - // } - // }, + // 濡傛灉闇�瑕佸埛鏂板苟鍒囨崲鍒板綋鍓嶈鍒� + if (app.globalData.needRefreshIrrigationList) { + // 閲嶇疆鍏ㄥ眬鍙橀噺 + app.globalData.needRefreshIrrigationList = false; + + console.log('妫�娴嬪埌闇�瑕佸埛鏂扮亴婧夎鍒掑垪琛�'); + + // 鍒囨崲鍒板綋鍓嶇亴婧夎鍒掓爣绛鹃〉 + if (this.data.currentTab !== 0) { + this.setData({ + currentTab: 0, + currentList: this.data.activeList + }); + } + } + }).catch(() => { + wx.hideLoading(); + }); + }, /** * 鍔犺浇杞亴鏁版嵁 @@ -148,10 +146,18 @@ /** * 鍔犺浇宸插畬鎴愮殑杞亴鏁版嵁 */ - loadCompletedIrrigationData: function () { + loadCompletedIrrigationData: function (isFirstPage) { // 濡傛灉姝e湪鍔犺浇鎴栨病鏈夋洿澶氭暟鎹紝鍒欎笉鍐嶈姹� if (this.data.loadingMore && !this.data.hasMoreData) { return Promise.resolve(); + } + + // 濡傛灉鏄噸鏂板姞杞界涓�椤碉紝閲嶇疆椤电爜鍜岀姸鎬� + if (isFirstPage) { + this.setData({ + pageCurr: 1, + hasMoreData: true + }); } // 璁剧疆鍔犺浇鐘舵�� @@ -320,7 +326,7 @@ // 瀵艰埅鍒扮亴婧夎鎯呴〉闈紝骞朵紶閫掑弬鏁� wx.navigateTo({ - url: `/pages/irrigationDetail/irrigationDetail?planId=${id}&fromList=true` + url: `/pages/irrigationDetail/irrigationDetail?planId=${id}&fromList=true&status=${status}` }); }, @@ -358,10 +364,17 @@ } }).catch(err => { console.error('鍙戝竷澶辫触锛�', err); - wx.showToast({ - title: '鍙戝竷澶辫触', - icon: 'none' - }); + if(err.code==='1003'){ + wx.showToast({ + title: err.msg || '鍙戝竷澶辫触', + icon: 'none' + }); + }else{ + wx.showToast({ + title: '鍙戝竷澶辫触', + icon: 'none' + }); + } }); } } @@ -443,8 +456,13 @@ title: '缁堟鎴愬姛', icon: 'success' }); - // 鍒锋柊鏁版嵁 - this.loadIrrigationData(); + // 鍚屾椂鍒锋柊褰撳墠璁″垝鍒楄〃鍜屽巻鍙茶鍒掑垪琛� + Promise.all([ + this.loadIrrigationData(), + this.loadCompletedIrrigationData(true) // 浼犲叆true琛ㄧず閲嶆柊鍔犺浇绗竴椤� + ]).catch(err => { + console.error('鍒锋柊鏁版嵁澶辫触:', err); + }); } else { wx.showToast({ title: res.msg || '缁堟澶辫触', @@ -578,5 +596,35 @@ console.error('鍔犺浇鏇村鍘嗗彶鏁版嵁澶辫触:', err); }); } + }, + + /** + * 浠庡垱寤虹亴婧夎鍒掗〉闈㈣繑鍥炴椂锛屽垏鎹㈠埌褰撳墠璁″垝鍒楄〃骞跺埛鏂版暟鎹� + */ + switchToCurrentPlans: function() { + console.log('浠庡垱寤洪〉闈㈣繑鍥烇紝鍒囨崲鍒板綋鍓嶈鍒掑垪琛ㄥ苟鍒锋柊'); + + // 濡傛灉褰撳墠涓嶅湪 "褰撳墠鐏屾簤璁″垝" 鏍囩椤碉紝鍏堝垏鎹㈠埌璇ユ爣绛鹃〉 + if (this.data.currentTab !== 0) { + this.setData({ + currentTab: 0, + currentList: this.data.activeList + }); + } + + // 鏄剧ず鍔犺浇鎻愮ず + wx.showLoading({ + title: '鍒锋柊鏁版嵁涓�', + mask: true + }); + + // 鍒锋柊褰撳墠鐏屾簤璁″垝鏁版嵁 + this.loadIrrigationData() + .then(() => { + wx.hideLoading(); + }) + .catch(() => { + wx.hideLoading(); + }); } }) \ No newline at end of file diff --git a/pages/irrigation/irrigation.wxml b/pages/irrigation/irrigation.wxml index 99ea2cc..1864f3e 100644 --- a/pages/irrigation/irrigation.wxml +++ b/pages/irrigation/irrigation.wxml @@ -70,7 +70,7 @@ </view> <!-- 鎿嶄綔鎸夐挳鍖哄煙 --> - <view class="action-section" catchtap="stopPropagation" wx:if="{{item.status !== '4'}}"> + <view class="action-section" catchtap="stopPropagation" wx:if="{{item.status === '1'||item.status === '2'||item.status === '3'}}"> <block wx:if="{{item.status === '1'}}"> <view class="action-buttons"> <button class="action-button delete-button" hover-class="delete-button-hover" bindtap="onDelete" data-id="{{item.id}}"> diff --git a/pages/irrigationDetail/irrigationDetail.js b/pages/irrigationDetail/irrigationDetail.js index d8a1a92..fff0558 100644 --- a/pages/irrigationDetail/irrigationDetail.js +++ b/pages/irrigationDetail/irrigationDetail.js @@ -12,7 +12,10 @@ planId: '', planStatusText: '', planStatusClass: '', - failureCount: 0 + failureCount: 0, + realStopTime: '', + originalStatus: '', + currentStatus: null }, /** @@ -23,7 +26,35 @@ this.setData({ planId: options.planId }); - this.fetchIrrigationData(options.planId); + + // 鑾峰彇鏈�鏂扮姸鎬� + this.fetchPlanLatestState(options.planId).then(res => { + if (res.success) { + const currentStatus = res.content; + this.setData({ + currentStatus: currentStatus, + originalStatus: currentStatus + }); + + // 鏍规嵁鏈�鏂扮姸鎬佽皟鐢ㄧ浉搴旂殑鎺ュ彛 + if (currentStatus === 5) { + this.fetchTerminatedIrrigationData(options.planId); + } else { + this.fetchNormalIrrigationData(options.planId); + } + } else { + wx.showToast({ + title: res.msg || '鑾峰彇鐘舵�佸け璐�', + icon: 'none' + }); + } + }).catch(err => { + console.error('鑾峰彇鐘舵�佸け璐ワ細', err); + wx.showToast({ + title: '鑾峰彇鐘舵�佸け璐�', + icon: 'none' + }); + }); } else { wx.showToast({ title: '缂哄皯璁″垝ID', @@ -36,9 +67,9 @@ }, /** - * 鑾峰彇鐏屾簤璁″垝鏁版嵁 + * 鑾峰彇甯歌鐏屾簤璁″垝璇︾粏鏁版嵁 */ - fetchIrrigationData: function(planId) { + fetchNormalIrrigationData: function(planId) { const { get } = require('../../api/request'); const data = { @@ -69,6 +100,57 @@ }, /** + * 鑾峰彇宸茬粓姝㈢亴婧夎鍒掕缁嗘暟鎹� + */ + fetchTerminatedIrrigationData: function(planId) { + const { get } = require('../../api/request'); + + const data = { + planId: planId || this.data.planId, + }; + + get({ + url: 'wx/plan/getTerminateResults', + isShowLoding: true, + useParams: true, + data: data + }).then(res => { + if (res.success) { + this.processIrrigationData(res.content); + } else { + wx.showToast({ + title: res.msg || '鑾峰彇鏁版嵁澶辫触', + icon: 'none' + }); + } + }).catch(err => { + console.error('璇锋眰澶辫触锛�', err); + wx.showToast({ + title: '璇锋眰澶辫触', + icon: 'none' + }); + }); + }, + + /** + * 鑾峰彇璁″垝鏈�鏂扮姸鎬� + */ + fetchPlanLatestState: function(planId) { + const { get } = require('../../api/request'); + + const data = { + planId: planId || this.data.planId, + }; + + return get({ + url: 'wx/plan/getPlanLatestState', + isShowLoding: true, + useParams: true, + data: data + }); + }, + + /** * 澶勭悊鎺ュ彛杩斿洖鐨勬暟鎹� */ processIrrigationData: function(data) { @@ -78,7 +160,9 @@ const statusMap = { 2: {status: 'pending', statusText: '鏈紑濮�'}, 3: {status: 'in_progress', statusText: '鐏屾簤涓�'}, - 4: {status: 'completed', statusText: '宸茬粨鏉�'} + 4: {status: 'completed', statusText: '宸茬粨鏉�'}, + 5: {status: 'terminated', statusText: '涓�斿叧闃�'}, + 6: {status: 'canceled', statusText: '鍙栨秷寮�闃�'} }; // 澶勭悊璁″垝鐘舵�� @@ -140,6 +224,7 @@ projectName: data.projectName, startTime: data.planStartTime, stopTime: data.planStopTime, + realStopTime: data.realStopTime || '', groupList: groupList, planStatusText: planStatusText, planStatusClass: planStatusClass, @@ -182,15 +267,41 @@ this.setData({ isRefreshing: true }); - - this.fetchIrrigationData(this.data.planId); - // 瀹屾垚鍒锋柊 - setTimeout(() => { + // 鑾峰彇鏈�鏂扮姸鎬佸苟鍒锋柊鏁版嵁 + this.fetchPlanLatestState(this.data.planId).then(res => { + if (res.success) { + const currentStatus = res.content; + this.setData({ + currentStatus: currentStatus + }); + + if (currentStatus === 5) { + this.fetchTerminatedIrrigationData(this.data.planId); + } else { + this.fetchNormalIrrigationData(this.data.planId); + } + } else { + wx.showToast({ + title: res.msg || '鑾峰彇鐘舵�佸け璐�', + icon: 'none' + }); + } + + // 瀹屾垚鍒锋柊 this.setData({ isRefreshing: false }); - }, 1000); + }).catch(err => { + console.error('鑾峰彇鐘舵�佸け璐ワ細', err); + wx.showToast({ + title: '鑾峰彇鐘舵�佸け璐�', + icon: 'none' + }); + this.setData({ + isRefreshing: false + }); + }); }, /** diff --git a/pages/irrigationDetail/irrigationDetail.wxml b/pages/irrigationDetail/irrigationDetail.wxml index cce7d1d..fa70cf6 100644 --- a/pages/irrigationDetail/irrigationDetail.wxml +++ b/pages/irrigationDetail/irrigationDetail.wxml @@ -27,6 +27,12 @@ <text class="value">{{stopTime}}</text> </view> + <!-- 瀹為檯涓鏃堕棿淇℃伅 --> + <view class="time-info" wx:if="{{planStatusClass === 'terminated' && realStopTime}}"> + <text class="label">瀹為檯涓鏃堕棿锛�</text> + <text class="value highlight-text">{{realStopTime}}</text> + </view> + <!-- 鍙栨按鍙e懡浠ゅ彂甯冨け璐ユ暟 --> <view class="time-info" wx:if="{{failureCount > 0}}"> <text class="label">鍛戒护鍙戝竷澶辫触鏁帮細</text> @@ -48,6 +54,7 @@ <!-- 杞亴缁勪俊鎭� --> <view class="group-info"> <view class="group-name-row"> + <text class="group-index">{{index + 1}}.</text> <text class="group-label">杞亴缁勶細</text> <text class="group-name">{{group.name}}</text> <!-- 杞亴缁勭姸鎬佹爣璇� --> @@ -56,7 +63,9 @@ <text class="status-text">{{group.statusText}}</text> </view> </view> - <view class="group-time-info"> + <!-- 杞亴鏃堕棿淇℃伅 - 鍙湁鍦ㄥ彇娑堝紑闃�鐘舵�佹椂涓嶆樉绀烘椂闂翠俊鎭� --> + <!-- 鍏朵粬鎵�鏈夌姸鎬�(鍖呮嫭涓�斿叧闃�)閮芥樉绀烘椂闂翠俊鎭� --> + <view class="group-time-info" wx:if="{{group.status !== 'canceled'}}"> <view class="time-row"> <text class="time-label">寮�濮嬫椂闂达細</text> <text class="time-value">{{group.startTime}}</text> diff --git a/pages/irrigationDetail/irrigationDetail.wxss b/pages/irrigationDetail/irrigationDetail.wxss index c73a291..49b79e4 100644 --- a/pages/irrigationDetail/irrigationDetail.wxss +++ b/pages/irrigationDetail/irrigationDetail.wxss @@ -86,6 +86,15 @@ font-weight: 500; } +/* 瀹為檯涓鏃堕棿楂樹寒鏍峰紡 */ +.time-info .highlight-text { + color: #F44336; + font-weight: bold; + background-color: rgba(244, 67, 54, 0.1); + padding: 4rpx 12rpx; + border-radius: 4rpx; +} + /* 鍛戒护鍙戝竷澶辫触鏁版牱寮� */ .time-info .error-text { color: #ff4d4f; @@ -209,6 +218,14 @@ background-color: #2196F3; } +.group-item.terminated .status-dot { + background-color: #F44336; +} + +.group-item.canceled .status-dot { + background-color: #9E9E9E; +} + .status-text { font-size: 26rpx; color: #666; @@ -227,6 +244,14 @@ color: #2196F3; } +.group-item.terminated .status-text { + color: #F44336; +} + +.group-item.canceled .status-text { + color: #9E9E9E; +} + /* 鏍规嵁涓嶅悓鐘舵�佹樉绀轰笉鍚岃儗鏅壊 */ .group-item.pending .group-status-indicator { background-color: rgba(255, 215, 0, 0.1); @@ -240,6 +265,14 @@ background-color: rgba(33, 150, 243, 0.1); } +.group-item.terminated .group-status-indicator { + background-color: rgba(244, 67, 54, 0.1); +} + +.group-item.canceled .group-status-indicator { + background-color: rgba(158, 158, 158, 0.1); +} + /* 杞亴缁勪俊鎭牱寮� */ .group-info { margin-top: 12rpx; @@ -250,6 +283,12 @@ align-items: center; margin-bottom: 12rpx; width: 100%; +} + +.group-index { + color: #1890FF; + margin-right: 8rpx; + font-size: 32rpx; } .group-label { @@ -280,7 +319,8 @@ .time-label { color: #666; font-size: 26rpx; - width: 160rpx; + width: 140rpx; + flex-shrink: 0; } .time-value { diff --git a/pages/valveList/valveList.js b/pages/valveList/valveList.js index 78d4eb5..1aee367 100644 --- a/pages/valveList/valveList.js +++ b/pages/valveList/valveList.js @@ -1,21 +1,28 @@ // pages/valveList/valveList.js 寮�鍏抽榾璁板綍 +const { + get, + post +} = require('../../api/request.js'); + Page({ /** * 椤甸潰鐨勫垵濮嬫暟鎹� */ data: { - listData: [{ - intakeNum: "1023356646612" - }, { - intakeNum: "1023356646612" - }, { - intakeNum: "1023356646612" - }, { - intakeNum: "1023356646612" - }, { - intakeNum: "1023356646612" - }] + listVirtualData: [], + listPhysicalData: [], + currentTab: 0, + isVirtualRefreshing: false, //铏氭嫙鍗″埛鏂颁腑 + isPhysicalRefreshing: false, //瀹炰綋鍗″埛鏂颁腑 + physicalPageCurr: 1, //瀹炰綋鍗″綋鍓嶉〉鏁� + pageSize: 20, + virtualPageCurr: 1, //铏氭嫙鍗″綋鍓嶉〉鏁� + virtualhasMore: true, + physicalHasMore: true, + virtualIsLoding: false, + physicalIsLoding: false, + useTestData: false, // 娣诲姞娴嬭瘯鏁版嵁鏍囧織 }, /** @@ -29,7 +36,8 @@ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚 */ onReady() { - + this.getPhysicalListData(); + this.getVirtualListData(); }, /** @@ -72,5 +80,183 @@ */ onShareAppMessage() { + }, + switchTab(e) { + const tab = parseInt(e.currentTarget.dataset.tab); + this.setData({ + currentTab: tab + }); + }, + //铏氭嫙鍗″埛鏂� + onPullVirtualDownRefresh() { + this.setData({ + isVirtualRefreshing: true, + }) + this.getVirtualListData(true); + }, + //瀹炰綋鍗″埛鏂� + onPullPhysicalDownRefresh() { + this.setData({ + isPhysicalRefreshing: true, + }) + this.getPhysicalListData(true); + }, + // 鐢熸垚铏氭嫙鍗℃祴璇曟暟鎹� + generateVirtualTestData() { + return Array(10).fill().map((_, index) => ({ + expense: (Math.random() * 100).toFixed(2), + cardNum: `VC${Math.floor(Math.random() * 10000).toString().padStart(4, '0')}`, + intakeNum: `IN${Math.floor(Math.random() * 1000).toString().padStart(3, '0')}`, + openType: ['鎵嬪姩寮�闃�', '鑷姩寮�闃�', '璁″垝寮�闃�'][Math.floor(Math.random() * 3)], + openTime: this.generateRandomTime(), + closeTime: this.generateRandomTime(), + duration: Math.floor(Math.random() * 120), + amount: (Math.random() * 50).toFixed(2) + })); + }, + + // 鐢熸垚瀹炰綋鍗℃祴璇曟暟鎹� + generatePhysicalTestData() { + return Array(10).fill().map((_, index) => ({ + expense: (Math.random() * 100).toFixed(2), + cardNum: `PC${Math.floor(Math.random() * 10000).toString().padStart(4, '0')}`, + intakeNum: `IN${Math.floor(Math.random() * 1000).toString().padStart(3, '0')}`, + openType: ['鎵嬪姩寮�闃�', '鑷姩寮�闃�', '璁″垝寮�闃�'][Math.floor(Math.random() * 3)], + openTime: this.generateRandomTime(), + closeTime: this.generateRandomTime(), + duration: Math.floor(Math.random() * 120), + amount: (Math.random() * 50).toFixed(2) + })); + }, + + // 鐢熸垚闅忔満鏃堕棿 + generateRandomTime() { + const now = new Date(); + const randomHours = Math.floor(Math.random() * 24); + const randomMinutes = Math.floor(Math.random() * 60); + const randomSeconds = Math.floor(Math.random() * 60); + + const date = new Date(now); + date.setHours(randomHours); + date.setMinutes(randomMinutes); + date.setSeconds(randomSeconds); + + return date.toLocaleString(); + }, + + //鑾峰彇瀹炰綋鍗″垪琛� + getPhysicalListData(isRefresh) { + if (this.data.useTestData) { + // 浣跨敤娴嬭瘯鏁版嵁 + const testData = this.generatePhysicalTestData(); + this.setData({ + listPhysicalData: isRefresh ? testData : this.data.listPhysicalData.concat(testData), + isPhysicalRefreshing: false, + physicalIsLoding: false, + physicalHasMore: this.data.physicalPageCurr < 3 // 妯℃嫙3椤垫暟鎹� + }); + return; + } + + get({ + url: 'wx/intake/getCardOpenClose', + data: { + clientId: getApp().globalData.clientId, + pageCurr: this.data.physicalPageCurr, + pageSize: this.data.pageSize + } + }) + .then((data) => { + this.setData({ + isPhysicalRefreshing: false, + physicalIsLoding: false + }); + if (data.success && data.code === "0001") { + const filteredData = data.content.obj.filter(item => item.openTime !== null && item.closeTime !== null); + this.setData({ + listPhysicalData: isRefresh ? filteredData : this.data.listPhysicalData.concat(filteredData), + physicalHasMore: this.data.physicalPageCurr < data.content.pageTotal, + }); + } else { + wx.showToast({ + title: data.msg, + }) + } + }) + .catch((error) => { + this.setData({ + isPhysicalRefreshing: false + }); + console.error('Failed to add item:', error); + }); + }, + + //鑾峰彇铏氭嫙鍗″紑鍏抽榾璁板綍 + getVirtualListData(isRefresh) { + if (this.data.useTestData) { + // 浣跨敤娴嬭瘯鏁版嵁 + const testData = this.generateVirtualTestData(); + this.setData({ + listVirtualData: isRefresh ? testData : this.data.listVirtualData.concat(testData), + isVirtualRefreshing: false, + virtualIsLoding: false, + virtualhasMore: this.data.virtualPageCurr < 3 // 妯℃嫙3椤垫暟鎹� + }); + return; + } + + get({ + url: 'wx/intake/getVcCardOpenClose', + data: { + clientId: getApp().globalData.clientId, + pageCurr: this.data.physicalPageCurr, + pageSize: this.data.pageSize + } + }) + .then((data) => { + this.setData({ + isVirtualRefreshing: false, + virtualIsLoding: false + }); + if (data.success && data.code === "0001") { + const filteredData = data.content.obj.filter(item => item.openTime !== null && item.closeTime !== null); + this.setData({ + listVirtualData: isRefresh ? filteredData : this.data.listVirtualData.concat(filteredData), + virtualhasMore: this.data.virtualPageCurr < data.content.pageTotal, + }); + } else { + wx.showToast({ + title: data.msg, + }) + } + }) + .catch((error) => { + this.setData({ + isVirtualRefreshing: false + }); + console.error('Failed to add item:', error); + }); + }, + //鍔犺浇鏇村鐨勫疄浣撳崱 + loadPhysicalMore() { + if (this.data.physicalHasMore) { + this.setData({ + physicalIsLoding: true, + physicalPageCurr: this.data.physicalPageCurr + 1 + }) + this.getPhysicalListData(); + } + }, + //鍔犺浇鏇村鐨勮櫄鎷熷崱 + loadVirtualMore() { + if (this.data.virtualhasMore) { + this.setData({ + virtualIsLoding: true, + virtualPageCurr: this.data.virtualPageCurr + 1 + }) + this.getVirtualListData(); + } + } + }) \ No newline at end of file diff --git a/pages/valveList/valveList.wxml b/pages/valveList/valveList.wxml index b48f7ae..3266c88 100644 --- a/pages/valveList/valveList.wxml +++ b/pages/valveList/valveList.wxml @@ -1,30 +1,79 @@ <!--pages/valveList/valveList.wxml 寮�鍏抽榾璁板綍--> -<view> - <scroll-view class="list-container" scroll-y="true" scroll-x="false"> - <block wx:if="{{listData.length > 0}}" wx:for="{{listData}}" wx:key="index"> - <view class="list-item" wx:for="{{listData}}" wx:for-item="item" wx:for-index="index"> +<view class="container"> + <!-- 椤堕儴 Tabs --> + <view class="tabs"> + <view class="tab" bindtap="switchTab" data-tab="0" id="tab0"> + 铏氭嫙鍗� + <view class="indicator" wx:if="{{currentTab === 0}}"></view> + </view> + <view class="tab" bindtap="switchTab" data-tab="1" id="tab1"> + 姘村崱 + <view class="indicator" wx:if="{{currentTab === 1}}"></view> + </view> + </view> + <scroll-view class="list-container" enable-flex="true" wx:if="{{currentTab === 0}}" scroll-y="true" scroll-x="false" refresher-enabled="true" bindrefresherrefresh="onPullVirtualDownRefresh" refresher-triggered="{{isVirtualRefreshing}}" bindscrolltolower="loadVirtualMore"> + <block wx:if="{{listVirtualData.length > 0}}" wx:for="{{listVirtualData}}" wx:key="index"> + <view class="list-item" > <!-- <image class="item-img" src="/images/pipeline.svg" /> --> <view class="item-time"> <text class="item-text">娑堣垂閲戦锛�</text> <view> - <text class="item-morny">50</text> + <text class="item-morny">{{item.expense}}</text> <text class="item-text"> 鍏�</text> </view> </view> - <text class="item-text">铏氭嫙鍗$紪鍙凤細{{item.intakeNum}}</text> - <text class="item-text">鍙栨按鍙g紪鍙凤細</text> - <text class="item-text">寮�闃�鏃堕棿锛�</text> - <text class="item-text">鍏抽榾鏃堕棿锛�</text> + <text class="item-text">姘村崱缂栧彿锛歿{item.cardNum}}</text> + <text class="item-text">鍙栨按鍙g紪鍙凤細{{item.intakeNum}}</text> + <text class="item-text">寮�闃�绫诲瀷锛歿{item.openType}}</text> + <text class="item-text">寮�闃�鏃堕棿锛歿{item.openTime}}</text> + <text class="item-text">鍏抽榾鏃堕棿锛歿{item.closeTime}}</text> <view class="item-time"> - <text class="item-text">鐢ㄦ按鏃堕暱锛�120 鍒嗛挓</text> - <text class="item-text">鐢ㄦ按閲忥細2 m鲁</text> + <text class="item-text">鐢ㄦ按鏃堕暱锛歿{item.duration}}鍒嗛挓</text> + <text class="item-text">鐢ㄦ按閲忥細{{item.amount}} m鲁</text> </view> </view> </block> - <view wx:if="{{listData.length === 0}}" class="noMore-View"> + <view wx:if="{{listVirtualData.length === 0}}" class="noMore-View"> <image class="noMore-img" src="/images/no_more.svg" /> <text class="noMore-text">娌℃湁鏁版嵁</text> </view> + <view wx:if="{{virtualIsLoding}}" class="loading">鍔犺浇涓�...</view> <!-- 鍔犺浇鎸囩ず鍣� --> + <view wx:if="{{ !virtualhasMore && listVirtualData.length > 0}}" class="no-more-data"> + <text>鈥� 宸插姞杞藉叏閮ㄦ暟鎹� 鈥�</text> + </view> + </scroll-view> + + <scroll-view class="list-container" wx:else enable-flex="true" scroll-y="true" scroll-x="false" refresher-enabled="true" bindrefresherrefresh="onPullPhysicalDownRefresh" scroll-x="false" refresher-triggered="{{isPhysicalRefreshing}}" bindscrolltolower="loadPhysicalMore"> + <block wx:if="{{listPhysicalData.length > 0}}" wx:for="{{listPhysicalData}}" wx:key="index"> + <view class="list-item" > + <!-- <image class="item-img" src="/images/pipeline.svg" /> --> + <view class="item-time"> + <text class="item-text">娑堣垂閲戦锛�</text> + <view> + <text class="item-morny">{{item.expense}}</text> + <text class="item-text"> 鍏�</text> + </view> + </view> + <text class="item-text">姘村崱缂栧彿锛歿{item.cardNum}}</text> + <text class="item-text">鍙栨按鍙g紪鍙凤細{{item.intakeNum}}</text> + <text class="item-text">寮�闃�绫诲瀷锛歿{item.openType}}</text> + <text class="item-text">寮�闃�鏃堕棿锛歿{item.openTime}}</text> + <text class="item-text">鍏抽榾鏃堕棿锛歿{item.closeTime}}</text> + <view class="item-time"> + <text class="item-text">鐢ㄦ按鏃堕暱锛歿{item.duration}}鍒嗛挓</text> + <text class="item-text">鐢ㄦ按閲忥細{{item.amount}} m鲁</text> + </view> + + </view> + </block> + <view wx:if="{{listPhysicalData.length === 0}}" class="noMore-View"> + <image class="noMore-img" src="/images/no_more.svg" /> + <text class="noMore-text">娌℃湁鏁版嵁</text> + </view> + <view wx:if="{{physicalIsLoding}}" class="loading">鍔犺浇涓�...</view> <!-- 鍔犺浇鎸囩ず鍣� --> + <view wx:if="{{!physicalHasMore && listPhysicalData.length > 0}}" class="no-more-data"> + <text>鈥� 宸插姞杞藉叏閮ㄦ暟鎹� 鈥�</text> + </view> </scroll-view> </view> \ No newline at end of file diff --git a/pages/valveList/valveList.wxss b/pages/valveList/valveList.wxss index babafeb..921e27e 100644 --- a/pages/valveList/valveList.wxss +++ b/pages/valveList/valveList.wxss @@ -1,4 +1,16 @@ /* pages/valveList/valveList.wxss */ +.container { + display: flex; + flex-direction: column; + height: 100vh; + width: 100%; + padding-left: 20rpx; + padding-right: 20rpx; + padding-top: 5rpx; + padding-bottom: 5rpx; + background-color: #fff; +} + .list-item { display: flex; flex-direction: column; @@ -26,4 +38,75 @@ color: #FFFF00; font-size: 50rpx; font-weight: bold; +} + +.tab { + font-size: 35rpx; + padding: 10px; + cursor: pointer; + position: relative; + width: 50%; + /* Tabs 骞冲垎鏁翠釜妯悜灞忓箷 */ + text-align: center; + /* 鏂囧瓧灞呬腑 */ +} + +.tabs { + display: flex; + justify-content: space-around; + position: relative; + width: 100%; + border-bottom: 1px solid #eee; + /* Tabs 鍗犳弧鏁翠釜妯悜灞忓箷 */ +} + +.list-container { + flex: 1; + width: 100%; + display: flex; + flex-direction: column; +} + +.noMore-View { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + height: 100%; + padding: 40rpx 0; + width: 100%; + text-align: center; +} + +.noMore-img { + width: 200rpx; + height: 200rpx; + margin-bottom: 20rpx; +} + +.noMore-text { + font-size: 32rpx; + color: #999; +} + +.indicator { + width: 100%; + height: 3px; + background-color: #1890FF; + position: absolute; + bottom: 0; + left: 0; + transform: translateX(0); + /* 鍒濆鍖栦綅缃� */ +} + +.no-more-data { + display: flex; + justify-content: center; + align-items: center; + padding: 20rpx 0; + color: #999; + font-size: 28rpx; + width: 100%; + text-align: center; } \ No newline at end of file diff --git a/pages/waterIntake/waterIntake.json b/pages/waterIntake/waterIntake.json index ce04389..2f8f564 100644 --- a/pages/waterIntake/waterIntake.json +++ b/pages/waterIntake/waterIntake.json @@ -2,7 +2,7 @@ "component": true, "usingComponents": { "t-avatar": "tdesign-miniprogram/avatar/avatar", - "t-switch": "tdesign-miniprogram/switch/switch", + "t-button": "tdesign-miniprogram/button/button", "t-dialog": "tdesign-miniprogram/dialog/dialog", "t-input": "tdesign-miniprogram/input/input", diff --git a/utils/projectConfig.js b/utils/projectConfig.js index 3c6c19a..83ca845 100644 --- a/utils/projectConfig.js +++ b/utils/projectConfig.js @@ -3,7 +3,8 @@ JYG: { tag: 'ym', displayName: '鍢夊唱鍏抽」鐩�', - needLogin: true // 闇�瑕佺櫥褰� + operatorId: '2025040415305200007', // 缁熶竴ID鐢ㄤ簬operator鍜宑lientId + needLogin: false // 涓嶉渶瑕佺櫥褰� }, MQ: { tag: 'mq', @@ -22,7 +23,19 @@ tag: 'XX', displayName: '瀛︽牎椤圭洰', operatorId: '2025040215305200006', // 缁熶竴ID鐢ㄤ簬operator鍜宑lientId - needLogin: true // 涓嶉渶瑕佺櫥褰� + needLogin: false // 涓嶉渶瑕佺櫥褰� + }, + JC: { + tag: 'jc', + displayName: '閲戞槍椤圭洰', + operatorId: '2025041710412400006', // 缁熶竴ID鐢ㄤ簬operator鍜宑lientId + needLogin: false // 涓嶉渶瑕佺櫥褰� + }, + GSCLT:{ + tag: 'test', + displayName: '鐢樿們鍐滅闄�-宕�', + operatorId: '2025041912201400006', // 缁熶竴ID鐢ㄤ簬operator鍜宑lientId + needLogin: false // 涓嶉渶瑕佺櫥褰� } }; -- Gitblit v1.8.0