uni-steps.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <view class="uni-steps">
  3. <view :class="[direction==='column'?'uni-steps__column':'uni-steps__row']">
  4. <view :class="[direction==='column'?'uni-steps__column-text-container':'uni-steps__row-text-container']">
  5. <view v-for="(item,index) in options" :key="index" :class="[direction==='column'?'uni-steps__column-text':'uni-steps__row-text']">
  6. <text :style="{color:index<=active?activeColor:deactiveColor}" :class="[direction==='column'?'uni-steps__column-title':'uni-steps__row-title']">{{item.status}}</text>
  7. <text :style="{color:index<=active?activeColor:deactiveColor}" :class="[direction==='column'?'uni-steps__column-desc':'uni-steps__row-desc']">{{item.context}}</text>
  8. <text :style="{color:index<=active?activeColor:deactiveColor}" :class="[direction==='column'?'uni-steps__column-desc':'uni-steps__row-desc']">{{item.time}}</text>
  9. </view>
  10. </view>
  11. <view :class="[direction==='column'?'uni-steps__column-container':'uni-steps__row-container']">
  12. <view :class="[direction==='column'?'uni-steps__column-line-item':'uni-steps__row-line-item']" v-for="(item,index) in options"
  13. :key="index">
  14. <view :class="[direction==='column'?'uni-steps__column-line':'uni-steps__row-line',direction==='column'?'uni-steps__column-line--before':'uni-steps__row-line--before']"
  15. :style="{backgroundColor:index<=active&&index!==0?activeColor:index===0?'transparent':deactiveColor}"></view>
  16. <view :class="[direction==='column'?'uni-steps__column-check':'uni-steps__row-check']" v-if="index === active">
  17. <uni-icons :color="activeColor" type="checkbox-filled" size="14"></uni-icons>
  18. </view>
  19. <view :class="[direction==='column'?'uni-steps__column-circle':'uni-steps__row-circle']" v-else :style="{backgroundColor:index<active?activeColor:deactiveColor}"></view>
  20. <view :class="[direction==='column'?'uni-steps__column-line':'uni-steps__row-line',direction==='column'?'uni-steps__column-line--after':'uni-steps__row-line--after']"
  21. :style="{backgroundColor:index<active&&index!==options.length-1?activeColor:index===options.length-1?'transparent':deactiveColor}"></view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import uniIcons from '../uni-icons/uni-icons.vue'
  29. export default {
  30. name: 'UniSteps',
  31. components: {
  32. uniIcons
  33. },
  34. props: {
  35. direction: {
  36. // 排列方向 row column
  37. type: String,
  38. default: 'row'
  39. },
  40. activeColor: {
  41. // 激活状态颜色
  42. type: String,
  43. default: '#1aad19'
  44. },
  45. deactiveColor: {
  46. // 未激活状态颜色
  47. type: String,
  48. default: '#999999'
  49. },
  50. active: {
  51. // 当前步骤
  52. type: Number,
  53. default: 0
  54. },
  55. options: {
  56. type: Array,
  57. default () {
  58. return []
  59. }
  60. } // 数据
  61. },
  62. data() {
  63. return {}
  64. }
  65. }
  66. </script>
  67. <style lang="scss" scoped>
  68. .uni-steps {
  69. /* #ifndef APP-NVUE */
  70. display: flex;
  71. width: 100%;
  72. /* #endif */
  73. /* #ifdef APP-NVUE */
  74. flex: 1;
  75. /* #endif */
  76. flex-direction: column;
  77. }
  78. .uni-steps__row {
  79. /* #ifndef APP-NVUE */
  80. display: flex;
  81. /* #endif */
  82. flex-direction: column;
  83. }
  84. .uni-steps__column {
  85. /* #ifndef APP-NVUE */
  86. display: flex;
  87. /* #endif */
  88. flex-direction: row-reverse;
  89. }
  90. .uni-steps__row-text-container {
  91. /* #ifndef APP-NVUE */
  92. display: flex;
  93. /* #endif */
  94. flex-direction: row;
  95. }
  96. .uni-steps__column-text-container {
  97. /* #ifndef APP-NVUE */
  98. display: flex;
  99. /* #endif */
  100. flex-direction: column;
  101. flex: 1;
  102. }
  103. .uni-steps__row-text {
  104. /* #ifndef APP-NVUE */
  105. display: inline-flex;
  106. /* #endif */
  107. flex: 1;
  108. flex-direction: column;
  109. }
  110. .uni-steps__column-text {
  111. padding: 6px 0px;
  112. border-bottom-style: solid;
  113. border-bottom-width: 1px;
  114. border-bottom-color: $uni-border-color;
  115. /* #ifndef APP-NVUE */
  116. display: flex;
  117. /* #endif */
  118. flex-direction: column;
  119. }
  120. .uni-steps__row-title {
  121. font-size: $uni-font-size-base;
  122. line-height: 16px;
  123. text-align: center;
  124. }
  125. .uni-steps__column-title {
  126. font-size: $uni-font-size-base;
  127. text-align: left;
  128. line-height: 18px;
  129. }
  130. .uni-steps__row-desc {
  131. font-size: 12px;
  132. line-height: 14px;
  133. text-align: center;
  134. }
  135. .uni-steps__column-desc {
  136. font-size: $uni-font-size-sm;
  137. text-align: left;
  138. line-height: 18px;
  139. }
  140. .uni-steps__row-container {
  141. /* #ifndef APP-NVUE */
  142. display: flex;
  143. /* #endif */
  144. flex-direction: row;
  145. }
  146. .uni-steps__column-container {
  147. /* #ifndef APP-NVUE */
  148. display: inline-flex;
  149. /* #endif */
  150. width: 30px;
  151. flex-direction: column;
  152. }
  153. .uni-steps__row-line-item {
  154. /* #ifndef APP-NVUE */
  155. display: inline-flex;
  156. /* #endif */
  157. flex-direction: row;
  158. flex: 1;
  159. height: 14px;
  160. line-height: 14px;
  161. align-items: center;
  162. justify-content: center;
  163. }
  164. .uni-steps__column-line-item {
  165. /* #ifndef APP-NVUE */
  166. display: flex;
  167. /* #endif */
  168. flex-direction: column;
  169. flex: 1;
  170. align-items: center;
  171. justify-content: center;
  172. }
  173. .uni-steps__row-line {
  174. flex: 1;
  175. height: 1px;
  176. background-color: $uni-text-color-grey;
  177. }
  178. .uni-steps__column-line {
  179. width: 1px;
  180. background-color: $uni-text-color-grey;
  181. }
  182. .uni-steps__row-line--after {
  183. transform: translateX(1px);
  184. }
  185. .uni-steps__column-line--after {
  186. flex: 1;
  187. transform: translate(0px, 1px);
  188. }
  189. .uni-steps__row-line--before {
  190. transform: translateX(-1px);
  191. }
  192. .uni-steps__column-line--before {
  193. height: 6px;
  194. transform: translate(0px, -1px);
  195. }
  196. .uni-steps__row-circle {
  197. width: 5px;
  198. height: 5px;
  199. border-radius: 100px;
  200. background-color: $uni-text-color-grey;
  201. margin: 0px 3px;
  202. }
  203. .uni-steps__column-circle {
  204. width: 5px;
  205. height: 5px;
  206. border-radius: 100px;
  207. background-color: $uni-text-color-grey;
  208. margin: 4px 0px 5px 0px;
  209. }
  210. .uni-steps__row-check {
  211. margin: 0px 6px;
  212. }
  213. .uni-steps__column-check {
  214. height: 14px;
  215. line-height: 14px;
  216. margin: 2px 0px;
  217. }
  218. </style>