From c6ad105d1b743bcfd8aa6ee2781d39039f319a87 Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期四, 04 七月 2024 11:28:51 +0800
Subject: [PATCH] 添加tag

---
 app.json                           |    2 +
 pages/home/home.js                 |   40 ++++++++++++++-----
 app.js                             |    1 
 api/request.js                     |   12 ++++-
 pages/waterIntake/waterIntake.wxss |    7 +++
 pages/waterIntake/waterIntake.js   |   42 ++++++++++++++-------
 pages/waterIntake/waterIntake.wxml |    4 +
 pages/home/home.wxml               |    4 +-
 pages/home/home.wxss               |    7 +++
 9 files changed, 86 insertions(+), 33 deletions(-)

diff --git a/api/request.js b/api/request.js
index 2b8e5f2..0833bc0 100644
--- a/api/request.js
+++ b/api/request.js
@@ -31,11 +31,12 @@
     data,
     ignoreToken,
     form,
-    isShowLoding
+    isShowLoding,
+    timeout,
+    header
   } = _options
   const app = getApp()
   // 璁剧疆璇锋眰澶�
-  let header = {}
   if (form) {
     header = {
       'content-type': 'application/x-www-form-urlencoded'
@@ -45,11 +46,16 @@
       'content-type': 'application/json' //鑷畾涔夎姹傚ご淇℃伅
     }
   }
+  if (!timeout) {
+    timeout = 60000
+  }
+
   if (!ignoreToken) {
     // 浠庡叏灞�鍙橀噺涓幏鍙杢oken
     let token = app.globalData.token
     header.Authorization = `Bearer ${token}`
   }
+  header.tag = app.globalData.tag;
   return new Promise((resolve, reject) => {
     console.log("url:" + BASEURL + url);
     if (isShowLoding) {
@@ -69,6 +75,7 @@
       data,
       header,
       method,
+      timeout: timeout,
       success: (res) => {
         let {
           statusCode: code
@@ -101,7 +108,6 @@
         if (isShowLoding) {
           wx.hideLoading(); // 闅愯棌鍔犺浇鍔ㄧ敾
         }
-
         // showToast(err.errMsg)
         reject(err)
       }
diff --git a/app.js b/app.js
index aa1d3eb..b009f3a 100644
--- a/app.js
+++ b/app.js
@@ -15,6 +15,7 @@
   },
   globalData: {
     sessionId:'2024052821300200006',
+    tag:'ym',
     userInfo: null,
     userId:"",
     userCode:"",
diff --git a/app.json b/app.json
index c680884..e405d06 100644
--- a/app.json
+++ b/app.json
@@ -25,4 +25,6 @@
   "componentFramework": "glass-easel",
   "sitemapLocation": "sitemap.json",
   "lazyCodeLoading": "requiredComponents"
+
+
 }
\ No newline at end of file
diff --git a/pages/home/home.js b/pages/home/home.js
index 023bfac..fb5c516 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,6 +313,11 @@
     // 浣跨敤姝e垯琛ㄨ揪寮忔浛鎹腑闂村洓浣嶆暟瀛椾负鏄熷彿
     const maskedPhoneNumber = phoneNumber.replace(/^(\d{3})\d{4}(\d{4})$/, "$1****$2");
     return maskedPhoneNumber;
+  },
+  closeDialog() {
+    this.setData({
+      showErrorDialog:false
+    })
   }
 
 
diff --git a/pages/home/home.wxml b/pages/home/home.wxml
index f4ee37e..c2bc9c0 100644
--- a/pages/home/home.wxml
+++ b/pages/home/home.wxml
@@ -64,6 +64,6 @@
       <text class="noMore-text">娌℃湁寮�娉佃褰�</text>
     </view>
   </scroll-view>
-  <t-dialog class="t-dialog" visible="{{showConfirm}}" content="纭鍏抽棴{{waterIntakeName}}鍚楋紵" confirm-btn="{{ { content: '纭', variant: 'base', theme: 'danger' } }}" close-on-overlay-click="false" cancel-btn="鍙栨秷"  bind:confirm="confirmDialog" bind:cancel="closeDialog" />
-
+  <t-dialog class="dialog" visible="{{showConfirm}}" content="纭鍏抽棴{{waterIntakeName}}鍚楋紵" confirm-btn="{{ { content: '纭', variant: 'base', theme: 'danger' } }}" close-on-overlay-click="false" cancel-btn="鍙栨秷"  bind:confirm="confirmDialog" bind:cancel="closeDialog" />
+  <t-dialog class="error-dialog"  title="鍏抽榾閿欒" visible="{{showErrorDialog}}" content="{{errorData}}" confirm-btn="{{ confirmBtn }}" bind:confirm="closeDialog" />
 </view>
\ No newline at end of file
diff --git a/pages/home/home.wxss b/pages/home/home.wxss
index 0b70b8e..ccf84a2 100644
--- a/pages/home/home.wxss
+++ b/pages/home/home.wxss
@@ -281,7 +281,7 @@
   margin-left: 20rpx;
 }
 
-.t-dialog {
+.dialog {
   --td-dialog-content-font-size: 40rpx;
   --td-dialog-content-line-height: 50rpx
 }
@@ -315,4 +315,9 @@
   width: 100%;
   margin-top: 2rpx;
   /* background-color: #e0e0e0; */
+}
+
+.error-dialog{
+  --td-dialog-title-color:red;
+  --td-dialog-title-font-size:40rpx;
 }
\ No newline at end of file
diff --git a/pages/waterIntake/waterIntake.js b/pages/waterIntake/waterIntake.js
index 81ded95..68f5a3c 100644
--- a/pages/waterIntake/waterIntake.js
+++ b/pages/waterIntake/waterIntake.js
@@ -13,7 +13,12 @@
     isRefreshing_common: false,
     showConfirm: false,
     waterIntakeName: "",
-    choseItem: null
+    choseItem: null,
+    errorData: '', //閿欒鍐呭
+    showErrorDialog: false,
+    confirmBtn: {
+      content: '纭'
+    },
   },
 
   // 鍒囨崲 Tabs
