home.vue 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <template>
  2. <view id="home">
  3. <manage-home v-if="userType==1" ref="manage"></manage-home>
  4. <user-home v-if="userType==2"></user-home>
  5. <supplier-home v-if="userType==3"></supplier-home>
  6. <tab-bar v-if="userType!=3"></tab-bar>
  7. </view>
  8. </template>
  9. <script>
  10. import { manageHome } from '@/pages/home/manageWorkbench'
  11. import { userHome } from '@/pages/home/studentWorkbench.vue'
  12. import { supplierHome } from '@/pages/home/supplierWorkbench.vue'
  13. import { tabBar } from '@/components/tabBar.vue'
  14. export default {
  15. name: "home",
  16. components: {
  17. manageHome,
  18. userHome,
  19. supplierHome,
  20. tabBar
  21. },
  22. data() {
  23. return {
  24. userType:0,
  25. }
  26. },
  27. onLoad() {
  28. },
  29. onShow(){
  30. if(uni.getStorageSync('token')&&uni.getStorageSync('userId')&&uni.getStorageSync('userType')){
  31. this.userType = uni.getStorageSync('userType')
  32. }else{
  33. uni.removeStorageSync('token');
  34. uni.removeStorageSync('userId');
  35. uni.removeStorageSync('userType');
  36. uni.redirectTo({
  37. url: '/pages/login/login',
  38. });
  39. }
  40. },
  41. methods: {
  42. },
  43. onHide(){
  44. this.userType = 0;
  45. },
  46. onUnload(){
  47. this.userType = 0;
  48. }
  49. }
  50. </script>
  51. <style lang="stylus" scoped>
  52. #home{
  53. height:100%;
  54. }
  55. </style>