step - 副本.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <view class="step-box" @touchstart="touchStart" @touchmove='move'>
  3. <view class="step-link">
  4. <view class="step-bg" :style="{'width': `${stepRatio}%`}"></view>
  5. <view class="step-node">
  6. <view :class="['node-item' , stepRatio >= 0 ? 'active-node-item' : '' , stepRatio == 0 ? 'now-node-item' : '' ]"></view>
  7. <view :class="['node-item' , stepRatio >= 25 ? 'active-node-item' : '' , stepRatio == 25 ? 'now-node-item' : '' ]"></view>
  8. <view :class="['node-item' , stepRatio >= 50 ? 'active-node-item' : '' , stepRatio == 50 ? 'now-node-item' : '' ]"></view>
  9. <view :class="['node-item' , stepRatio >= 75 ? 'active-node-item' : '' , stepRatio == 75 ? 'now-node-item' : '' ]"></view>
  10. <view :class="['node-item' , stepRatio >= 100 ? 'active-node-item' : '' , stepRatio == 100 ? 'now-node-item' : '' ]"></view>
  11. </view>
  12. </view>
  13. <view class="step-node-nums">
  14. <view class="num-ratio">0%</view>
  15. <view class="num-ratio">25%</view>
  16. <view class="num-ratio">50%</view>
  17. <view class="num-ratio">75%</view>
  18. <view class="num-ratio">100%</view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. stepRatio: 0,
  27. movePlace:null,
  28. };
  29. },
  30. methods:{
  31. touchStart(e){
  32. this.movePlace = e.changedTouches[0].clientX
  33. },
  34. touchEnd(e){
  35. // console.log('touchEnd = ' , e.changedTouches[0])
  36. },
  37. move(e){
  38. const PlaceX = e.changedTouches[0].clientX
  39. console.log('move = ' , PlaceX , this.movePlace )
  40. if(PlaceX < this.movePlace ){
  41. if(this.stepRatio > 0){
  42. this.stepRatio -= 1;
  43. }
  44. }else{
  45. if(this.stepRatio < 100){
  46. this.stepRatio += 1;
  47. }
  48. }
  49. this.movePlace = e.changedTouches[0].clientX;
  50. }
  51. }
  52. }
  53. </script>
  54. <style lang="scss" scoped>
  55. .step-box {
  56. width: 100%;
  57. height: 54rpx;
  58. border-radius: 2rpx;
  59. .step-link {
  60. height: 6rpx;
  61. background: #e6e6e6;
  62. border-radius: 3rpx;
  63. position: relative;
  64. .step-bg {
  65. position: absolute;
  66. z-index: 1;
  67. left: 0;
  68. top: 0;
  69. background-color: #05C175;
  70. border-radius: 3rpx;
  71. height: 100%;
  72. }
  73. .step-node {
  74. position: absolute;
  75. z-index: 1;
  76. width: 100%;
  77. height: 100%;
  78. display: flex;
  79. justify-content: space-between;
  80. align-items: center;
  81. .node-item{
  82. width: 16rpx;
  83. height: 16rpx;
  84. background: #ffffff;
  85. border: 4rpx solid #e6e6e6;
  86. border-radius: 50%;
  87. }
  88. .active-node-item{
  89. border-color: #05c175;
  90. }
  91. .now-node-item{
  92. width: 22rpx;
  93. height: 22rpx;
  94. border: 6rpx solid #05c175;
  95. }
  96. }
  97. }
  98. // <view class="step-node-nums">
  99. // <view class="num-ratio">0%</view>
  100. // <view class="num-ratio">25%</view>
  101. // <view class="num-ratio">50%</view>
  102. // <view class="num-ratio">75%</view>
  103. // <view class="num-ratio">100%</view>
  104. // </view>
  105. .step-node-nums{
  106. width: 100%;
  107. display: flex;
  108. justify-content: space-between;
  109. padding-top: 10rpx;
  110. .num-ratio{
  111. flex: 1;
  112. font-size: 20rpx;
  113. font-family: PingFang SC, PingFang SC-Regular;
  114. font-weight: 400;
  115. text-align: center;
  116. color: #808080;
  117. line-height: 28rpx;
  118. &:first-child{
  119. text-align: left;
  120. }
  121. &:last-child{
  122. text-align: right;
  123. }
  124. }
  125. }
  126. }
  127. </style>