ajax.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. const baseUrl="https://oa.g107.com/";
  2. var header={
  3. 'Content-Type': 'application/x-www-form-urlencoded',
  4. 'A-Token':'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvb2EuZzEwNy5jb21cL2FwaVwvaW50ZWdyYWxcL3dvcmtcL2xpc3QiLCJpYXQiOjE1OTM2NzYwNTQsImV4cCI6MTU5Mzg2NzExMiwibmJmIjoxNTkzODMxMTEyLCJqdGkiOiJlWXM0QWpUNXZDa3I3cTNHIiwic3ViIjoxNDMsInBydiI6ImNhNjQ4OWQ1MGYyNDA3YTY3ODMwZTgwOTBkMDE0ODgzNTY4NTk2MmIiLCJyb2xlIjoiZW1wbG95ZWUifQ.R3Y_3zr4BWpuuEmXKr2H3mvmI7wzHxPI0-lIw59Kvbk'
  5. }
  6. export function post(url,data,onsuccess,onfail,oncomplete=function(){}){
  7. // Content-Type为application/x-www-form-urlencoded即默认的接口请求方式
  8. dd.httpRequest({
  9. url: baseUrl+url,
  10. method: 'POST',
  11. headers:header,
  12. data:data,
  13. dataType: 'json',
  14. success: function(res) {
  15. onsuccess(res);
  16. },
  17. fail: function(res) {
  18. onfail(res);
  19. },
  20. complete: function(res) {
  21. oncomplete(res);
  22. }
  23. });
  24. };
  25. export function get(url,data,onsuccess,onfail,oncomplete=function(){}){
  26. // Content-Type为application/x-www-form-urlencoded即默认的接口请求方式
  27. dd.httpRequest({
  28. url: baseUrl+url,
  29. method: 'GET',
  30. headers:header,
  31. data:data,
  32. dataType: 'json',
  33. success: function(res) {
  34. onsuccess(res);
  35. },
  36. fail: function(res) {
  37. onfail(res);
  38. },
  39. complete: function(res) {
  40. oncomplete(res);
  41. }
  42. });
  43. };