step - 副本.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view class="step-box">
  3. <view class="slider-item-box">
  4. <u-slider class="step-slider" v-model="stepRatio" activeColor="#05C175" min="0" max="100"
  5. inactiveColor="#e6e6e6">
  6. </u-slider>
  7. <view class="slider-item">
  8. <text
  9. :class="['item' , stepRatio >= 0 ? 'active-item' : '' , stepRatio == 0 ? 'now-item' : '' ]"></text>
  10. <text
  11. :class="['item' , stepRatio >= 25 ? 'active-item' : '' , stepRatio == 25 ? 'now-item' : '' ]"></text>
  12. <text
  13. :class="['item' , stepRatio >= 50 ? 'active-item' : '' , stepRatio == 50 ? 'now-item' : '' ]"></text>
  14. <text
  15. :class="['item' , stepRatio >= 75 ? 'active-item' : '' , stepRatio == 75 ? 'now-item' : '' ]"></text>
  16. <text
  17. :class="['item' , stepRatio >= 100 ? 'active-item' : '' , stepRatio == 100 ? 'now-item' : '' ]"></text>
  18. </view>
  19. </view>
  20. <view class="step-node-nums">
  21. <view class="num-ratio">0%</view>
  22. <view class="num-ratio">25%</view>
  23. <view class="num-ratio">50%</view>
  24. <view class="num-ratio">75%</view>
  25. <view class="num-ratio">100%</view>
  26. </view>
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. props: {
  32. width: {
  33. type: Number,
  34. default: 0
  35. },
  36. percent: {
  37. type: Number,
  38. default: 0
  39. }
  40. },
  41. data() {
  42. return {
  43. stepRatio: 0,
  44. };
  45. },
  46. watch: {
  47. percent: {
  48. handler(newPercent , old) {
  49. if(newPercent !== old){
  50. this.stepRatio = newPercent || 0
  51. }
  52. },
  53. immediate: true
  54. },
  55. stepRatio: {
  56. handler(stepRatio , old) {
  57. if(stepRatio !== old){
  58. this.$emit("update:percent", stepRatio)
  59. }
  60. },
  61. immediate: true
  62. }
  63. },
  64. methods: {
  65. }
  66. }
  67. </script>
  68. <style lang="scss" scoped>
  69. .step-box {
  70. width: 100%;
  71. height: 54rpx;
  72. border-radius: 2rpx;
  73. .slider-item-box {
  74. width: 100%;
  75. height: 22rpx;
  76. display: flex;
  77. align-items: center;
  78. position: relative;
  79. .slider-item {
  80. position: absolute;
  81. left: 0;
  82. top: 0;
  83. width: 100%;
  84. height: 100%;
  85. display: flex;
  86. justify-content: space-between;
  87. align-items: center;
  88. .item {
  89. width: 16rpx;
  90. height: 16rpx;
  91. background: #ffffff;
  92. border: 4rpx solid #e6e6e6;
  93. border-radius: 50%;
  94. }
  95. .active-item {
  96. border-color: #05c175;
  97. }
  98. .now-item {}
  99. }
  100. }
  101. .step-slider {
  102. width: 100%;
  103. position: relative;
  104. .slider-item {
  105. position: absolute;
  106. width: 10px;
  107. height: 10px;
  108. background-color: red;
  109. }
  110. ::v-deep uni-slider {
  111. margin: 0;
  112. .uni-slider-handle-wrapper {
  113. height: 6rpx;
  114. }
  115. .uni-slider-thumb {
  116. margin-top: -11rpx !important;
  117. width: 22rpx !important;
  118. height: 22rpx !important;
  119. border: 6rpx solid #05c175;
  120. }
  121. }
  122. }
  123. .step-node-nums {
  124. width: 100%;
  125. display: flex;
  126. justify-content: space-between;
  127. padding-top: 10rpx;
  128. .num-ratio {
  129. flex: 1;
  130. font-size: 20rpx;
  131. font-family: PingFang SC, PingFang SC-Regular;
  132. font-weight: 400;
  133. text-align: center;
  134. color: #808080;
  135. line-height: 28rpx;
  136. &:first-child {
  137. text-align: left;
  138. }
  139. &:last-child {
  140. text-align: right;
  141. }
  142. }
  143. }
  144. }
  145. </style>