Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. <template>
  2. <div class="row">
  3. <div class="col-md-6">
  4.  
  5. <div class="form-group">
  6. <label>Matricula</label>
  7. <input type="matricula" v-model="user.matricula" class="form-control">
  8. </div>
  9.  
  10. <div class="form-group" v-if="showPassword">
  11. <label>Senha</label>
  12. <input type="text" v-model="user.senha" class="form-control">
  13. </div>
  14. <div class="form-group" v-else="showPassword">
  15. <label>Senha</label>
  16. <input type="password" v-model="user.senha" class="form-control">
  17. </div>
  18.  
  19. <div class="form-group">
  20. <input type="checkbox" @click="changeType">
  21. <label>Visualizar a senha ao digitar?</label>
  22. </div>
  23.  
  24. <button type="submit" @click="doLogin" class="btn btn-success" :disabled="!isValid">Logar</button>
  25.  
  26. <sweet-modal icon="success" ref="modalSucess" @close="redirectPage">
  27. Logado com sucesso!
  28. </sweet-modal>
  29. <sweet-modal icon="warning" ref="modalFail">
  30. Dados incorretos. Tente novamente.
  31. </sweet-modal>
  32.  
  33. <!-- modal para reenvio de senha -->
  34. <button class="btn btn-default" @click="showModalReenvioSenha=true">Esqueceu a senha?</button>
  35. <modalReenvioSenha v-if="showModalReenvioSenha" @close="showModalReenvioSenha=false"></modalReenvioSenha>
  36. </div>
  37. </div>
  38. </template>
  39.  
  40. <script>
  41. import { mapActions } from 'vuex'
  42. import { isEmpty } from 'lodash'
  43. import modalReenvioSenha from './../../../../components/root/modals/ReenvioSenha.vue'
  44. import modalMudarSenha from './../../../../components/root/modals/MudarSenha.vue'
  45. import { SweetModal, SweetModalTab } from 'sweet-modal-vue'
  46.  
  47. export default {
  48.  
  49. name: 'login',
  50.  
  51. components: { modalReenvioSenha, modalMudarSenha, SweetModal, SweetModalTab },
  52.  
  53. data () {
  54. return {
  55. user: {
  56. matricula: '',
  57. senha: ''
  58. },
  59. showModalReenvioSenha: false,
  60. showModalMudarSenha: false,
  61. showPassword: false
  62. }
  63. },
  64.  
  65. methods: {
  66. ...mapActions(['attemptLogin']),
  67.  
  68. doLogin () {
  69. const user = this.user
  70. this.attemptLogin({...user})
  71. .then(() => {
  72. this.user.matricula = ''
  73. this.user.senha = ''
  74. this.$refs.modalSucess.open()
  75. })
  76. .catch(() => {
  77. this.$refs.modalFail.open()
  78. })
  79. },
  80.  
  81. redirectPage () {
  82. this.$router.push('/dashboard')
  83. },
  84.  
  85. changeType () {
  86. this.showPassword = !this.showPassword
  87. }
  88. },
  89.  
  90. computed: {
  91. isValid () {
  92. const user = this.user
  93. return !isEmpty(user.matricula) && !isEmpty(user.senha)
  94. }
  95. }
  96.  
  97. }
  98. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement