login.uts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * 登录接口
  3. */
  4. import { request } from '../../utils/request'
  5. import { encryptAES } from '../../utils/crypto'
  6. import {getStoreIsKey} from '../../utils/storage'
  7. /**
  8. * 账号密码登录
  9. * @returns 返回整个响应对象 { status, msg, success, data }
  10. */
  11. export const loginByAccount = async (username: string, password: string): Promise<any> => {
  12. let dataForm = {
  13. username: username,
  14. password: password,
  15. deviceCode: 'app',
  16. };
  17. /* const isKey = getStoreIsKey();
  18. if(isKey == "1"){
  19. dataForm.username = encryptAES(username);
  20. dataForm.password = encryptAES(password);
  21. } */
  22. return request({
  23. url: '/login',
  24. method: 'POST',
  25. header: {
  26. isToken: false,
  27. repeatSubmit: false
  28. },
  29. data: dataForm,
  30. })
  31. }
  32. /**
  33. * SSO账号登录
  34. * @returns 返回整个响应对象 { status, msg, success, data }
  35. */
  36. export const loginSSO = async (ticket: string): Promise<any> => {
  37. return request({
  38. url: `/callback`,
  39. method: 'POST',
  40. header: {
  41. isToken: false,
  42. repeatSubmit: false
  43. },
  44. data: { ticket: ticket }
  45. })
  46. }
  47. export const getUserInfo = ():Promise<any> =>{
  48. return request({
  49. url: '/getInfo',
  50. method: 'GET'
  51. })
  52. }
  53. export const resetPassword = async (username: string, password: string, newPassword: string): Promise<any> => {
  54. let dataForm = {
  55. username: username,
  56. newPassword: newPassword,
  57. password: password
  58. };
  59. return request({
  60. url: '/initPassword',
  61. method: 'PUT',
  62. header: {
  63. isToken: false,
  64. repeatSubmit: false
  65. },
  66. data: dataForm,
  67. })
  68. }
  69. export const getIsKey = ():Promise<any> =>{
  70. return request({
  71. url: '/crypto/isKey',
  72. method: 'GET'
  73. })
  74. }