|
|
/*
|
|
|
* 数据中心接口调用
|
|
|
* */
|
|
|
import axios from 'axios'
|
|
|
const querystring = require('querystring');
|
|
|
import {Modal} from 'ant-design-vue';
|
|
|
// function getContextHtmlPath (){//获取桶名信息
|
|
|
// let pathName = document.location.pathname;
|
|
|
// let index = pathName.substr(1).indexOf("/");
|
|
|
// let result = pathName.substr(0, index + 1);
|
|
|
// if (result != "/dsideal_yy") {
|
|
|
// result = pathName.substr(0, 0);
|
|
|
// }
|
|
|
// console.log("result:",result)
|
|
|
// return result;
|
|
|
// }
|
|
|
// axios.defaults.baseURL = getContextHtmlPath();
|
|
|
|
|
|
// function createRandomNum(){
|
|
|
// let random_num = 0;
|
|
|
// for(let i=0;i<6;i++) {
|
|
|
// random_num+=Math.floor(Math.random()*100000);
|
|
|
// }
|
|
|
// return random_num;
|
|
|
// }
|
|
|
//let interUrl = "http://10.10.14.186:9009/dataex/report/QuerySimpleGP";
|
|
|
let interUrl = "https://dsdataex.cpolar.cn/dataex/report/QuerySimpleGP";
|
|
|
//https://dsdataex.cpolar.cn/
|
|
|
//https://53cebb99.cpolar.cn/
|
|
|
//let interUrl = "https://www.edusoa.com/dataex/report/QuerySimpleGP";
|
|
|
export default {
|
|
|
/*
|
|
|
* interfaceConfigAry[{
|
|
|
* url:string 接口地址 从dsideal_yy/(ypt/) 开始的接口地址
|
|
|
* method:string 掉用方法 "get" "post"
|
|
|
* params:{} 参数
|
|
|
* isTestLogin 是否检测登录状态(是否加"ypt/")
|
|
|
* isOfficeInterface 是否是办公的接口 弹出提示的时候用来判断接口结构 默认为true
|
|
|
* }]
|
|
|
* callBack:(result)=>{}回调方法 result为返回值数组
|
|
|
*
|
|
|
* */
|
|
|
callInterface:(interfaceConfigAry=[],callBack=null,)=>{
|
|
|
console.log("开始调用接口")
|
|
|
//let randomCount = createRandomNum();
|
|
|
if (interfaceConfigAry && Array.isArray(interfaceConfigAry) && interfaceConfigAry.length > 0){
|
|
|
let ary = [];
|
|
|
interfaceConfigAry.forEach((interfaceConfig)=>{
|
|
|
if (interfaceConfig.method === "get"){
|
|
|
ary.push(axios.get(interUrl,{params:interfaceConfig.params}))
|
|
|
}else{
|
|
|
ary.push(axios.post(interUrl,interfaceConfig.params))
|
|
|
}
|
|
|
});
|
|
|
axios.all(ary)
|
|
|
.then(axios.spread(function (res){
|
|
|
let success = true;
|
|
|
for(let i = 0;i < interfaceConfigAry.length; i++){
|
|
|
//let item = interfaceConfigAry[i];
|
|
|
let result = arguments[i].data;
|
|
|
if (!result.success){
|
|
|
Modal.warning({
|
|
|
title:"接口调用错误",
|
|
|
content:result.message,
|
|
|
centered:true
|
|
|
})
|
|
|
success = result.success;
|
|
|
break;
|
|
|
}
|
|
|
// else {
|
|
|
// if(result.result === ""){
|
|
|
// Modal.warning({
|
|
|
// title:"",
|
|
|
// content:"未查询到数据",
|
|
|
// centered:true
|
|
|
// })
|
|
|
// success = false;
|
|
|
// break;
|
|
|
// }
|
|
|
// }
|
|
|
}
|
|
|
if (success && callBack){
|
|
|
callBack(arguments)
|
|
|
}
|
|
|
}))
|
|
|
.catch(function(error){
|
|
|
console.log("接口调用失败!status:"+error.response.status);
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|