江西小程序管理端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
5.3 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. <template>
  2. <view class="tab-bar">
  3. <view v-for="(item,index) in list" :key="index" class="tab-bar-item" @click="switchTab(item, index)">
  4. <image class="tab_img" :src="name == item.text ? item.selectedIconPath : item.iconPath"></image>
  5. <view class="tab_text" :style="{color: name == item.text ? selectedColor : color}">{{item.text}}</view>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. props: {
  12. name: { // 当前选中的tab index
  13. default: 0
  14. },
  15. },
  16. data() {
  17. return {
  18. color: "#999",
  19. selectedColor: "#218DFF",
  20. list: [],
  21. currentIndex:0,
  22. }
  23. },
  24. watch: {
  25. identity(newVal) {
  26. this.initTabbar()
  27. }
  28. },
  29. created() {
  30. this.currentName = this.name;
  31. this.initTabbar()
  32. },
  33. methods: {
  34. switchTab(item, index) {
  35. this.currentName = item.text;
  36. let url = item.pagePath;
  37. console.log(url)
  38. uni.switchTab({
  39. url
  40. })
  41. // uni.reLaunch({url:url})
  42. },
  43. initTabbar() {
  44. if (uni.getStorageSync('identity') == '实操教练') {
  45. //教练
  46. this.list = [
  47. // {
  48. // "pagePath": "/pages/tabbar/statistics/index",
  49. // "text": "统计",
  50. // "iconPath": require("../../static/images/tabbar/tj.png"),
  51. // "selectedIconPath": require("../../static/images/tabbar/tjActive.png")
  52. // },
  53. // {
  54. // "pagePath": "/pages/tabbar/examSimulation/index",
  55. // "text": "考场模拟",
  56. // "iconPath": require("../../static/images/tabbar/kc.png"),
  57. // "selectedIconPath": require("../../static/images/tabbar/kcActive.png")
  58. // },
  59. {
  60. "pagePath": "/pages/tabbar/student/index",
  61. "text": "学员",
  62. "iconPath": require("../../static/images/tabbar/xy.png"),
  63. "selectedIconPath": require("../../static/images/tabbar/xyActive.png")
  64. },
  65. {
  66. "pagePath": "/pages/tabbar/operateTrain/index",
  67. "text": "实操训练",
  68. "iconPath": require("../../static/images/tabbar/sc.png"),
  69. "selectedIconPath": require("../../static/images/tabbar/scActive.png")
  70. },
  71. {
  72. "pagePath": "/pages/tabbar/mine/index",
  73. "text": "我的",
  74. "iconPath": require("../../static/images/tabbar/wd.png"),
  75. "selectedIconPath": require("../../static/images/tabbar/wdActive.png")
  76. }
  77. ]
  78. } else if(uni.getStorageSync('identity') == '校长') {
  79. //校长
  80. this.list = [{
  81. "pagePath": "/pages/tabbar/statistics/index",
  82. "text": "统计",
  83. "iconPath": require("../../static/images/tabbar/tj.png"),
  84. "selectedIconPath": require("../../static/images/tabbar/tjActive.png")
  85. },
  86. {
  87. "pagePath": "/pages/tabbar/student/index",
  88. "text": "学员",
  89. "iconPath": require("../../static/images/tabbar/xy.png"),
  90. "selectedIconPath": require("../../static/images/tabbar/xyActive.png")
  91. },
  92. {
  93. "pagePath": "/pages/tabbar/mine/index",
  94. "text": "我的",
  95. "iconPath": require("../../static/images/tabbar/wd.png"),
  96. "selectedIconPath": require("../../static/images/tabbar/wdActive.png")
  97. }
  98. ]
  99. }else if(uni.getStorageSync('identity') == '考场模拟教练'){
  100. this.list = [{
  101. "pagePath": "/pages/tabbar/statistics/index",
  102. "text": "统计",
  103. "iconPath": require("../../static/images/tabbar/tj.png"),
  104. "selectedIconPath": require("../../static/images/tabbar/tjActive.png")
  105. },
  106. {
  107. "pagePath": "/pages/tabbar/examSimulation/index",
  108. "text": "预约记录",
  109. "iconPath": require("../../static/images/tabbar/kc.png"),
  110. "selectedIconPath": require("../../static/images/tabbar/kcActive.png")
  111. },
  112. {
  113. "pagePath": "/pages/tabbar/mine/index",
  114. "text": "我的",
  115. "iconPath": require("../../static/images/tabbar/wd.png"),
  116. "selectedIconPath": require("../../static/images/tabbar/wdActive.png")
  117. }]
  118. }else if(uni.getStorageSync('identity') == '模拟器老师'){
  119. this.list = [
  120. {
  121. "pagePath": "/pages/tabbar/examSimulation/index",
  122. "text": "学员评价",
  123. "iconPath": require("../../static/images/tabbar/kc.png"),
  124. "selectedIconPath": require("../../static/images/tabbar/kcActive.png")
  125. },
  126. {
  127. "pagePath": "/pages/tabbar/mine/index",
  128. "text": "我的",
  129. "iconPath": require("../../static/images/tabbar/wd.png"),
  130. "selectedIconPath": require("../../static/images/tabbar/wdActive.png")
  131. }]
  132. }
  133. }
  134. }
  135. }
  136. </script>
  137. <style lang="scss">
  138. .tab-bar {
  139. position: fixed;
  140. bottom: 0;
  141. left: 0;
  142. right: 0;
  143. height: 100rpx;
  144. background: white;
  145. display: flex;
  146. justify-content: center;
  147. align-items: center;
  148. padding-bottom: env(safe-area-inset-bottom); // 适配iphoneX的底部
  149. .tab-bar-item {
  150. flex: 1;
  151. text-align: center;
  152. display: flex;
  153. justify-content: center;
  154. align-items: center;
  155. flex-direction: column;
  156. .tab_img {
  157. width: 48rpx;
  158. height: 48rpx;
  159. }
  160. .tab_text {
  161. font-size: 24rpx;
  162. margin-top: 4rpx;
  163. }
  164. }
  165. }
  166. </style>