<template>
  <div>
  </div>
</template>

<script>
import {mapActions} from "vuex";
export default {
  name: "qv-login",
  data() {
    return {}
  },
  methods: {
    ...mapActions([
      'afterLogin'
    ]),
    /**
     * @desc   : 扫码登录
     * @author : 洪旭东
     * @date   : 2022-06-09 13:20
     */
    login(){
      let param = {
        sysId: this.$route.query.state == 'login' ? this.$config.sysType.SYS_MERCHANT : this.$config.sysType.SYS_HEGII,
        appUuid: this.$route.query.state == 'login' ? this.$config.appType.APP_WEB_MERCHANT : this.$config.appType.APP_WEB_HEGII,
        name: this.$route.query.code,
        clientId: this.$config.qvScanClientId
      }
      userService.qvScanLogin(param).then(res=>{
        this.$Spin.hide()
        if (res.code == 200 && res.data) {
          this.afterLogin(res.data)
          this.$router.push({
            name: this.$config.homeName
          })
        } else {
          this.$Message.warning(res.message)
          this.$router.push({
            name: this.$route.query.state
          })
        }
      })
    }
  },
  created() {
    this.$Spin.show({
      render: (h) => {
        return h('div', [
          h('Icon', {
            'class': 'demo-spin-icon-load',
            props: {
              type: 'ios-loading',
              size: 30
            }
          }),
          h('div', this.$t('loginLoading'))
        ])
      }
    });
    this.login()
  }
}
</script>

<style scoped>

</style>
