From f3058f900e3143c0245c9b1686397b6e6e561422 Mon Sep 17 00:00:00 2001 From: zuoxiao <470321431@qq.com> Date: 星期五, 08 十一月 2024 10:09:48 +0800 Subject: [PATCH] 1.解绑添加二次确认。2.接口返回的金额都是元 --- pages/valveList/valveList.js | 158 +++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 131 insertions(+), 27 deletions(-) diff --git a/pages/valveList/valveList.js b/pages/valveList/valveList.js index 2a416af..1c5d89f 100644 --- a/pages/valveList/valveList.js +++ b/pages/valveList/valveList.js @@ -1,37 +1,28 @@ // pages/valveList/valveList.js 寮�鍏抽榾璁板綍 +const { + get, + post +} = require('../../api/request.js'); + Page({ /** * 椤甸潰鐨勫垵濮嬫暟鎹� */ data: { - listData: [{ - intakeNum: "1023356646612", - watername:"娴嬭瘯", - startTime:"2024.10.15 12:23", - endTime:"2024.10.15 16:23" + listVirtualData: [], + listPhysicalData: [], + currentTab: 0, + isVirtualRefreshing: false, //铏氭嫙鍗″埛鏂颁腑 + isPhysicalRefreshing: false, //瀹炰綋鍗″埛鏂颁腑 + physicalPageCurr: 1, //瀹炰綋鍗″綋鍓嶉〉鏁� + pageSize: 20, + virtualPageCurr: 1, //铏氭嫙鍗″綋鍓嶉〉鏁� + virtualhasMore: true, + physicalHasMore: true, + virtualIsLoding: false, + physicalIsLoding: false, - }, { - intakeNum: "1023356646612", - watername:"娴嬭瘯1", - startTime:"2024.10.15 12:23", - endTime:"2024.10.15 16:23" - }, { - intakeNum: "1023356646612", - watername:"娴嬭瘯2", - startTime:"2024.10.15 12:23", - endTime:"2024.10.15 16:23" - }, { - intakeNum: "1023356646612", - watername:"娴嬭瘯3", - startTime:"2024.10.15 12:23", - endTime:"2024.10.15 16:23" - }, { - intakeNum: "1023356646612", - watername:"娴嬭瘯4", - startTime:"2024.10.15 12:23", - endTime:"2024.10.15 16:23" - }] }, /** @@ -45,7 +36,8 @@ * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚 */ onReady() { - + this.getPhysicalListData(); + this.getVirtualListData(); }, /** @@ -88,5 +80,117 @@ */ 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); + }, + //鑾峰彇瀹炰綋鍗″垪琛� + getPhysicalListData(isRefresh) { + 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, + }) + } + console.log('Failed to add item:'); + }) + .catch((error) => { + this.setData({ + isWXRefreshing: false + }); + console.error('Failed to add item:', error); + }); + }, + //鑾峰彇铏氭嫙鍗″紑鍏抽榾璁板綍 + getVirtualListData(isRefresh) { + 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, + }) + } + console.log('Failed to add item:'); + }) + .catch((error) => { + this.setData({ + isWXRefreshing: 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 -- Gitblit v1.8.0