<template>
  <div style="width: 100vw;">
    <div class="home">
    	<div class="content">
    		<router-view></router-view>
    	</div>
    </div>
  </div>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	import {
		munList
	} from '@/assets/js/admun.js'
	import {
		getUserInfo
	} from '@/request/user.js'
	export default {
		name: 'Home',
		data() {

			return {
				numList: [{
						tit: '首页',
						path: '',

					},
					{
						tit: '用户中心',
						path: '',

					},
					{
						tit: '订单列表',
						path: '',

					},
					{
						tit: '订单结算',
						path: '',

					}
				],
				isopen: true,
				openOrClose: ['el-icon-arrow-right', 'el-icon-arrow-left'],
			}
		},
		computed: {
			...mapState(['userInfo', 'baseInfo']),
			currenIndex() {
				return this.$route.path
			},
			menulist() {
				return munList
			}
		},
		methods: {
			...mapMutations(['setUserInfo']),
			getUserInfo() {
				getUserInfo().then(res => {
					this.setUserInfo(res.data)
					if(this.userInfo.agent_id == 0) {
						this.$router.push('/home/addOrder')
					}else {
						this.$router.push('/home/statistics')
					}
				})
			},
			
			logout() {
				window.sessionStorage.clear()
				this.$router.push('/login')
			},
			async getMenList() {
				const {
					data: res
				} = await this.$http.get('menus')
				if (res.meta.status !== 200) return this.$message.error(res.meta.msg)
				this.menulist = res.data
			},
			closeBtn() {
				this.isopen = !this.isopen
			},
		},
		created() {
			this.getUserInfo()
		},
	}
</script>

<style scoped lang="scss">
	.content {
		width: 1425px;
		margin: auto;
		min-width: 1425px;
	}
</style>