Browse Source

圣木的sso跳转问题修改requestt

Shan9312 1 year ago
parent
commit
c0c4a7a1e4
1 changed files with 5 additions and 7 deletions
  1. 5 7
      src/utils/request.js

+ 5 - 7
src/utils/request.js

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