index.vue 582 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <template>
  2. <view>
  3. </view>
  4. </template>
  5. <script>
  6. import {
  7. mapGetters
  8. } from "vuex";
  9. import {
  10. toLogin
  11. } from '@/libs/login.js';
  12. export default {
  13. data() {
  14. return {
  15. userInfo: {}
  16. }
  17. },
  18. computed: mapGetters(['isLogin']),
  19. onLoad() {
  20. if (this.isLogin) {
  21. this.getUserInfo();
  22. }else{
  23. toLogin();
  24. }
  25. },
  26. methods: {
  27. getUserInfo: function() {
  28. let that = this;
  29. getUserInfo().then(res => {
  30. that.userInfo = res.data;
  31. that.$store.commit("SETUID", res.data.uid);
  32. });
  33. }
  34. }
  35. }
  36. </script>
  37. <style lang="scss">
  38. </style>