| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <template>
- <view class="box adfac">
- <div class="box-btn l" @click="valueChange(1)">-</div>
- <div class="box-input">
- <u-input :min="min" v-model="value" @change="e=>valueChange(3,e)" @blur="valueBlur" border="none" fontSize="30rpx" color="#002846"></u-input>
- </div>
- <div class="box-btn r" @click="valueChange(2)">+</div>
- </view>
- </template>
- <script>
- export default {
- props:{
- min:{
- typeof:Number,
- default:0
- },
- number:{
- typeof:Number,
- default:0
- }
- },
- data(){
- return {
- value:0
- }
- },
- mounted() {
- this.value = this.number;
- },
- methods:{
- valueChange(type,e){
- if(type===1){
- if(this.value<=this.min) return this.$showToast(`当前限制最小值为${this.min}`)
- this.value--;
- }
- else if(type===2) this.value++;
- else if(type===3) this.value = e;
- this.$emit('valChange',this.value)
- },
- valueBlur(e){
- if(e<=this.min){
- this.value = this.min;
- return this.$showToast(`当前限制最小值为${this.min}`)
- }
- this.value = e;
- this.$emit('valChange',this.value)
- }
- }
- }
- </script>
- <style scoped lang="scss">
-
- .box{
- background: #FFFFFF;
- height: 64rpx;
- border-radius: 10rpx;
- border: 2rpx solid #E5E7EB;
- &-btn{
- width: 54rpx;
- height: 64rpx;
- background: #F5F8FA;
- font-family: PingFangSC, PingFang SC;
- font-weight: 400;
- font-size: 30rpx;
- color: #002846;
- line-height: 64rpx;
- text-align: center;
- &.l{
- border-radius: 10rpx 0rpx 0rpx 10rpx;
- }
- &.r{
- border-radius: 0rpx 10rpx 10rpx 0rpx;
- }
- }
- &-input{
- width: 70rpx;
- padding: 0 20rpx;
- }
- }
- </style>
|