year.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import axios from 'axios';
  2. //获取列表
  3. export function getLoginUser(){
  4. return axios.get('/user/cur').then(result => result.data)
  5. }
  6. //登录
  7. export function login({username, password,loginFrom}) {
  8. return axios({
  9. method: 'post',
  10. url: '/login',
  11. data: {
  12. username,
  13. password,
  14. loginFrom
  15. },
  16. transformRequest: [function(data) {
  17. let ret = ''
  18. for (let it in data) {
  19. ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
  20. }
  21. return ret;
  22. }],
  23. headers: {
  24. // 'Content-Type': 'application/x-www-form-urlencoded'
  25. }
  26. }).then(res => res.data)
  27. }
  28. //验证身份唯一
  29. export function checkOnly(name){
  30. return axios.get('/open/user/checkUsername?username=' + name).then(result => result.data)
  31. }
  32. //注册
  33. export function register(reg) {
  34. return axios({
  35. method: 'post',
  36. url: '/open/user/register',
  37. data: reg
  38. }).then(res => res.data)
  39. }
  40. //登出
  41. export function logout() {
  42. return axios.get('/logout').then(res => res.data);
  43. }