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

151 lines
4.4 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 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. created() {
  25. this.currentName = this.name;
  26. var _this = this
  27. if (uni.getStorageSync('identity') == '1') {
  28. //教练
  29. _this.list = [{
  30. "pagePath": "/pages/tabbar/statistics/index",
  31. "text": "首页",
  32. "iconPath": "../../static/images/tabbar/tj.png",
  33. "selectedIconPath": "../../static/images/tabbar/tjActive.png"
  34. },
  35. {
  36. "pagePath": "/pages/tabbar/examSimulation/index",
  37. "text": "考场模拟",
  38. "iconPath": "../../static/images/tabbar/kc.png",
  39. "selectedIconPath": "../../static/images/tabbar/kcActive.png"
  40. },
  41. {
  42. "pagePath": "/pages/tabbar/operateTrain/index",
  43. "text": "实操训练",
  44. "iconPath": "../../static/images/tabbar/sc.png",
  45. "selectedIconPath": "../../static/images/tabbar/scActive.png"
  46. },
  47. {
  48. "pagePath": "/pages/tabbar/student/index",
  49. "text": "学员",
  50. "iconPath": "../../static/images/tabbar/xy.png",
  51. "selectedIconPath": "../../static/images/tabbar/xyActive.png"
  52. },
  53. {
  54. "pagePath": "/pages/tabbar/mine/index",
  55. "text": "我的",
  56. "iconPath": "../../static/images/tabbar/wd.png",
  57. "selectedIconPath": "../../static/images/tabbar/wdActive.png"
  58. }
  59. ]
  60. } else if(uni.getStorageSync('identity') == '2') {
  61. //校长
  62. _this.list = [{
  63. "pagePath": "/pages/tabbar/statistics/index",
  64. "text": "统计",
  65. "iconPath": "../../static/images/tabbar/tj.png",
  66. "selectedIconPath": "../../static/images/tabbar/tjActive.png"
  67. },
  68. {
  69. "pagePath": "/pages/tabbar/student/index",
  70. "text": "学员",
  71. "iconPath": "../../static/images/tabbar/xy.png",
  72. "selectedIconPath": "../../static/images/tabbar/xyActive.png"
  73. },
  74. {
  75. "pagePath": "/pages/tabbar/mine/index",
  76. "text": "我的",
  77. "iconPath": "../../static/images/tabbar/wd.png",
  78. "selectedIconPath": "../../static/images/tabbar/wdActive.png"
  79. }
  80. ]
  81. }else {
  82. _this.list = [{
  83. "pagePath": "/pages/tabbar/statistics/index",
  84. "text": "统计",
  85. "iconPath": "../../static/images/tabbar/tj.png",
  86. "selectedIconPath": "../../static/images/tabbar/tjActive.png"
  87. },
  88. {
  89. "pagePath": "/pages/tabbar/examSimulation/index",
  90. "text": "预约记录",
  91. "iconPath": "../../static/images/tabbar/xy.png",
  92. "selectedIconPath": "../../static/images/tabbar/xyActive.png"
  93. },
  94. {
  95. "pagePath": "/pages/tabbar/mine/index",
  96. "text": "我的",
  97. "iconPath": "../../static/images/tabbar/wd.png",
  98. "selectedIconPath": "../../static/images/tabbar/wdActive.png"
  99. }]
  100. }
  101. },
  102. methods: {
  103. switchTab(item, index) {
  104. this.currentName = item.text;
  105. let url = item.pagePath;
  106. console.log(url)
  107. uni.switchTab({
  108. url
  109. })
  110. // uni.reLaunch({url:url})
  111. }
  112. }
  113. }
  114. </script>
  115. <style lang="scss">
  116. .tab-bar {
  117. position: fixed;
  118. bottom: 0;
  119. left: 0;
  120. right: 0;
  121. height: 100rpx;
  122. background: white;
  123. display: flex;
  124. justify-content: center;
  125. align-items: center;
  126. padding-bottom: env(safe-area-inset-bottom); // 适配iphoneX的底部
  127. .tab-bar-item {
  128. flex: 1;
  129. text-align: center;
  130. display: flex;
  131. justify-content: center;
  132. align-items: center;
  133. flex-direction: column;
  134. .tab_img {
  135. width: 48rpx;
  136. height: 48rpx;
  137. }
  138. .tab_text {
  139. font-size: 24rpx;
  140. margin-top: 4rpx;
  141. }
  142. }
  143. }
  144. </style>