taskListLayout.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <view class="container">
  3. <task-list v-if="currentTab === 0"></task-list>
  4. <my-task-list ref="myTaskList" v-if="currentTab === 1"></my-task-list>
  5. <system-settings v-if="currentTab === 2"></system-settings>
  6. <!-- 底部导航栏 -->
  7. <view class="tab-bar">
  8. <view
  9. class="tab-item"
  10. :class="{ active: currentTab === 0 }"
  11. @click="switchTab(0)"
  12. >
  13. <text class="iconfont icon-mrenwuliebiao" :style="{ color: currentTab === 0 ? '#1d5fdf' : '748498' }"></text>
  14. <text>任务列表</text>
  15. </view>
  16. <view
  17. class="tab-item"
  18. :class="{ active: currentTab === 1 }"
  19. @click="switchTab(1)"
  20. >
  21. <text class="iconfont icon-woderenwu" :style="{ color: currentTab === 1 ? '#1d5fdf' : '748498' }"></text>
  22. <text>我的任务</text>
  23. </view>
  24. <view
  25. class="tab-item"
  26. :class="{ active: currentTab === 2 }"
  27. @click="switchTab(2)"
  28. >
  29. <text class="iconfont icon-xitongshezhi" :style="{ color: currentTab === 2 ? '#1d5fdf' : '748498' }"></text>
  30. <text>系统设置</text>
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import TaskList from "./components/taskList.vue";
  37. import MyTaskList from "./components/myTaskList.vue";
  38. import SystemSettings from "../systemSet/systemSet.vue";
  39. export default {
  40. components: {
  41. TaskList,
  42. MyTaskList,
  43. SystemSettings,
  44. },
  45. data() {
  46. return {
  47. currentTab: 0,
  48. };
  49. },
  50. onLoad(options) {
  51. // 如果有传入 tab 参数,则切换到对应标签
  52. if (options.tab) {
  53. this.currentTab = parseInt(options.tab);
  54. }
  55. },
  56. onShow() {
  57. if (this.currentTab === 1) {
  58. this.$nextTick(() => {
  59. this.$refs.myTaskList.initTaskList();
  60. });
  61. // this.$refs.myTaskList && this.$refs.myTaskList.onShow();
  62. }
  63. // && this.$refs.myTaskList.onShow();
  64. },
  65. methods: {
  66. switchTab(index) {
  67. this.currentTab = index;
  68. },
  69. },
  70. };
  71. </script>
  72. <style lang="scss" scoped>
  73. .container {
  74. display: flex;
  75. flex-direction: column;
  76. height: 100vh;
  77. box-sizing: border-box;
  78. background-color: #f5f6fa;
  79. position: relative;
  80. padding-bottom: 100rpx;
  81. }
  82. .tab-bar {
  83. height: 100rpx;
  84. display: flex;
  85. background-color: #fff;
  86. border-top: 1rpx solid #eee;
  87. position: fixed;
  88. bottom: 0;
  89. left: 0;
  90. right: 0;
  91. z-index: 999;
  92. .tab-item {
  93. flex: 1;
  94. display: flex;
  95. flex-direction: column;
  96. align-items: center;
  97. justify-content: center;
  98. font-size: 24rpx;
  99. color: #666;
  100. &.active {
  101. color: #1976d2;
  102. }
  103. text {
  104. margin-top: 4rpx;
  105. }
  106. }
  107. }
  108. </style>