api.js 1.3 KB

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