[本时生活小程序-线上备份]
This commit is contained in:
54
api/err.js
Normal file
54
api/err.js
Normal file
@@ -0,0 +1,54 @@
|
||||
|
||||
/**
|
||||
* 处理错误信息
|
||||
* @property {Object} errInfo
|
||||
*/
|
||||
|
||||
const errInfo = (obj) =>{
|
||||
if(obj.status_code == 401){
|
||||
wx.showModal({
|
||||
title : "登录提示",
|
||||
content : "长时间未操作,登录已过期,请重新登录",
|
||||
showCancel : false,
|
||||
confirmColor: "#0b0041",
|
||||
confirmText : "确定",
|
||||
success : ()=>{
|
||||
// 清理客户端登录缓存
|
||||
wx.removeStorageSync("token")
|
||||
// 返回首页
|
||||
wx.redirectTo({
|
||||
url: "/pages/index/index",
|
||||
})
|
||||
}
|
||||
})
|
||||
}else if(obj.status_code == 422){
|
||||
wx.showToast({
|
||||
title: obj.message,
|
||||
icon : "none"
|
||||
})
|
||||
}else if(obj.status_code == 400 || obj.status_code == 0){
|
||||
wx.showToast({
|
||||
title: obj.message,
|
||||
icon : "none"
|
||||
})
|
||||
}else if(obj.status_code == 404){
|
||||
wx.showToast({
|
||||
title: "接口地址不存在,请联系系统管理员",
|
||||
icon : "none"
|
||||
})
|
||||
}else if(obj.status_code == 500){
|
||||
wx.showToast({
|
||||
title: "服务端:" + obj.message,
|
||||
icon : "none"
|
||||
})
|
||||
}else {
|
||||
wx.showToast({
|
||||
title: "code:" + obj.status_code + ", msg:" + obj.message,
|
||||
icon : "none"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
errInfo
|
||||
}
|
||||
Reference in New Issue
Block a user