Commit f3830937 authored by liwenhong's avatar liwenhong

fix:刷新丢失权限

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