LoginBlock.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. request_password () {
  37. console.log('request_password');
  38. },
  39. create_account () {
  40. console.log('create_account');
  41. }
  42. },
  43. beforeMount() {
  44. // console.log('LoginBlock beforeMount', this._props.block);
  45. if(this._props.block){
  46. // console.log('LoginBlock beforeMount if this._props.block ok');
  47. this.template = Vue.compile(this._props.block)
  48. this.$options.staticRenderFns = [];
  49. this._staticTrees = [];
  50. this.template.staticRenderFns.map(fn => (this.$options.staticRenderFns.push(fn)));
  51. }
  52. },
  53. mounted(){
  54. // console.log('LoginBlock mounted');
  55. Drupal.attachBehaviors(this.$el);
  56. },
  57. render(h) {
  58. // console.log('LoginBlock render');
  59. if(!this.template){
  60. // console.log('LoginBlock render NAN');
  61. return h('span', 'Loading ...')
  62. }else{
  63. // console.log('LoginBlock render template');
  64. return this.template.render.call(this)
  65. }
  66. }
  67. }
  68. </script>
  69. <style lang="scss" scoped>
  70. // section{
  71. // max-width:300px;
  72. // }
  73. // input{
  74. // display:block;
  75. // max-width:100%;
  76. // margin:0.5em 0 0 0;
  77. // }
  78. // button{
  79. // margin:0.5em 0 0 0;
  80. // }
  81. // ul{
  82. // margin:0; padding:0.5em 0 0 0;
  83. // }
  84. // li{
  85. // list-style:none;
  86. // margin:0.5em 0 0 0; padding:0;
  87. // font-size:0.882em;
  88. // }
  89. // a{
  90. // }
  91. </style>