home.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <div class="all-box">
  3. <el-scrollbar class="mian-content" ref="scrollBarRef">
  4. <Header></Header>
  5. <div class="main">
  6. <router-view />
  7. </div>
  8. <Footer></Footer>
  9. </el-scrollbar>
  10. <!-- 右边漂浮框mos+ -->
  11. <div class="back-top-container" v-show="isShow">
  12. <div class="yb_conct">
  13. <div class="yb_bar">
  14. <ul>
  15. <li class="yb_top" @click="backTop">返回顶部</li>
  16. <li class="yb_phone">400-6877-880</li>
  17. <li class="yb_shouji">13322611222</li>
  18. <li class="yb_QQ" @click="$openUrl">在线咨询</li>
  19. <li class="yb_ercode" style="height: 53px;">
  20. <div style="position: relative;left: -8px;">扫码体验手机版</div>
  21. <img style="width: 140px;" src="@/assets/images/public/qrcord_m.png" alt="积分系统" title="积分系统" />
  22. </li>
  23. </ul>
  24. </div>
  25. </div>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. import Header from '@/components/Header.vue'
  31. import Footer from '@/components/Footer.vue'
  32. export default {
  33. components: {
  34. Header,
  35. Footer
  36. },
  37. data() {
  38. return {
  39. scrollTop: 0, //默认距离顶部的距离
  40. isShow:false,
  41. };
  42. },
  43. created() {
  44. },
  45. mounted () {
  46. window.addEventListener('scroll', this.scrollToTop)
  47. },
  48. destroyed () {
  49. window.removeEventListener('scroll', this.scrollToTop)
  50. },
  51. methods: {
  52. // 点击图片回到顶部方法,加计时器是为了过渡顺滑
  53. backTop () {
  54. const that = this
  55. let timer = setInterval(() => {
  56. let ispeed = Math.floor(-that.scrollTop / 5)
  57. document.documentElement.scrollTop = document.body.scrollTop = that.scrollTop + ispeed
  58. if (that.scrollTop === 0) {
  59. clearInterval(timer)
  60. }
  61. }, 16)
  62. },
  63. // 为了计算距离顶部的高度,当高度大于60显示回顶部图标,小于60则隐藏
  64. scrollToTop () {
  65. const that = this
  66. let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
  67. that.scrollTop = scrollTop
  68. if (that.scrollTop > 60) {
  69. this.isShow=true;
  70. } else {
  71. this.isShow=false;
  72. }
  73. }
  74. }
  75. };
  76. </script>
  77. <style scoped="scoped">
  78. /* 右边漂浮框 */
  79. .back-top-container {
  80. display: block;
  81. position: fixed;
  82. right: 50px;
  83. bottom: 50px;
  84. cursor: pointer;
  85. z-index: 99999;
  86. }
  87. .back-top {
  88. opacity: 0.8;
  89. width: 32px;
  90. height: 32px;
  91. z-index: 10000000;
  92. background: #868686
  93. }
  94. .back-top:hover {
  95. opacity: 1;
  96. }
  97. .back-top-text {
  98. margin-top: 3px;
  99. padding-left: 7.5px;
  100. width: 32px;
  101. border: 1px solid #000;
  102. border-radius: 5px;
  103. background: #fff;
  104. }
  105. .back-top:hover {
  106. opacity: 1;
  107. }
  108. .yb_conct {
  109. position: fixed;
  110. z-index: 9999999;
  111. top: 200px;
  112. right: -127px;
  113. /* right: 0px; */
  114. cursor: pointer;
  115. transition: all .3s ease;
  116. }
  117. .yb_conct:hover {
  118. right: 0px;
  119. }
  120. .yb_conct:hover .yb_ercode {
  121. height: 200px !important;
  122. }
  123. .yb_bar ul li {
  124. width: 180px;
  125. height: 53px;
  126. font: 15px/53px 'Microsoft YaHei';
  127. color: #fff;
  128. text-indent: 54px;
  129. margin-bottom: 1px;
  130. border-radius: 3px;
  131. transition: all .5s ease;
  132. overflow: hidden;
  133. }
  134. .yb_bar .yb_top {
  135. background: #409eff url(@/assets/images/public/return_top.png) no-repeat 10px 10px;
  136. }
  137. .yb_bar .yb_phone {
  138. background: #409eff url(@/assets/images/public/zuoji.png) no-repeat 10px 10px;
  139. }
  140. .yb_bar .yb_shouji {
  141. background: #409eff url(@/assets/images/public/shouji2.png) no-repeat 10px 10px;
  142. }
  143. .yb_bar .yb_QQ {
  144. background: #409eff url(@/assets/images/public/shangqiao.png) no-repeat 10px 10px;
  145. }
  146. .yb_bar .yb_ercode {
  147. background: #409eff url(@/assets/images/public/ercode.png) no-repeat 10px 10px;
  148. text-align: center;
  149. }
  150. .yb_QQ a {
  151. display: block;
  152. text-indent: 54px;
  153. font-size: 15px;
  154. width: 100%;
  155. height: 100%;
  156. color: #fff;
  157. }
  158. </style>