api.js
5.41 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
import axios from 'axios';
let base = 'https://api.k.wxpai.cn/bizproxy';
// let base = 'https://ow.go.qudone.com';
//formDataHeaders设置
let formDataHeaders = {
headers: {
"Content-Type": "multipart/form-data"
}
}
// get方法demo
export const getDemo = params => {
return axios.get(`${base}/path1/path2/getdemo`, {
params: params
}).then(res => res.data);
};
// post方法demo
export const postDemo = params => {
return axios.post(`${base}/path1/path2/postdemo`, params).then(res => res.data);
};
// postformdata
export const updatePostformdata = params => {
return axios.post(`${base}/path1/path2/postformdata`, params, formDataHeaders).then(res => res.data);
};
// 获取视频列表
export const getVideoList = params => {
return axios.get(`${base}/zcrapi/admin/vedios/list`, {
params: params
}).then(res => res.data);
};
// 保存视频
export const saveVideo = params => {
return axios.post(`${base}/zcrapi/admin/vedios/save`, params).then(res => res.data);
};
// 删除视频
export const deleteVideo = params => {
return axios.post(`${base}/zcrapi/admin/vedios/delete`, params).then(res => res.data);
};
// 获取文章分类列表
export const getClassifyList = params => {
return axios.get(`${base}/zcrapi/admin/article/classify/list`, {
params: params
}).then(res => res.data);
};
// 获取话题列表
export const getTagList = params => {
return axios.get(`${base}/zcrapi/admin/article/tag/list`, {
params: params
}).then(res => res.data);
};
// 保存话题
export const saveTag = params => {
return axios.post(`${base}/zcrapi/admin/article/tag/save`, params).then(res => res.data);
};
// 删除话题
export const deleteTag = params => {
return axios.post(`${base}/zcrapi/admin/article/tag/delete`, params).then(res => res.data);
};
// 获取头图列表
export const getBannerList = params => {
return axios.get(`${base}/zcrapi/admin/article/banner/list`, {
params: params
}).then(res => res.data);
};
// 保存头图
export const saveBanner = params => {
return axios.post(`${base}/zcrapi/admin/article/banner/save`, params).then(res => res.data);
};
// 删除头图
export const deleteBanner = params => {
return axios.post(`${base}/zcrapi/admin/article/banner/delete`, params).then(res => res.data);
};
// 删除头图
export const changeBanner = params => {
console.log("params:", params);
return axios.post(`${base}/zcrapi/admin/article/banner/change`, params).then(res => res.data);
};
// 获取文章列表
export const getArticleList = params => {
return axios.get(`${base}/zcrapi/admin/article/list`, {
params: params
}).then(res => res.data);
};
// 保存文章
export const saveArticle = params => {
return axios.post(`${base}/zcrapi/admin/article/save`, params).then(res => res.data);
};
// 删除文章
export const deleteArticle = params => {
return axios.post(`${base}/zcrapi/admin/article/delete`, params).then(res => res.data);
};
// 获取门店列表
export const getStoreList = params => {
return axios.get(`${base}/zcrapi/admin/store/list`, {
params: params
}).then(res => res.data);
};
// 文件上传 包含图片 postformdata
export const uploadFile = params => {
return axios.post(`${base}/zcrapi/admin/file/upload`, params, formDataHeaders).then(res => res.data);
};
// 获取门店列表
export const postDashboard = params => {
return axios.get(`${base}/zcrapi/admin/dashboard`, {
params: params
}).then(res => res.data);
};
export const requestLogin = params => {
return axios.post(`${base}/login`, params).then(res => res.data);
};
export const getUserList = params => {
return axios.get(`${base}/user/list`, {
params: params
}).then(res => res.data);
};
export const getUserListPage = params => {
return axios.get(`${base}/user/listpage`, {
params: params
}).then(res => res.data);;
};
export const removeUser = params => {
return axios.get(`${base}/user/remove`, {
params: params
}).then(res => res.data);;
};
export const batchRemoveUser = params => {
return axios.get(`${base}/user/batchremove`, {
params: params
}).then(res => res.data);
};
export const editUser = params => {
return axios.get(`${base}/user/edit`, {
params: params
}).then(res => res.data);
};
export const addUser = params => {
return axios.get(`${base}/user/add`, {
params: params
}).then(res => res.data);
};
export const dashboardExport = params => {
// return axios.get(`${base}/user/add`, {
// params: params
// }).then(res => res.data);
let url = `${base}/zcrapi/admin/dashboard/export` + '?fromDate=' + params.fromDate + '&toDate=' + params.toDate;
console.log("url:", url);
window.open(url)
};
export const request = {
post(url, data) {
return axios.post(`${base}${url}`, data);
},
get(url, data) {
return axios.get(`${base}${url}`, { params: data });
},
form(url, params) {
let formData = new FormData(); //使用formData对象
for (let key in params) {
formData.append(key, params[key]);
}
let requestUrl = url.indexOf("://") >= 0 ? `${url}` : `${base}${url}`;
return axios.post(requestUrl, formData, formDataHeaders)
},
build(url, params) {
let fullUrl = `${base}${url}`;
let split = "";
for (let key in params) {
if (split) {
split = "&";
} else {
split = "?"
}
fullUrl += split + key + "=" + params[key];
}
return fullUrl;
},
requestDomain() {
return `${base}`
}
/*test*/
};