|
@@ -89,7 +89,7 @@ function getFunList() {
|
|
|
}
|
|
|
//console.log(funList)
|
|
|
|
|
|
-const auth = (to, from, next) => {
|
|
|
+const checkAuth = (to, from, next) => {
|
|
|
if (to.meta != null && to.meta.requireAuth) {
|
|
|
if (store.state.person_data || store.state.fun_list) {
|
|
|
|
|
@@ -125,12 +125,36 @@ const checkRole = (to, from, next) => {
|
|
|
API_User.exchangePopedom({
|
|
|
id: to.query.role_id
|
|
|
}).then(response => {
|
|
|
- auth(to, from, next)
|
|
|
+ checkFun(to, from, next)
|
|
|
}).catch(error => {
|
|
|
mui.toast(error);
|
|
|
})
|
|
|
} else {
|
|
|
- auth(to, from, next)
|
|
|
+ checkFun(to, from, next)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const checkFun = (to, from, next) => {
|
|
|
+ //如果funlist不存在,在更新版本号清空后,先重新请求再判断
|
|
|
+ var token = to.query.token;
|
|
|
+ if (token) {
|
|
|
+ //这里token一定要存在,从微信模板消息带过来的
|
|
|
+ API_User.getAllFunList(token).then(response => {
|
|
|
+
|
|
|
+ if (response && response.allIcon) {
|
|
|
+ var allIcon = response.allIcon;
|
|
|
+ store.commit('SET_FUN_LIST', allIcon);
|
|
|
+
|
|
|
+ checkAuth(to, from, next);
|
|
|
+ } else {
|
|
|
+ mui.toast('token已过期');
|
|
|
+ }
|
|
|
+
|
|
|
+ }).catch(error => {
|
|
|
+ mui.toast(error);
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ checkAuth(to, from, next);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -154,31 +178,7 @@ router.beforeEach((to, from, next) => {
|
|
|
store.commit('SET_TOKEN', to.query.token);
|
|
|
}
|
|
|
|
|
|
- //如果funlist不存在,在更新版本号清空后,先重新请求再判断
|
|
|
- if (!store.state.fun_list) {
|
|
|
- var token = to.query.token;
|
|
|
- if (token) {
|
|
|
- //这里token一定要存在,从微信模板消息带过来的
|
|
|
- API_User.getAllFunList(token).then(response => {
|
|
|
-
|
|
|
- if (response && response.allIcon) {
|
|
|
- var allIcon = response.allIcon;
|
|
|
- store.commit('SET_FUN_LIST', allIcon);
|
|
|
-
|
|
|
- checkRole(to, from, next);
|
|
|
- } else {
|
|
|
- mui.toast('token已过期');
|
|
|
- }
|
|
|
-
|
|
|
- }).catch(error => {
|
|
|
- mui.toast(error);
|
|
|
- })
|
|
|
- } else {
|
|
|
- checkRole(to, from, next);
|
|
|
- }
|
|
|
- } else {
|
|
|
- checkRole(to, from, next);
|
|
|
- }
|
|
|
+ checkRole(to, from, next);
|
|
|
|
|
|
})
|
|
|
|