user.js 617 B

123456789101112131415161718192021222324252627282930313233
  1. import {
  2. reqLogin
  3. } from "@/request/api.js";
  4. const state = {
  5. loginInfo: {}, //当前登录用户信息
  6. loginInfoUserDeptId: undefined, //当前登录用户所属科室id
  7. };
  8. const getters = {};
  9. const mutations = {
  10. vxLogin(state, args) {
  11. state.loginInfo = args;
  12. state.loginInfoUserDeptId = args.user.dept.id;
  13. },
  14. };
  15. const actions = {
  16. async vxLogin({
  17. commit
  18. }, args) {
  19. let result = await reqLogin(args);
  20. if (result.status == 200) {
  21. commit("vxLogin", result.user);
  22. }
  23. return result;
  24. },
  25. };
  26. export default {
  27. namespaced: true,
  28. state,
  29. getters,
  30. mutations,
  31. actions,
  32. };