<script>
	export default {
		globalData: {
			
			baseURL: "http://127.0.0.1:8111/",
			wxSilentLoginURL: "http://127.0.0.1:8111/portal/v1/sysUser/wxSilentLogin",
			wxAuthLoginURL: "http://127.0.0.1:8111/portal/v1/sysUser/wxAuthLogin",
			// baseURL: "https://gateway.yyundong.com/",
			// wxSilentLoginURL: "https://gateway.yyundong.com/portal/v1/sysUser/wxSilentLogin",
			// wxAuthLoginURL: "https://gateway.yyundong.com/portal/v1/sysUser/wxAuthLogin",
			isDebug: true,
			token: "",
			isLogin: false,
			sysUserSid: "",
			isOnLunch: false,
			statusBarHeight: "",
			navHeight: "",
			navWidth: "",
			totalHeight: "",
			statusBarHeightPx: "",
			navHeightPx: "",
			navWidthPx: "",
			totalHeightPx: "",
			statusBarHeightUpx: "",
			navHeightUpx: "",
			navWidthUpx: "",
			totalHeightUpx: "",
			windowWidth: "",
			isAuthentication: false,
			gameCache: {
				gameData: {
					"isCache": false
				},
				cache: false
			}
		},
		onLaunch: function() {
			
			this.WxSilentLogin()
			let sysUserSid = this.ReadPreference("sysUserSid")
			if (sysUserSid != null && sysUserSid.length != 0) {
				this.globalData.sysUserSid = sysUserSid
			}
			let isLogin = this.ReadPreference("isLogin")
			if (isLogin != null && isLogin == 1) {
				this.globalData.isLogin = isLogin
			}
			let token = this.ReadPreference("token")
			if (token != null && token.length != 0) {
				this.globalData.token = token
			} 

			console.log('用户Sid', this.globalData.sysUserSid)
			console.log('是否登陆', this.globalData.isLogin)
			console.log('App', 'onLaunch')
			// 不要删除
			console.log('高德地图定位Web服务key', '59970402d1c3f7dc1efff17d4dfcff21')
			this.globalData.isOnLunch = true
			let cache = this.ReadPreference("cache")
			if (cache != null && cache.length != 0) {
				this.globalData.gameCache.cache = cache
			} else {
				this.globalData.gameCache.cache = false
			}
			if (this.globalData.gameCache.cache) {
				let gameCache = this.ReadPreference2("cacheData")
				if (gameCache == undefined || gameCache == null || gameCache === "" || gameCache === "null") {
					this.globalData.gameCache.cache = false
				} else {
					gameCache.isCache = true
					this.globalData.gameCache.gameData = gameCache
				}
			} else {
				this.globalData.gameCache.gameData = {
					"isCache": false
				}
			}

			// 获取状态栏高度
			let info = uni.getSystemInfoSync()
			// 状态栏高度 赋值给全局
			this.globalData.statusBarHeight = info.statusBarHeight

			this.globalData.windowWidth = info.windowWidth
			this.globalData.windowWidthPx = info.windowWidth + 'px'
			//console.log("屏幕原始宽度" + this.globalData.windowWidthPx)

			// 默认导航栏高度
			this.globalData.navHeight = '45'
			// 默认导航栏宽度
			this.globalData.navWidth = this.globalData.windowWidth
			// 默认导航栏总高度
			this.globalData.totalHeight = 45 + this.globalData.statusBarHeight

			// 获取胶囊高度
			// #ifdef MP-WEIXIN||MP-BAID||MP-QQ||MP-TOUTIAO
			let menuButton = uni.getMenuButtonBoundingClientRect()
			let top = menuButton.top
			let bottom = menuButton.bottom
			let navHeight = bottom - top + (top - this.globalData.statusBarHeight) * 2 + 4
			this.globalData.navHeight = navHeight
			this.globalData.navWidth = menuButton.left
			this.globalData.totalHeight = navHeight + this.globalData.statusBarHeight
			// #endif

			//console.log('计算导航栏可用宽度', this.globalData.navWidth)
			//console.log('计算导航栏可用高度', this.globalData.navHeight)
			//console.log('计算状态栏高度', this.globalData.statusBarHeight)
			//console.log('计算导航栏总高度', this.globalData.totalHeight)

			this.globalData.navWidthPx = this.globalData.navWidth + 'px'
			this.globalData.navHeightPx = this.globalData.navHeight + 'px'
			this.globalData.statusBarHeightPx = this.globalData.statusBarHeight + 'px'
			this.globalData.totalHeightPx = this.globalData.totalHeight + 'px'

			//console.log('计算导航栏可用宽度像素值', this.globalData.navWidthPx)
			//console.log('计算导航栏可用高度像素值', this.globalData.navHeightPx)
			//console.log('计算状态栏高度像素值', this.globalData.statusBarHeightPx)
			//console.log('计算导航栏总高度像素值', this.globalData.totalHeightPx)

			this.globalData.navWidthUpx = this.Px2Upx(this.globalData.windowWidth, this.globalData.navWidth)
			this.globalData.navHeightUpx = this.Px2Upx(this.globalData.windowWidth, this.globalData.navHeight)
			this.globalData.statusBarHeightUpx = this.Px2Upx(this.globalData.windowWidth, this.globalData
				.statusBarHeight)
			this.globalData.totalHeightUpx = this.Px2Upx(this.globalData.windowWidth, this.globalData.totalHeight)


			//console.log('计算导航栏可用宽度upx', this.globalData.navWidthUpx)
			//console.log('计算导航栏可用高度upx', this.globalData.navHeightUpx)
			//console.log('计算状态栏高度upx', this.globalData.statusBarHeightUpx)
			//console.log('计算导航栏总高度upx', this.globalData.totalHeightUpx)

			// 可能会报错 一定要放在最后执行
			// #ifdef  APP-PLUS 
			plus.navigator.closeSplashscreen();
			// #endif
		},
		onShow: function() {
			//console.log('App Show')
		},
		onHide: function() {
			//console.log('App Hide')
		}
	}
</script>

<style>
	/*每个页面公共css */
	/*每个页面公共css */
	page {
		height: 100%;
		width: 100%;
	}
</style>
