Files
xdd-uniapp-new/components/SubSection.vue
T

81 lines
1.6 KiB
Vue

<script>
export default {
name: "SubSection",
props: {
current: { // 当前选中
type: Number,
default: 0
},
canUse: { // 可用
type: [String, Number],
default: 0
},
notUse: { // 不可用
type: [String, Number],
default: 0
},
radioModel: {
type: Boolean,
default: false
},
},
data() {
return {
index: 0
}
},
mounted() {
this.index = this.current
},
methods: {
change(index) {
this.index = index
this.$emit('change', index)
}
}
}
</script>
<template>
<view class="sub-section flex">
<view class="sub-section__item flex jc-center ai-center"
@click="change(0)">
可使用 ({{ canUse }})
</view>
<view class="sub-section__item flex jc-center ai-center"
@click="change(1)">
{{radioModel?'不可用':'已到期'}} ({{ notUse }})
</view>
<view class="sub-section__active" :style="{left: (80 + index * 360) + 'rpx'}"></view>
</view>
</template>
<style scoped lang="less">
.sub-section {
width: 686rpx;
height: 80rpx;
box-sizing: border-box;
border-radius: 20rpx;
font-size: 32rpx;
overflow: hidden;
position: relative;
.sub-section__item {
width: 50%;
background: #FFFFFF;
color: #333333;
font-weight: bold;
position: relative;
}
.sub-section__active {
position: absolute;
width: 140rpx;
height: 8rpx;
background: linear-gradient(to right, #C52733 0%, rgba(211,92,101,0.91) 54%, rgba(255,255,255,0.62) 100%);
border-radius: 0rpx 0rpx 26rpx 26rpx;
bottom: (80 - 34) / 2 * 1rpx;
transition: left ease-in-out 0.3s;
}
}
</style>