api.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. var LayuiGetJson = param => {
  2. return new Promise((resovle, reject) => {
  3. $.ajax({
  4. type: param.type || "get",
  5. async: param.async || true,
  6. url: param.url,
  7. data: param.data || {},
  8. header:{
  9. "Content-Type": "application/json;charset=utf-8",
  10. "Authorization":"Bearer " + localStorage.getItem("token")
  11. },
  12. success: res => {
  13. resovle(res);
  14. },
  15. error: err => {
  16. reject(err);
  17. }
  18. })
  19. })
  20. }
  21. var LayuiPostJson = param => {
  22. return new Promise((resovle, reject) => {
  23. $.ajax({
  24. type: param.type || "post",
  25. async: param.async || true,
  26. url: param.url,
  27. data: param.data || {},
  28. header:{
  29. "Content-Type": "application/json;charset=utf-8",
  30. "Authorization":"Bearer " + localStorage.getItem("token")
  31. },
  32. success: res => {
  33. resovle(res);
  34. },
  35. error: err => {
  36. reject(err);
  37. }
  38. })
  39. })
  40. }
  41. // 接口配置
  42. const HOST = "http://47.108.130.28:8000"
  43. var LOGINAPI = HOST + "/v1/login"