From 19804e37592d2250c551fcf5df1d87cdf551f1d1 Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期一, 12 八月 2024 09:06:39 +0800
Subject: [PATCH] 添加识别二维码切换地址的功能

---
 pages/home/home.js |  117 +++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 103 insertions(+), 14 deletions(-)

diff --git a/pages/home/home.js b/pages/home/home.js
index 023bfac..dabd0d4 100644
--- a/pages/home/home.js
+++ b/pages/home/home.js
@@ -20,7 +20,14 @@
     scrollViewHeight: 0,
     listData: [],
     isRefreshing: false,
-    isWXRefreshing: false
+    isWXRefreshing: false,
+    errorData: '', //閿欒鍐呭
+    showErrorDialog: false,
+    confirmBtn: {
+      content: '纭'
+    },
+    errorDialogTitle: "鍏抽榾閿欒",
+    showForceConfirm: false //鏄惁寮哄埗寮�闃�
   },
 
   openValve: function (e) {
@@ -187,7 +194,16 @@
     });
   },
   closeDialog() {
+    console.log("closeDialog");
     this.setData({
+      showConfirm: false,
+      showErrorDialog: false,
+      showForceConfirm: false
+    });
+  },
+  cancelDialog(){
+    this.setData({
+      showForceConfirm: false,
       showConfirm: false
     });
   },
@@ -213,7 +229,8 @@
     post({
       url: "wx/valve/close_wx",
       data: data,
-      isShowLoding: false
+      isShowLoding: false,
+      timeout: 185000
     }).then(response => {
 
       // 澶勭悊鎴愬姛鍝嶅簲
@@ -228,13 +245,11 @@
       })
     }).catch(error => {
       wx.hideLoading();
-      if (error.code === "1002") {
-        wx.showToast({
-          title: '鍏抽榾澶辫触',
-          icon: 'error',
-          duration: 3000 // 鎻愮ず鐨勬寔缁椂闂达紝鍗曚綅姣
-        })
-      }
+      this.setData({
+        showErrorDialog: true,
+        errorData: error.msg,
+        errorDialogTitle: "鍏抽榾閿欒"
+      })
       // 澶勭悊閿欒鍝嶅簲
       console.error('璇锋眰澶辫触:', error);
 
@@ -261,6 +276,12 @@
       // 閿欒鍥炶皟
       this.setData({
         isRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚
+        isWXRefreshing: false, // 灏唗riggered灞炴�ц缃负false锛岃〃绀轰笅鎷夊埛鏂板凡瀹屾垚
+      })
+      wx.showToast({
+        title: err.msg,
+        icon: 'error',
+        duration: 3000
       })
     });
   },
@@ -278,7 +299,7 @@
   getUserDataBySession() {
     const app = getApp();
     const params = {
-      url: 'sell/client/simple_info',
+      url: 'wx/client/simple_info',
       data: {
         sessionId: app.globalData.sessionId
       }
@@ -290,7 +311,11 @@
       })
     }).catch(err => {
       // 閿欒鍥炶皟
-
+      wx.showToast({
+        title: err.msg,
+        icon: 'error',
+        duration: 3000
+      })
     })
   },
   maskPhoneNumber(phoneNumber) {
@@ -300,8 +325,72 @@
     // 浣跨敤姝e垯琛ㄨ揪寮忔浛鎹腑闂村洓浣嶆暟瀛椾负鏄熷彿
     const maskedPhoneNumber = phoneNumber.replace(/^(\d{3})\d{4}(\d{4})$/, "$1****$2");
     return maskedPhoneNumber;
+  },
+
+  closeDialog() {
+    this.setData({
+      showErrorDialog: false
+    })
+  },
+  /**
+   * 鎵爜寮�闃�
+   */
+  scenCode() {
+    const that = this;
+    wx.scanCode({
+      success(res) {
+        console.log(res.result); // 褰撲笖浠呭綋鎵爜涓洪潪寰俊浜岀淮鐮佹椂锛屼細杩斿洖result  
+        wx.showLoading({
+          title: '姝e湪寮�闃�璇风◢鍊�...', // 鍔犺浇鎻愮ず鏂囧瓧
+          mask: true // 鏄惁鏄剧ず閫忔槑钂欏眰锛岄槻姝㈣Е鎽哥┛閫忥紝榛樿涓� false
+        });
+        const app = getApp();
+        const data = {
+          intakeName: res.result, //鍙栨按鍙D
+          // vcId: vcId, //铏氭嫙鍗D
+          operator: app.globalData.sessionId //鎿嶄綔鍛�
+        };
+        post({
+          url: "wx/valve/open_wx",
+          data: data,
+          timeout: 180000
+        }).then(response => {
+
+          // 澶勭悊鎴愬姛鍝嶅簲
+          console.log('璇锋眰鎴愬姛:', response);
+          // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢�
+          wx.hideLoading();
+          //瀹屾垚鍚庡洖鍒伴椤�
+          wx.reLaunch({
+            url: '/pages/home/home?param=true' // 棣栭〉鐨勮矾寰勶紝鏍规嵁瀹為檯鎯呭喌濉啓
+          });
+        }).catch(error => {
+          // 鍔犺浇瀹屾垚鍚庨殣钘忓姞杞藉姩鐢�
+          wx.hideLoading();
+          // 澶勭悊閿欒鍝嶅簲
+          console.error('璇锋眰澶辫触:', error);
+          if (error.code==="1003") {
+            that.setData({
+              showForceConfirm:true
+            })
+          } else {
+            that.setData({
+              showErrorDialog: true,
+              errorData: error.msg,
+              errorDialogTitle: "寮�闃�閿欒"
+            })
+          }
+    
+
+        });
+      },
+      fail(err) {
+        console.error(err);
+      }
+
+    })
+  },
+  confirmForceDialog(){
+    console.log("confirmForceDialog");
   }
-
-
-
 })
\ No newline at end of file

--
Gitblit v1.8.0