login.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import api from './index'
  2. import { axios } from '@/utils/request'
  3. export function login ({ username, password }) {
  4. return axios({
  5. url: 'auth/login',
  6. data: { username, password },
  7. method: 'post',
  8. headers:{
  9. 'module': encodeURIComponent('登录')
  10. }
  11. })
  12. }
  13. export function logout () {
  14. return axios({
  15. url: 'auth/logout',
  16. method: 'get',
  17. headers:{
  18. 'module': encodeURIComponent('登出')
  19. }
  20. })
  21. }
  22. export function getSmsCaptcha (parameter) {
  23. return axios({
  24. url: api.SendSms,
  25. method: 'post',
  26. data: parameter
  27. })
  28. }
  29. export function getInfo () {
  30. return axios({
  31. url: '/user/info',
  32. method: 'get',
  33. headers: {
  34. 'Content-Type': 'application/json;charset=UTF-8'
  35. }
  36. })
  37. }
  38. export function getCurrentUserNav (token) {
  39. return axios({
  40. url: '/user/nav',
  41. method: 'get'
  42. })
  43. }
  44. /**
  45. * get user 2step code open?
  46. * @param parameter {*}
  47. */
  48. export function get2step (parameter) {
  49. return axios({
  50. url: api.twoStepCode,
  51. method: 'post',
  52. data: parameter
  53. })
  54. }
  55. // 修改密码
  56. export function changePwd (parameter) {
  57. return axios({
  58. url: '/user/changePWD',
  59. method: 'post',
  60. data: parameter,
  61. headers:{
  62. 'module': encodeURIComponent('修改密码')
  63. }
  64. })
  65. }