企获客基础班本接口方法等描述
This commit is contained in:
62
apis/err.js
Normal file
62
apis/err.js
Normal file
@@ -0,0 +1,62 @@
|
||||
|
||||
/**
|
||||
* 处理错误信息
|
||||
* @property {Object} errInfo
|
||||
*/
|
||||
|
||||
const errInfo = (obj) =>{
|
||||
if(obj.status_code == 401){
|
||||
wx.showModal({
|
||||
title : "登录提示",
|
||||
content : "长时间未操作,登录已过期,请重新登录",
|
||||
confirmColor: "#2d6bf6",
|
||||
confirmText : "立即登录",
|
||||
cancelText : "返回首页",
|
||||
cancelColor : "#aeafb1",
|
||||
success : res=>{
|
||||
// 清理客户端登录缓存
|
||||
wx.removeStorageSync("token")
|
||||
if(res.confirm){
|
||||
wx.navigateTo({
|
||||
url: "/pages/login/login",
|
||||
})
|
||||
//转跳到登录页面
|
||||
}else if(res.cancel){
|
||||
//考虑是否增加一个跳转首页的操作
|
||||
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