<script>
	// 业绩统计打包路径 /h5  库存信息 /CKselect
	export default {
		onLaunch: function() {
			this.fontSizeSetting()
			uni.toast = (...args) => uni.showToast({
				duration: 5678,
				title: args[0],
				icon: 'none'
			});
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods: {
			fontSizeSetting() {
				window.onload = function() {
					setAndroidFontsize();
					htmlFontSize()
				}
				window.onresize = function() {
					setAndroidFontsize();
					htmlFontSize()
				}
				// 安卓解决微信浏览器字体被调大导致页面错乱的办法
				function setAndroidFontsize() {
					if (typeof window.WeixinJSBridge == "object" && typeof window.WeixinJSBridge.invoke == "function") {
						handleFontSize();
					} else {
						if (document.addEventListener) {
							document.addEventListener("WeixinJSBridgeReady", handleFontSize, false);
						} else if (document.attachEvent) {
							document.attachEvent("WeixinJSBridgeReady", handleFontSize);
							document.attachEvent("onWeixinJSBridgeReady", handleFontSize);
						}
					}
				}
				function handleFontSize() {
					window.WeixinJSBridge.invoke('setFontSizeCallback', {
						'fontSize': 0
					});
					window.WeixinJSBridge.on('menu:setfont', function() {
						window.WeixinJSBridge.invoke('setFontSizeCallback', {
							'fontSize': 0
						});
					});
				}
		
				function htmlFontSize() {
					var h = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
					var w = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
					var width = w > h ? h : w;
					width = width > 720 ? 720 : width
					var fz = ~~(width / 15)
					document.getElementsByTagName("html")[0].style.cssText = 'font-size: ' + fz + "px";
					var realfz = ~~(+window.getComputedStyle(document.getElementsByTagName("html")[0]).fontSize.replace(
							'px', '') *
						10000) / 10000
					if (fz !== realfz) {
						document.getElementsByTagName("html")[0].style.cssText = 'font-size: ' + fz * (fz / realfz) + "px";
					}
				}
			}
		}
	}
</script>

<style lang="scss">
	@import './static/css/iconfont.css';
	@import 'common/style/icon.scss'; //引入 ColorUI 组件库图标样式
	/*每个页面公共css */
	page {
		background-color: #F5F5F5;
		font-size: 28rpx;
	}
	.flexV {
		display: flex;
		align-items: center;
	}
	.flexC {
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.flexS {
		display: flex;
		align-items: center;
		justify-content: flex-start;
	}
	.flexB {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
	.flexT {
		display: flex;
		justify-content: space-between;
		align-items: flex-start;
	}
</style>
