<template>
  <div id="app" v-if="showPage">
    <router-view/>
  </div>
</template>

<script>
import { createNamespacedHelpers } from 'vuex'
const { mapActions: mapIndexActions } = createNamespacedHelpers('main')
export default {
  data () {
    return {
      showPage: false
    }
  },
  created () {
    if (location.search && this.toolClass.UrlSearch(location.search).code) {
      this.code = this.toolClass.UrlSearch(location.search).code
      let oldCode = localStorage.getItem('code')
      if (this.code === oldCode) {
        localStorage.setItem('code', this.code)
        this.toolClass.getCode('wx32e2e8c81f66070e')
      } else {
        localStorage.setItem('code', this.code)
        this.customer(this.code).then(() => {
          this.showPage = true
        })
      }
    } else {
      this.toolClass.getCode('wx32e2e8c81f66070e')
    }
  },
  methods: {
    ...mapIndexActions(['customer'])
  }
}
</script>


<style lang="scss">
@import "./assets/reset.css";
#app {
  width: 100%;
  height: 100%;
  position: relative;
}
</style>
