2022-10-12 16:54:34 +08:00
|
|
|
import baseurl from './baseurl.js'
|
|
|
|
|
|
|
|
|
|
var request = function(config) {
|
|
|
|
|
return new Promise((resolve, rejected) => {
|
2022-10-18 08:54:14 +08:00
|
|
|
uni.showLoading({
|
|
|
|
|
title: ''
|
|
|
|
|
});
|
2022-10-12 16:54:34 +08:00
|
|
|
uni.request({
|
|
|
|
|
url: baseurl + config.url,
|
|
|
|
|
data: config.data,
|
|
|
|
|
method: config.method,
|
|
|
|
|
timeout: 5000,
|
|
|
|
|
// header: {
|
|
|
|
|
// token: uni.getStorageSync('token')
|
|
|
|
|
// },
|
|
|
|
|
success(res) {
|
|
|
|
|
// if (res.data.code == 20002) {
|
|
|
|
|
// uni.showModal({
|
|
|
|
|
// title: "登录提示",
|
|
|
|
|
// content: res.data.message,
|
|
|
|
|
// success(res1) {
|
|
|
|
|
// if (res1.confirm) {
|
|
|
|
|
// uni.navigateTo({
|
|
|
|
|
// url: '/pages/user/login/login'
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
// } else {
|
|
|
|
|
// if (res.data.success) {
|
2022-10-18 08:54:14 +08:00
|
|
|
uni.hideLoading();
|
2022-10-12 16:54:34 +08:00
|
|
|
resolve(res.data)
|
|
|
|
|
// } else {
|
|
|
|
|
// uni.showToast({
|
|
|
|
|
// title: res.data.message,
|
|
|
|
|
// icon: "none"
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
},
|
|
|
|
|
fail(err) {
|
2022-10-18 08:54:14 +08:00
|
|
|
uni.hideLoading();
|
2022-10-12 16:54:34 +08:00
|
|
|
rejected(err)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default request
|