login.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import request from '@/utils/request'
  2. // 登录方法 test git
  3. export function login(username, password, code, uuid) {
  4. const data = {
  5. username,
  6. password,
  7. code,
  8. uuid
  9. }
  10. return request({
  11. url: '/auth/login',
  12. method: 'post',
  13. data: data
  14. })
  15. }
  16. // 注册方法
  17. export function register(data) {
  18. return request({
  19. url: '/register',
  20. headers: {
  21. isToken: false
  22. },
  23. method: 'post',
  24. data: data
  25. })
  26. }
  27. // 获取用户详细信息
  28. export function getInfo() {
  29. return request({
  30. url: '/system/user/getInfo',
  31. method: 'get'
  32. }).then(res => {
  33. try {
  34. if (!Array.isArray(res.pharmacyList) || res.pharmacyList.length === 0) {
  35. res.pharmacyList = [{id: 18, name: '默认药房'}];
  36. }
  37. } catch (err) {}
  38. return res;
  39. });
  40. }
  41. // 退出方法
  42. export function logout() {
  43. return request({
  44. url: '/auth/logout',
  45. method: 'delete'
  46. })
  47. }
  48. // 获取验证码
  49. export function getCodeImg() {
  50. return request({
  51. url: '/code',
  52. method: 'get',
  53. timeout: 20000
  54. })
  55. }
  56. //忘记密码
  57. export function forgetPwd(code, phone, pwd, password) {
  58. const data = {
  59. code,
  60. phone,
  61. pwd,
  62. password
  63. }
  64. return request({
  65. url: '/forgetPwd',
  66. method: 'post',
  67. data: data
  68. })
  69. }
  70. //发送验证码
  71. export function sendCode(data) {
  72. return request({
  73. url: `/sendCode?phone=${data}`,
  74. method: 'get',
  75. })
  76. }