Browse Source

网络请求报错修改

lijuncheng0816
lijuncheng 3 months ago
parent
commit
082cd2658a
  1. 34
      src/api/httpRequest3.js

34
src/api/httpRequest3.js

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

Loading…
Cancel
Save