useLoginSuccess.js 948 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { useLoginUserStore } from '@/stores/loginUser'
  2. const loginUserStore = useLoginUserStore()
  3. export function useLoginSuccess() {
  4. /**
  5. * 登录成功后的操作
  6. */
  7. const loginSuccess = (user) => {
  8. loginUserStore.setLoginHospital(user.infoPermission.hospitals);
  9. loginUserStore.setLoginUser(user.user);
  10. loginUserStore.setLoginUserMenu(user.menu);
  11. let loginType = uni.getStorageSync('loginType'); //1:处理 2:报修
  12. // 判断用户标识是否为处理人
  13. if (user.user.engineer === 1) {
  14. if(loginType==1){
  15. uni.reLaunch({
  16. url: "/pages/incidentList/incidentList"
  17. })
  18. }else if(loginType==2){
  19. uni.reLaunch({
  20. url: "/pages/repair/home"
  21. })
  22. }
  23. } else {
  24. if(loginType==1){
  25. uni.reLaunch({
  26. url: "/pages/repairEntrance/repairEntrance"
  27. })
  28. }else if(loginType==2){
  29. uni.reLaunch({
  30. url: "/pages/repair/home"
  31. })
  32. }
  33. }
  34. }
  35. return {
  36. loginSuccess
  37. };
  38. }