loginHandle.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /**
  2. * data {
  3. * code:string;
  4. * headUrl:string;
  5. * hiId:number;
  6. * hospName:string;
  7. * id:number;
  8. * name:string
  9. * nowPermission:number;
  10. * permissions:number[];
  11. * token:string;
  12. }
  13. */
  14. export const loginAfterHandle = (data,hospSign) => {
  15. const rolList = [{
  16. permission: 1,
  17. name: '管理员',
  18. pagePath: 'pages/situationsCenter/situationsCenter'
  19. }, // targetIndexs:targetList种对应的下标
  20. {
  21. permission: 2,
  22. name: '查核组长',
  23. pagePath: 'pages/situationsCenter/situationsCenter'
  24. },
  25. {
  26. permission: 3,
  27. name: '查核组员',
  28. pagePath: 'pages/situationsCenter/situationsCenter'
  29. },
  30. {
  31. permission: 4,
  32. name: '单位负责人',
  33. pagePath: 'pages/mission/mission'
  34. },
  35. {
  36. permission: 5,
  37. name: '改善者',
  38. pagePath: 'pages/mission/mission'
  39. }
  40. ]
  41. /**
  42. * nowPermission:number
  43. */
  44. //角色和对应的跳转页面
  45. const rolToTarget = (nowPermission) => {
  46. if (nowPermission != 0) {
  47. let current = rolList.find(item => item.permission == nowPermission);
  48. if (current) {
  49. // 页面跳转
  50. uni.redirectTo({
  51. url: `/${current.pagePath}`
  52. });
  53. }
  54. }
  55. }
  56. if (data) {
  57. uni.setStorageSync('hiId', data.hiId);
  58. uni.setStorageSync('permissions', data.permissions);
  59. uni.setStorageSync('token', data.token);
  60. uni.setStorageSync('code', data.code);
  61. uni.setStorageSync('nowPermission', data.nowPermission);
  62. uni.setStorageSync('id', data.id);
  63. uni.setStorageSync('name', data.name);
  64. uni.setStorageSync('hospSign',hospSign);
  65. rolToTarget(data.nowPermission)
  66. }
  67. }