loginBox2.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <div class="c-loginBox">
  3. <el-button
  4. type="primary"
  5. class="login-btn"
  6. @click="handleLogin"
  7. v-if="!isLogin">
  8. {{$t('login.login')}}
  9. </el-button>
  10. <el-button
  11. type="primary"
  12. class="login-btn"
  13. :loading="true"
  14. v-else>
  15. {{$t('login.autoLogin')}}
  16. </el-button>
  17. <p>{{$t('login.loginWithScatter')}}</p>
  18. <a class="tip" href="https://get-scatter.com/" target="_blank" v-if="!scatter">{{$t('login.loadScatter')}}</a>
  19. </div>
  20. </template>
  21. <script>
  22. import Vue from 'vue'
  23. import { Button } from 'element-ui'
  24. import { mapState } from 'vuex'
  25. import { constants } from 'fs'
  26. Vue.component(Button.name, Button)
  27. export default {
  28. name: 'loginBox2',
  29. created () {
  30. },
  31. computed: {
  32. ...mapState([
  33. 'account',
  34. 'scatter'
  35. ]),
  36. isLogin () {
  37. return this.$store.state.chat.isLogin
  38. }
  39. },
  40. methods: {
  41. async handleLogin () {
  42. try {
  43. await this.$store.dispatch('doScatterLogin', this.$router)
  44. await this.$store.dispatch('doContractLogin')
  45. this.$store.commit('chatAppLogin', true)
  46. this.$store.commit('toApp', true)
  47. } catch (error) {
  48. this.$store.commit('chatAppLogin', false)
  49. }
  50. }
  51. }
  52. }
  53. </script>
  54. <style lang="scss" scoped>
  55. .c-loginBox{
  56. position: absolute;
  57. top: 50%;
  58. left: 50%;
  59. margin-left: -200px;
  60. margin-top: -100px;
  61. border-radius: 4px;
  62. -moz-border-radius: 4px;
  63. -webkit-border-radius: 4px;
  64. background-color: #fff;
  65. width: 400px;
  66. height: 200px;
  67. box-shadow: 0 2px 10px #999;
  68. -moz-box-shadow: #999 0 2px 10px;
  69. -webkit-box-shadow: #999 0 2px 10px;
  70. text-align: center;
  71. p{
  72. text-align: center;
  73. color: #a3a3a3;
  74. font-size: 15px;
  75. padding: 0 40px;
  76. line-height: 1.8;
  77. }
  78. .login-btn{
  79. margin-top: 50px;
  80. margin-bottom: 30px;
  81. min-width: 150px;
  82. font-size: 20px;
  83. }
  84. .tip{
  85. display: block;
  86. color: #f93c3c;
  87. font-size: 12px;
  88. }
  89. }
  90. </style>