let isToLoginSend = false;
var requestTask = null
var elabprojectname = ''
var elabsystem = ''
var elabEnvironment = ''
export const myRequest = (options) => {
	if (!options.hasOwnProperty("showLoading")) {
		var localDate = uni.getStorageSync('loadingStamp') || 0
		var date = new Date().getTime()
		if (date - localDate > 2000) {
			uni.setStorageSync('loadingStamp', date)
			uni.showLoading({
				mask: true,
				title: "正在加载中"
			})
		}
	}
	let token = getApp().globalData.token
	if (token) {
		options.token = token
	} else {
		options.token = null
	}
	let BASE_URL = getApp().globalData.BASE_URL;
	return new Promise((resolve, reject) => {
		requestTask = uni.request({
			url: BASE_URL + options.url,
			method: options.method || "POST",
			data: options.data || {},
			header: {
				'token': options.token || null,
			},
			success: res => {
				uni.hideLoading()
				uni.hideNavigationBarLoading();
				uni.stopPullDownRefresh();
				resolve(res)
			},
			fail: (err) => {
				uni.hideLoading()
				uni.hideNavigationBarLoading();
				uni.stopPullDownRefresh();
				reject(err)
			}
		})
	})
}
