|
@@ -53,28 +53,26 @@ export default {
|
|
|
* @param response 请求成功时的回调函数
|
|
|
* @param exception 异常的回调函数
|
|
|
*/
|
|
|
- post (url, data, response, exception) {
|
|
|
- axios({
|
|
|
- method: 'post',
|
|
|
- url: handleUrl(url),
|
|
|
- data: handleParams(data),
|
|
|
- timeout: TIME_OUT_MS,
|
|
|
- headers: {
|
|
|
- 'Content-Type': 'application/json; charset=UTF-8'
|
|
|
- }
|
|
|
- }).then(
|
|
|
- (result) => {
|
|
|
- response(handleResults(result))
|
|
|
- }
|
|
|
- ).catch(
|
|
|
- (error) => {
|
|
|
- if (exception) {
|
|
|
- exception(error)
|
|
|
- } else {
|
|
|
- console.log(error)
|
|
|
+ post (url, data) {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ axios({
|
|
|
+ method: 'post',
|
|
|
+ url: handleUrl(url),
|
|
|
+ data: handleParams(data),
|
|
|
+ timeout: TIME_OUT_MS,
|
|
|
+ headers: {
|
|
|
+ 'Content-Type': 'application/json; charset=UTF-8'
|
|
|
}
|
|
|
- }
|
|
|
- )
|
|
|
+ }).then(
|
|
|
+ (result) => {
|
|
|
+ resolve(result)
|
|
|
+ }
|
|
|
+ ).catch(
|
|
|
+ (error) => {
|
|
|
+ reject(error)
|
|
|
+ }
|
|
|
+ )
|
|
|
+ })
|
|
|
},
|
|
|
/*
|
|
|
* get 请求
|
|
@@ -84,7 +82,7 @@ export default {
|
|
|
*/
|
|
|
get (url, params) {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
- axios.get(url, {params: params})
|
|
|
+ axios.get(handleUrl(url), {params: params})
|
|
|
.then(response => {
|
|
|
resolve(response.data)
|
|
|
}).catch(error => {
|