LoginBlock.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <script>
  2. // import Vue from 'vue'
  3. import { mapState } from 'pinia'
  4. // import router from 'vuejs/route'
  5. import { UserStore } from '@/stores/user'
  6. export default {
  7. setup() {
  8. const userStore = UserStore()
  9. return { userStore }
  10. },
  11. // router,
  12. // props: ['title', 'block'],
  13. data () {
  14. return {
  15. template: null,
  16. mail: '',
  17. passwd: ''
  18. }
  19. },
  20. computed: {
  21. ...mapState(UserStore,['loginMessage'])
  22. },
  23. methods: {
  24. // ...mapActions({
  25. // userLogin: 'User/userLogin',
  26. // openCloseHamMenu: 'Common/openCloseHamMenu'
  27. // }),
  28. onSubmitLogin (event) {
  29. console.log("onSubmitLogin", event, this.mail, this.passwd);
  30. this.userStore.userLogin({
  31. mail: this.mail,
  32. pass: this.passwd
  33. }).then(() => {
  34. console.log('LoginBlock user logged-in then')
  35. })
  36. // this.userLogin({
  37. // mail: this.mail,
  38. // pass: this.password
  39. // })
  40. // moved to user.js store
  41. // .then(() => {
  42. // console.log('LoginBlock user logged-in')
  43. // this.openCloseHamMenu(false)
  44. // this.$router.push({
  45. // name: 'base'
  46. // })
  47. // })
  48. }
  49. }
  50. }
  51. </script>
  52. <template>
  53. <form action="" @submit.prevent="onSubmitLogin">
  54. <input type="email" placeholder="email" name="email" v-model="mail">
  55. <input type="password" placeholder="mot de passe" name="passwd" v-model="passwd">
  56. <input type="submit" value="login">
  57. <p v-if="loginMessage">{{ loginMessage }}</p>
  58. </form>
  59. </template>
  60. <style lang="css" scoped>
  61. </style>