Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
voucher-h5
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
潘琦
voucher-h5
Commits
5f0ef44b
Commit
5f0ef44b
authored
Sep 06, 2019
by
潘琦
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
电子券接口域名
parent
92c81f3f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
15 deletions
+20
-15
request.js
src/router/request.js
+17
-12
baseUrl.js
src/util/baseUrl.js
+3
-3
No files found.
src/router/request.js
View file @
5f0ef44b
...
...
@@ -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
src/util/baseUrl.js
View file @
5f0ef44b
...
...
@@ -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
:
base
Url
,
voucherUrl
:
voucher
Url
,
sjkgUrl
:
sjkgUrl
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment