LoginBlock.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <script>
  2. import Vue from 'vue'
  3. import { mapState, mapActions } from 'vuex'
  4. import router from 'vuejs/route'
  5. export default {
  6. name: "LoginBlock",
  7. router,
  8. props: ['title', 'block'],
  9. data () {
  10. return {
  11. template: null,
  12. mail: '',
  13. password: ''
  14. }
  15. },
  16. computed: {
  17. ...mapState({
  18. loginMessage: state => state.User.loginMessage,
  19. })
  20. },
  21. methods: {
  22. ...mapActions({
  23. userLogin: 'User/userLogin',
  24. openCloseHamMenu: 'Common/openCloseHamMenu'
  25. }),
  26. login () {
  27. this.userLogin({
  28. mail: this.mail,
  29. pass: this.password
  30. }).then(() => {
  31. console.log('LoginBlock user logged-in')
  32. this.openCloseHamMenu(false)
  33. this.$router.push({
  34. name: 'base'
  35. })
  36. })
  37. }
  38. },
  39. beforeMount() {
  40. // console.log('LoginBlock beforeMount', this._props.block)
  41. if (this._props.block) {
  42. // console.log('LoginBlock beforeMount if this._props.block ok')
  43. this.template = Vue.compile(this._props.block)
  44. this.$options.staticRenderFns = [];
  45. this._staticTrees = [];
  46. this.template.staticRenderFns.map(fn => (this.$options.staticRenderFns.push(fn)));
  47. }
  48. },
  49. mounted(){
  50. // console.log('LoginBlock mounted')
  51. Drupal.attachBehaviors(this.$el);
  52. },
  53. render(h) {
  54. // console.log('LoginBlock render')
  55. if (!this.template) {
  56. // console.log('LoginBlock render NAN')
  57. return h('span', 'Loading ...')
  58. } else {
  59. // console.log('LoginBlock render template')
  60. return this.template.render.call(this)
  61. }
  62. }
  63. }
  64. </script>
  65. <style lang="scss" scoped>
  66. // section{
  67. // max-width:300px;
  68. // }
  69. // input{
  70. // display:block;
  71. // max-width:100%;
  72. // margin:0.5em 0 0 0;
  73. // }
  74. // button{
  75. // margin:0.5em 0 0 0;
  76. // }
  77. // ul{
  78. // margin:0; padding:0.5em 0 0 0;
  79. // }
  80. // li{
  81. // list-style:none;
  82. // margin:0.5em 0 0 0; padding:0;
  83. // font-size:0.882em;
  84. // }
  85. // a{
  86. // }
  87. </style>