整合应用进入判断

This commit is contained in:
aixianling
2022-06-29 17:59:29 +08:00
parent 4f1592540e
commit 2655a44573
3 changed files with 34 additions and 26 deletions

View File

@@ -61,6 +61,37 @@ export const user = {
if (count <= 3) {
return dispatch("getCode").then(code => dispatch("getToken", code).catch(() => dispatch("autoLogin", ++count)))
} else return Promise.reject("登录失败,请联系管理员")
},
authCheck({state, dispatch}, {checkType, modulePath}) {
//用于进入应用的权限判断
//checkType 1、登录认证 2、居民认证 3、党员认证
//判断是否需要校验认证信息
let {token, user: userInfo} = state
if (!checkType) {
//如果需要校验认证信息,必定要先验证是否登录
uni.navigateTo({url: modulePath});
} else if (checkType == 1) {
if (!token) {
return dispatch('autoLogin');
}
uni.navigateTo({url: modulePath});
} else if (checkType == 2) {
if (!token) {
return dispatch('autoLogin');
}
if (!(userInfo.residentId && userInfo.status == 2)) {
return uni.navigateTo({url: '/mods/AppAuth/AppAuth'});
}
uni.navigateTo({url: modulePath});
} else if (checkType == 3) {
if (!token) {
return dispatch('autoLogin');
}
if (!userInfo.partyId) {
return uni.showToast({title: "您还不是党员,暂时无法使用该功能", icon: "none"});
}
uni.navigateTo({url: modulePath});
}
}
}
}