// 同时发送异步代码的次数
let ajaxTimes = 0;
export const request = (params) => {

	var openid = wx.getStorageSync("openid") || '';
	let header = {
		...params.header
	};

	let urls;
	if (params.url.indexOf('?')) {
		urls = params.url 
	} else {
		urls = params.url 
	}



	// 定义公共的url
	// const baseUrl="https://jfsc.lmweixin.com/";
	const baseUrl = "http://192.168.1.159:8080/";
	return new Promise((resolve, reject) => {
		wx.request({
			...params,
			header: header,
			
			url: baseUrl + urls,
			success: (result) => {
				resolve(result.data);
			},
			fail: (err) => {
				reject(err);
			},
			complete: () => {
				ajaxTimes--;
				if (ajaxTimes === 0) {
					//  关闭正在等待的图标
					wx.hideLoading();
				}
			}
		});
	})
}