NurseStationPersonAppletUl/api/request.js

53 lines
1.1 KiB
JavaScript
Raw Normal View History

2023-03-28 10:02:47 +08:00
import baseurl from './baseurl.js'
var request = function(config) {
return new Promise((resolve, rejected) => {
uni.showLoading({
title: ''
});
uni.request({
url: baseurl + config.url,
data: config.data,
method: config.method,
timeout: 10000,
header: {
Authorization: 'Bearer' + ' ' + uni.getStorageSync('token')
},
success(res) {
if (res.data.code == 9999) {
uni.removeStorageSync('token');
2023-04-04 17:14:06 +08:00
uni.removeStorageSync('nursePersonId');
2023-03-28 10:02:47 +08:00
uni.showModal({
title: "登录提示",
content: '登录失效,请重新登录',
success(res1) {
if (res1.confirm) {
uni.navigateTo({
url: '/pages/login/login'
})
} else if (res1.cancel) {
uni.reLaunch({
2023-04-04 17:14:06 +08:00
url: '/pages/startup/startup'
2023-03-28 10:02:47 +08:00
})
}
},
fail(err1) {
uni.reLaunch({
2023-04-04 17:14:06 +08:00
url: '/pages/startup/startup'
2023-03-28 10:02:47 +08:00
})
}
})
}
uni.hideLoading();
resolve(res.data)
},
fail(err) {
uni.hideLoading();
rejected(err)
}
})
})
}
export default request