api.js 733 B

1234567891011121314151617181920212223242526272829303132333435
  1. function request(config = {}) {
  2. let s4 = new SM4Util();
  3. let postCfg = {
  4. headers: {
  5. 'Content-Type': 'application/json',
  6. 'Authorization': "Bearer " + localStorage.getItem("GlWorkPlatform-AccessToken")
  7. }
  8. };
  9. let {
  10. url,
  11. data,
  12. header = {}
  13. } = config
  14. url = apiurljs.login + url
  15. let headers = {
  16. 'Content-Type': 'application/json',
  17. 'Authorization': "Bearer " + localStorage.getItem("GlWorkPlatform-AccessToken")
  18. }
  19. return new Promise((resolve, reject) => {
  20. axios.post(url, {
  21. data: s4.encryptData_CBC(JSON.stringify(data))
  22. }, {headers})
  23. .then(response => {
  24. resolve(strToJson(s4.decryptData_CBC(response.data.data)))
  25. })
  26. .catch(error => {
  27. reject(error)
  28. });
  29. })
  30. }