|  | @@ -1,6 +1,9 @@
 | 
	
		
			
				|  |  |  import store from "@/store";
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +import CryptoJS from '@/assets/crypto-js.min.js';
 | 
	
		
			
				|  |  |  var doubleClickList = []; //防连击的数组对象
 | 
	
		
			
				|  |  | +var keys = "ELAB_AUTHOPENAPI";
 | 
	
		
			
				|  |  | +var iv = "ELAB_SECRET_APIS";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  // 请求地址对象
 | 
	
		
			
				|  |  |  const endpoints = {
 | 
	
		
			
				|  |  |      upload: 'elab-marketing-system/behavior/brandMiniWeb/upload', //埋点接口
 | 
	
	
		
			
				|  | @@ -53,6 +56,24 @@ const endpoints = {
 | 
	
		
			
				|  |  |  	submitAnswer: 'elab-marketing-content/question/submitAnswer',//答题
 | 
	
		
			
				|  |  |  	// predictions: "https://api.replicate.com/v1/deployments/feathers-wing/spacely-realistic-style-softedge-a100/predictions", // 分享查看
 | 
	
		
			
				|  |  |  };
 | 
	
		
			
				|  |  | +/**
 | 
	
		
			
				|  |  | + * 加密参数
 | 
	
		
			
				|  |  | + * @param content
 | 
	
		
			
				|  |  | + * @returns {string}
 | 
	
		
			
				|  |  | + * @constructor
 | 
	
		
			
				|  |  | + */
 | 
	
		
			
				|  |  | +function AES_encrypt(content) {
 | 
	
		
			
				|  |  | +	content = JSON.stringify(content);
 | 
	
		
			
				|  |  | +	let param = CryptoJS.enc.Utf8.parse(content);
 | 
	
		
			
				|  |  | +	let _key = CryptoJS.enc.Utf8.parse(keys);
 | 
	
		
			
				|  |  | +	let _iv = CryptoJS.enc.Utf8.parse(iv);
 | 
	
		
			
				|  |  | +	let encrypted = CryptoJS.AES.encrypt(param, _key, {
 | 
	
		
			
				|  |  | +		mode: CryptoJS.mode.CBC,
 | 
	
		
			
				|  |  | +		padding: CryptoJS.pad.Pkcs7,
 | 
	
		
			
				|  |  | +		iv: _iv,
 | 
	
		
			
				|  |  | +	});
 | 
	
		
			
				|  |  | +	return encrypted.ciphertext.toString();
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  |  // var source = CancelToken.source();
 | 
	
		
			
				|  |  |  window.requestConfig = async(endpoint, options, isHideLoading = false, preventDoubleClick = false, method = 'post',uploadProgress=null,cancel=null) => {
 | 
	
		
			
				|  |  |  	if (!endpoints.hasOwnProperty(endpoint)) {
 | 
	
	
		
			
				|  | @@ -65,6 +86,11 @@ window.requestConfig = async(endpoint, options, isHideLoading = false, preventDo
 | 
	
		
			
				|  |  |          path: endpoints[endpoint],
 | 
	
		
			
				|  |  |          data: options,
 | 
	
		
			
				|  |  |      };
 | 
	
		
			
				|  |  | +	let encryptedData = '';
 | 
	
		
			
				|  |  | +	if (endpoint.indexOf('authorizedMobile') >= 0) {
 | 
	
		
			
				|  |  | +	    encryptedData = await AES_encrypt(requestOptions.data);
 | 
	
		
			
				|  |  | +	    requestOptions.data = {};
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  |      if (preventDoubleClick) {
 | 
	
		
			
				|  |  |          //说明该接口需要防止连击
 | 
	
		
			
				|  |  |          if (doubleClickList[requestOptions.path] && doubleClickList[requestOptions.path].isRunning) {
 | 
	
	
		
			
				|  | @@ -98,6 +124,10 @@ window.requestConfig = async(endpoint, options, isHideLoading = false, preventDo
 | 
	
		
			
				|  |  |      if (isHideLoading) {
 | 
	
		
			
				|  |  |          store.state.loading = false; //显示loading态
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | +	if (encryptedData) {
 | 
	
		
			
				|  |  | +		requestOptions.headers = {};
 | 
	
		
			
				|  |  | +	    requestOptions.headers.sign = encryptedData;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  |      if (requestOptions.url.includes('elab-marketing-analyse/heavenlyEye/importLocations') ||
 | 
	
		
			
				|  |  |          requestOptions.url.includes('elab-marketing-sms/aliyun/openapi/uploadOss') ||
 | 
	
		
			
				|  |  |  		requestOptions.url.includes('/robust_video')) {
 | 
	
	
		
			
				|  | @@ -131,7 +161,13 @@ window.requestConfig = async(endpoint, options, isHideLoading = false, preventDo
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			response = await axios.post(requestOptions.url, requestOptions.data,_dt);
 | 
	
		
			
				|  |  |  		}else{
 | 
	
		
			
				|  |  | -			response = await axios.post(requestOptions.url, requestOptions.data);
 | 
	
		
			
				|  |  | +			if(requestOptions.headers){
 | 
	
		
			
				|  |  | +				response = await axios.post(requestOptions.url, requestOptions.data,{
 | 
	
		
			
				|  |  | +					headers:requestOptions.headers
 | 
	
		
			
				|  |  | +				});
 | 
	
		
			
				|  |  | +			}else{
 | 
	
		
			
				|  |  | +				response = await axios.post(requestOptions.url, requestOptions.data);
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |          
 | 
	
		
			
				|  |  |      }
 |