home.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <view id="home">
  3. <teacherHome class="flex-box-page" v-if="userType==1"></teacherHome>
  4. <pupilHome class="flex-box-page" v-if="userType==2"></pupilHome>
  5. </view>
  6. </template>
  7. <script>
  8. import {
  9. teacherHome
  10. } from '@/pages/views/teacherPage/teacherHome'
  11. import {
  12. pupilHome
  13. } from '@/pages/views/pupilPage/pupilHome'
  14. export default {
  15. name: "home",
  16. components: {
  17. teacherHome,
  18. pupilHome,
  19. },
  20. data() {
  21. return {
  22. userType: 0,
  23. }
  24. },
  25. onLoad() {
  26. },
  27. onShow() {
  28. if (uni.getStorageSync('token') && uni.getStorageSync('userId') && uni.getStorageSync('userType')) {
  29. this.userType = uni.getStorageSync('userType')
  30. } else {
  31. uni.removeStorageSync('token');
  32. uni.removeStorageSync('userId');
  33. uni.removeStorageSync('userType');
  34. uni.redirectTo({
  35. url: '/pages/login/login',
  36. });
  37. }
  38. },
  39. methods: {
  40. },
  41. onHide() {
  42. this.userType = 0;
  43. },
  44. onUnload() {
  45. this.userType = 0;
  46. }
  47. }
  48. </script>
  49. <style lang="stylus" scoped>
  50. #home {
  51. height: 100%;
  52. display: flex;
  53. flex-direction: column;
  54. .flex-box-page{
  55. flex:1;
  56. display: flex;
  57. flex-direction: column;
  58. }
  59. }
  60. </style>