Commit 5f0ef44b by 潘琦

电子券接口域名

parent 92c81f3f
......@@ -2,23 +2,28 @@ import axios from 'axios'
import store from '../store'
import { Toast } from 'mint-ui'
// import router from '@/router/index'
// import baseUrl from '@/util/baseUrl'
import baseUrl from '@/util/baseUrl'
import { removeUrlParam } from '@/util/index'
axios.defaults.timeout = 30000
console.log('NODE_ENV' + process.env.NODE_ENV)
if (process.env.NODE_ENV === 'production') {
let root = process.env.API_ROOT
axios.defaults.baseURL = root // 开发服
}
// 创建axios实例
const service = axios.create({
baseURL: baseUrl.voucherUrl,
timeout: 30000 // 请求超时时间
})
// console.log('NODE_ENV' + process.env.NODE_ENV)
// if (process.env.NODE_ENV === 'production') {
// // let root = process.env.API_ROOT
// axios.defaults.baseURL = baseUrl.voucherUrl // 开发服
// }
// 返回其他状态吗
axios.defaults.validateStatus = function (status) {
service.defaults.validateStatus = function (status) {
return status // 默认的
}
// 跨域请求,允许保存cookie
axios.defaults.withCredentials = true
service.defaults.withCredentials = true
// request拦截器
axios.interceptors.request.use(config => {
service.interceptors.request.use(config => {
let token = store.getters.access_token
if (token) {
config.headers['Authorization'] = 'Bearer ' + token
......@@ -31,7 +36,7 @@ axios.interceptors.request.use(config => {
})
// respone拦截器
axios.interceptors.response.use(response => {
service.interceptors.response.use(response => {
let res = response
if (response.request) {
res = response.data
......@@ -99,4 +104,4 @@ axios.interceptors.response.use(response => {
return Promise.reject(new Error(error))
})
export default axios
export default service
......@@ -7,8 +7,8 @@ const authUrl = 'http://test.icareyou.net' // 开发
/**
* 项目接口请求地址
*/
const baseUrl = '"http://voucher.check.icaremgt.com"' // 开发
// const baseUrl = '"http://voucher.icaremgt.com"' // 正式
const voucherUrl = 'http://voucher.check.icaremgt.com' // 开发
// const voucherUrl = 'http://voucher.icaremgt.com' // 正式
/**
* 机构控件项目接口请求地址
......@@ -19,7 +19,7 @@ const sjkgUrl = 'https://api-wx-service.check.icaremgt.com' // 开发
const defaultUrl = {
authUrl: authUrl,
baseUrl: baseUrl,
voucherUrl: voucherUrl,
sjkgUrl: sjkgUrl
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment