28 lines
621 B
JavaScript
28 lines
621 B
JavaScript
const BaseUrl = 'http://spread.angyakeji.com'
|
|
export default ((url, method = 'POST', data = {},domain=BaseUrl) => {
|
|
// // #ifdef APP || APP-PLUS
|
|
// const BaseUrl = domain
|
|
// var _url = url.split('/api')
|
|
// url = _url.length > 1 ? '/api' + _url.slice(1).join('/api') : '';
|
|
// // #endif
|
|
|
|
// // #ifdef H5 || WEB
|
|
// const BaseUrl = ""
|
|
// // #endif
|
|
return new Promise((resolve, reject) => {
|
|
// url.request请求
|
|
let api = domain + url
|
|
uni.request({
|
|
url:api,
|
|
method,
|
|
data,
|
|
success: (res) => {
|
|
// console.log(res)
|
|
resolve(res.data)
|
|
},
|
|
fail: (erro) => {
|
|
reject(erro)
|
|
}
|
|
})
|
|
})
|
|
}) |