学员端小程序
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.

116 lines
3.3 KiB

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="currentIndex == index ? item.selectedIconPath : item.iconPath"></image>
  5. <view class="tab_text" :style="{color: currentIndex == index ? selectedColor : color}">{{item.text}}</view>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. props: {
  12. selectedIndex: { // 当前选中的tab index
  13. default: 0
  14. },
  15. },
  16. data() {
  17. return {
  18. color: "#666666",
  19. selectedColor: "#00BAB2",
  20. list: [],
  21. currentIndex:0,
  22. }
  23. },
  24. created() {
  25. this.currentIndex = this.selectedIndex;
  26. var _this = this
  27. if (uni.getStorageSync('identify') == 'nurse') {
  28. //护士
  29. _this.list = [
  30. {
  31. "pagePath": "/pages/tabbar/index/index",
  32. "text": "首页",
  33. "iconPath": "/static/images/tabbar/sy.png",
  34. "selectedIconPath": "/static/images/tabbar/syActive.png"
  35. },
  36. {
  37. "pagePath": "/pages/tabbar/question/index",
  38. "text": "题库",
  39. "iconPath": "/static/images/tabbar/tk.png",
  40. "selectedIconPath": "/static/images/tabbar/tkActive.png"
  41. },
  42. {
  43. "pagePath": "/pages/tabbar/mine/index",
  44. "text": "我的",
  45. "iconPath": "/static/images/tabbar/wd.png",
  46. "selectedIconPath": "/static/images/tabbar/wdActive.png"
  47. }
  48. ]
  49. } else {
  50. //医管
  51. _this.list = [{
  52. "pagePath": "/pages/tabbar/index/index",
  53. "text": "首1页",
  54. "iconPath": "/static/images/tabbar/sy.png",
  55. "selectedIconPath": "/static/images/tabbar/syActive.png"
  56. },
  57. {
  58. "pagePath": "/pages/tabbar/question/index",
  59. "text": "题2库",
  60. "iconPath": "/static/images/tabbar/tk.png",
  61. "selectedIconPath": "/static/images/tabbar/tkActive.png"
  62. },
  63. {
  64. "pagePath": "/pages/tabbar/mine/index",
  65. "text": "我3的",
  66. "iconPath": "/static/images/tabbar/wd.png",
  67. "selectedIconPath": "/static/images/tabbar/wdActive.png"
  68. }
  69. ]
  70. }
  71. },
  72. methods: {
  73. switchTab(item, index) {
  74. this.currentIndex = index;
  75. let url = item.pagePath;
  76. console.log(url)
  77. uni.reLaunch({url:url})
  78. }
  79. }
  80. }
  81. </script>
  82. <style lang="scss">
  83. .tab-bar {
  84. position: fixed;
  85. bottom: 0;
  86. left: 0;
  87. right: 0;
  88. height: 100rpx;
  89. background: white;
  90. display: flex;
  91. justify-content: center;
  92. align-items: center;
  93. padding-bottom: env(safe-area-inset-bottom); // 适配iphoneX的底部
  94. .tab-bar-item {
  95. flex: 1;
  96. text-align: center;
  97. display: flex;
  98. justify-content: center;
  99. align-items: center;
  100. flex-direction: column;
  101. .tab_img {
  102. width: 48rpx;
  103. height: 48rpx;
  104. }
  105. .tab_text {
  106. font-size: 24rpx;
  107. margin-top: 4rpx;
  108. }
  109. }
  110. }
  111. </style>