43 lines
1.0 KiB
JavaScript
43 lines
1.0 KiB
JavaScript
import baseurl from './baseurl.js'
|
|
|
|
var request = function(config) {
|
|
if (uni.getStorageSync('openid')) {
|
|
if (!config.header) {
|
|
config.header = {}
|
|
}
|
|
config.header.openid = uni.getStorageSync('openid')
|
|
config.header.appletType = ''
|
|
} else {
|
|
config.header = {
|
|
appletType: ''
|
|
}
|
|
}
|
|
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: ''
|
|
});
|
|
}
|
|
return new Promise((resolve, rejected) => {
|
|
uni.request({
|
|
url: baseurl + config.url,
|
|
data: config.data,
|
|
method: config.method,
|
|
timeout: 60000,
|
|
header: config.header,
|
|
success(res) {
|
|
uni.hideLoading();
|
|
resolve(res.data)
|
|
},
|
|
fail(err) {
|
|
uni.hideLoading();
|
|
rejected(err)
|
|
}
|
|
})
|
|
})
|
|
}
|
|
|
|
export default request |