index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <view>
  3. <!-- 用户端 -->
  4. <view v-if="isShow">
  5. <u-tabbar :value="currentTab" activeColor="#2D73F0" inactiveColor="#333" :border="true">
  6. <u-tabbar-item
  7. v-for="item in clientList"
  8. :key="item.name"
  9. :text="item.text"
  10. :name="item.name"
  11. @click="handTab(item)"
  12. >
  13. <image class="bar_img" slot="active-icon" :src="item.selectedIconPath" />
  14. <image class="bar_img" slot="inactive-icon" :src="item.iconPath" />
  15. </u-tabbar-item>
  16. </u-tabbar>
  17. </view>
  18. <!-- 商家端 -->
  19. <view v-if="!isShow">
  20. <u-tabbar :value="currentTab" activeColor="#2D73F0" inactiveColor="#333" :border="true">
  21. <u-tabbar-item
  22. v-for="item in merchantList"
  23. :key="item.name"
  24. :text="item.text"
  25. :name="item.name"
  26. @click="handTab(item)"
  27. >
  28. <image class="bar_img" slot="active-icon" :src="item.selectedIconPath" />
  29. <image class="bar_img" slot="inactive-icon" :src="item.iconPath" />
  30. </u-tabbar-item>
  31. </u-tabbar>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. name: 'TabBar',
  38. props: {
  39. currentTab: {
  40. type: String,
  41. default: 'clientHome',
  42. },
  43. },
  44. data() {
  45. return {
  46. isShow: true,
  47. clientList: [
  48. {
  49. text: '首页',
  50. name: 'clientHome',
  51. pagePath: '/pages/client/tabBar/home/index',
  52. iconPath: '/static/images/home.png',
  53. selectedIconPath: '/static/images/home-select.png',
  54. },
  55. // {
  56. // text: '社区',
  57. // name: 'clientCommunity',
  58. // pagePath: '/pages/client/tabBar/community/index',
  59. // iconPath: '/static/images/community.png',
  60. // selectedIconPath: '/static/images/community-select.png',
  61. // },
  62. {
  63. text: '消息',
  64. name: 'clientMessage',
  65. pagePath: '/pages/client/tabBar/message/index',
  66. iconPath: '/static/images/message.png',
  67. selectedIconPath: '/static/images/message-select.png',
  68. },
  69. {
  70. text: '我的',
  71. name: 'clientMine',
  72. pagePath: 'pages/client/tabBar/mine/index',
  73. iconPath: '/static/images/mine.png',
  74. selectedIconPath: '/static/images/mine-select.png',
  75. },
  76. ],
  77. merchantList: [
  78. {
  79. text: '订单',
  80. name: 'merchantOrder',
  81. pagePath: 'pages/merchant/tabBar/order/index',
  82. iconPath: '/static/images/home.png',
  83. selectedIconPath: '/static/images/home-select.png',
  84. },
  85. {
  86. text: '消息',
  87. name: 'merchantMessage',
  88. pagePath: 'pages/merchant/tabBar/message/index',
  89. iconPath: '/static/images/community.png',
  90. selectedIconPath: '/static/images/community-select.png',
  91. },
  92. // {
  93. // text: '推广',
  94. // name: 'merchantExtend',
  95. // pagePath: 'pages/merchant/tabBar/extend/index',
  96. // iconPath: '/static/images/community.png',
  97. // selectedIconPath: '/static/images/community-select.png',
  98. // },
  99. {
  100. text: '店铺',
  101. name: 'merchantStore',
  102. pagePath: 'pages/merchant/tabBar/store/index',
  103. iconPath: '/static/images/message.png',
  104. selectedIconPath: '/static/images/message-select.png',
  105. },
  106. {
  107. text: '我的',
  108. name: 'merchantMine',
  109. pagePath: 'pages/merchant/tabBar/mine/index',
  110. iconPath: '/static/images/mine.png',
  111. selectedIconPath: '/static/images/mine-select.png',
  112. },
  113. ],
  114. };
  115. },
  116. mounted() {
  117. this.isShow = uni.getStorageSync('tabbar_type');
  118. // if(!this.isShow){
  119. // this.isShow = true
  120. // }
  121. },
  122. watch: {
  123. isShow(newValue) {
  124. console.log('@@@isShownewValue', newValue);
  125. },
  126. },
  127. methods: {
  128. handTab(row) {
  129. if (this.isShow) {
  130. uni.switchTab({
  131. url: row.pagePath,
  132. });
  133. } else {
  134. uni.redirectTo({
  135. url: row.pagePath,
  136. });
  137. }
  138. },
  139. },
  140. };
  141. </script>
  142. <style lang="scss" scoped>
  143. .bar_img {
  144. width: 54rpx;
  145. height: 54rpx;
  146. }
  147. ::deep .u-tabbar {
  148. border-top: 2rpx solid #dadbde;
  149. }
  150. </style>