index.js 703 B

12345678910111213141516171819202122232425262728
  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://tkhtest.natapp1.cc' /* 根域名 */
  14. /* defaultConfig 为默认全局配置 */
  15. // if (process.env.NODE_ENV === 'development') {
  16. // defaultConfig.baseURL = '/api' /* 根域名 */
  17. // }
  18. // if (process.env.NODE_ENV === 'production') {
  19. // defaultConfig.baseURL = '/api' /* 根域名 */
  20. // }
  21. return defaultConfig
  22. })
  23. requestInterceptors()
  24. responseInterceptors()
  25. }
  26. export {
  27. initRequest
  28. }