From a84175b5e189ac6da0d80ac64f77a4b45e7c9157 Mon Sep 17 00:00:00 2001 From: zuoxiao <470321431@qq.com> Date: 星期四, 14 十一月 2024 13:48:34 +0800 Subject: [PATCH] 1.添加瞬时流量相关2.优化界面3.修改原开阀和未关阀列表的sessionId为clientId --- pages/home/home.js | 99 +++++++++++++++++++++++++++++++++++-------------- 1 files changed, 71 insertions(+), 28 deletions(-) diff --git a/pages/home/home.js b/pages/home/home.js index e311702..cd54a3f 100644 --- a/pages/home/home.js +++ b/pages/home/home.js @@ -34,6 +34,7 @@ showInfoDialog: false, showTipDialog: false, options: '', + showUnBind: false }, openValve: function (e) { @@ -91,7 +92,7 @@ onLoad(options) { //褰撳紑闃�鎴愬姛鍚庤皟鐢ㄥ埛鏂� console.log("onLoad锛�" + options.param); - if (options.param) { + if (options.param === "1" || options.param === "2") { this.setData({ options: options, isLogin: true, @@ -113,40 +114,51 @@ isLogin: true }) if (app.globalData.sessionId) { - this.getOpenList(); this.getUserDataBySession(); } }).catch((err) => {}); storage.getItem('clientId').then((data) => { app.globalData.clientId = data; + this.getOpenList(); }).catch((err) => {}); } else { //鏈湴娌℃湁缂撳瓨寰俊鐧诲綍 this.wxLogin(); } - if (this.data.options.param) { + if (this.data.options.param === "1") { this.setData({ - showTipDialog: true, - tipData: "寮�闃�鍛戒护涓嬪彂鎴愬姛锛岀害20-60绉掑悗鍙埛鏂板揩閫熷叧闃�鍒楄〃鏌ョ湅鎵ц缁撴灉銆�" + tipData: "寮�闃�鍛戒护涓嬪彂鎴愬姛锛屽洜寮�闃�闇�瑕佹椂闂达紝绾�20-60绉掑悗鍙埛鏂板揩閫熷叧闃�鍒楄〃鏌ョ湅鎵ц缁撴灉銆�" + }) + setTimeout(() => { + this.getOpenList(); + }, 20000) + + } else if (this.data.options.param === "2") { + this.setData({ + showTipDialog: true, + tipData: "棰勭害寮�闃�鍛戒护涓嬪彂鎴愬姛锛屽綋鍒拌揪棰勭害鏃堕棿骞朵笖鎴愬姛寮�闃�鍚庡揩閫熷叧闃�鍒楄〃浼氭樉绀烘湭鍏抽榾璁板綍" }) this.getOpenList(); } }, wxLogin() { - const that = this; - wx.login({ - success: function (res) { - if (res.code) { - var code = res.code; - console.log(code); - // 灏哻ode鍙戦�佸埌鏈嶅姟鍣ㄨ幏鍙杘penid - that.codeLogin(code); - } else { - console.log('鐧诲綍澶辫触锛�' + res.errMsg); + // if (!this.data.isLogin) { + const that = this; + wx.login({ + success: function (res) { + if (res.code) { + var code = res.code; + console.log(code); + // 灏哻ode鍙戦�佸埌鏈嶅姟鍣ㄨ幏鍙杘penid + that.codeLogin(code); + } else { + console.log('鐧诲綍澶辫触锛�' + res.errMsg); + } } - } - }); + }); + // } + }, //寰俊code鐧诲綍 codeLogin(codeData) { @@ -268,7 +280,8 @@ this.setData({ showForceConfirm: false, showConfirm: false, - showTipDialog: false + showTipDialog: false, + showUnBind: false }); }, /** @@ -308,7 +321,9 @@ showTipDialog: true, tipData: "鍏抽榾鍛戒护涓嬪彂鎴愬姛锛岀害20-60绉掑悗鍙埛鏂板揩閫熷叧闃�鍒楄〃鏌ョ湅鎵ц缁撴灉銆�" }) - this.getOpenList(); + setTimeout(() => { + this.getOpenList(); + }, 40000) } else { wx.showToast({ title: '鍛戒护鎵ц澶辫触', @@ -337,7 +352,7 @@ const params = { url: 'wx/valve/get', data: { - operator: app.globalData.sessionId + operator: app.globalData.clientId } }; get(params).then(data => { @@ -552,9 +567,6 @@ title: '姝e湪寮哄埗鍒犻櫎璇风◢鍊�...', // 鍔犺浇鎻愮ず鏂囧瓧 mask: true // 鏄惁鏄剧ず閫忔槑钂欏眰锛岄槻姝㈣Е鎽哥┛閫忥紝榛樿涓� false }); - that.setData({ - lastIntakeName: intakeName - }) const data = { vcNum: item.vcNum, //鍙栨按鍙D rtuAddr: item.rtuAddr, //闃�鎺у櫒鍦板潃 @@ -586,9 +598,22 @@ } 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 + displayText, + deleteText, + time }; // 淇濈暀鎵�鏈夊叾浠栧瓧娈碉紝骞舵坊鍔� displayText 瀛楁 }); // 鏇存柊鍒楄〃鏁版嵁 @@ -598,11 +623,14 @@ }, //瑙g粦 unbind() { - //娓呯┖鏁版嵁 this.setData({ - userPhone: "鏈櫥褰�", - userName: "璇风櫥褰�", - listData: [] + showUnBind: true + }) + }, + //纭瑙g粦 + unBindPost() { + this.setData({ + showUnBind: false }) wx.showLoading({ title: '姝e湪瑙g粦璇风◢鍊�...', // 鍔犺浇鎻愮ず鏂囧瓧 @@ -641,6 +669,11 @@ wx.hideLoading(); // 澶勭悊閿欒鍝嶅簲 console.error('璇锋眰澶辫触:', error); + wx.showToast({ + title: '瑙g粦澶辫触', + icon: 'error', + duration: 3000 + }) }); }, //鐐瑰嚮鎻愮ず鎸夐挳 @@ -654,5 +687,15 @@ this.setData({ showInfoDialog: false }) + }, + //澶勭悊鏃堕棿鍘绘帀骞存湀鏃� + 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 -- Gitblit v1.8.0