home.vue 1.3 KB

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