From 8e3ce2861b7b685e19d6109079911c731e3ae2c3 Mon Sep 17 00:00:00 2001 From: gongdi <410827992@qq.com> Date: Tue, 28 Jun 2022 14:15:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B4=8B=E6=B5=A6=E5=AD=A6=E6=A0=A1=E5=85=AB?= =?UTF-8?q?=E5=A4=A7=E4=B8=AD=E5=BF=83=20=E5=BE=B7=E8=82=B2=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=89=8D=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/global-llibs/dataex-report-axios.js | 78 +++++++++++ src/utils/global-import.js | 2 + .../pages/partyCenter/brandCreation.vue | 127 ++++++++++++++---- .../pages/partyCenter/teamHelp.vue | 1 - 4 files changed, 184 insertions(+), 24 deletions(-) create mode 100644 src/global-llibs/dataex-report-axios.js diff --git a/src/global-llibs/dataex-report-axios.js b/src/global-llibs/dataex-report-axios.js new file mode 100644 index 0000000..0dcaf22 --- /dev/null +++ b/src/global-llibs/dataex-report-axios.js @@ -0,0 +1,78 @@ +/* +* 数据中心接口调用 +* */ +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"; +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; + } + } + if (success && callBack){ + callBack(arguments) + } + })) + .catch(function(error){ + console.log("接口调用失败!status:"+error.response.status); + }) + } + } +} + + diff --git a/src/utils/global-import.js b/src/utils/global-import.js index 6136d70..dddcb1c 100644 --- a/src/utils/global-import.js +++ b/src/utils/global-import.js @@ -2,6 +2,7 @@ import Vue from 'vue' import cookie from '../global-llibs/cookie' import baseConfig from '../global-llibs/base-config' import interfaceConfig from '../global-llibs/axios-config' +import dataexReportInterface from '../global-llibs/dataex-report-axios' import Common from './common'; import TypesCheck from '../global-llibs/under-score/types-check'; import Base64 from '../global-llibs/base64'; @@ -10,6 +11,7 @@ import StaticParams from '../global-llibs/staticParams' Vue.prototype.Cookie = cookie Vue.prototype.BaseConfig = baseConfig Vue.prototype.InterfaceConfig = interfaceConfig +Vue.prototype.DataexReportInterface = dataexReportInterface Vue.prototype.Common = Common Vue.prototype.TypesCheck = TypesCheck Vue.prototype.Base64 = Base64 diff --git a/src/views/screenAdaptation/pages/partyCenter/brandCreation.vue b/src/views/screenAdaptation/pages/partyCenter/brandCreation.vue index aec21b9..0a229a5 100644 --- a/src/views/screenAdaptation/pages/partyCenter/brandCreation.vue +++ b/src/views/screenAdaptation/pages/partyCenter/brandCreation.vue @@ -1,56 +1,70 @@