From 25ebc714977470b5ed02b0ec7f30ea0615ebd89f Mon Sep 17 00:00:00 2001
From: zuoxiao <zuoxiao>
Date: 星期五, 14 三月 2025 16:48:09 +0800
Subject: [PATCH] 更新应用配置,添加AppID并修改页面路由;优化取水口界面,增加定时开阀功能和相关参数设置;修复首页反馈图标及提示信息。

---
 api/request.js |   28 ++++++++++++++++++----------
 1 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/api/request.js b/api/request.js
index 62f4b83..1f7bc0a 100644
--- a/api/request.js
+++ b/api/request.js
@@ -1,9 +1,7 @@
 // 寮曞叆鐘舵�佺爜statusCode
 const statusCode = require('./statusCode')
 // 瀹氫箟璇锋眰璺緞, BASEURL: 鏅�氳姹侫PI; CBASEURL: 涓彴API,涓嶄娇鐢ㄤ腑鍙板彲涓嶅紩鍏BASEURL
-const {
-  BASEURL
-} = require('./config')
+const config = require('./config')
 // 瀹氫箟榛樿鍙傛暟
 const defaultOptions = {
   data: {},
@@ -31,11 +29,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,13 +44,22 @@
       '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;
+  header.appId = app.globalData.AppID;
   return new Promise((resolve, reject) => {
-    console.log("url:" + BASEURL + url);
+    // 鑾峰彇鏈�鏂扮殑 BASEURL
+    let currentBaseUrl = app.globalData.baseUrl || config.BASEURL;
+    
+    console.log("url:" + currentBaseUrl + url);
     if (isShowLoding) {
       wx.showLoading({
         title: '閫氫俊涓�...', // 鍔犺浇鍔ㄧ敾鏍囬
@@ -62,13 +70,14 @@
     if (url.startsWith('http')) {
       myUrl = url;
     } else {
-      myUrl = BASEURL + url;
+      myUrl = currentBaseUrl + url;
     }
     wx.request({
       url: myUrl,
       data,
       header,
       method,
+      timeout: timeout,
       success: (res) => {
         let {
           statusCode: code
@@ -80,7 +89,7 @@
         if (code === statusCode.SUCCESS) {
           if (res.data.code !== "0001") {
             // 缁熶竴澶勭悊璇锋眰閿欒
-            showToast(res.data.errorMsg)
+            // showToast(res.data.errorMsg)
             reject(res.data)
             return
           }
@@ -101,8 +110,7 @@
         if (isShowLoding) {
           wx.hideLoading(); // 闅愯棌鍔犺浇鍔ㄧ敾
         }
-
-        showToast(err.errMsg)
+        // showToast(err.errMsg)
         reject(err)
       }
     })

--
Gitblit v1.8.0