|
@@ -14,13 +14,14 @@ if (DoMainString) {
|
|
var reg = /(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)/;
|
|
var reg = /(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)\.(25[0-5]|2[0-4]\d|[0-1]\d{2}|[1-9]?\d)/;
|
|
var browserUrl = window.location.hostname
|
|
var browserUrl = window.location.hostname
|
|
console.log("========url===",reg.test(browserUrl))
|
|
console.log("========url===",reg.test(browserUrl))
|
|
-// 打包的时候打开,日常关掉
|
|
|
|
if (reg.test(browserUrl)){
|
|
if (reg.test(browserUrl)){
|
|
- URL = window.location.protocol +"//"+ browserUrl + ":80/"
|
|
|
|
|
|
+ URL = window.location.protocol +"//"+ browserUrl + ":8082"
|
|
}
|
|
}
|
|
|
|
|
|
Cookies.set('url',URL)
|
|
Cookies.set('url',URL)
|
|
-// test
|
|
|
|
|
|
+console.log(process.env.VUE_APP_BASE_API,'===========URL1111')
|
|
|
|
+console.log(URL,'===========URL')
|
|
|
|
+
|
|
const service = axios.create({
|
|
const service = axios.create({
|
|
baseURL: URL, // url = base url + request url
|
|
baseURL: URL, // url = base url + request url
|
|
withCredentials: true, // send cookies when cross-domain requests
|
|
withCredentials: true, // send cookies when cross-domain requests
|
|
@@ -32,7 +33,7 @@ service.interceptors.request.use(
|
|
// do something before request is sent
|
|
// do something before request is sent
|
|
// config.headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8' //此处是增加的代码,设置请求头的类型
|
|
// config.headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8' //此处是增加的代码,设置请求头的类型
|
|
if (process.env.VUE_APP_BASE_API !== '/dev-api') {
|
|
if (process.env.VUE_APP_BASE_API !== '/dev-api') {
|
|
- config.headers['Content-Type'] = 'application/json'
|
|
|
|
|
|
+ config.headers['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'
|
|
config.withCredentials = false
|
|
config.withCredentials = false
|
|
}
|
|
}
|
|
|
|
|
|
@@ -117,9 +118,6 @@ service.interceptors.response.use(
|
|
console.log('config.__retryCount==>', config.__retryCount) // for debug
|
|
console.log('config.__retryCount==>', config.__retryCount) // for debug
|
|
// 设置请求超时次数
|
|
// 设置请求超时次数
|
|
config.__retryCount = config.__retryCount || 0
|
|
config.__retryCount = config.__retryCount || 0
|
|
- // 君盛牧场不需要多次请求
|
|
|
|
- // if (config.__retryCount >= 0) {
|
|
|
|
- // 其他牧场失败后需要多次尝试
|
|
|
|
if (config.__retryCount >= 3) {
|
|
if (config.__retryCount >= 3) {
|
|
// Message({ message:error.message, type: 'error', duration: 5 * 1000 })
|
|
// Message({ message:error.message, type: 'error', duration: 5 * 1000 })
|
|
Message({ message:'请求超时', type: 'error', duration: 5 * 1000 })
|
|
Message({ message:'请求超时', type: 'error', duration: 5 * 1000 })
|