UserBlock.vue 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <template lang="html">
  2. <UserTools v-if="isloggedin" />
  3. <LoginBlock v-bind:title="title" v-bind:block="block" v-else/>
  4. </template>
  5. <script>
  6. import { mapState, mapActions } from 'vuex'
  7. import LoginBlock from 'vuejs/components/Block/LoginBlock'
  8. import UserTools from 'vuejs/components/User/UserTools'
  9. import { MA } from 'vuejs/api/ma-axios'
  10. export default {
  11. props: ['title', 'loginblock'],
  12. data(){
  13. return {
  14. block: null
  15. }
  16. },
  17. computed: {
  18. ...mapState({
  19. isloggedin: state => state.User.isloggedin
  20. })
  21. },
  22. beforeMount() {
  23. console.log('UserBlock beforeMount')
  24. if (this.loginblock) {
  25. this.block = this.loginblock
  26. } else {
  27. this.getLoginBlock()
  28. }
  29. },
  30. methods: {
  31. getLoginBlock(){
  32. MA.get(`/materio_user/login_block`)
  33. .then(({data}) => {
  34. // console.log("getLoginBlock data", data)
  35. this.block = data.rendered
  36. })
  37. .catch((error) => {
  38. console.warn('Issue with getLoginBlock', error)
  39. })
  40. }
  41. },
  42. components: {
  43. LoginBlock,
  44. UserTools
  45. }
  46. }
  47. </script>
  48. <style lang="css" scoped>
  49. </style>