You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
514 B
26 lines
514 B
|
4 years ago
|
const BASE_URL = 'http://localhost:7031'
|
||
|
|
export const http = (options) => {
|
||
|
|
return new Promise((resolve, reject) => {
|
||
|
|
uni.request({
|
||
|
|
url: BASE_URL + options.url,
|
||
|
|
method: options.method || 'GET',
|
||
|
|
data: options.data || {},
|
||
|
|
success: (res) => {
|
||
|
|
if (res.data.status !== 0) {
|
||
|
|
return uni.showToast({
|
||
|
|
title: '数据获取失败!'
|
||
|
|
})
|
||
|
|
}
|
||
|
|
resolve(res)
|
||
|
|
},
|
||
|
|
fail: (err) => {
|
||
|
|
uni.showToast({
|
||
|
|
title: "请求失败",
|
||
|
|
icon: 'error'
|
||
|
|
})
|
||
|
|
reject(err)
|
||
|
|
}
|
||
|
|
})
|
||
|
|
})
|
||
|
|
}
|