app-tab-bar.vue 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <view class="app-navigation-bar" :style="{height: botNavHei + 'rpx',}" :class="{'app-tab-bar-shadow': shadow}" >
  3. <view v-for="(item, index) in tabBarNavs.navs" :key="index" class="app-tab-bar-item box-grow-1" :style="{backgroundColor: bottom_background_color, width: `${100/tabBarNavs.navs.length}%`}">
  4. <app-jump-button :backgroundColor="bottom_background_color"
  5. form
  6. class="app-button"
  7. :url="item.url"
  8. :open_type="item.open_type"
  9. :params="item.param"
  10. arrangement="column"
  11. >
  12. <image class="app-icon" :src=" router === item.url ? item.active_icon : item.icon"></image>
  13. <text class="app-nav-text" v-bind:style="{'color': router === item.url ? item.active_color : item.color}">
  14. {{item.text}}
  15. </text>
  16. </app-jump-button>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. import { mapGetters, mapState } from 'vuex';
  22. export default {
  23. data() {
  24. return {
  25. router: '',
  26. }
  27. },
  28. props: {
  29. pageCount: Number,
  30. },
  31. computed: {
  32. ...mapGetters('mallConfig', {
  33. tabBarNavs: 'getNavBar'
  34. }),
  35. ...mapGetters('iPhoneX', {
  36. botNavHei: 'getNavHei',
  37. }),
  38. ...mapState('mallConfig', {
  39. bottom_background_color: state => state.navbar.bottom_background_color,
  40. shadow: state => state.navbar.shadow,
  41. }),
  42. },
  43. mounted() {
  44. this.router = this.$platDiff.tabBarUrl(null, this.pageCount);
  45. }
  46. };
  47. </script>
  48. <style lang="scss" scoped>
  49. .app-navigation-bar {
  50. display: flex;
  51. flex-direction: row;
  52. width: 100%;
  53. background-color: white;
  54. z-index: 1600;
  55. }
  56. .app-nav-text {
  57. font-size: #{22rpx};
  58. line-height: #{22rpx};
  59. /*position: absolute;*/
  60. /*top: 0;*/
  61. margin-top: #{75rpx};
  62. }
  63. .app-icon {
  64. width: #{50rpx};
  65. height: #{50rpx};
  66. position: absolute;
  67. top: 0;
  68. left: 50%;
  69. margin-top: #{20rpx};
  70. transform: translateX(-50%);
  71. }
  72. .app-tab-bar-item {
  73. flex-grow: 1;
  74. position: relative;
  75. }
  76. .app-tab-bar-shadow {
  77. border-top: 1rpx solid $uni-weak-color-one;
  78. }
  79. </style>