zycp-ddxcx/utils/utils.js

26 lines
625 B
JavaScript

import config from '/config/config'
export default {
$http(url, method, data,token) {
return new Promise(function(resolve, reject) {
dd.httpRequest({
url: config.BASE_URL+url,
method: method,
data: data,
headers:{
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Authorization': 'Bearer '+token || ''
},
success: (res) => {
if (res.status == 200) {
resolve(res);
} else {
reject(res);
}
},
fail: () => {
reject();
}
})
})
}
}