<template>
  <div>
    <template v-if="isMobile">
      <step-select v-if="step === 'select'" @stepEvent="setStep" @setDataEvent="setInfo"/>
      <step-mobile v-if="step === 'mobile'" @stepEvent="setStep" @tokenEvent="loadToken" :info="info"/>
      <step-email v-if="step === 'email'" @stepEvent="setStep" :info="info"/>
      <step-new v-if="step === 'new'" @stepEvent="setStep" :tokenId="tokenId"/>
      <step-success v-if="step === 'success'"/>
    </template>
    <template v-else>
      <accountCenter-header/>
      <encrypted-setting/>
    </template>
  </div>
</template>
<script>
  import AccountCenterHeader from '~components/default/AccountCenterHeader.vue'
  import EncryptedSetting from '~components/encrypted-setting/EncryptedSetting.vue'
  import {StepSelect, StepMobile, StepEmail, StepNew, StepSuccess} from '~components/mobile/encryptedSetting'
  export default {
    layout (content) {
      return content.store.state.option.isMobile ? 'mobile' : 'default'
    },
    transition: {
      name: 'fade',
      mode: 'out-in'
    },
    middleware: 'authenticated',
    data () {
      return {
        step: 'select',
        info: '',
        tokenId: ''
      }
    },
    components: {
      AccountCenterHeader,
      EncryptedSetting,
      StepSelect,
      StepMobile,
      StepEmail,
      StepNew,
      StepSuccess
    },
    mounted () {
      this.$route.query.token ? this.step = 'new' : this.step = 'select'
    },
    computed: {
      isMobile () {
        return this.$store.state.option.isMobile
      }
    },
    methods: {
      setStep (step) {
        this.step = step
      },
      setInfo (info) {
        this.info = info
      },
      loadToken (token) {
        this.tokenId = token
      }
    }
  }
</script>
