<template>
  <div id="app">
    <nav-bar :address="address" :showMenu="isShow" :userName.sync="userInfo.name" :title="title" v-if="userInfo.name"></nav-bar>
    <router-view class="child-container"></router-view>
  </div>
</template>

<script>
import navBar from '@/components/nav-bar';
import { mapGetters } from 'vuex';

export default {
  name: 'app',
  data() {
    return {
      isShow: false,
      address: 'title.png',
      title: '微商城后台管理',
    };
  },
  computed: {
    ...mapGetters([
      'userInfo',
    ]),
  },
  components: {
    navBar,
  },
  mounted() {
    // 此处调用服务端提供的登录接口，模拟mock，需要修改为真实链接
    this.$store.dispatch('Login', {
      params: {
        params: {
          id: 'admin',
        },
      },
    }).then(() => {
      this.$router.push({ path: '/dashboard/index' });
    }).catch(() => {
      // console.log('登录失败~');
    });
  },
};
</script>

<style lang="less">
  html, body, #app {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    min-width: 1000px;
    min-height: 594px;
    -webkit-font-smoothing: antialiased;
    font-family: "Helvetica Neue",Helvetica,"PingFang SC","Hiragino Sans GB","Microsoft YaHei",SimSun,sans-serif;
    font-size: 14px;
    color: #1F2D3D;
    background-color: #ffffff;
    box-sizing: border-box;
  }
</style>
