data_request.js 773 B

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