<template>
  <view class="login" />
</template>

<script>
export default {
  data() {
    return {
      path: '/pages/index/index'
    }
  },
  computed: {},
  methods: {
    login() {
      this.$loading('登陆中...')
      this.$api.user.login().then(async res => {
        this.$hideLoading()
        const { token, user_info } = res.data
        await this.$store.dispatch('user/token', token)
        await this.$store.dispatch('user/info', user_info)
        uni.reLaunch({
          url: this.path.replace('//', '/')
        })
      })
    }
  },
  onLoad(options) {
    this.path = options.path ? options.path : this.path
    this.login()
  }
}
</script>

<style lang="scss" scoped>
    .login{

    }
</style>
