From a84175b5e189ac6da0d80ac64f77a4b45e7c9157 Mon Sep 17 00:00:00 2001
From: zuoxiao <470321431@qq.com>
Date: 星期四, 14 十一月 2024 13:48:34 +0800
Subject: [PATCH] 1.添加瞬时流量相关2.优化界面3.修改原开阀和未关阀列表的sessionId为clientId
---
api/request.js | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/api/request.js b/api/request.js
index 0833bc0..985fe4c 100644
--- a/api/request.js
+++ b/api/request.js
@@ -33,7 +33,8 @@
form,
isShowLoding,
timeout,
- header
+ header,
+ useParams
} = _options
const app = getApp()
// 璁剧疆璇锋眰澶�
@@ -56,6 +57,8 @@
header.Authorization = `Bearer ${token}`
}
header.tag = app.globalData.tag;
+ header.appId = app.globalData.AppID;
+
return new Promise((resolve, reject) => {
console.log("url:" + BASEURL + url);
if (isShowLoding) {
@@ -70,6 +73,12 @@
} else {
myUrl = BASEURL + url;
}
+ // 濡傛灉 useParams 涓� true锛屾嫾鎺ユ煡璇㈠弬鏁�
+ if (useParams && data) {
+ const queryString = objToQueryString(data); // 浣跨敤涓婇潰瀹氫箟鐨勫嚱鏁�
+ myUrl += `?${queryString}`; // 鎷兼帴鏌ヨ瀛楃涓�
+ data = {}; // 璇锋眰浣撴暟鎹涓虹┖
+ }
wx.request({
url: myUrl,
data,
@@ -114,7 +123,14 @@
})
})
}
-
+function objToQueryString(obj) {
+ return Object.keys(obj)
+ .map(key => {
+ // 瀵归敭鍜屽�艰繘琛� URL 缂栫爜
+ return `${encodeURIComponent(key)}=${encodeURIComponent(obj[key])}`;
+ })
+ .join('&'); // 灏嗘墍鏈夐敭鍊煎鐢� '&' 杩炴帴璧锋潵
+}
// 灏佽toast鍑芥暟
function showToast(title, icon = 'none', duration = 2500, mask = false) {
wx.showToast({
--
Gitblit v1.8.0