小程序整合完毕

This commit is contained in:
aixianling
2022-06-29 18:27:54 +08:00
parent 3c762e0f69
commit 2bbc303c00

View File

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