Last active
August 23, 2017 16:59
-
-
Save viniazvd/0461e6b032df16587907d44f218c3758 to your computer and use it in GitHub Desktop.
showPassword
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div class="row"> | |
<div class="col-md-6"> | |
<div class="form-group"> | |
<label>Matricula</label> | |
<input type="matricula" v-model="user.matricula" class="form-control"> | |
</div> | |
<div class="form-group"> | |
<label>Senha</label> | |
<input :type="changeType ? 'text' : 'password'" class="form-control"> | |
</div> | |
<div class="form-group"> | |
<input type="checkbox" @click="showPassword"> | |
<label>Visualizar a senha ao digitar?</label> | |
</div> | |
<button type="submit" @click="doLogin" class="btn btn-success" :disabled="!isValid">Logar</button> | |
<sweet-modal icon="success" ref="modalSucess" @close="redirectPage"> | |
Logado com sucesso! | |
</sweet-modal> | |
<sweet-modal icon="warning" ref="modalFail"> | |
Dados incorretos. Tente novamente. | |
</sweet-modal> | |
<!-- modal para reenvio de senha --> | |
<button class="btn btn-default" @click="showModalReenvioSenha=true">Esqueceu a senha?</button> | |
<modalReenvioSenha v-if="showModalReenvioSenha" @close="showModalReenvioSenha=false"></modalReenvioSenha> | |
</div> | |
</div> | |
</template> | |
<script> | |
import { mapActions } from 'vuex' | |
import { isEmpty } from 'lodash' | |
import modalReenvioSenha from './../../../../components/root/modals/ReenvioSenha.vue' | |
import modalMudarSenha from './../../../../components/root/modals/MudarSenha.vue' | |
import { SweetModal, SweetModalTab } from 'sweet-modal-vue' | |
export default { | |
name: 'login', | |
components: { modalReenvioSenha, modalMudarSenha, SweetModal, SweetModalTab }, | |
data () { | |
return { | |
user: { | |
matricula: '', | |
senha: '' | |
}, | |
showModalReenvioSenha: false, | |
showModalMudarSenha: false, | |
changeType: false | |
} | |
}, | |
methods: { | |
...mapActions(['attemptLogin']), | |
doLogin () { | |
const user = this.user | |
this.attemptLogin({...user}) | |
.then(() => { | |
this.user.matricula = '' | |
this.user.senha = '' | |
this.$refs.modalSucess.open() | |
}) | |
.catch(() => { | |
this.$refs.modalFail.open() | |
}) | |
}, | |
redirectPage () { | |
this.$router.push('/dashboard') | |
}, | |
showPassword () { | |
this.changeType = !this.changeType | |
} | |
}, | |
computed: { | |
isValid () { | |
const user = this.user | |
return !isEmpty(user.matricula) && !isEmpty(user.senha) | |
} | |
} | |
} | |
</script> |
Author
viniazvd
commented
Aug 23, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment