(function (doc, win) {
	var getFontSize = function () {
		var fontSize = 0;
		var clientWidth = docEl.clientHeight;
		//console.log(clientWidth,"clientWidth---")
		if (!clientWidth) {
			return
		} else {
			//clientWidth = clientWidth < 1024  ? 1024 : clientWidth;
			// 1479  这个值看设计图的尺寸大小算出
			//   设计图是按照 1920*1080   该 值禁止修改
			//fontSize = 100 * (clientWidth / 1080);
			fontSize = 100 * (clientWidth / 1080);
			//fontSize = 100 * (clientWidth / 1479) ;
			//docEl.style.fontSize = fontSize;
		}
		//console.log(fontSize)
		return fontSize;
	}
	var getPxToRem = function (px) {
		var fontSzie = getFontSize();
		/*if(px < 0){
			return 0
		}*/
		var rem = px / fontSzie;
		return rem
	}
	var getRemToPx = function (rem) {
		var fontSzie = getFontSize();
		/*if(rem < 0){
			return 0
		}*/
		var px = rem * fontSzie;
		return px
	}

	var docEl = doc.documentElement,
		resizeEvt = "orientationchange" in window ? 'orientationchange' : 'resize',
		recalc = function () {
			var clientWidth = docEl.clientHeight;
			if (!clientWidth) {
				return
			} else {
				var fontSize = getFontSize() + "px";
				docEl.style.fontSize = fontSize;
			}
		}
	if (!doc.addEventListener) return;
	win.addEventListener(resizeEvt, recalc, false);
	doc.addEventListener("DOMContentLoaded", recalc, false);

	// 禁止双击放大
	document.documentElement.addEventListener('touchstart', function (event) {
		if (event.touches.length > 1) {
			event.preventDefault();
		}
	}, false);
	var lastTouchEnd = 0;
	document.documentElement.addEventListener('touchend', function (event) {
		var now = Date.now();
		if (now - lastTouchEnd <= 300) {
			event.preventDefault();
		}
		lastTouchEnd = now;
	}, false);

	recalc();
	window.getFontSize = getFontSize;
	window.getPxToRem = getPxToRem;
	window.getRemToPx = getRemToPx;

	win.getFontSize = getFontSize;
	win.getPxToRem = getPxToRem;
	win.getRemToPx = getRemToPx;


})(document, window)