tabbar.vue 3.7 KB

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