user.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { getMobileUserInfo } from '@/api/index';
  2. import { selectAllocationPermission } from '@/api/week';
  3. const user = {
  4. state: {
  5. userInfo: null,
  6. activaTypeStore: null,
  7. },
  8. mutations: {
  9. SET_USER_INFO: (state, userInfo) => {
  10. state.userInfo = userInfo;
  11. },
  12. SET_ACTIVA_TYPE_STORE: (state, value) => {
  13. state.activaTypeStore = value;
  14. },
  15. SET_ASSIGN_FLAG: (state, value) => {
  16. state.isAssignFlag = value;
  17. },
  18. },
  19. actions: {
  20. // 获取用户信息
  21. getUserInfo({ dispatch, commit, state }) {
  22. return new Promise((resolve, reject) => {
  23. getMobileUserInfo()
  24. .then((res) => {
  25. commit('SET_USER_INFO', res.data);
  26. localStorage.setItem('nickName', res.data.nickName);
  27. localStorage.setItem('postName', res.data.postName);
  28. localStorage.setItem('zipPhoto', res.data.zipPhoto);
  29. localStorage.setItem('deptLevel', res.data.depts[0].deptLevel);
  30. localStorage.setItem('userId', res.data.userId);
  31. resolve();
  32. })
  33. .catch((error) => {
  34. reject(error);
  35. });
  36. });
  37. },
  38. // 储存提示类-未拜访-从那个店铺类型进入未拜访列表
  39. setActivaTypeStore({ commit }, value) {
  40. commit('SET_ACTIVA_TYPE_STORE', value);
  41. },
  42. },
  43. };
  44. export default user;