From f66a9a2c565966e98720be5e20604c6f75030f82 Mon Sep 17 00:00:00 2001 From: zuoxiao <470321431@qq.com> Date: 星期一, 28 十月 2024 17:40:13 +0800 Subject: [PATCH] 1.首页添加使用说明。2.修改扫码开阀功能。3.问题反馈功能相关 --- pages/home/home.js | 131 ++++++++++++++++++++++++++++--------------- 1 files changed, 84 insertions(+), 47 deletions(-) diff --git a/pages/home/home.js b/pages/home/home.js index cbba07e..ce099b8 100644 --- a/pages/home/home.js +++ b/pages/home/home.js @@ -31,6 +31,8 @@ showForceConfirm: false, //鏄惁寮哄埗寮�闃� lastIntakeName: "", isLogin: false, //鏄惁宸茬粡鐧诲綍 + showInfoDialog: false, + }, openValve: function (e) { @@ -44,7 +46,6 @@ icon: 'error' }) } - }, calculateScrollViewHeight: function () { wx.createSelectorQuery().selectAll('.list-item').boundingClientRect((rects) => { @@ -55,7 +56,7 @@ }).exec(); }, startPullDownRefresh() { - if(this.data.isLogin){ + if (this.data.isLogin) { if (!this.data.isWXRefreshing) { var self = this; console.log(this.data.isRefreshing); @@ -64,14 +65,12 @@ }); this.getOpenList(); } - }else{ + } else { wx.showToast({ title: '璇峰厛鐧诲綍', icon: 'error' }) } - - }, //鑾峰彇鐢ㄦ埛鏁版嵁 getUserData() { @@ -115,6 +114,9 @@ const app = getApp(); storage.getItem('sessionId').then((data) => { app.globalData.sessionId = data; + this.setData({ + isLogin: true + }) if (app.globalData.sessionId) { this.getOpenList(); this.getUserDataBySession(); @@ -324,32 +326,44 @@ * 鑾峰彇涓哄叧闃�璁板綍 */ getOpenList() { - const app = getApp(); - const params = { - url: 'wx/valve/get', - data: { - operator: app.globalData.sessionId - } - }; - get(params).then(data => { - this.setData({ - listData: data.content, - isRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚 - isWXRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚 - }) - this.updateDisplayText(); - }).catch(err => { - // 閿欒鍥炶皟 - this.setData({ - isRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚 - isWXRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚 - }) + if (this.data.isLogin) { + const app = getApp(); + const params = { + url: 'wx/valve/get', + data: { + operator: app.globalData.sessionId + } + }; + get(params).then(data => { + this.setData({ + listData: data.content, + isRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚 + isWXRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚 + }) + this.updateDisplayText(); + }).catch(err => { + // 閿欒鍥炶皟 + this.setData({ + isRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚 + isWXRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚 + }) + wx.showToast({ + title: err.msg, + icon: 'error', + duration: 3000 + }) + }); + } else { wx.showToast({ - title: err.msg, - icon: 'error', - duration: 3000 + title: '璇峰厛鐧诲綍', + icon: 'error' }) - }); + this.setData({ + isRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚 + isWXRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚 + }) + } + }, /** * 纭鍏抽棴鍥炶皟 @@ -403,25 +417,36 @@ * 鎵爜寮�闃� */ scenCode() { - const that = this; - wx.scanCode({ - success(res) { - console.log(res.result); // 褰撲笖浠呭綋鎵爜涓洪潪寰俊浜岀淮鐮佹椂锛屼細杩斿洖result - if (res.result.startsWith("content://")) { - let jsonStr = res.result.replace("content://", "") - try { - that.saveData(jsonStr) - } catch (error) { - console.error('Error parsing JSON:', error); + if (this.data.isLogin) { + const that = this; + wx.scanCode({ + success(res) { + console.log(res.result); // 褰撲笖浠呭綋鎵爜涓洪潪寰俊浜岀淮鐮佹椂锛屼細杩斿洖result + if (res.result.startsWith("content://")) { + let jsonStr = res.result.replace("content://", "") + try { + that.saveData(jsonStr) + } catch (error) { + console.error('Error parsing JSON:', error); + } + } else { + wx.navigateTo({ + url: '/pages/openCard/openCard?intakeName=' + res.result, + }) + // that.postOppenValva() } - } else { - that.postOppenValva(res.result) + }, + fail(err) { + console.error(err); } - }, - fail(err) { - console.error(err); - } - }) + }) + } else { + wx.showToast({ + title: '璇峰厛鐧诲綍', + icon: 'error' + }) + } + }, confirmForceDialog() { console.log("confirmForceDialog"); @@ -594,7 +619,7 @@ userPhone: "璇风櫥褰�", userName: "鏈櫥褰�", listData: [], - isLogin:false + isLogin: false }) app.globalData.sessionId = ""; app.globalData.clientId = "" @@ -611,5 +636,17 @@ // 澶勭悊閿欒鍝嶅簲 console.error('璇锋眰澶辫触:', error); }); + }, + //鐐瑰嚮鎻愮ず鎸夐挳 + infoShow() { + this.setData({ + showInfoDialog: true + }) + }, + //鎻愮ず绐楃‘璁ゆ寜閽� + confirmBtnInfoDialog() { + this.setData({ + showInfoDialog: false + }) } }) \ No newline at end of file -- Gitblit v1.8.0