Commit c4626648 by 李伟康

commit 无网络提示

1 parent 2b6bd914
...@@ -31,9 +31,21 @@ class Request { ...@@ -31,9 +31,21 @@ class Request {
); );
} }
request (RequestMethods, params, returnAll, hostType = "dj") { request (RequestMethods, params, returnAll, hostType = "dj") {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let header = let _this = this
RequestMethods === "POST" uni.getNetworkType({
success (res) {
if(res.networkType == 'none'){
uni.hideLoading();
uni.showToast({
title:'网络异常',
icon: "error",
});
reject('网络异常');
return
}
let header = RequestMethods === "POST"
? { ? {
"content-type": "application/x-www-form-urlencoded", "content-type": "application/x-www-form-urlencoded",
} }
...@@ -41,9 +53,9 @@ class Request { ...@@ -41,9 +53,9 @@ class Request {
"Cache-Control": "no-cache", "Cache-Control": "no-cache",
}; };
let projectName = params.projectName; let projectName = params.projectName;
if (!projectName) projectName = this.getRopProject(params.method); if (!projectName) projectName = _this.getRopProject(params.method);
const path = pathEnum[projectName]; const path = pathEnum[projectName];
params = this.getData(params, hostType); params = _this.getData(params, hostType);
uni.request({ uni.request({
url: `${HOST[hostType]}${path}router?method=${params.method}`, url: `${HOST[hostType]}${path}router?method=${params.method}`,
data: params, data: params,
...@@ -93,6 +105,8 @@ class Request { ...@@ -93,6 +105,8 @@ class Request {
uni.stopPullDownRefresh(); uni.stopPullDownRefresh();
}, },
}); });
}
})
}); });
} }
getData (params, hostType = "scrm") { getData (params, hostType = "scrm") {
......
const target = ["ip", "dev", "uat", "prod", "beta"]; const target = ["ip", "dev", "uat", "prod", "beta"];
const index = 1; const index = 2;
/** /**
* *
0本地 0本地
...@@ -116,7 +116,6 @@ const CONFIG_ENV_MAP = { ...@@ -116,7 +116,6 @@ const CONFIG_ENV_MAP = {
3: "production", 3: "production",
4: "beta", 4: "beta",
}; };
console.log(secretKey, "===");
module.exports = { module.exports = {
index, index,
domain, domain,
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!