scrollTop.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template name="scrollTop">
  2. <!-- 商品详情价格判断 -->
  3. <view>
  4. <view class="scrollTop" :style="{bottom:bottom+'rpx'}">
  5. <view class="icon msg">
  6. <!-- #ifdef MP-WEIXIN -->
  7. <button class="contact-btn" open-type="contact" @bindcontact="handleContact">
  8. <text class="iconfont icon-zixunrexian"></text>
  9. </button>
  10. <!-- #endif -->
  11. </view>
  12. <view class="icon top" @click="onPageScrollTop" :class="isScrollTop ? 'show' : 'none'">
  13. <text class="iconfont icon-zhiding"></text>
  14. </view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  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. },
  31. data() {
  32. return{
  33. isPhone:false,
  34. telPhone:'0755-22907771',
  35. mobilePhone:'15338851365'
  36. }
  37. },
  38. created() {
  39. },
  40. methods:{
  41. onPageScrollTop(){
  42. uni.pageScrollTo({
  43. scrollTop: 0,
  44. duration: 600
  45. })
  46. },
  47. handleContact(e){
  48. console.log(e.detail.path)
  49. console.log(e.detail.query)
  50. },
  51. },
  52. }
  53. </script>
  54. <style lang="scss">
  55. .scrollTop{
  56. width: 80rpx;
  57. height: 200rpx;
  58. position: fixed;
  59. right: 20rpx;
  60. z-index: 99;
  61. .icon{
  62. width: 80rpx;
  63. height: 80rpx;
  64. border-radius: 50%;
  65. float: left;
  66. margin: 10rpx 0;
  67. line-height: 80rpx;
  68. text-align: center;
  69. .contact-btn{
  70. width: 80rpx;
  71. height: 80rpx;
  72. background-color: rgba(0,0,0,0);
  73. line-height: 80rpx;
  74. .iconfont{
  75. font-size: $font-size-44;
  76. color: #FFFFFF;
  77. }
  78. }
  79. &.msg{
  80. background: $btn-confirm;
  81. }
  82. &.top{
  83. background-color: rgba(0,0,0,0.4);
  84. &.show{
  85. opacity: 1;
  86. }
  87. &.none{
  88. opacity: 0;
  89. }
  90. }
  91. .iconfont{
  92. font-size: $font-size-44;
  93. color: #FFFFFF;
  94. }
  95. }
  96. }
  97. </style>