From d796875e4dee22341c48469973d03e1015db61e8 Mon Sep 17 00:00:00 2001 From: zuoxiao <470321431@qq.com> Date: 星期五, 05 七月 2024 11:40:28 +0800 Subject: [PATCH] 首页添加扫码 --- pages/home/home.js | 58 ++++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 44 insertions(+), 14 deletions(-) diff --git a/pages/home/home.js b/pages/home/home.js index 023bfac..5c6dad9 100644 --- a/pages/home/home.js +++ b/pages/home/home.js @@ -20,7 +20,12 @@ scrollViewHeight: 0, listData: [], isRefreshing: false, - isWXRefreshing: false + isWXRefreshing: false, + errorData: '', //閿欒鍐呭 + showErrorDialog: false, + confirmBtn: { + content: '纭' + }, }, openValve: function (e) { @@ -213,7 +218,8 @@ post({ url: "wx/valve/close_wx", data: data, - isShowLoding: false + isShowLoding: false, + timeout: 185000 }).then(response => { // 澶勭悊鎴愬姛鍝嶅簲 @@ -228,13 +234,10 @@ }) }).catch(error => { wx.hideLoading(); - if (error.code === "1002") { - wx.showToast({ - title: '鍏抽榾澶辫触', - icon: 'error', - duration: 3000 // 鎻愮ず鐨勬寔缁椂闂达紝鍗曚綅姣 - }) - } + this.setData({ + showErrorDialog: true, + errorData: error.msg + }) // 澶勭悊閿欒鍝嶅簲 console.error('璇锋眰澶辫触:', error); @@ -261,6 +264,12 @@ // 閿欒鍥炶皟 this.setData({ isRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚 + isWXRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚 + }) + wx.showToast({ + title: err.msg, + icon: 'error', + duration: 3000 }) }); }, @@ -278,7 +287,7 @@ getUserDataBySession() { const app = getApp(); const params = { - url: 'sell/client/simple_info', + url: 'wx/client/simple_info', data: { sessionId: app.globalData.sessionId } @@ -290,7 +299,11 @@ }) }).catch(err => { // 閿欒鍥炶皟 - + wx.showToast({ + title: err.msg, + icon: 'error', + duration: 3000 + }) }) }, maskPhoneNumber(phoneNumber) { @@ -300,8 +313,25 @@ // 浣跨敤姝e垯琛ㄨ揪寮忔浛鎹腑闂村洓浣嶆暟瀛椾负鏄熷彿 const maskedPhoneNumber = phoneNumber.replace(/^(\d{3})\d{4}(\d{4})$/, "$1****$2"); return maskedPhoneNumber; + }, + + closeDialog() { + this.setData({ + showErrorDialog: false + }) + }, + scenCode() { + wx.scanCode({ + success(res) { + console.log(res.result); // 褰撲笖浠呭綋鎵爜涓洪潪寰俊浜岀淮鐮佹椂锛屼細杩斿洖result + // 濡傛灉鎵爜缁撴灉涓篣RL锛屼細鑷姩灏濊瘯鎵撳紑 + // 濡傛灉鎵爜缁撴灉涓哄井淇″皬绋嬪簭鐨勭爜锛屼細鐩存帴璺宠浆鍒板搴旂殑灏忕▼搴忛〉闈� + // 濡傛灉鎵爜缁撴灉涓哄叕浼楀彿浜岀淮鐮侊紝鍒欎細鍦ㄦ墜鏈轰笂鎵撳紑寰俊骞惰烦杞埌瀵瑰簲鐨勫叕浼楀彿 + }, + fail(err) { + console.error(err); + } + + }) } - - - }) \ No newline at end of file -- Gitblit v1.8.0