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.
40 lines
680 B
40 lines
680 B
|
|
const BaseURL = "" |
|
function request(url, method, data) { |
|
return new Promise(function(resolve, reject) { |
|
let token = uni.getStorageSync('token'); |
|
uni.request({ |
|
url: BaseURL + url, |
|
method: method, |
|
data: data, |
|
header: { |
|
'content-type': 'application/json', |
|
'Authorization': token, |
|
}, |
|
success(res) { |
|
if (res.data.code == 200) { |
|
resolve(res.data) |
|
} else { |
|
uni.showToast({ |
|
title: res.data.msg, |
|
icon: "none", |
|
duration: 2000, |
|
success: () => { |
|
setTimeout(() => { |
|
reject(res.data) |
|
}, 2000) |
|
} |
|
}) |
|
|
|
} |
|
}, |
|
fail(err) { |
|
reject(err) |
|
} |
|
}) |
|
}) |
|
} |
|
|
|
export { |
|
request |
|
} |