function jsonToQueryString(json) {
	return Object.keys(json)
		.map(key => encodeURIComponent(key) + '=' + encodeURIComponent(json[key]))
		.join('&');
}

export function eventSite(params) {
	var p = jsonToQueryString(Object.assign({
		experiment_id: '7028276368903241728',
		experiment_connection_id: '7201846824305426432',
	}, params))
	var xhr = new XMLHttpRequest();
	xhr.open('GET', `https://saas-dml-pro.ezijing.com/api/lab/v1/experiment/member/event-create-by-shop?${p}`, true);
	xhr.withCredentials = true;
	xhr.send();
}

export function getCurrentTime() {
	var currentTime = new Date();
	var year = currentTime.getFullYear();
	var month = currentTime.getMonth() + 1; // 月份从0开始，因此需要1
	var day = currentTime.getDate();
	var hours = currentTime.getHours();
	var minutes = currentTime.getMinutes();
	var seconds = currentTime.getSeconds();
	return `${year}-${toDo(month)}-${toDo(day)} ${toDo(hours)}:${toDo(minutes)}:${toDo(seconds)}`
}
function toDo(n) {
	return n < 10 ? '0' + n : n
}