home.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. uni.removeStorageSync('planSensorList');
  29. if (uni.getStorageSync('token') && uni.getStorageSync('userId') && uni.getStorageSync('userType')) {
  30. this.userType = uni.getStorageSync('userType')
  31. } else {
  32. uni.removeStorageSync('token');
  33. uni.removeStorageSync('userId');
  34. uni.removeStorageSync('userType');
  35. uni.redirectTo({
  36. url: '/pages/login/login',
  37. });
  38. }
  39. },
  40. methods: {
  41. },
  42. onHide() {
  43. this.userType = 0;
  44. },
  45. onUnload() {
  46. this.userType = 0;
  47. }
  48. }
  49. </script>
  50. <style lang="stylus" scoped>
  51. #home {
  52. height: 100%;
  53. display: flex;
  54. flex-direction: column;
  55. .flex-box-page{
  56. flex:1;
  57. display: flex;
  58. flex-direction: column;
  59. }
  60. }
  61. </style>