自定义uniapp小程序步骤条

  html:

<view class="step">
	<view class="stepBox">
		<view class="stepLine"></view>
		<view class="stepItem">
			<view v-if="stepStatus < 1" class="stopUnover">1</view>
			<image v-if="stepStatus == 1" class="stopActive" :src="host_url + 'static/stopActive.png'" mode="aspectFill"></image>
			<image v-else class="stopOver" :src="host_url + 'static/stopOver.png'" mode="aspectFill"></image>
			<view class="text">第一步</view>
		</view>
		<view class="stepItem">
			<view v-if="stepStatus < 2" class="stopUnover">2</view>
			<image v-else-if="stepStatus == 2" class="stopActive" :src="host_url + 'static/stopActive.png'" mode="aspectFill"></image>
			<image v-else class="stopOver" :src="host_url + 'static/stopOver.png'" mode="aspectFill"></image>
			<view class="text">第二步</view>
		</view>
		<view class="stepItem">
			<view v-if="stepStatus < 3" class="stopUnover">3</view>
			<image v-else-if="stepStatus == 3" class="stopActive" :src="host_url + 'static/stopActive.png'" mode="aspectFill"></image>
			<image v-else class="stopOver" :src="host_url + 'static/stopOver.png'" mode="aspectFill"></image>
			<view class="text">第三步</view>
		</view>
	</view>
</view>

<view class="send_bottom bgSubMainColor">
	<view class="send_btn stopMinus" v-if="stepStatus != 1" @click="stopMinus">上一步</view>
	<view class="send_btn" v-if="stepStatus != 3" @click="increase">下一步</view>
</view>

js变量:

data () {
    return {
        // 步骤条状态
		stepStatus: 1
    }
},

js方法:

/**
 * 上一步
 */
stopMinus() {
	this.stepStatus -= 1;
},
/**
 * 下一步
 */
increase() {
	this.stepStatus -= 1;
}

css:

.step {
	height: 176rpx;
	box-sizing: border-box;
	padding: 32rpx 112rpx 40rpx 112rpx;
	background: #FFFFFF;
	
	.stepBox {
		width: 100%;
		height: 100rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
		position: relative;
		
		.stepLine {
			width: 418rpx;
			height: 8rpx;
			background-color: rgba(150, 190, 15, 0.3);
			position: absolute;
			top: 18rpx;
			left: 50rpx;
		}
		
		.stepItem {
			width: 112rpx;
			height: 100rpx;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;
			z-index: 2;
			
			image {
				margin-bottom: 20rpx;
			}
			
			.stopActive {
				width: 50rpx;
				height: 50rpx;
			}
			
			.stopOver, .stopUnover {
				width: 40rpx;
				height: 40rpx;
			}
			
			.stopUnover .text {
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 28rpx;
			}
			.stopUnover {
				margin-bottom: 20rpx;
				background: #EAE8E8;
				color: #FFFFFF;
				display: flex;
				justify-content: center;
				align-items: center;
				border-radius: 50%;
			}
			
			.text {
				color: #333333;
			}
		}
	}
}

.send_bottom {
	box-sizing: border-box;
	padding: 28rpx;
	
	.stopMinus {
		background-color: #fff;
		border: 2rpx solid var(--view-theme);
		color: var(--view-theme);
	}
	
	.send_btn:nth-of-type(2) {
		margin-left: 24rpx;
	}
}

效果图:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值