From 2bbc303c007261002510b40efd639f21d9fdc267 Mon Sep 17 00:00:00 2001 From: aixianling Date: Wed, 29 Jun 2022 18:27:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=95=B4=E5=90=88?= =?UTF-8?q?=E5=AE=8C=E6=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/utils/modules.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/utils/modules.js b/src/components/utils/modules.js index e3bf59d..38f5b9e 100644 --- a/src/components/utils/modules.js +++ b/src/components/utils/modules.js @@ -62,22 +62,22 @@ export const user = { return dispatch("getCode").then(code => dispatch("getToken", code).catch(() => dispatch("autoLogin", ++count))) } else return Promise.reject("登录失败,请联系管理员") }, - authCheck({state, dispatch}, {checkType, modulePath}) { + authCheck({state, dispatch, rootState}, {checkType, modulePath}) { //用于进入应用的权限判断 //checkType 1、登录认证 2、居民认证 3、党员认证 //判断是否需要校验认证信息 - let {token, user: userInfo} = state + let {user: userInfo, token} = rootState if (!checkType) { //如果需要校验认证信息,必定要先验证是否登录 uni.navigateTo({url: modulePath}); } else if (checkType == 1) { if (!token) { - return dispatch('autoLogin'); + return dispatch('autoLogin').then(() => dispatch('authCheck', {checkType, modulePath})); } uni.navigateTo({url: modulePath}); } else if (checkType == 2) { if (!token) { - return dispatch('autoLogin'); + return dispatch('autoLogin').then(() => dispatch('authCheck', {checkType, modulePath})); } if (!(userInfo.residentId && userInfo.status == 2)) { return uni.navigateTo({url: '/mods/AppAuth/AppAuth'}); @@ -85,9 +85,9 @@ export const user = { uni.navigateTo({url: modulePath}); } else if (checkType == 3) { 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"}); } uni.navigateTo({url: modulePath});