@@ -67,7 +72,8 @@
     };
     post({
       url: "wx/valve/open_wx",
-      data: data
+      data: data,
+      timeout: 180000
     }).then(response => {
 
       // 澶勭悊鎴愬姛鍝嶅簲
@@ -84,13 +90,12 @@
       wx.hideLoading();
       // 澶勭悊閿欒鍝嶅簲
       console.error('璇锋眰澶辫触:', error);
-      if (error.code === "1002") {
-        wx.showToast({
-          title: '寮�闃�澶辫触',
-          icon: 'error',
-          duration: 3000 // 鎻愮ず鐨勬寔缁椂闂达紝鍗曚綅姣
-        })
-      }
+
+      this.setData({
+        showErrorDialog: true,
+        errorData: error.msg
+      })
+
     });
   },
 
@@ -151,7 +156,7 @@
    */
   getallWaterPoints: function (intakeNum) {
     let params = {
-      url: 'project/intake/all_intakes'
+      url: 'wx/intake/all_intakes'
     };
     if (intakeNum) {
       params.data = {
@@ -178,13 +183,18 @@
         this.setData({
           isRefreshing_all: false
         });
+        wx.showToast({
+          title: error.msg,
+          icon: 'error',
+          duration: 3000 // 鎻愮ず鐨勬寔缁椂闂达紝鍗曚綅姣
+        })
         console.error('Failed to add item:', error);
       });
   },
   //鑾峰彇甯哥敤鍙栨按鍙�
   getcommonWaterPoints() {
     get({
-        url: 'project/intake/used_intakes',
+        url: 'wx/intake/used_intakes',
         data: {
           operator: getApp().globalData.sessionId
         }
@@ -209,7 +219,7 @@
           isRefreshing_common: false
         });
         wx.showToast({
-          title: error.code,
+          title: error.msg,
           icon: 'error',
           duration: 3000 // 鎻愮ず鐨勬寔缁椂闂达紝鍗曚綅姣
         })
@@ -227,7 +237,7 @@
   },
   confirmDialog() {
     this.setData({
-      showConfirm:false
+      showConfirm: false
     })
     this.postOpenValva(this.data.choseItem.intakeId);
   },
@@ -235,6 +245,10 @@
     this.setData({
       showConfirm: false
     })
+  },
+  closeErrorDialog() {
+    this.setData({
+      showErrorDialog: false
+    })
   }
-
 })
\ No newline at end of file
diff --git a/pages/waterIntake/waterIntake.wxml b/pages/waterIntake/waterIntake.wxml
index f9a559a..e433296 100644
--- a/pages/waterIntake/waterIntake.wxml
+++ b/pages/waterIntake/waterIntake.wxml
@@ -51,5 +51,7 @@
     </scroll-view>
   </view>
 
-  <t-dialog class="t-dialog" visible="{{showConfirm}}" content="纭鎵撳紑{{choseItem.intakeNum}}鍚楋紵" confirm-btn="{{ { content: '纭', variant: 'base', theme: 'danger' } }}" close-on-overlay-click="false" cancel-btn="鍙栨秷"  bind:confirm="confirmDialog" bind:cancel="closeDialog" />
+  <t-dialog class="dialog" visible="{{showConfirm}}" content="纭鎵撳紑{{choseItem.intakeNum}}鍚楋紵" confirm-btn="{{ { content: '纭', variant: 'base', theme: 'danger' } }}" close-on-overlay-click="false" cancel-btn="鍙栨秷"  bind:confirm="confirmDialog" bind:cancel="closeDialog" />
+
+  <t-dialog class="error-dialog"  title="寮�闃�閿欒" visible="{{showErrorDialog}}" content="{{errorData}}" confirm-btn="{{ confirmBtn }}" bind:confirm="closeErrorDialog" />
 </view>
diff --git a/pages/waterIntake/waterIntake.wxss b/pages/waterIntake/waterIntake.wxss
index 4369c9a..519475c 100644
--- a/pages/waterIntake/waterIntake.wxss
+++ b/pages/waterIntake/waterIntake.wxss
@@ -135,7 +135,12 @@
   flex-direction: column;
   padding-bottom: 10rpx; /* 澧炲姞搴曢儴濉厖 */
 }
-.t-dialog{
+.dialog{
   --td-dialog-content-font-size:40rpx;
   --td-dialog-content-line-height:50rpx
+}
+
+.error-dialog{
+  --td-dialog-title-color:red;
+  --td-dialog-title-font-size:45rpx;
 }
\ No newline at end of file

--
Gitblit v1.8.0