From b7b4cb32f94622fbb91a8a5b1c7ea22bdbb19995 Mon Sep 17 00:00:00 2001
From: 付延余 <f-yanyu@outlook.com>
Date: 星期五, 19 八月 2022 11:09:53 +0800
Subject: [PATCH] 正式域名配置
---
utils/request.js | 25 ++++++++++++-------------
1 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/utils/request.js b/utils/request.js
index 43fa9c7..abe7958 100644
--- a/utils/request.js
+++ b/utils/request.js
@@ -23,16 +23,11 @@
duration: 2000
});
setTimeout(() => {
- try {
uni.clearStorageSync();
// 閲嶅畾鍚戠櫥褰�
uni.redirectTo({
url: '/pages/login/login'
})
- } catch (e) {
- // error
- console.log(e)
- }
}, 2000);
return false;
}
@@ -73,7 +68,7 @@
title: response.data.msg,
icon: 'error',
position: 'top',
- duration: 1000
+ duration: 2000
})
return false;
}
@@ -87,24 +82,28 @@
500: responseError
}
+// let BaseUrl = 'http://192.168.3.159:9999';
+// const BaseUrl = 'https://mx.jzeg.cn:443/app';
+const BaseUrl = "https://mx.jzeg.cn:9998";
// 璇锋眰鎷︽埅
-const fetch = (url, opt) => {
+const fetch = (url, opt ,urlParam) => {
+
let urls = (api[opt.url]?.url || api[url]?.url || jihua[opt.url]?.url || jihua[url]?.url);
let params = opt.params ? ('?' + Object.keys(opt.params).map(key => key + '=' + opt.params[key]).join('&')) :
'';
- opt.url = urls + params
+ opt.url = urlParam ? BaseUrl + urls + `/${urlParam}` + params : BaseUrl + urls + params
opt.method = opt.method || "GET";
var header = {}
if (uni.getStorageSync('access_token')) {
header = {
"TENANT-ID": 5,
Authorization: 'Bearer ' + uni.getStorageSync('access_token'),
- VERSION: "zzl"
+ VERSION: "zzl",
+ Accept:'application/json, text/plain, */*' // 瀹㈡埛绔墍鑳芥帴鍙楃殑鏁版嵁绫诲瀷
}
}
- // 'Bearer'
- // 'version:zzl'
+
opt.header = {
...opt.header,
...header
@@ -136,7 +135,6 @@
statusCode,
data
} = resp;
-
// 楠岃瘉http鐘舵�佺爜
const handlerHTTPStatus = handlerCode[statusCode];
@@ -154,5 +152,6 @@
export {
- fetch
+ fetch,
+ BaseUrl
}
--
Gitblit v1.9.1