index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <view class="tab_bar">
  3. <view class="tabbarBox">
  4. <view class="handleBox" v-for="(item, index) in tabBarList" :key="index">
  5. <view class="menuBox" @click="goPages(item,index)">
  6. <view class="menuIcon">
  7. <image v-if="index != selectIndex" class="img" :src="item.iconPath"></image>
  8. <image v-else class="img" :src="item.selectedIconPath"></image>
  9. </view>
  10. <view class="menuName">
  11. <text :class="index == selectIndex ? 'TextColor' : 'Text'">{{ item.text }}</text>
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. props: {
  21. page: {
  22. type: String,
  23. default: "homeIndex"
  24. }
  25. },
  26. watch: {
  27. page: {
  28. handler(value) {
  29. console.log('value',value);
  30. this.selectIndex = value;
  31. },
  32. immediate: true,
  33. deep: true
  34. }
  35. },
  36. data() {
  37. return {
  38. selectIndex: null,
  39. userType: uni.getStorageSync('userType') //读取本地存储
  40. }
  41. },
  42. computed: {
  43. //获取当前页面
  44. tabBarList() {
  45. if(this.userType === 1){
  46. return [
  47. {
  48. "pagePath": "/pages/index",
  49. "iconPath": "/static/images/tabbar/home.png",
  50. "selectedIconPath": "/static/images/tabbar/home_.png",
  51. "text": "首页",
  52. },
  53. {
  54. "pagePath": "/pages/mallMenu",
  55. "iconPath": "/static/images/tabbar/class.png",
  56. "selectedIconPath": "/static/images/tabbar/class_.png",
  57. "text": "分类",
  58. },
  59. {
  60. "pagePath": "/pages/classify",
  61. "iconPath": "/static/images/tabbar/work.png",
  62. "selectedIconPath": "/static/images/tabbar/work_.png",
  63. "text": "订单",
  64. },
  65. {
  66. "pagePath": "/pages/mine",
  67. "iconPath": "/static/images/tabbar/mine.png",
  68. "selectedIconPath": "/static/images/tabbar/mine_.png",
  69. "text": "我的",
  70. }
  71. ]
  72. }
  73. return [
  74. {
  75. "pagePath": "/pages/index",
  76. "iconPath": "/static/images/tabbar/home.png",
  77. "selectedIconPath": "/static/images/tabbar/home_.png",
  78. "text": "首页",
  79. },
  80. {
  81. "pagePath": "/pages/mallMenu",
  82. "iconPath": "/static/images/tabbar/class.png",
  83. "selectedIconPath": "/static/images/tabbar/class_.png",
  84. "text": "分类",
  85. },
  86. // {
  87. // "pagePath": "/pages/chat",
  88. // "iconPath": "/static/images/tabbar/class.png",
  89. // "selectedIconPath": "/static/images/tabbar/class_.png",
  90. // "text": "消息",
  91. // },
  92. {
  93. "pagePath": "/pages/classify",
  94. "iconPath": "/static/images/tabbar/work.png",
  95. "selectedIconPath": "/static/images/tabbar/work_.png",
  96. "text": "订单",
  97. },
  98. {
  99. "pagePath": "/pages/mine",
  100. "iconPath": "/static/images/tabbar/mine.png",
  101. "selectedIconPath": "/static/images/tabbar/mine_.png",
  102. "text": "我的",
  103. }
  104. ]
  105. }
  106. },
  107. //uniapp子组件不支持应用生命周期,所以只能用vue生命周期
  108. created() {
  109. },
  110. methods: {
  111. //进入tabble页
  112. goPages(page,index) {
  113. console.log('page,index',page,index,this.userType);
  114. uni.switchTab({
  115. url: page.pagePath
  116. })
  117. },
  118. },
  119. }
  120. </script>
  121. <style lang="scss">
  122. .tab_bar {
  123. width: 100vw;
  124. height: 150rpx;
  125. position: fixed;
  126. bottom: 0rpx;
  127. /* 模糊大小就是靠的blur这个函数中的数值大小 */
  128. // backdrop-filter: blur(10px);
  129. // border-radius: 60rpx;
  130. background-color: #fff;
  131. .tabbarBox {
  132. display: flex;
  133. margin-top: 10rpx;
  134. justify-content: space-evenly;
  135. .handleBox {
  136. width: 20vw;
  137. height: 110rpx;
  138. .menuBox {
  139. padding: 0rpx 20rpx;
  140. width: 120rpx;
  141. height: 98%;
  142. text-align: center;
  143. .img {
  144. width: 50rpx;
  145. height: 50rpx;
  146. }
  147. }
  148. }
  149. }
  150. }
  151. .Text {
  152. font-size: 24rpx;
  153. font-family: Cochin, serif;
  154. font-weight: 900;
  155. }
  156. .TextColor {
  157. @extend .Text;
  158. color: #d81e06;
  159. }
  160. </style>