home.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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/manageWorkbench'
  11. import { userHome } from '@/pages/studentWorkbench.vue'
  12. import { supplierHome } from '@/pages/supplierWorkbench.vue'
  13. import { tabBar } from '@/component/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',
  38. });
  39. }
  40. console.log("onShow")
  41. },
  42. methods: {
  43. },
  44. onHide(){
  45. this.userType = 0;
  46. },
  47. onUnload(){
  48. this.userType = 0;
  49. }
  50. }
  51. </script>
  52. <style lang="stylus" scoped>
  53. #home{
  54. height:100%;
  55. }
  56. </style>