scrollTop.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template name="scrollTop">
  2. <view>
  3. <view class="scrollTop" :style="{ bottom: bottom + 'rpx' }">
  4. <view class="icon msg" v-if="isShowKefu">
  5. <!-- #ifdef MP-WEIXIN -->
  6. <button class="contact-btn" open-type="contact" @bindcontact="handleContact">
  7. <text class="iconfont icon-zixunrexian"></text>
  8. </button>
  9. <!-- #endif -->
  10. </view>
  11. <view class="icon top" @click="onPageScrollTop" :class="isScrollTop ? 'show' : 'none'">
  12. <text class="iconfont icon-zhiding"></text>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import { mapState, mapMutations } from 'vuex'
  19. export default {
  20. name: 'scrollTop',
  21. props: {
  22. bottom: {
  23. type: Number,
  24. default: 100
  25. },
  26. isScrollTop: {
  27. type: Boolean,
  28. default: false
  29. },
  30. isShowKefu:{
  31. type: Boolean,
  32. default: true
  33. },
  34. isShowSupplier: {
  35. // 是否展示供应商服务图标
  36. type: Boolean,
  37. default: false
  38. }
  39. },
  40. data() {
  41. return {
  42. isPhone: false,
  43. telPhone: '0755-22907771',
  44. mobilePhone: '15338851365',
  45. isShowIcon: true
  46. }
  47. },
  48. created() {},
  49. computed: {
  50. ...mapState(['hasLogin'])
  51. },
  52. methods: {
  53. onPageScrollTop() {
  54. uni.pageScrollTo({
  55. scrollTop: 0,
  56. duration: 600
  57. })
  58. },
  59. handleContact(e) {
  60. console.log(e.detail.path)
  61. console.log(e.detail.query)
  62. }
  63. }
  64. }
  65. </script>
  66. <style lang="scss">
  67. .scrollTop {
  68. width: 80rpx;
  69. height: 120rpx;
  70. position: fixed;
  71. right: 20rpx;
  72. z-index: 99;
  73. .icon {
  74. width: 80rpx;
  75. height: 80rpx;
  76. border-radius: 50%;
  77. float: left;
  78. margin: 10rpx 0;
  79. line-height: 80rpx;
  80. text-align: center;
  81. .contact-btn {
  82. width: 80rpx;
  83. height: 80rpx;
  84. background-color: rgba(0, 0, 0, 0);
  85. line-height: 80rpx;
  86. .iconfont {
  87. font-size: $font-size-44;
  88. color: #ffffff;
  89. }
  90. }
  91. &.msg {
  92. background-color: #ffe6dc;
  93. .iconfont {
  94. color: #ff5b00;
  95. }
  96. }
  97. &.top {
  98. background-color: rgba(0, 0, 0, 0.4);
  99. &.show {
  100. opacity: 1;
  101. }
  102. &.none {
  103. opacity: 0;
  104. }
  105. }
  106. .iconfont {
  107. font-size: $font-size-44;
  108. color: #ffffff;
  109. }
  110. }
  111. }
  112. </style>