接口错误提示优化
This commit is contained in:
16
http/http.js
16
http/http.js
@@ -41,7 +41,7 @@ function commonsProcess(showLoading, httpReqCallback,isreturm) {
|
|||||||
|
|
||||||
return httpReqCallback()
|
return httpReqCallback()
|
||||||
.then((httpData) => {
|
.then((httpData) => {
|
||||||
|
console.log(1)
|
||||||
reqFinishFunc(); // 请求完毕的动作
|
reqFinishFunc(); // 请求完毕的动作
|
||||||
// 从http响应数据中解构响应数据 [ 响应码、 bodyData ]
|
// 从http响应数据中解构响应数据 [ 响应码、 bodyData ]
|
||||||
let { statusCode, data } = httpData;
|
let { statusCode, data } = httpData;
|
||||||
@@ -95,15 +95,15 @@ function commonsProcess(showLoading, httpReqCallback,isreturm) {
|
|||||||
return Promise.resolve(bodyData.data || bodyData.page|| bodyData);
|
return Promise.resolve(bodyData.data || bodyData.page|| bodyData);
|
||||||
})
|
})
|
||||||
.catch((res) => {
|
.catch((res) => {
|
||||||
|
console.log(2)
|
||||||
if (res.status == 404) {
|
if (res.status == 404) {
|
||||||
infoBox.showErrorToast("接口404").then(() => {});
|
infoBox.showToast("接口404").then(() => {});
|
||||||
reject();
|
reject();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (res.code == 401) {
|
if (res.code == 401) {
|
||||||
infoBox.showErrorToast(res.message || "请登录").then(() => {
|
infoBox.showToast(res.message || "请登录").then(() => {
|
||||||
uni.redirectTo({
|
uni.redirectTo({
|
||||||
url: "/pages/login/login",
|
url: "/pages/login/login",
|
||||||
});
|
});
|
||||||
@@ -111,18 +111,18 @@ function commonsProcess(showLoading, httpReqCallback,isreturm) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (res.code != 0) {
|
if (res.code != 0) {
|
||||||
infoBox.showErrorToast(res.msg).then(() => {});
|
infoBox.showToast(res.msg).then(() => {});
|
||||||
reject();
|
reject();
|
||||||
}
|
}
|
||||||
if (res.code == 500) {
|
if (res.code == 500) {
|
||||||
infoBox.showErrorToast(res.msg || "服务器异常").then(() => {});
|
infoBox.showToast(res.msg || "服务器异常").then(() => {});
|
||||||
reject();
|
reject();
|
||||||
}
|
}
|
||||||
reqFinishFunc(); // 请求完毕的动作
|
reqFinishFunc(); // 请求完毕的动作
|
||||||
|
|
||||||
// 如果没有提示错误, 那么此处提示 异常。
|
// 如果没有提示错误, 那么此处提示 异常。
|
||||||
if (!isShowErrorToast) {
|
if (!isShowErrorToast) {
|
||||||
infoBox.showErrorToast(`请求网络异常`);
|
infoBox.showToast(`请求网络异常`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Promise.reject(res);
|
return Promise.reject(res);
|
||||||
@@ -224,7 +224,7 @@ function upload(uri, data, file, showLoading = true, extParams = {}) {
|
|||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
uni.hideLoading();
|
uni.hideLoading();
|
||||||
infoBox.showErrorToast(`上传失败`);
|
infoBox.showToast(`上传失败`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user