box.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view class="container">
  3. <!-- 首页 -->
  4. <Home v-if="show === 'home'" />
  5. <!-- 工单管理 -->
  6. <Management v-if="show === 'management'" />
  7. <!-- 通讯录 -->
  8. <AddressBook v-if="show === 'addressBook'" />
  9. <!-- 待处理池 -->
  10. <Pending v-if="show === 'pending'" />
  11. <!-- 报修 -->
  12. <Repairs v-if="show === 'repairs'" />
  13. <!-- 我的报修 -->
  14. <MyRepairs v-if="show === 'myRepairs'" />
  15. <!-- 底部导航栏 -->
  16. <Tabbar :list="routes" :currentRouter="currentRouter" @changeRouter="handleChangeRouter" />
  17. </view>
  18. </template>
  19. <script>
  20. import Home from '../home/home.vue'
  21. import Management from '../management/management.vue'
  22. import AddressBook from '../addressBook/addressBook.vue'
  23. import Pending from '../pending/pending.vue'
  24. import Repairs from '../repairs/repairs.vue'
  25. import MyRepairs from '../myRepairs/myRepairs.vue'
  26. import Tabbar from '../components/tabbar.vue'
  27. export default {
  28. components: {
  29. Home,
  30. Management,
  31. AddressBook,
  32. Pending,
  33. Repairs,
  34. MyRepairs,
  35. Tabbar
  36. },
  37. mounted() {
  38. const repairsUserInfo = uni.getStorageSync('repairsUserInfo')
  39. if (repairsUserInfo.routes) {
  40. this.routes = this.filterRoute(this.list, repairsUserInfo.routes)
  41. }
  42. const currentIndexRepairs = uni.getStorageSync('currentIndexRepairs')
  43. if (currentIndexRepairs) {
  44. this.currentRouter = currentIndexRepairs
  45. this.show = this.routes[currentIndexRepairs].show
  46. uni.setNavigationBarTitle({
  47. title: this.routes[currentIndexRepairs].text
  48. })
  49. } else {
  50. this.currentRouter = 0
  51. this.show = this.routes[0].show
  52. uni.setNavigationBarTitle({
  53. title: this.routes[0].text
  54. })
  55. }
  56. },
  57. data() {
  58. return {
  59. // 展示的路由
  60. routes: [],
  61. // 所有的路由
  62. list: [
  63. {
  64. text: '报修',
  65. imgUrl: '../../static/images/repairsImg/repairs.png',
  66. imgUrlActive: '../../static/images/repairsImg/repairs-active.png',
  67. show: 'repairs'
  68. },
  69. {
  70. text: '我的报修',
  71. imgUrl: '../../static/images/repairsImg/myRepairs.png',
  72. imgUrlActive: '../../static/images/repairsImg/myRepairs-active.png',
  73. show: 'myRepairs'
  74. },
  75. {
  76. text: '首页',
  77. imgUrl: '../../static/images/repairsImg/home.png',
  78. imgUrlActive: '../../static/images/repairsImg/home-active.png',
  79. show: 'home'
  80. },
  81. {
  82. text: '工单管理',
  83. imgUrl: '../../static/images/repairsImg/management.png',
  84. imgUrlActive: '../../static/images/repairsImg/management-active.png',
  85. show: 'management'
  86. },
  87. {
  88. text: '待处理池',
  89. imgUrl: '../../static/images/repairsImg/myRepairs.png',
  90. imgUrlActive: '../../static/images/repairsImg/myRepairs-active.png',
  91. show: 'pending'
  92. },
  93. {
  94. text: '通讯录',
  95. imgUrl: '../../static/images/repairsImg/addressBook.png',
  96. imgUrlActive: '../../static/images/repairsImg/addressBook-active.png',
  97. show: 'addressBook'
  98. }
  99. ],
  100. // box页面展示哪个组件
  101. show: '',
  102. // 当前显示组件的index
  103. currentRouter: 0
  104. }
  105. },
  106. methods: {
  107. // 底部导航栏切换回调
  108. handleChangeRouter(show, text, e) {
  109. uni.setStorageSync('currentIndexRepairs', e)
  110. this.show = show
  111. this.currentRouter = e
  112. uni.setNavigationBarTitle({
  113. title: text
  114. })
  115. },
  116. // 路由过滤方法
  117. filterRoute(arr1, arr2) {
  118. return arr1.filter((item) => {
  119. return arr2.includes(item.text)
  120. })
  121. }
  122. }
  123. }
  124. </script>
  125. <style lang="scss" scoped>
  126. .container {
  127. width: 100vw;
  128. height: calc(100vh - 152rpx);
  129. }
  130. </style>