<template>
    <div class="main-content-con">
        <!--https://youzan.github.io/vant/#/zh-CN/nav-bar-->
        <van-nav-bar :title="title"
                     :left-arrow="$route.meta.leftArrow!==false"
                     v-if="$route.meta.hideNavBar!==true"
                     @click-left="_back"></van-nav-bar>
        <div class="main-layout-cont" :class="[{'main-layout-cont-hide-navbar':$route.meta.hideNavBar===true}]">
            <router-view></router-view>
        </div>
    </div>
</template>

<script>

    export default {
        name: "Index",
        components: {},
        computed: {
            title: {
                get() {
                    let title = ''
                    if (this.$route.meta.customerNavBarTitle !== true) {
                        title = this.$route.meta.title
                    } else {
                        title = this.$route.query.title
                    }
                    return title
                }
            }
        },
        mounted() {
            this._login()
        },
        methods: {
            _login() {
                if (this.$global.getToken) {
                    console.log('已登录')
                } else {
                    //无权限的时候退出登录
                    this.$router.replace('/login');
                }
            },
            _back() {
                if (this.$route.meta.leftArrow !== false) {
                    this.$router.go(-1)
                }
            }
        }
    }
</script>

<style scoped>

</style>
