lock.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <div class="mac_bg"></div>
  3. <div class="login animate__animated" :class="{ animate__bounceOut: pass }">
  4. <div class="head">
  5. <img
  6. src="https://avatar.gitee.com/uploads/61/632261_smallweigit.jpg!avatar100?1518660401"
  7. alt=""
  8. />
  9. </div>
  10. <div class="message">{{ userInfo.username }}</div>
  11. <div class="form">
  12. <div class="item" style="width: 320px" :class="passwdError ? 'error' : ''">
  13. <input class="password" placeholder="password here..." v-model="passwd" type="password" />
  14. <i class="iconfont el-icon-unlock" @click="handleLogin"></i>
  15. <i class="iconfont icon-tuichu" @click="handleLogout"></i>
  16. </div>
  17. </div>
  18. </div>
  19. </template>
  20. <script>
  21. import { mapGetters } from 'vuex';
  22. export default {
  23. data() {
  24. return {
  25. passwdError: false,
  26. passwd: '',
  27. pass: false,
  28. };
  29. },
  30. computed: {
  31. ...mapGetters(['userInfo', 'tag', 'lockPasswd']),
  32. },
  33. methods: {
  34. handleLogout() {
  35. this.$store.dispatch('LogOut').then(() => {
  36. this.$router.push({ path: '/login' });
  37. });
  38. },
  39. handleLogin() {
  40. if (this.passwd != this.lockPasswd) {
  41. this.passwd = '';
  42. this.passwdError = true;
  43. setTimeout(() => {
  44. this.passwdError = false;
  45. }, 1000);
  46. return;
  47. }
  48. this.pass = true;
  49. setTimeout(() => {
  50. this.$store.commit('CLEAR_LOCK');
  51. this.$router.push({
  52. path: this.tag.value,
  53. });
  54. }, 1000);
  55. },
  56. },
  57. };
  58. </script>
  59. <style scoped>
  60. @import url('./login.css');
  61. </style>