|
@@ -1,6 +1,6 @@
|
|
import axios from "axios";
|
|
import axios from "axios";
|
|
// import { Toast } from 'vant';
|
|
// import { Toast } from 'vant';
|
|
-import { Message } from "element-ui";
|
|
|
|
|
|
+import { Message, Loading } from "element-ui";
|
|
import { Decrypt, Encrypt } from "./utils";
|
|
import { Decrypt, Encrypt } from "./utils";
|
|
import { oSessionStorage } from "./utils";
|
|
import { oSessionStorage } from "./utils";
|
|
import { router } from "@/router";
|
|
import { router } from "@/router";
|
|
@@ -19,8 +19,8 @@ import { router } from "@/router";
|
|
|
|
|
|
|
|
|
|
//https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx658b72887c56f6b4&redirect_uri=http%3A%2F%2F192.168.18.51%3A8085&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect
|
|
//https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx658b72887c56f6b4&redirect_uri=http%3A%2F%2F192.168.18.51%3A8085&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect
|
|
-export const basePath='http://10.113.248.3:8086'
|
|
|
|
-// export const basePath='http://43.143.198.30:8086'
|
|
|
|
|
|
+// export const basePath = 'http://10.113.248.3:8086'
|
|
|
|
+export const basePath = process.env.VUE_APP_FILESERVER
|
|
axios.defaults.baseURL = basePath;
|
|
axios.defaults.baseURL = basePath;
|
|
// axios.defaults.baseURL = "http://43.143.198.30:8086";
|
|
// axios.defaults.baseURL = "http://43.143.198.30:8086";
|
|
|
|
|
|
@@ -31,8 +31,8 @@ axios.defaults.baseURL = basePath;
|
|
var urlCode = "";
|
|
var urlCode = "";
|
|
|
|
|
|
//接口白名单
|
|
//接口白名单
|
|
-var whiteList=[
|
|
|
|
- '/user/blogin','/user/getCode'
|
|
|
|
|
|
+var whiteList = [
|
|
|
|
+ '/user/blogin', '/user/getCode'
|
|
]
|
|
]
|
|
|
|
|
|
// axios.defaults.baseURL = 'http://cognitive.wistcm.com:8060/';
|
|
// axios.defaults.baseURL = 'http://cognitive.wistcm.com:8060/';
|
|
@@ -40,7 +40,7 @@ var whiteList=[
|
|
|
|
|
|
sessionStorage.setItem("codeImage", urlCode);
|
|
sessionStorage.setItem("codeImage", urlCode);
|
|
|
|
|
|
-axios.defaults.timeout = 30000; // 超时时间
|
|
|
|
|
|
+axios.defaults.timeout = 1000000; // 超时时间
|
|
axios.defaults.headers.common["Content-Type"] =
|
|
axios.defaults.headers.common["Content-Type"] =
|
|
"application/JSON;charset=UTF-8";
|
|
"application/JSON;charset=UTF-8";
|
|
axios.defaults.withCredentials = true;
|
|
axios.defaults.withCredentials = true;
|
|
@@ -48,18 +48,18 @@ axios.defaults.withCredentials = true;
|
|
|
|
|
|
axios.interceptors.request.use(
|
|
axios.interceptors.request.use(
|
|
function (config) {
|
|
function (config) {
|
|
- for(let i=0;i<whiteList.length;i++){
|
|
|
|
- if(whiteList[i]!==config.url){
|
|
|
|
|
|
+ for (let i = 0; i < whiteList.length; i++) {
|
|
|
|
+ if (whiteList[i] !== config.url) {
|
|
////不在白名单内,需要判断用户是否在,不在的话存储到登录页
|
|
////不在白名单内,需要判断用户是否在,不在的话存储到登录页
|
|
-
|
|
|
|
- if(oSessionStorage.getItem("userInfo")==''){
|
|
|
|
|
|
+
|
|
|
|
+ if (oSessionStorage.getItem("userInfo") == '') {
|
|
router.replace({
|
|
router.replace({
|
|
path: "/",
|
|
path: "/",
|
|
// query: {redirect: router.currentRoute.fullPath}
|
|
// query: {redirect: router.currentRoute.fullPath}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
//在此判断需要 判断用户缓存是否存在
|
|
//在此判断需要 判断用户缓存是否存在
|
|
- // break
|
|
|
|
|
|
+ // break
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//发送请求前判断token是存在
|
|
//发送请求前判断token是存在
|
|
@@ -83,7 +83,7 @@ axios.interceptors.request.use(
|
|
config.headers.Authorization = oSessionStorage.getItem("token")
|
|
config.headers.Authorization = oSessionStorage.getItem("token")
|
|
? `Bearer ${oSessionStorage.getItem("token")}`
|
|
? `Bearer ${oSessionStorage.getItem("token")}`
|
|
: "";
|
|
: "";
|
|
- // console.log(config.headers.Authorization)
|
|
|
|
|
|
+ // console.log(config.headers.Authorization)
|
|
return config;
|
|
return config;
|
|
},
|
|
},
|
|
function (error) {
|
|
function (error) {
|
|
@@ -129,6 +129,26 @@ const http = {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+ formData: (url, data, sCallBack, eCallBack) => {
|
|
|
|
+ // 获取远端图片
|
|
|
|
+ axios({
|
|
|
|
+ method: 'post',
|
|
|
|
+ url: url,
|
|
|
|
+ data: data,
|
|
|
|
+ headers: {
|
|
|
|
+ 'Content-Type': 'multipart/form-data',
|
|
|
|
+ 'Access-Control-Allow-Origin': '*'
|
|
|
|
+ },
|
|
|
|
+ responseType: 'application/octet-stream;charset=utf-8'
|
|
|
|
+ })
|
|
|
|
+ .then(function (response) {
|
|
|
|
+ console.log(response)
|
|
|
|
+ sCallBack(response);
|
|
|
|
+ }).catch(function(err){
|
|
|
|
+ eCallBack(err)
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+
|
|
getImg: (url, data, sCallBack) => {
|
|
getImg: (url, data, sCallBack) => {
|
|
if (data) {
|
|
if (data) {
|
|
data = Encrypt(JSON.stringify(data));
|
|
data = Encrypt(JSON.stringify(data));
|
|
@@ -140,9 +160,9 @@ const http = {
|
|
params: data,
|
|
params: data,
|
|
headers: {
|
|
headers: {
|
|
Accept: "application/octet-stream",
|
|
Accept: "application/octet-stream",
|
|
- // "Content-Disposition":"attachment"
|
|
|
|
|
|
+ // "Content-Disposition":"attachment"
|
|
},
|
|
},
|
|
- },{responseType:"arraybuffer"}).then((res) => {
|
|
|
|
|
|
+ }, { responseType: "arraybuffer" }).then((res) => {
|
|
sCallBack(res);
|
|
sCallBack(res);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
@@ -157,7 +177,7 @@ const http = {
|
|
params: data,
|
|
params: data,
|
|
headers: {
|
|
headers: {
|
|
// Accept: "application/octet-stream",
|
|
// Accept: "application/octet-stream",
|
|
- "Content-Disposition": "attachment"
|
|
|
|
|
|
+ "Content-Disposition": "attachment"
|
|
},
|
|
},
|
|
}).then((res) => {
|
|
}).then((res) => {
|
|
sCallBack(res);
|
|
sCallBack(res);
|