MobileFooter.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. <a @click="goCollect">
  15. <i :class="activeType=='user'?'iconfont icon-icon':'iconfont icon-wo'"></i><p>我</p>
  16. </a>
  17. </span>
  18. <a @click="toTop" v-show="!hideToTop"><i class="iconfont icon-arrow-up icon-xlg"></i></a>
  19. <login-box @onLoginBoxClose="showLoginBox = false" v-if="showLoginBox"></login-box>
  20. </div>
  21. </template>
  22. <script>
  23. import { scrollTo } from '~utils/scroll'
  24. import {LoginBox} from '~components/mobile/common'
  25. export default{
  26. name: 'MobileFooter',
  27. data () {
  28. return {
  29. hideToTop: true,
  30. showLoginBox: false
  31. }
  32. },
  33. components: {
  34. LoginBox
  35. },
  36. computed: {
  37. activeType () {
  38. return this.$route.path === '/' ? 'home' : this.$route.path === '/mobile/shop' ? 'shops' : this.$route.path === '/mobile/user' ? 'user' : ''
  39. },
  40. user () {
  41. return this.$store.state.option.user
  42. }
  43. },
  44. mounted: function () {
  45. this.$nextTick(function () {
  46. window.addEventListener('scroll', this.onScroll)
  47. })
  48. },
  49. methods: {
  50. onScroll () {
  51. let scrolled = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop
  52. if (scrolled > window.screen.availHeight) {
  53. this.hideToTop = false
  54. } else {
  55. this.hideToTop = true
  56. }
  57. },
  58. toTop () {
  59. scrollTo('body', 300)
  60. },
  61. goCollect: function () {
  62. if (this.user.logged) {
  63. this.$router.push('/mobile/user')
  64. } else {
  65. this.showLoginBox = true
  66. }
  67. }
  68. }
  69. }
  70. </script>
  71. <style scoped>
  72. .mobile-footer{
  73. position:fixed;
  74. bottom:0;
  75. width:100%;
  76. height:.98rem;
  77. text-align: center;
  78. border-top:.04rem solid #ccc;
  79. background: #ffffff;
  80. z-index: 10;
  81. }
  82. .mobile-footer span{
  83. display: inline-block;
  84. width: 2.5rem;
  85. font-size:.32rem;
  86. color:#b0b0b0;
  87. padding-top:.1rem;
  88. }
  89. .mobile-footer span a{
  90. color:#b0b0b0;
  91. }
  92. .mobile-footer span a i{
  93. font-size:.45rem;
  94. }
  95. .mobile-footer span a p{
  96. font-size:.22rem;
  97. }
  98. .mobile-footer span.active a{
  99. color:#3976f4;
  100. }
  101. .mobile-footer >a {
  102. position: absolute;
  103. right: .1rem;
  104. top: -1rem;
  105. background: rgba(0,0,0,.4);
  106. color: #fff;
  107. width: .88rem;
  108. height: .88rem;
  109. line-height: .88rem;
  110. border-radius: 100%;
  111. }
  112. .mobile-footer >a i{
  113. font-size: .46rem;
  114. }
  115. </style>