<template>
  <div class="af-entry">
    <keep-alive>
      <router-view v-if="$route.meta.keepAlive"></router-view>
    </keep-alive>
    <router-view v-if="!$route.meta.keepAlive"></router-view>
  </div>
</template>

<script>
import { WxConfig } from './utils/wxConfig'
import { platform } from './utils/platform'

export default {
  name: 'App',
  data () {
    return {
      activeTab: 'PlaceList'
    }
  },
  watch: {
    '$route.name': {
      handler: function (newVal) {
        this.activeTab = newVal
      },
      immediate: true
    }
  },
  async created () {
    platform.isWeixin && WxConfig()
    await this.$store.dispatch('common/fetchBarList')
  },
  mounted () {
    const routeName = this.$route.name
    this.activeTab = ['PlaceList', 'PlaceReserve'].findIndex(item => item === routeName) > -1 ? routeName : ''
  },
  methods: {
    onChange (routeName) {
      this.$router.replace({ name: routeName })
    }
  }
}
</script>

<style lang="scss">
@import "./assets/styles/reset";

.clearfix {
  display: inline-block;

  &:after {
    display: block;
    content: ".";
    height: 0;
    line-height: 0;
    clear: both;
    visibility: hidden;
  }
}
</style>
