<template>
	<div id="app">
		<div v-if="$route.meta.keepAlive">
			<navTop></navTop>
			<view class="">
				<router-view></router-view>
			</view>
			
		</div>
		<div v-if="!$route.meta.keepAlive">
			<router-view></router-view>
		</div>
		<router-view />
	</div>
</template>
<script>
	import navTop from './components/navTop/navTop.vue'
	import {
		mapState,
		mapMutations
	} from 'vuex';
	import {
		getIndex
	} from '@/request/agent.js'
	export default {
		components: {
			navTop
		},
		created() {
			// if(this.isMobile()) {
			// 	window.location.href = 'https://www.ezsredcross.org.cn/index/#/'
			// }
			this.getIndex()
			console.log('dd');
			let userInfo = JSON.parse(window.localStorage.getItem('user'))
			console.log(userInfo, 'userInfo');
			if (userInfo && userInfo.id) {
				this.setUserInfo(userInfo)
			} else {
				this.$router.push('/login')
			}
		},
		methods: {
			...mapMutations(['setUserInfo', 'setBaseInfo']),
			getIndex() {
				getIndex().then(res => {
					// console.log(res);
					this.setBaseInfo(res.data)
				})
			}
			// isMobile() {
			// 	if(/android/i.test(navigator.userAgent)) {
			// 		//document.write("This is Android'browser.");//这是Android平台下浏览器
			// 		return true;
			// 	}
			// 	if(/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
			// 		//document.write("This is iOS'browser.");//这是iOS平台下浏览器
			// 		return true;
			// 	}
			// 	return false;
			// }
		}
	}
</script>
<style lang="scss">
	.el-cascader-menu {
		height: 300px !important;
	}

	.el-cascader-menu__wrap {
		height: 300px !important;
	}

	#app {
		max-width: 1920px;
		min-width: 1202px;
		margin: 0 auto;
	}

	.main-wrapper {
		width: 1202px;
		margin: 0 auto;
	}

	.bg {
		// position: absolute;
		// left: 0;
		// right: 0;
		// margin: 0 auto;
		// margin: 0 auto -300px;
		height: 280px;
		// max-width: 1920px;
		// min-width: 1202px;
		margin-bottom: -280px;
		// background-image: url(assets/img/m1.png);
		// background-size: auto 100%;
		z-index: -1;

		img {
			width: 100%;

			height: 300px;
		}
	}
</style>