Commit f3830937 authored by liwenhong's avatar liwenhong

fix:刷新丢失权限

parent dfafbc36
.DS_Store .DS_Store
node_modules node_modules
*.lock *.lock
package-lock.json *package-lock.json
*.log *.log
dist dist
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
<script> <script>
import { getCookie, redirectToLogin } from "@/utils/util"; import { getCookie, redirectToLogin } from "@/utils/util";
import { fetchCurrentUser } from "./service/user";
export default { export default {
async mounted() { async mounted() {
...@@ -19,6 +20,16 @@ export default { ...@@ -19,6 +20,16 @@ export default {
this.$message('请先登录'); this.$message('请先登录');
return redirectToLogin(); return redirectToLogin();
} }
if (!this.$store.state.permissions) {
const { status, user } = await fetchCurrentUser();
if (status === "success") {
this.$store.commit("updateUserInfo", user);
await this.$store.dispatch("updateUserPermission", { email: user.email });
this.$store.dispatch("fetchPermission", {
appId: "merchant-op-auditing",
});
}
}
}, },
}; };
</script> </script>
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<script> <script>
import { createNamespacedHelpers } from 'vuex' import { createNamespacedHelpers } from 'vuex'
const { mapActions } = createNamespacedHelpers('login') const { mapActions } = createNamespacedHelpers('login')
// import { fetchCurrentUser } from "@/service/user"; import { fetchCurrentUser } from "@/service/user";
import { redirectPage } from "@/utils/util"; import { redirectPage } from "@/utils/util";
import { import {
// getAll_role_list as reqGetAll_role_list, // getAll_role_list as reqGetAll_role_list,
...@@ -62,27 +62,21 @@ export default { ...@@ -62,27 +62,21 @@ export default {
} }
this.userInfo.email = email.indexOf("@") === -1 ? email + "@yidian-inc.com" : email; this.userInfo.email = email.indexOf("@") === -1 ? email + "@yidian-inc.com" : email;
const res = await this.userLogin({ payload: this.userInfo }); const res = await this.userLogin({ payload: this.userInfo });
// res && await this.fentchUser() res && await this.fentchUser()
res && redirectPage() redirectPage()
// reqGetAll_role_list(email).then(res => {
// this.permissionsAll = res
// console.log('permissionsAll',this.permissionsAll)
// })
// this.$router.push('/')
}, },
// async fentchUser() { async fentchUser() {
// if (this.$store.state.permissions && this.$store.state.userInfo) return; if (!this.$store.state.permissions) {
// // const { status, user } = await fetchCurrentUser(); const { status, user } = await fetchCurrentUser();
// // if (status === "success") { if (status === "success") {
// this.$store.commit("updateUserInfo", this.userInfo); this.$store.commit("updateUserInfo", user);
// this.$store.dispatch("updateUserPermission", { email: this.userInfo.email }); await this.$store.dispatch("updateUserPermission", { email: user.email });
// // 无奈之举,后期需要重构到提现管理中 this.$store.dispatch("fetchPermission", {
// this.$store.dispatch("fetchPermission", { appId: "merchant-op-auditing",
// appId: "merchant-op-auditing", });
// }); }
// // } }
// } }
}, },
}; };
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment