LoginBlock.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. }),
  25. login () {
  26. this.userLogin({
  27. mail: this.mail,
  28. pass: this.password
  29. }).then(() => {
  30. console.log("LoginBlock user logged-in")
  31. this.$router.push({
  32. name: 'base'
  33. })
  34. })
  35. }
  36. },
  37. beforeMount() {
  38. // console.log('LoginBlock beforeMount', this._props.block);
  39. if(this._props.block){
  40. // console.log('LoginBlock beforeMount if this._props.block ok');
  41. this.template = Vue.compile(this._props.block)
  42. this.$options.staticRenderFns = [];
  43. this._staticTrees = [];
  44. this.template.staticRenderFns.map(fn => (this.$options.staticRenderFns.push(fn)));
  45. }
  46. },
  47. mounted(){
  48. // console.log('LoginBlock mounted');
  49. Drupal.attachBehaviors(this.$el);
  50. },
  51. render(h) {
  52. // console.log('LoginBlock render');
  53. if(!this.template){
  54. // console.log('LoginBlock render NAN');
  55. return h('span', 'Loading ...')
  56. }else{
  57. // console.log('LoginBlock render template');
  58. return this.template.render.call(this)
  59. }
  60. }
  61. }
  62. </script>
  63. <style lang="scss" scoped>
  64. // section{
  65. // max-width:300px;
  66. // }
  67. // input{
  68. // display:block;
  69. // max-width:100%;
  70. // margin:0.5em 0 0 0;
  71. // }
  72. // button{
  73. // margin:0.5em 0 0 0;
  74. // }
  75. // ul{
  76. // margin:0; padding:0.5em 0 0 0;
  77. // }
  78. // li{
  79. // list-style:none;
  80. // margin:0.5em 0 0 0; padding:0;
  81. // font-size:0.882em;
  82. // }
  83. // a{
  84. // }
  85. </style>