<template>
  <div class="mobile-container">
    <el-result :title="title" :subTitle="subTitle" icon="error">
      <template slot="icon" v-if="success">
        <i class="el-icon-loading" style="font-size: 48px"/>
      </template>
      <template slot="extra">
        <el-button type="text" size="medium" @click="redirectToWx" >没有反应？点我跳转</el-button>
      </template>
    </el-result>
  </div>
</template>

<script>
import wx from 'weixin-js-sdk'
import { tansParams } from '@/utils/ruoyi'

export default {
  name: 'Liveness',
  data() {
    return {
      success: true,
    }
  },
  computed: {
    subTitle() {
      if (this.success) {
        return "正在获取结果中，请稍后"
      } else {
        return "认证失败，请重新认证"
      }
    },
    title() {
      if (this.success) {
        return "跳转中"
      } else {
        return "认证失败"
      }
    }
  },
  created() {
    this.success = this.$route.query.success === 'true';
    this.redirectToWx();
  },
  methods: {
    redirectToWx() {
      wx.miniProgram.getEnv( (envRes) => {
        if (envRes.miniprogram) {
          wx.miniProgram.navigateBack()
        }
      })
    }
  }
}
</script>
<style scoped lang="scss">
.mobile-container {
  position: absolute;
  width: 100%;
  height: 100vh;
  padding-top: 20vh;
}
</style>
