footer.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <view class="footer flex p-y-xs2 bg-tab-nav">
  3. <view class="flex-fill" v-for="item,index in navList" :key="index" @click="tabChange(item.url)">
  4. <view class="icon">
  5. <image class="h-15" v-if="item.url.split('?')[0] == activeRouter" :src="item.activeIcon" mode="heightFix"></image>
  6. <image class="h-15" v-else :src="item.icon" mode="heightFix"></image>
  7. </view>
  8. <view class="fn-12" :class="{ 'router-link-active': item.url.split('?')[0] == activeRouter }">{{ $t(item.label) }}</view>
  9. <view class="tip-right" v-if="item.num">
  10. {{item.num}}
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. import {
  17. leak_num
  18. } from '@/api/index.js';
  19. import {
  20. mapMutations
  21. } from "vuex";
  22. import {
  23. navList
  24. } from "./list.js";
  25. export default {
  26. computed: {
  27. navList
  28. },
  29. data() {
  30. return {
  31. activeRouter:''
  32. };
  33. },
  34. created() {
  35. const routes = getCurrentPages(); //获取当前打开过的页面路由数组
  36. const curRoute = routes[routes.length - 1].route //获取当前页面路由
  37. this.activeRouter = '/' + curRoute;
  38. this.leak_num();
  39. },
  40. methods: {
  41. ...mapMutations('user', [ 'setOrderNumber']),
  42. leak_num(){
  43. leak_num().then(res => {
  44. this.setOrderNumber(res.data.num)
  45. }).catch(err => {
  46. uni.showToast({
  47. title: err,
  48. icon: 'none',
  49. })
  50. });
  51. },
  52. tabChange(url) {
  53. uni.switchTab({
  54. url: url
  55. });
  56. },
  57. },
  58. };
  59. </script>
  60. <style lang="scss" scoped>
  61. .flex-fill{
  62. text-align: center;
  63. line-height: 1;
  64. position: relative;
  65. }
  66. .p-y-xs2 {
  67. padding: 4px 0px;
  68. }
  69. .h-15{
  70. height: 20px;
  71. width: 20px;
  72. }
  73. .footer {
  74. box-shadow: 0rpx 2rpx 5rpx 0rpx rgba(0,0,0,0.16);
  75. border-top: 1rpx solid #f8f8f8;
  76. position: fixed;
  77. bottom: 0;
  78. width: 100%;
  79. left: 0;
  80. z-index: 999 !important;
  81. color: rgba(#fff, 0.3);
  82. justify-content: space-around !important;
  83. .tip-right{
  84. font-size: $font-sm;
  85. color: #FFF;
  86. background-color: $uni-color-error;
  87. border-radius: 100%;
  88. position: absolute;
  89. right:-1em;
  90. top: -1em;
  91. min-width: 1.5em;
  92. height: 1.5em;
  93. line-height: 1.5em;
  94. }
  95. }
  96. .fn-12{
  97. margin-top: 4px;
  98. color:#666992;
  99. font-size:24rpx ;
  100. }
  101. .router-link-active {
  102. color:#17C474;
  103. }
  104. .bg-tab-nav {
  105. background-color: #fff;
  106. }
  107. </style>