<template>
  <div class="error-page">
    <!-- <img class="error-icon" src="@/assets/gic-error.png" alt="404" />
    <div class="error-message">{{ message }}</div>
    <el-button type="primary" @click="toLogin">返回好办登录页</el-button> -->
  </div>
</template>

<script>
export default {
  name: 'page404',
  data() {
    return {
      gicHost: '',
      message: ''
    };
  },
  methods: {
    toLogin() {
      location.href = this.gicHost + '/gic-web/#/login?ishb=1';
    }
  },
  mounted() {
    const errorCode = this.$route.query.errorCode;
    const message = {
      '1000': '系统异常', //传入的导购id错误、传入的企业微信id错误
      '1001': '您还不是好办的管理员，请在 GIC 后台绑定好办企业后再登录',
      '1003': '系统异常，通过手机号查询失败',
      '1004': '企微应用未授权',
      '1005': '登录超时,请重新登录'
    };
    this.message = message[errorCode] || '系统异常，请联系达摩管理员';
    this.$message.error(this.message);
    setTimeout(this.toLogin, 3000);

    const userInfos = JSON.parse(sessionStorage.getItem('userInfos') || '{}');
    this.gicHost = typeof userInfos.gicHost == 'string' ? userInfos.gicHost.replace(/\/$/, '') : '';
  }
};
</script>

<style lang="scss" scoped>
.error-page {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  width: 100%;
  background: #f2f3f5;
  .error-icon {
    width: 148px;
    height: auto;
    vertical-align: middle;
  }
  .error-message {
    margin: 60px 0 37px;
    color: #606266;
    font-size: 14px;
    line-height: 28px;
  }
}
</style>
