index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <div class="lock-container">
  3. <div class="lock-form animated bounceInDown">
  4. <div class="animated"
  5. :class="{'shake':passwdError,'bounceOut':pass}">
  6. <h3 class="title">{{userInfo.username}}</h3>
  7. <el-input placeholder="请输入登录密码"
  8. type="password"
  9. class="input-with-select animated"
  10. v-model="passwd"
  11. @keyup.enter.native="handleLogin">
  12. <el-button slot="append"
  13. icon="icon-jiesuo"
  14. @click="handleLogin"></el-button>
  15. <el-button slot="append"
  16. icon="icon-tuichu"
  17. @click="handleLogout"></el-button>
  18. </el-input>
  19. </div>
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. import { mapGetters, mapState } from "vuex";
  25. export default {
  26. name: "lock",
  27. data() {
  28. return {
  29. passwd: "",
  30. passwdError: false,
  31. pass: false
  32. };
  33. },
  34. created() {},
  35. mounted() {},
  36. computed: {
  37. ...mapState({
  38. userInfo: state => state.user.userInfo
  39. }),
  40. ...mapGetters(["tag", "lockPasswd"])
  41. },
  42. props: [],
  43. methods: {
  44. handleLogout() {
  45. this.$confirm("是否退出系统, 是否继续?", "提示", {
  46. confirmButtonText: "确定",
  47. cancelButtonText: "取消",
  48. type: "warning"
  49. }).then(() => {
  50. this.$store.dispatch("LogOut").then(() => {
  51. this.$router.push({ path: "/login" });
  52. });
  53. });
  54. },
  55. handleLogin() {
  56. if (this.passwd != this.lockPasswd) {
  57. this.passwd = "";
  58. this.$message({
  59. message: "解锁密码错误,请重新输入",
  60. type: "error"
  61. });
  62. this.passwdError = true;
  63. setTimeout(() => {
  64. this.passwdError = false;
  65. }, 1000);
  66. return;
  67. }
  68. this.pass = true;
  69. setTimeout(() => {
  70. this.$store.commit("CLEAR_LOCK");
  71. this.$router.push({
  72. path: this.$router.$avueRouter.getPath({ src: this.tag.value })
  73. });
  74. }, 1000);
  75. }
  76. },
  77. components: {}
  78. };
  79. </script>
  80. <style lang="scss">
  81. .lock-container {
  82. height: 100%;
  83. display: flex;
  84. align-items: center;
  85. justify-content: center;
  86. position: relative;
  87. .title {
  88. text-align: center;
  89. margin-bottom: 8px;
  90. }
  91. }
  92. .lock-container::before {
  93. z-index: -999;
  94. content: "";
  95. position: absolute;
  96. left: 0;
  97. top: 0;
  98. width: 100%;
  99. height: 100%;
  100. background-image: url("/img/bg/login.png");
  101. background-size: cover;
  102. }
  103. .lock-form {
  104. width: 300px;
  105. }
  106. </style>