scrollTop.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. .icon{
  61. width: 80rpx;
  62. height: 80rpx;
  63. border-radius: 50%;
  64. float: left;
  65. margin: 10rpx 0;
  66. line-height: 80rpx;
  67. text-align: center;
  68. .contact-btn{
  69. width: 80rpx;
  70. height: 80rpx;
  71. background-color: rgba(0,0,0,0);
  72. line-height: 80rpx;
  73. .iconfont{
  74. font-size: $font-size-44;
  75. color: #FFFFFF;
  76. }
  77. }
  78. &.msg{
  79. background-image: linear-gradient(0deg, #f28e31 0%, #e15616 100%);
  80. }
  81. &.top{
  82. background-color: rgba(0,0,0,0.4);
  83. &.show{
  84. opacity: 1;
  85. }
  86. &.none{
  87. opacity: 0;
  88. }
  89. }
  90. .iconfont{
  91. font-size: $font-size-44;
  92. color: #FFFFFF;
  93. }
  94. }
  95. }
  96. </style>