loginHandle.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. permission: 6,
  42. name: '职能科室负责人',
  43. pagePath: 'pages/situationsCenter/situationsCenter'
  44. },
  45. {
  46. permission: 7,
  47. name: '职能科室人员',
  48. pagePath: 'pages/situationsCenter/situationsCenter'
  49. },
  50. {
  51. permission: 8,
  52. name: '自查人',
  53. pagePath: 'pages/situationsCenter/situationsCenter'
  54. }
  55. ]
  56. /**
  57. * nowPermission:number
  58. */
  59. //角色和对应的跳转页面
  60. const rolToTarget = (nowPermission) => {
  61. if (nowPermission != 0) {
  62. let current = rolList.find(item => item.permission == nowPermission);
  63. if (current) {
  64. // 页面跳转
  65. uni.redirectTo({
  66. url: `/${current.pagePath}`
  67. });
  68. }
  69. }
  70. }
  71. if (data) {
  72. uni.setStorageSync('hiId', data.hiId);
  73. uni.setStorageSync('permissions', data.permissions);
  74. uni.setStorageSync('token', data.token);
  75. uni.setStorageSync('code', data.code);
  76. uni.setStorageSync('nowPermission', data.nowPermission);
  77. uni.setStorageSync('id', data.id);
  78. uni.setStorageSync('name', data.name);
  79. uni.setStorageSync('hospSign',hospSign);
  80. rolToTarget(data.nowPermission)
  81. }
  82. }