<template>
  <div class="mainPage flex-v">
    <div class="subPage flex-item">
      <div>
        <router-view></router-view>
      </div>
    </div>
    <nav class="flex-h" :style="{paddingBottom: isIphoneX ? '.1rem' : '0'}">
      <router-link :to="{name:item.pathName,query:{}}" v-if="showTabBar" class="flex-item" active-class="active" v-for="(item, index) in tabBar" :key="index">
        <div>
          <img v-if="index==0" class="centerLabel" src="../../../common/icon/tabBar-icon-1.png" alt="">
          <img v-if="index==1" class="centerLabel" src="../../../common/icon/tabBar-icon-2.png" alt="">
          <img v-if="index==2" class="centerLabel" src="../../../common/icon/tabBar-icon-4.png" alt="">
          <img v-if="index==3" class="centerLabel" src="../../../common/icon/tabBar-icon-3.png" alt="">
        </div>
        <span>{{item.name}}</span>
      </router-link>
    </nav>
  </div>
</template>

<script>
import { mapState, mapActions } from 'vuex'
export default {
  name: '',
  data () {
    return {
      isIphoneX: false,
      tabBar: [{
        pathName: 'indexPage',
        name: '城的空间'
      }, {
        pathName: 'coffeeIndex',
        name: '城咖啡'
      }, {
        pathName: 'libraryIndex',
        name: '图书馆'
      }, {
        pathName: 'userCenter',
        name: '会员'
      }],
      showTabBar: false
    }
  },
  computed: {
    ...mapState({
      userInfo: x => x.userCenter.userInfo
    })
  },
  components: {
  },
  created () {
    var aHeight = document.documentElement.clientHeight,
      aWidth = document.documentElement.clientWidth
    if (aHeight === 724 && aWidth === 375) {
      this.isIphoneX = true
    }
    if (!this.userInfo.customer.MapUser || !this.$route.query.hideTabbar) {
      this.showTabBar = true
    }
    if (this.$route.query.hideTabbar) {
      sessionStorage.setItem('from', 'sales')
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
@import 'page.scss';
</style>
