info.uts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * 用户信息接口
  3. */
  4. import { request } from '../../utils/request'
  5. import type { UserInfo } from '../../types/user'
  6. import { encryptAES } from '../../utils/crypto'
  7. import {getStoreIsKey} from '../../utils/storage'
  8. /**
  9. * 获取用户信息
  10. */
  11. export const getUserInfo = (userId: any): Promise<UserInfo> => {
  12. return request({
  13. url: '/system/user/'+userId,
  14. method: 'GET'
  15. })
  16. }
  17. /**
  18. * 更新用户信息
  19. */
  20. export const updateUserInfo = (userInfo: UserInfo): Promise<boolean> => {
  21. return request<boolean>({
  22. url: '/api/user/info',
  23. method: 'PUT',
  24. data: userInfo as any as UTSJSONObject
  25. })
  26. }
  27. /**
  28. * 更新密码
  29. */
  30. export const updatePassword = async (password: string, newPassword: string): Promise<any> => {
  31. let dataForm = {
  32. newPassword: newPassword,
  33. oldPassword: password
  34. };
  35. const isKey = getStoreIsKey();
  36. if(isKey == "1"){
  37. dataForm.newPassword = encryptAES(newPassword);
  38. dataForm.oldPassword = encryptAES(password);
  39. }
  40. return request({
  41. url: '/system/user/profile/updatePwd',
  42. method: 'PUT',
  43. data: dataForm,
  44. })
  45. }