import baseurl from './baseurl.js'

// Authorization: 'Bearer' + ' ' + uni.getStorageSync('token')
var request = function(config) {
	return new Promise((resolve, rejected) => {
		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: ''
			});
		}
		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