
<template>
  <div class="login-wrapper">
    <img class="logo" :src="logo" />

    <el-button
      type="primary"
      @click="submit"
      style="width:100%; margin-top: 6px;"
      :loading="loading"
    >登录问诊平台</el-button>
  </div>
</template>

<script>

export default {
  name: 'Login',
  components: {

  },
  data() {
    return {
      logo: require(process.env.VUE_APP_LOG_URL),
      loading: false
    }
  },
  methods: {
    submit() {
      this.login()
    },
    login() {
      this.loading = true
      this.tim
        .login({
          userID: this.$store.getters.userID,
          userSig: this.$store.getters.userSig
        })
        .then(() => {
          this.loading = false
          this.$store.commit('toggleIsLogin', true)
          this.$store.commit('startComputeCurrent')
          this.$store.commit('showMessage', { type: 'success', message: '登录成功' })
        })
        .catch(error => {
          this.loading = false
          this.$store.commit('showMessage', {
            message: '登录失败：' + error.message,
            type: 'error'
          })
        })
    },
  }
}
</script>

<style lang="stylus" scoped>
.login-wrapper
  display flex
  align-items center
  flex-direction column
  width 450px
  background $white
  color $black
  border-radius 5px
  box-shadow: 0 11px 20px 0 rgba(0,0,0,0.3)
  .row-div
    display flex
    justify-content center
    align-items center
    flex-direction row
  .logo
    width 80px;
    height 80px;
    border-radius:15rpx;
    margin-bottom:20px;
  .loginBox
    width 320px
    margin 0 0 20px 0
    .send-code
      width 112px
    .login-im-btn
      width 100%
  .loginFooter
    color: #8c8a8ac7
    text-align: center
    padding: 0 0 20px 0
    cursor: pointer
.login-wrapper {
  display: flex;
  align-items: center;
  flex-direction: column;
  width: 400px;
  padding: 20px 80px 50px;
  background: $white;
  color: $black;
  border-radius: 5px;
  box-shadow: 0 11px 20px 0 rgba(0, 0, 0, 0.3);

  .register-button {
    width: 100%;
    margin: 6px 0 0 0;
  }

  .user-selector {
    width: 100%;
  }
}
</style>
