From f26f29d84e0a68831a6af14dab3eec5500496d2e Mon Sep 17 00:00:00 2001 From: spring <2396852758@qq.com> Date: 星期三, 28 五月 2025 16:48:52 +0800 Subject: [PATCH] 初始化项目 --- uview-ui/components/u-steps/u-steps.vue | 200 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 200 insertions(+), 0 deletions(-) diff --git a/uview-ui/components/u-steps/u-steps.vue b/uview-ui/components/u-steps/u-steps.vue new file mode 100644 index 0000000..f12968f --- /dev/null +++ b/uview-ui/components/u-steps/u-steps.vue @@ -0,0 +1,200 @@ +<template> + <view class=""> + <view + class="u-steps" + :style="{ + flexDirection: direction + }" + > + <view class="u-steps__item" + :class="['u-steps__item--' + direction]" + v-for="(item, index) in list" :key="index" + > + <view + class="u-steps__item__num" + v-if="mode == 'number'" + :style="{ + backgroundColor: current < index ? 'transparent' : activeColor, + borderColor: current < index ? unActiveColor : activeColor + }" + > + <text v-if="current < index" :style="{ + color: current < index ? unActiveColor : activeColor, + }"> + {{ index + 1 }} + </text> + <u-icon v-else size="22" color="#ffffff" :name="icon"></u-icon> + </view> + <view class="u-steps__item__dot" v-if="mode == 'dot'" :style="{ + backgroundColor: index <= current ? activeColor : unActiveColor + }"></view> + <text class="u-line-1" :style="{ + color: index <= current ? activeColor : unActiveColor, + }" :class="['u-steps__item__text--' + direction]"> + {{ item.name }} + </text> + <view class="u-steps__item__line" :class="['u-steps__item__line--' + mode]" v-if="index < list.length - 1"> + <u-line :direction="direction" length="100%" :hair-line="false" :color="unActiveColor"></u-line> + </view> + </view> + </view> + </view> +</template> + +<script> +/** + * steps 姝ラ鏉� + * @description 璇ョ粍浠朵竴鑸敤浜庡畬鎴愪竴涓换鍔¤鍒嗗嚑涓楠わ紝鏍囪瘑鐩墠澶勪簬绗嚑姝ョ殑鍦烘櫙銆� + * @tutorial https://www.uviewui.com/components/steps.html + * @property {String} mode 璁剧疆妯″紡锛堥粯璁ot锛� + * @property {Array} list 鏁拌酱鏉℃暟鎹紝鏁扮粍銆傚叿浣撹涓婃柟绀轰緥 + * @property {String} type type涓婚锛堥粯璁rimary锛� + * @property {String} direction row-妯悜锛宑olumn-绔栧悜锛堥粯璁ow锛� + * @property {Number String} current 璁剧疆褰撳墠澶勪簬绗嚑姝� + * @property {String} active-color 宸插畬鎴愭楠ょ殑婵�娲婚鑹诧紝濡傝缃紝type鍊间細澶辨晥 + * @property {String} un-active-color 鏈縺娲荤殑棰滆壊锛岀敤浜庤〃绀烘湭瀹屾垚姝ラ鐨勯鑹诧紙榛樿#606266锛� + * @example <u-steps :list="numList" active-color="#fa3534"></u-steps> + */ +export default { + name: 'u-steps', + props: { + // 姝ラ鏉$殑绫诲瀷锛宒ot|number + mode: { + type: String, + default: 'dot' + }, + // 姝ラ鏉$殑鏁版嵁 + list: { + type: Array, + default() { + return []; + } + }, + // 涓婚绫诲瀷, primary|success|info|warning|error + type: { + type: String, + default: 'primary' + }, + // 褰撳墠鍝竴姝ユ槸婵�娲荤殑 + current: { + type: [Number, String], + default: 0 + }, + // 婵�娲绘楠ょ殑棰滆壊 + activeColor: { + type: String, + default: '#497bff' + }, + // 鏈縺娲荤殑棰滆壊 + unActiveColor: { + type: String, + default: '#909399' + }, + // 鑷畾涔夊浘鏍� + icon: { + type: String, + default: 'checkmark' + }, + // step鐨勬帓鍒楁柟鍚戯紝row-妯悜锛宑olumn-绔栧悜 + direction: { + type: String, + default: 'row' + } + }, + data() { + return {}; + }, +}; +</script> + +<style lang="scss" scoped> +@import '../../libs/css/style.components.scss'; + +$u-steps-item-number-width: 44rpx; +$u-steps-item-dot-width: 20rpx; + +.u-steps { + @include vue-flex; + + .u-steps__item { + flex: 1; + text-align: center; + position: relative; + min-width: 100rpx; + font-size: 26rpx; + color: #8799a3; + @include vue-flex; + justify-content: center; + flex-direction: column; + align-items: center; + + &--row { + @include vue-flex; + flex-direction: column; + + .u-steps__item__line { + position: absolute; + z-index: 0; + left: 75%; + width: 50%; + + &--dot { + top: calc(#{$u-steps-item-dot-width} / 2); + } + + &--number { + top: calc(#{$u-steps-item-number-width} / 2); + } + } + } + + &--column { + @include vue-flex; + flex-direction: row; + justify-content: flex-start; + min-height: 120rpx; + + .u-steps__item__line { + position: absolute; + z-index: 0; + height: 50%; + top: 75%; + + &--dot { + left: calc(#{$u-steps-item-dot-width} / 2); + } + + &--number { + left: calc(#{$u-steps-item-number-width} / 2); + } + } + } + + &__num { + @include vue-flex; + align-items: center; + justify-content: center; + width: $u-steps-item-number-width; + height: $u-steps-item-number-width; + border: 1px solid #8799a3; + border-radius: 50%; + overflow: hidden; + } + + &__dot { + width: $u-steps-item-dot-width; + height: $u-steps-item-dot-width; + @include vue-flex; + border-radius: 50%; + } + + &__text--row { + margin-top: 14rpx; + } + + &__text--column { + margin-left: 14rpx; + } + } +} +</style> -- Gitblit v1.9.3