mrr.sj.front/components/step-tab/step-tab.vue

293 lines
6.9 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="step-tab">
<view class="step-container">
<!-- 步骤1: 入驻协议 -->
<view class="step-item" :class="getStepClass(0)">
<view class="step-icon">
<image
v-if="currentStep === 0"
src="https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/55a51333-318f-4ae4-8402-aca265bd499d"
class="step-img active-circle"
mode="aspectFit"
/>
<view v-else-if="currentStep > 0" class="step-done">1</view>
<view v-else class="step-number">1</view>
</view>
<text class="step-text" :class="{ active: currentStep === 0 }">入驻协议</text>
</view>
<!-- 第一个连接线 -->
<view class="line-segment line-1">
<view class="line-progress" :class="{ active: line1Active, deactivating: line1Deactivating }"></view>
</view>
<!-- 步骤2: 根据身份显示不同信息 -->
<view class="step-item" :class="getStepClass(1)">
<view class="step-icon">
<image
v-if="currentStep === 1"
src="https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/55a51333-318f-4ae4-8402-aca265bd499d"
class="step-img active-circle"
mode="aspectFit"
/>
<view v-else-if="currentStep > 1" class="step-done">2</view>
<view v-else class="step-number">2</view>
</view>
<text class="step-text" :class="{ active: currentStep === 1 }">
{{ identity === 1 ? '个人信息' : '资质信息' }}
</text>
</view>
<!-- 第二个连接线 -->
<view class="line-segment line-2">
<view class="line-progress" :class="{ active: line2Active, deactivating: line2Deactivating }"></view>
</view>
<!-- 步骤3: 根据身份显示不同信息 -->
<view class="step-item" :class="getStepClass(2)">
<view class="step-icon">
<image
v-if="currentStep === 2"
src="https://mrrplus.oss-cn-beijing.aliyuncs.com/photo/system/55a51333-318f-4ae4-8402-aca265bd499d"
class="step-img active-circle"
mode="aspectFit"
/>
<view v-else-if="currentStep > 2" class="step-done">3</view>
<view v-else class="step-number">3</view>
</view>
<text class="step-text" :class="{ active: currentStep === 2 }">
{{ identity === 1 ? '资质信息' : '门店信息' }}
</text>
</view>
</view>
</view>
</template>
<script>
export default {
name: "StepTab",
props: {
// 当前步骤索引 (0, 1, 2)
currentStep: {
type: Number,
default: 0
},
// 身份类型1-手艺人2-商家
identity: {
type: Number,
default: 2
}
},
data() {
return {
prevStep: 0, // 记录上一步骤
line1Active: false, // 第一条线激活状态
line2Active: false, // 第二条线激活状态
line1Deactivating: false, // 第一条线正在取消激活
line2Deactivating: false // 第二条线正在取消激活
};
},
watch: {
// 监听currentStep变化处理线条动画
currentStep(newVal, oldVal) {
this.prevStep = oldVal;
// 处理前进动画
if (newVal > oldVal) {
if (newVal >= 1) {
this.line1Active = true;
this.line1Deactivating = false;
}
if (newVal >= 2) {
this.line2Active = true;
this.line2Deactivating = false;
}
}
// 处理返回动画
else if (newVal < oldVal) {
if (newVal < 2) {
this.line2Deactivating = true;
setTimeout(() => {
this.line2Active = false;
this.line2Deactivating = false;
}, 300); // 与动画持续时间匹配
}
if (newVal < 1) {
this.line1Deactivating = true;
setTimeout(() => {
this.line1Active = false;
this.line1Deactivating = false;
}, 300); // 与动画持续时间匹配
}
}
}
},
mounted() {
// 初始化线条状态
this.line1Active = this.currentStep >= 1;
this.line2Active = this.currentStep >= 2;
},
methods: {
// 获取步骤的CSS类名
getStepClass(stepIndex) {
if (stepIndex === this.currentStep) {
return 'active';
}
else if (stepIndex < this.currentStep) {
return 'completed';
}
return '';
}
}
}
</script>
<style scoped>
.step-tab {
height: 98rpx;
position: relative;
padding: 31rpx 0;
background-color: #fff;
}
.step-container {
display: flex;
justify-content: space-between;
align-items: center;
padding: 5rpx 60rpx;
position: relative;
z-index: 2;
}
.step-item {
display: flex;
flex-direction: column;
align-items: center;
position: relative;
z-index: 2;
transition: all 0.3s ease;
flex: 1;
}
.step-icon {
width: 50rpx;
height: 50rpx;
display: flex;
justify-content: center;
align-items: center;
margin-bottom: 14rpx;
}
.step-img.active-circle {
width: 50rpx;
height: 50rpx;
}
.step-number {
width: 50rpx;
height: 50rpx;
border-radius: 50%;
background-color: #F4F6FA;
display: flex;
justify-content: center;
align-items: center;
font-size: 28rpx;
color: #999999;
font-weight: 500;
transition: all 0.3s ease;
}
.step-done {
width: 50rpx;
height: 50rpx;
border-radius: 50%;
background-color: #FAD0D3;
display: flex;
justify-content: center;
align-items: center;
font-size: 28rpx;
color: #E8101E;
font-weight: 500;
transition: all 0.3s ease;
box-shadow: inset 0 0 4rpx rgba(232, 16, 30, 0.2);
}
.step-text {
font-size: 24rpx;
color: #999;
font-weight: 400;
transition: all 0.3s ease;
}
.step-text.active {
color: #333333;
font-weight: 500;
}
.step-item.completed .step-text {
color: #333333;
font-weight: 500;
}
.line-segment {
position: relative;
height: 8rpx;
background-color: #F4F6FA;
border-radius: 4rpx;
top: -25rpx;
overflow: hidden;
width: 126rpx;
transition: all 0.3s ease;
}
.line-1 {
margin-left: 20rpx;
margin-right: 20rpx;
}
.line-2 {
margin-left: 20rpx;
margin-right: 20rpx;
}
.line-progress {
height: 100%;
width: 0%;
background-color: #F4F6FA;
border-radius: 4rpx;
transition: width 0.3s ease;
transform-origin: left center;
}
/* 激活状态的线条 - 前进动画 */
.line-progress.active {
width: 100%;
background-color: #E8101E;
transition: width 0.3s ease;
}
/* 取消激活状态的线条 - 返回动画 */
.line-progress.deactivating {
width: 0%;
background-color: #E8101E;
transition: width 0.3s ease;
transform-origin: right center;
}
/* 响应式调整 */
@media (max-width: 750rpx) {
.step-container {
/* padding: 5rpx 40rpx; */
}
.line-segment {
/* width: 100rpx; */
}
/* .line-1,
.line-2 {
margin-left: 15rpx;
margin-right: 15rpx;
} */
}
</style>