scrollTop.vue 1.9 KB

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