Commit 02f1dc1d by 李伟康

commit 修复

1 parent 2f3e02ef
......@@ -14,13 +14,13 @@ const HOST = {
ip: 'http://192.168.9.119:8292'
};
class Request {
get(params, returnAll = false, hostType) {
get (params, returnAll = false, hostType) {
return this.request("GET", params, returnAll, hostType);
}
post(params, returnAll = false, hostType) {
post (params, returnAll = false, hostType) {
return this.request("POST", params, returnAll, hostType);
}
fetch(method, data, returnAll = true, hostType) {
fetch (method, data, returnAll = true, hostType) {
return this.post(
{
method,
......@@ -30,16 +30,16 @@ class Request {
hostType
);
}
request(RequestMethods, params, returnAll, hostType = "dj") {
request (RequestMethods, params, returnAll, hostType = "dj") {
return new Promise((resolve, reject) => {
let header =
RequestMethods === "POST"
? {
"content-type": "application/x-www-form-urlencoded",
}
"content-type": "application/x-www-form-urlencoded",
}
: {
"Cache-Control": "no-cache",
};
"Cache-Control": "no-cache",
};
let projectName = params.projectName;
if (!projectName) projectName = this.getRopProject(params.method);
const path = pathEnum[projectName];
......@@ -51,7 +51,7 @@ class Request {
header,
dataType: "json",
responseType: "text",
success(response) {
success (response) {
/**业务代码 */
let {
data: { code, message },
......@@ -77,25 +77,25 @@ class Request {
}
}
},
fail(error) {
fail (error) {
uni.hideLoading();
console.error(`${params.method}接口异常:`, error);
uni.showToast({
title:
typeof error == "string"
? error
: JSON.stringify(error) || "系统异常",
: error.errMsg ? error.errMsg : JSON.stringify(error) || "系统异常",
icon: "error",
});
reject(error);
},
complete() {
complete () {
uni.stopPullDownRefresh();
},
});
});
}
getData(params, hostType = "scrm") {
getData (params, hostType = "scrm") {
let projectName = params.projectName;
if (!projectName) projectName = this.getRopProject(params.method);
else delete params.projectName;
......@@ -127,11 +127,11 @@ class Request {
params.appKey = appKey;
return sign(params, secret, noSignAttr);
}
getRopProject(method) {
getRopProject (method) {
const projectName = method.split(".")[2];
return projectName;
}
uni_request({
uni_request ({
url,
method = "GET",
data = {},
......@@ -147,7 +147,7 @@ class Request {
header,
dataType,
responseType,
success(response) {
success (response) {
resolve(response.data);
},
});
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!