<template>
    <div id="app">
        <div>
            <router-view />
        </div>
        <div class="nav" v-if="windowWidth">
            <div class="navBox">
                <router-link to="/home">
                    <div class="cell">
                        <div>
                            <van-icon :color="navNum==1?'#38D0C9':'#BBBBBB'" class="iconfont" size="30" class-prefix="icon" slot="left-icon" name="lvyou"></van-icon>
                        </div>
                        <div><span :style="{color:navNum==1?'#38D0C9':'#BBBBBB'}">{{ $t("navbar.home") }}</span></div>
                    </div>
                </router-link>
                <router-link to="/news">
                    <div class="cell">
                        <div>
                            <van-icon :color="navNum==2?'#38D0C9':'#BBBBBB'" name="chat-o" />
                        </div>
                        <div><span :style="{color:navNum==2?'#38D0C9':'#BBBBBB'}">{{ $t("navbar.news") }}</span></div>
                    </div>
                </router-link>
                <router-link to="/shopping">
                    <div class="cell">
                        <div>
                            <van-icon :color="navNum==3?'#38D0C9':'#BBBBBB'" name="shopping-cart-o" />
                        </div>
                        <div><span :style="{color:navNum==3?'#38D0C9':'#BBBBBB'}">{{ $t("navbar.shopping") }}</span></div>
                    </div>
                </router-link>
                <router-link to="/personal">
                    <div class="cell">
                        <div>
                            <van-icon :color="navNum==4?'#38D0C9':'#BBBBBB'" name="user-o" />
                        </div>
                        <div><span :style="{color:navNum==4?'#38D0C9':'#BBBBBB'}">{{ $t("navbar.personal") }}</span></div>
                    </div>
                </router-link>
            </div>
        </div>
        <van-notify />
    </div>
</template>
<script>
export default {
    name: "App",
    computed: {
        windowWidth() {
            return this.$store.state.app.navbarShow;
        },
        navNum() {
            return this.$store.state.app.navbarType;
        },
    },
};
//这里做一个rem的fong-size的适应 默认size是1rem=100px 默认设计图是375的
var windowWidth = document.documentElement.getBoundingClientRect().width;
windowWidth = windowWidth > 750 ? 750 : windowWidth;
var fontSize = windowWidth / 3.75;
document.documentElement.style.fontSize = fontSize + "px";
// store.state.app.navbarShow
</script>
<style lang="scss">
#app {
    margin: auto;
    font-family: Avenir, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: center;
    color: #2c3e50;
    .nav {
        width: 100%;
        height: 0.84rem /* 84/100 */;
        .navBox {
            position: fixed;
            left: 0;
            bottom: 0;
            width: 100%;
            height: 0.84rem /* 84/100 */;
            display: flex;
            padding: 0.14rem /* 14/100 */ 0.34rem /* 34/100 */ 0.24rem
                /* 24/100 */ 0.34rem /* 34/100 */;
            box-sizing: border-box;
            justify-content: space-between;
            align-items: center;
            box-shadow: 0px 0px 5px #e9e9e9;
            background: #fff;
            z-index: 2;
            .cell {
                width: 0.6rem /* 30/100 */;
                > div:nth-child(1) {
                    font-size: 0.3rem /* 12/100 */;
                }
                > div:nth-child(2) {
                    font-size: 0.12rem /* 12/100 */;
                }
            }
        }
    }
}

#nav {
    // padding: 0.3rem /* 30/100 */;
    a {
        font-weight: bold;
        color: #2c3e50;

        &.router-link-exact-active {
            color: #42b983;
        }
    }
}
</style>
