request.js 537 B

123456789101112131415161718192021222324252627282930
  1. let baseUrl = "http://test.cloud.boyuantech.net:9001"
  2. function
  3. request(url, method, data) {
  4. uni.showLoading({
  5. title: '加载中'
  6. })
  7. let header = {
  8. Token: uni.getStorageSync('Token')
  9. }
  10. return new Promise(
  11. (resolve, reject) => {
  12. uni.request({
  13. url: baseUrl + url,
  14. method: method || 'get',
  15. data: data || {},
  16. header,
  17. success: (result) => {
  18. uni.hideLoading()
  19. resolve(result.data)
  20. },
  21. fail: (err) => {
  22. reject(err)
  23. console.log(err, 'err');
  24. }
  25. })
  26. }
  27. )
  28. }
  29. export default request