MobileFooter.vue 3.5 KB

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