-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathrequestUrl.js
52 lines (43 loc) · 1.49 KB
/
requestUrl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import axios from "axios";
import qs from 'qs';
import baseURL from './configUrl.js';
function baseRequest(method, path, params, data, type) {
method = method.toUpperCase() || 'GET';
let url = '';
let paramsobj = { params: params };
if (type === 'msg') {
url = baseURL.onbaseURL;
} else {
url = baseURL.baseURL;
}
axios.defaults.baseURL = url;
if (method === 'POST') {
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8';
return axios.post(path, qs.stringify(data));
} else if (method === 'GET') {
return axios.get(path, paramsobj);
} else {
return axios.delete(path, qs.stringify(data));
}
}
export let get_category = function get_category(params){
return baseRequest("GET", '/category/all/', params, '');
};
export let get_all_video = function get_all_video(params){
return baseRequest("GET", '/video/all/', params, '');
};
export let get_all_img = function get_img(params){
return baseRequest("GET", '/image/all/', params, '');
};
export let get_img = function get_all_img(params){
return baseRequest("POST", '/image/', '', params);
};
export let get_code = function get_code(params){
return baseRequest("GET", '/user/code/', params, '');
};
export let register = function register(params){
return baseRequest("POST", '/user/register/', '', params)
};
export let login = function login(params){
return baseRequest("POST", '/user/login/', '', params)
};