app-tab-bar.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <view class="app-navigation-bar safe-area-inset-bottom" :style="{backgroundColor: bottom_background_color}" :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="{height: botNavHei + 'rpx',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. created() {
  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. bottom: 0;
  54. left: 0;
  55. background-color: white;
  56. z-index: 1600;
  57. position: fixed;
  58. }
  59. .app-nav-text {
  60. font-size: #{22rpx};
  61. line-height: #{22rpx};
  62. margin-top: #{75rpx};
  63. }
  64. .app-icon {
  65. width: #{50rpx};
  66. height: #{50rpx};
  67. position: absolute;
  68. top: 0;
  69. left: 50%;
  70. margin-top: #{20rpx};
  71. transform: translateX(-50%);
  72. }
  73. .app-tab-bar-item {
  74. flex-grow: 1;
  75. position: relative;
  76. }
  77. .app-tab-bar-shadow {
  78. border-top: 1rpx solid $uni-weak-color-one;
  79. }
  80. </style>