index.js 522 B

123456789101112131415161718192021222324
  1. // 引入配置
  2. import config from '@/common/config'
  3. // 引入拦截器配置
  4. import {
  5. requestInterceptors,
  6. responseInterceptors
  7. } from './interceptors.js'
  8. // 引入luch-request
  9. import {
  10. http
  11. } from '@/uni_modules/uview-plus'
  12. // 初始化请求配置
  13. const initRequest = (vm) => {
  14. http.setConfig((defaultConfig) => {
  15. /* defaultConfig 为默认全局配置 */
  16. defaultConfig.baseURL = config.baseUrl /* 根域名 */
  17. return defaultConfig
  18. })
  19. requestInterceptors()
  20. responseInterceptors()
  21. }
  22. export {
  23. initRequest
  24. }