Browse Source

网络请求报错修改

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

30
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)

Loading…
Cancel
Save