1234567891011121314151617181920212223242526272829303132333435363738 |
- // 引入拦截器配置
- import {
- requestInterceptors,
- responseInterceptors
- } from './interceptors.js'
- // 引入luch-request
- import {
- http
- } from '@/uni_modules/uview-plus'
- // 初始化请求配置
- const initRequest = (vm) => {
- http.setConfig((defaultConfig) => {
- defaultConfig.baseURL = 'http://8.155.45.217' /* 根域名 */
- // defaultConfig.baseURL = 'http://tkhtest.natapp1.cc' /* 根域名 */
- // defaultConfig.baseURL = 'http://127.0.0.1' /* 根域名 */
- defaultConfig = {
- ...defaultConfig,
- custom: {
- loading: true, //是否显示loading
- isCloseLoad: true, //请求返回数据后,是否关闭loading
- validateCode: true, //验证code
- },
- }
- /* defaultConfig 为默认全局配置 */
- // if (process.env.NODE_ENV === 'development') {
- // defaultConfig.baseURL = '/api' /* 根域名 */
- // }
- // if (process.env.NODE_ENV === 'production') {
- // defaultConfig.baseURL = '/api' /* 根域名 */
- // }
- return defaultConfig
- })
- requestInterceptors()
- responseInterceptors()
- }
- export {
- initRequest
- }
|