index.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // 引入拦截器配置
  2. import {
  3. requestInterceptors,
  4. responseInterceptors
  5. } from './interceptors.js'
  6. // 引入luch-request
  7. import {
  8. http
  9. } from '@/uni_modules/uview-plus'
  10. // 初始化请求配置
  11. const initRequest = (vm) => {
  12. http.setConfig((defaultConfig) => {
  13. defaultConfig.baseURL = 'http://133.46.152.185' /* 根域名 */
  14. // defaultConfig.baseURL = 'http://tkhtest.natapp1.cc' /* 根域名 */
  15. // defaultConfig.baseURL = 'http://127.0.0.1' /* 根域名 */
  16. defaultConfig = {
  17. ...defaultConfig,
  18. custom: {
  19. loading: true, //是否显示loading
  20. isCloseLoad: true, //请求返回数据后,是否关闭loading
  21. validateCode: true, //验证code
  22. },
  23. }
  24. /* defaultConfig 为默认全局配置 */
  25. // if (process.env.NODE_ENV === 'development') {
  26. // defaultConfig.baseURL = '/api' /* 根域名 */
  27. // }
  28. // if (process.env.NODE_ENV === 'production') {
  29. // defaultConfig.baseURL = '/api' /* 根域名 */
  30. // }
  31. return defaultConfig
  32. })
  33. requestInterceptors()
  34. responseInterceptors()
  35. }
  36. export {
  37. initRequest
  38. }