request.js 726 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import config, {
  2. baseUrl,
  3. loginUrl
  4. } from '@/config'
  5. let timeout = 10000
  6. console.log(loginUrl)
  7. const request = config => {
  8. console.log("登录接口----" + loginUrl + config.url)
  9. return new Promise((resolve, reject) => {
  10. uni.request({
  11. method: config.method,
  12. header: {
  13. "Content-Type": "application/x-www-form-urlencoded"
  14. },
  15. url: loginUrl + config.url,
  16. timeout: config.timeout || timeout,
  17. data: config.data,
  18. success: (res) => {
  19. console.log("----then----" + res);
  20. // let str = parseXML(res.data)
  21. resolve(res.data)
  22. },
  23. fail(error) {
  24. console.log("----then----" + error);
  25. reject(error)
  26. }
  27. })
  28. }
  29. )
  30. }
  31. export default request