xinelu-applet-ui/api/request.js

43 lines
1.0 KiB
JavaScript
Raw Normal View History

2023-09-19 15:16:00 +08:00
import baseurl from './baseurl.js'
var request = function(config) {
2024-04-18 15:00:46 +08:00
if (uni.getStorageSync('openid')) {
2024-04-18 15:11:38 +08:00
if (!config.header) {
config.header = {}
}
2024-04-18 15:00:46 +08:00
config.header.openid = uni.getStorageSync('openid')
2024-05-31 17:27:27 +08:00
config.header.appletType = ''
} else {
config.header = {
appletType: ''
}
2024-04-18 15:00:46 +08:00
}
const urls = config.url.split('?')[0]
if (config.url != '/nurseApplet/chatRecord/updateReadStatus' && config.url !=
"/nurseApplet/chatRecord/sendMessage" && config.url !=
`/applet/sign/apply/checkSignApply/` + uni.getStorageSync('userinfo').cardNo && urls !=
`/nurseApplet/chatRecord/getChatRecord` && urls != '/applet/register/wxSportDecrypt') {
uni.showLoading({
title: ''
});
}
2023-09-19 15:16:00 +08:00
return new Promise((resolve, rejected) => {
uni.request({
url: baseurl + config.url,
data: config.data,
method: config.method,
2023-10-12 09:47:40 +08:00
timeout: 60000,
2023-10-10 14:43:59 +08:00
header: config.header,
2023-09-19 15:16:00 +08:00
success(res) {
uni.hideLoading();
resolve(res.data)
},
fail(err) {
uni.hideLoading();
rejected(err)
}
})
})
}
2023-11-01 14:30:45 +08:00
export default request