江西小程序管理端
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
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months ago
1 year ago
12 months 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 (this.identity == '实操教练') {
  45. //教练
  46. this.list = [
  47. {
  48. "pagePath": "/pages/tabbar/student/index",
  49. "text": "学员",
  50. "iconPath": require("../../static/images/tabbar/xy.png"),
  51. "selectedIconPath": require("../../static/images/tabbar/xyActive.png")
  52. },
  53. {
  54. "pagePath": "/pages/tabbar/operateTrain/index",
  55. "text": "实操训练",
  56. "iconPath": require("../../static/images/tabbar/sc.png"),
  57. "selectedIconPath": require("../../static/images/tabbar/scActive.png")
  58. },
  59. {
  60. "pagePath": "/pages/tabbar/mine/index",
  61. "text": "我的",
  62. "iconPath": require("../../static/images/tabbar/wd.png"),
  63. "selectedIconPath": require("../../static/images/tabbar/wdActive.png")
  64. }
  65. ]
  66. } else if(this.identity == '校长'|| this.identity == '驾校财务') {
  67. //校长
  68. this.list = [{
  69. "pagePath": "/pages/tabbar/statistics/index",
  70. "text": "统计",
  71. "iconPath": require("../../static/images/tabbar/tj.png"),
  72. "selectedIconPath": require("../../static/images/tabbar/tjActive.png")
  73. },
  74. {
  75. "pagePath": "/pages/tabbar/student/index",
  76. "text": "学员",
  77. "iconPath": require("../../static/images/tabbar/xy.png"),
  78. "selectedIconPath": require("../../static/images/tabbar/xyActive.png")
  79. },
  80. {
  81. "pagePath": "/pages/tabbar/mine/index",
  82. "text": "我的",
  83. "iconPath": require("../../static/images/tabbar/wd.png"),
  84. "selectedIconPath": require("../../static/images/tabbar/wdActive.png")
  85. }
  86. ]
  87. }else if(this.identity == '考场模拟教练'){
  88. this.list = [{
  89. "pagePath": "/pages/tabbar/statistics/index",
  90. "text": "统计",
  91. "iconPath": require("../../static/images/tabbar/tj.png"),
  92. "selectedIconPath": require("../../static/images/tabbar/tjActive.png")
  93. },
  94. {
  95. "pagePath": "/pages/tabbar/examSimulation/index",
  96. "text": "预约记录",
  97. "iconPath": require("../../static/images/tabbar/kc.png"),
  98. "selectedIconPath": require("../../static/images/tabbar/kcActive.png")
  99. },
  100. {
  101. "pagePath": "/pages/tabbar/mine/index",
  102. "text": "我的",
  103. "iconPath": require("../../static/images/tabbar/wd.png"),
  104. "selectedIconPath": require("../../static/images/tabbar/wdActive.png")
  105. }]
  106. }else if(this.identity == '模拟器老师'){
  107. this.list = [
  108. {
  109. "pagePath": "/pages/tabbar/examSimulation/index",
  110. "text": "学员评价",
  111. "iconPath": require("../../static/images/tabbar/kc.png"),
  112. "selectedIconPath": require("../../static/images/tabbar/kcActive.png")
  113. },
  114. {
  115. "pagePath": "/pages/tabbar/mine/index",
  116. "text": "我的",
  117. "iconPath": require("../../static/images/tabbar/wd.png"),
  118. "selectedIconPath": require("../../static/images/tabbar/wdActive.png")
  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>