LoginBlock.vue 1.9 KB

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