passport.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /**
  2. * Created by Andste on 2018/5/2.
  3. * 用户认证相关API
  4. */
  5. import storage from "@/utils/storage.js";
  6. import { http, Method } from "@/utils/request.js";
  7. import { md5 } from "@/utils/md5.js";
  8. /**
  9. * 普通登录
  10. * @param username
  11. * @param password
  12. * @param captcha
  13. */
  14. export function login(username, password, captcha) {
  15. return http.request({
  16. url: "passport/login",
  17. method: Method.POST,
  18. params: {
  19. username,
  20. password: md5(password),
  21. captcha,
  22. uuid: storage.getUuid(),
  23. },
  24. });
  25. }
  26. /**
  27. * 验证账户信息
  28. * @param captcha
  29. * @param account
  30. */
  31. export function validAccount(captcha, account) {
  32. return http.request({
  33. url: "passport/find-pwd",
  34. method: Method.GET,
  35. params: {
  36. uuid: storage.getUuid(),
  37. captcha,
  38. account,
  39. },
  40. });
  41. }
  42. /**
  43. * 发送找回密码短信
  44. * @param uuid
  45. * @param captcha
  46. */
  47. export function sendFindPasswordSms(uuid, captcha) {
  48. return http.request({
  49. url: "passport/find-pwd/send",
  50. method: Method.POST,
  51. header: { "content-type": "application/x-www-form-urlencoded" },
  52. data: {
  53. uuid: uuid,
  54. captcha,
  55. },
  56. });
  57. }
  58. /**
  59. * 校验找回密码验证码
  60. * @param uuid
  61. * @param sms_code
  62. */
  63. export function validFindPasswordSms(uuid, sms_code) {
  64. return http.request({
  65. url: "passport/find-pwd/valid",
  66. method: Method.GET,
  67. params: {
  68. uuid,
  69. sms_code,
  70. },
  71. });
  72. }
  73. /**
  74. * 修改密码【找回密码用】
  75. * @param password
  76. * @param uuid
  77. */
  78. export function changePassword(password, uuid) {
  79. if (!uuid) {
  80. uuid = storage.getUuid();
  81. }
  82. return http.request({
  83. url: "passport/find-pwd/update-password",
  84. method: Method.PUT,
  85. header: { "content-type": "application/x-www-form-urlencoded" },
  86. data: {
  87. uuid,
  88. password: md5(password),
  89. },
  90. });
  91. }
  92. // 保存生物认证登录
  93. export function setBiolofy(params) {
  94. return http.request({
  95. url: `passport/login/save/biology`,
  96. method: "POST",
  97. params,
  98. });
  99. }