update
init
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
import axios from 'axios';
|
||||
import qs from 'qs';
|
||||
import hrefParams from '@/utils/herfParams';
|
||||
// import htp from 'public/http';
|
||||
|
||||
// let baseUrl = '';
|
||||
const token = `${sessionStorage.getItem('tokenF')}`;
|
||||
const { urlF, tokenF } = hrefParams;
|
||||
|
||||
const defHttp = axios.create({
|
||||
timeout: 40000,
|
||||
// baseURL: '/api',
|
||||
baseURL: '',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-Access-Token': tokenF + '',
|
||||
...getHeader(),
|
||||
},
|
||||
});
|
||||
|
||||
function getHeader() {
|
||||
let result = {};
|
||||
if (hrefParams?.vitePlatform == 'QH') {
|
||||
result = { 'X-ClientSign': 'Quarry' };
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
let u = (urlF + '').replace('lol', '://');
|
||||
const get = (url: string, params: any) =>
|
||||
new Promise((resolve, reject) => {
|
||||
defHttp
|
||||
.get(`${u}${url}${qs.stringify(params) ? '?' + qs.stringify(params) : ''}`, params)
|
||||
.then((res) => {
|
||||
resolve(res.data);
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
|
||||
const post = (url: string, params: any) =>
|
||||
new Promise((resolve, reject) => {
|
||||
defHttp
|
||||
.post(`${u}${url}`, params)
|
||||
.then((res) => {
|
||||
resolve(res.data);
|
||||
})
|
||||
.catch((err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
export { get, post };
|
||||
@@ -0,0 +1,43 @@
|
||||
import axios from 'axios';
|
||||
import qs from 'qs';
|
||||
const baseURL = 'https://demos.trtc.tencent-cloud.com'; // 国内
|
||||
// const baseURL = 'https://demos3w.trtc.tencent-cloud.com'; // 国际
|
||||
const ENV = 'prod'; // prod: 生产 dev: 测试
|
||||
|
||||
const instance = axios.create({
|
||||
baseURL: `${baseURL}/${ENV}`,
|
||||
headers: { 'content-type': 'application/x-www-form-urlencoded' },
|
||||
});
|
||||
|
||||
|
||||
export async function getSmsVerifyCode(data: { appId: any; }) {
|
||||
const options = buildOptions(data, '/base/v1/auth_users/user_verify_by_picture', 'GET');
|
||||
return instance(options);
|
||||
}
|
||||
|
||||
export async function loginSystemByVerifyCode(loginInfo: any) {
|
||||
const options = buildOptions(loginInfo, '/base/v1/auth_users/user_login_code');
|
||||
return instance(options);
|
||||
}
|
||||
|
||||
export async function loginSystemByToken(data: any) {
|
||||
const options = buildOptions(data, '/base/v1/auth_users/user_login_token');
|
||||
return instance(options);
|
||||
}
|
||||
|
||||
export async function cancellation(data:any) {
|
||||
const options = buildOptions(data, '/base/v1/auth_users/user_delete');
|
||||
return instance(options);
|
||||
}
|
||||
function buildOptions(data:any, url:string, method?:string) {
|
||||
const options:any = {
|
||||
method: method || 'POST',
|
||||
url,
|
||||
};
|
||||
if (options.method === 'GET') {
|
||||
options.params = data;
|
||||
} else {
|
||||
options.data = qs.stringify(data);
|
||||
}
|
||||
return options;
|
||||
}
|
||||
Reference in New Issue
Block a user