Browse Source

网络请求报错修改

lijuncheng0816
lijuncheng 1 month ago
parent
commit
082cd2658a
  1. 40
      src/api/httpRequest3.js

40
src/api/httpRequest3.js

@ -43,18 +43,40 @@ function service(options = {}) {
url: '/pages/login/index'
})
}
reject("系统异常:" + res.data.msg)
console.log("系统异常", res.data.msg)
if (res.data.msg) {
if (res.data.msg.includes('get lock')) {
reject("系统异常:" + "数据库死锁")
} else {
reject("系统异常:" + res.data.msg)
}
} else {
reject("系统异常:")
}
}
} else {
reject("系统异常:" + res.data.msg)
console.log("系统异常", res.data.msg)
if (res.data.msg) {
if (res.data.msg.includes('get lock')) {
reject("系统异常:" + "数据库死锁")
} else {
reject("系统异常:" + res.data.msg)
}
} else {
reject("系统异常:")
}
}
} else {
reject("系统异常:" + res.data.msg)
console.log("系统异常", res.data.msg)
if (res.data.msg) {
if (res.data.msg.includes('get lock')) {
reject("系统异常:" + "数据库死锁")
} else {
reject("系统异常:" + res.data.msg)
}
} else {
reject("系统异常:")
}
}
};
options.fail = (error) => {
@ -65,6 +87,8 @@ function service(options = {}) {
message = '接口请求超时'
} else if (message.includes('Request failed with status code')) {
message = '接口' + message.substr(message.length - 3) + '异常'
} else if (message.includes('get lock')) {
message = '接口' + "数据库死锁"
}
reject("系统异常:" + message);
console.log("系统异常", message)
@ -84,9 +108,9 @@ function service(options = {}) {
// #endif
// #ifdef H5
console.log("网s络H5", navigator.onLine)
if(navigator.onLine){
if (navigator.onLine) {
uni.request(options);
}else {
} else {
reject("当前无网络");
}
// #endif

Loading…
Cancel
Save