import request from '../utils/request';
import request1 from '../utils/request1';
import request2 from '../utils/request2';
import request3 from '../utils/requsetThree.js';
import JSEncrypt from 'jsencrypt'
import url1 from '../utils/url'
const httpGet = (query,url) => {
    return request({
        url:url1 +url,
        method: "GET",
        params: query
    });
};
// const httpGet2 = (query,url) => {
//     return request4({
//         url:url1 +url,
//         method: "GET",
//         params: query
//     });
// };
const httpPost = (query,url) => {
    return request({
        url: url1+url,
        method: "POST",
        data: query
    });
};
const download = (query,url) => {
    return request({
        url: url1+url,
        method: "GET",
        params: query,
        responseType: 'blob'
    });
};
const downloadPost = (query,url) => {
    return request({
        url: url1+url,
        method: "POST",
        data: query,
        responseType: 'blob'
    });
};
 function setCode(str,text){ // 注册方法
  let pubKey = str;// ES6 模板字符串 引用 rsa 公钥
  let encryptStr = new JSEncrypt();
  encryptStr.setPublicKey(pubKey); // 设置 加密公钥
  let  data = encryptStr.encrypt(text.toString());  // 进行加密
  return data;
}
const httpGet1 = (query,url) => {
    return request1({
        url: url1+url,
        method: "GET",
        params: query
    });
};
const httpPost1 = (query,url) => {
    return request2({
        url: url1+url,
        method: "POST",
        data: query
    });
};

const httgetaxio = (query,url) => {
    return request1({
        url: url,
        method: "GET",
        params: query
    });
};
const httgetaxio1 = (query,url) => {
    return request2({
        url: url1+url,
        method: "POST",
        data: query
    });
};
const httpPostno = (query,url) => {
    return request3({
        url: url1+url,
        method: "POST",
        data: query
    });
};
const httpGetno = (query,url) => {
    return request3({
        url: url1+url,
        method: "GET",
        data: query
    });
};
const silentRequest = (query,url) => {
    return request3({
        url: url1+url,
        method: "GET",
        params: query
    });
};
export {httpGet,RefreshToken,httpPost,setCode,httpGet1,httpPost1,download,httgetaxio,httgetaxio1,downloadPost,httpPostno,httpGetno,silentRequest}
