index.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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://tkhtest.natapp1.cc' /* 根域名 */
  16. defaultConfig.baseURL = 'http://127.0.0.1' /* 根域名 */
  17. defaultConfig = {
  18. ...defaultConfig,
  19. custom: {
  20. loading: true, //是否显示loading
  21. isCloseLoad: true, //请求返回数据后,是否关闭loading
  22. validateCode: true, //验证code
  23. },
  24. }
  25. /* defaultConfig 为默认全局配置 */
  26. // if (process.env.NODE_ENV === 'development') {
  27. // defaultConfig.baseURL = '/api' /* 根域名 */
  28. // }
  29. // if (process.env.NODE_ENV === 'production') {
  30. // defaultConfig.baseURL = '/api' /* 根域名 */
  31. // }
  32. return defaultConfig
  33. })
  34. requestInterceptors()
  35. responseInterceptors()
  36. }
  37. export {
  38. initRequest
  39. }