MobileFooter.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <div class="mobile-footer">
  3. <span :class="activeType=='home'?'active':''">
  4. <nuxt-link to="/">
  5. <i :class="activeType=='home'?'iconfont icon-shouye':'iconfont icon-shouye1'"></i><p>首页</p>
  6. </nuxt-link>
  7. </span>
  8. <span :class="activeType=='shops'?'active':''">
  9. <nuxt-link to="/mobile/shop">
  10. <i :class="activeType=='shops'?'iconfont icon-dianpu':'iconfont icon-dianpu1'"></i><p>店铺</p>
  11. </nuxt-link>
  12. </span>
  13. <span :class="activeType=='user'?'active':''">
  14. <nuxt-link to="/mobile/user">
  15. <i :class="activeType=='user'?'iconfont icon-icon':'iconfont icon-wo'"></i><p>我</p>
  16. </nuxt-link>
  17. </span>
  18. <a @click="toTop" v-show="!hideToTop"><i class="iconfont icon-arrow-up icon-xlg"></i></a>
  19. </div>
  20. </template>
  21. <script>
  22. import { scrollTo } from '~utils/scroll'
  23. export default{
  24. name: 'MobileFooter',
  25. data () {
  26. return {
  27. hideToTop: true
  28. }
  29. },
  30. computed: {
  31. activeType () {
  32. return this.$route.path === '/' ? 'home' : this.$route.path === '/mobile/shop' ? 'shops' : this.$route.path === '/mobile/user' ? 'user' : ''
  33. }
  34. },
  35. mounted: function () {
  36. this.$nextTick(function () {
  37. window.addEventListener('scroll', this.onScroll)
  38. })
  39. },
  40. methods: {
  41. onScroll () {
  42. let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  43. if (scrolled > window.screen.availHeight) {
  44. this.hideToTop = false
  45. } else {
  46. this.hideToTop = true
  47. }
  48. },
  49. toTop () {
  50. scrollTo('body', 300)
  51. }
  52. }
  53. }
  54. </script>
  55. <style scoped>
  56. .mobile-footer{
  57. position:fixed;
  58. bottom:0;
  59. width:100%;
  60. height:.98rem;
  61. text-align: center;
  62. border-top:.04rem solid #ccc;
  63. background: #ffffff;
  64. z-index: 10;
  65. }
  66. .mobile-footer span{
  67. display: inline-block;
  68. width: 2.5rem;
  69. font-size:.32rem;
  70. color:#b0b0b0;
  71. padding-top:.1rem;
  72. }
  73. .mobile-footer span a{
  74. color:#b0b0b0;
  75. }
  76. .mobile-footer span a i{
  77. font-size:.45rem;
  78. }
  79. .mobile-footer span a p{
  80. font-size:.22rem;
  81. }
  82. .mobile-footer span.active a{
  83. color:#3976f4;
  84. }
  85. .mobile-footer >a {
  86. position: absolute;
  87. right: .1rem;
  88. top: -1rem;
  89. background: rgba(0,0,0,.4);
  90. color: #fff;
  91. width: .88rem;
  92. height: .88rem;
  93. line-height: .88rem;
  94. border-radius: 100%;
  95. }
  96. .mobile-footer >a i{
  97. font-size: .46rem;
  98. }
  99. </style>