tabbar.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <view class="tabbar">
  3. <view :class="['item',current == 0?'active':'']" @click="currentTab(0)">
  4. <image v-if="current==0" src="../static/image/home-fill.png" mode=""></image>
  5. <image v-else src="../static/image/home.png" mode=""></image>
  6. <view class="name">
  7. 工单列表
  8. </view>
  9. </view>
  10. <view v-if="is_monitor || is_admin" :class="['item',current == 1?'active':'']" @click="currentTab(1)">
  11. <image v-if="current==1" src="../static/image/help-fill.png" mode=""></image>
  12. <image v-else src="../static/image/help.png" mode=""></image>
  13. <view class="name">
  14. 任务
  15. </view>
  16. </view>
  17. <view :class="['item',current == 2?'active':'']" @click="currentTab(2)">
  18. <image v-if="current==2" src="../static/image/mine-fill.png" mode=""></image>
  19. <image v-else src="../static/image/mine.png" mode=""></image>
  20. <view class="name">
  21. 我的
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. name: "tabbar",
  29. props: {
  30. current: {
  31. type: Number,
  32. default: 5
  33. }
  34. },
  35. data() {
  36. return {
  37. // current: ''
  38. roles: [],
  39. is_monitor: false,
  40. is_polling: false,
  41. is_admin: false,
  42. };
  43. },
  44. watch: {
  45. current() {
  46. console.log('opopopopop')
  47. },
  48. },
  49. onShow() {
  50. },
  51. created() {
  52. let status = false
  53. let roles = this.$store.state.vuex_user.roles
  54. let arr = []
  55. roles.map(item => {
  56. arr.push(item.name)
  57. })
  58. let index = arr.indexOf('polling')
  59. if (index >= 0) this.is_polling = true
  60. let index2 = arr.indexOf('monitor')
  61. if (index2 >= 0) this.is_monitor = true
  62. let index3 = arr.indexOf('admin')
  63. if (index3 >= 0) this.is_admin = true
  64. console.log(index, index2, index3, 'opopop')
  65. },
  66. methods: {
  67. currentTab(index) {
  68. console.log(index, 'opopopo')
  69. // this.current = index
  70. if (index == 0) {
  71. uni.switchTab({
  72. url: '/pages/index/index'
  73. })
  74. } else if (index == 1) {
  75. console.log(index, 'opopop')
  76. uni.switchTab({
  77. url: '/pages/task/index'
  78. })
  79. } else if (index == 2) {
  80. uni.switchTab({
  81. url: '/pages/mine/mine'
  82. })
  83. }
  84. },
  85. }
  86. }
  87. </script>
  88. <style lang="scss">
  89. .tabbar {
  90. height: 60px;
  91. padding: 5px 0;
  92. width: 100%;
  93. background-color: #10C08C;
  94. display: flex;
  95. align-items: center;
  96. justify-content: space-around;
  97. position: fixed;
  98. left: 0;
  99. bottom: 0;
  100. z-index: 2;
  101. button::after {
  102. border: none;
  103. }
  104. .item {
  105. text-align: center;
  106. image {
  107. width: 25px;
  108. height: 25px;
  109. }
  110. .name {
  111. // margin-top: -5px;
  112. // line-height: 25px;
  113. font-size: 12px;
  114. color: #fff;
  115. font-weight: 400;
  116. }
  117. }
  118. .active {
  119. image {
  120. width: 25px;
  121. height: 25px;
  122. }
  123. .name {
  124. font-size: 12px;
  125. color: #f4ea2a !important;
  126. font-weight: 400;
  127. }
  128. }
  129. }
  130. </style>