<script>
	import {
		onBackPress
	} from "@dcloudio/uni-app"
	import {
		toast,
		getUserIdentity
	} from "@/utils/common";
	import cacheManager from "@/utils/cacheManager.js";
	import {useIsCanBack} from "@/store/isCanBack.js"
	export default {

		// creat by wgy 0619  生命周期 钩子
		onLaunch: function() {
			// #ifdef APP-PLUS
			if (cacheManager.get('auth')) {
				uni.reLaunch({
					url: `/pages/study/index`,
					success() {
						  plus.navigator.closeSplashscreen();
					}
				})
			}else if(cacheManager.get('wxLogin') &&!(cacheManager.get('wxLogin').bind)){
					console.log('微信登录且未绑定')
				// 微信登录且未绑定 
			} else {
				cacheManager.clearAll()
				uni.reLaunch({
					url: '/pages/login/index' ,
					success() {
						  plus.navigator.closeSplashscreen();
					}
				});
			}
					// #endif
		},
		onShow: function() {
			// #ifdef APP-PLUS
			// if (cacheManager.get('auth')) {	
			// 	uni.reLaunch({
			// 		url: `/pages/study/index`
			// 	})
			// }else if(!(cacheManager.get('wxLogin').bind)){
			// 		console.log('asdfadsfadsfasd')
			// 	// 微信登录且未绑定 
			// } else {
			// 	cacheManager.clearAll()
			// 	uni.redirectTo({
			// 		url: '/pages/login/index' 
			// 	});
			// }

			const webview = plus.webview.currentWebview();
			plus.key.addEventListener('backbutton', () => {
				const store = useIsCanBack();
				if (!store.isCanBack) {
					event.preventDefault();
					return false
				} else {
					return true
				}
			});
			// #endif
		},
		onHide: function() {
	// 	//	console.log('App Hide')
	// 	// #ifdef APP-PLUS
	// 	if (cacheManager.get('auth')) {
	// 		uni.reLaunch({
	// 			url: `/pages/study/index`
	// 		})
	// 	}else if(!(cacheManager.get('wxLogin').bind)){
	// 			console.log('asdfadsfadsfasd')
	// 		// 微信登录且未绑定
	// 	} else {
	// 		cacheManager.clearAll()
	// 		uni.redirectTo({
	// 			url: '/pages/login/index'
	// 		});
	// 	}

	// 	// #endif

		}
	}
</script>

<style lang="scss">
	/* 公共样式 */
	@import '/common/styles/index.scss';

	// 西文、雅黑、黑体、宋体
	body,
	html,
	#app {
		font-family: "Helvetica Neue", "Microsoft YaHei", "SimHei", "SimSun", "Arial", sans-serif;
		margin: 0;
		padding: 0;
		box-sizing: border-box;
	}
</style>