江西小程序管理端
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.

158 lines
4.8 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. <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 {
  119. // 模拟器老师
  120. }
  121. }
  122. }
  123. }
  124. </script>
  125. <style lang="scss">
  126. .tab-bar {
  127. position: fixed;
  128. bottom: 0;
  129. left: 0;
  130. right: 0;
  131. height: 100rpx;
  132. background: white;
  133. display: flex;
  134. justify-content: center;
  135. align-items: center;
  136. padding-bottom: env(safe-area-inset-bottom); // 适配iphoneX的底部
  137. .tab-bar-item {
  138. flex: 1;
  139. text-align: center;
  140. display: flex;
  141. justify-content: center;
  142. align-items: center;
  143. flex-direction: column;
  144. .tab_img {
  145. width: 48rpx;
  146. height: 48rpx;
  147. }
  148. .tab_text {
  149. font-size: 24rpx;
  150. margin-top: 4rpx;
  151. }
  152. }
  153. }
  154. </style>