uni-app季度选择控件

代码中涉及到图片需要自己加哦,效果如图:在这里插入图片描述
在这里插入图片描述

<template>
    <view class="content">
        <view class="input_year">
            <button @click="quarterTime" style="display: none">季度</button>
            <span @click="showDoubleMonth">
                <input class="select_year" v-model="choseQuarter" placeholder="请选择季度"/>
            </span>
            <view v-show="showTime1a">
                <p>
                    <image src="~@/static/img/year/left.png"  @click="prev" class="left"></image>
                    <span class="span-year">{{ year }}</span>
                    <image src="~@/static/img/year/right.png" @click="next" class="right"></image>
                </p>
                <view>
                    <p v-for="(item,index) in fullMonth" :key="index" class="selectMonth" @click="selectQuarter(item)">{{ item }}</p>
                </view>
            </view>
        </view>
    </view>
</template>
<script>
    export default {
        //data配置变量
        data(){
            return {
                showTime2: false,
                showTime1a: false,
                year: new Date().getFullYear(),
                fullMonth: ['第一季度', '第二季度', '第三季度', '第四季度'],
            }
        },
        methods:{
            // 点击季度按钮
            quarterTime () {
                this.showTime2 = true
                this.choseQuarter = ''
                this.fullMonth = ['第一季度', '第二季度', '第三季度', '第四季度']
            },
            // 点击半年按钮
            halfYear () {
                this.showTime2 = true
                this.choseQuarter = ''
                this.fullMonth = ['上半年', '下半年']
            },
            // 点击input框
            showDoubleMonth () {
                this.showTime1a = true
            },
            // 上一年
            prev () {
                this.year = this.year * 1 - 1
            },
            // 下一年
            next () {
                this.year = this.year * 1 + 1
            },
            // 点击选项事件
            selectQuarter (item) {
                switch (item) {
                    case '第一季度':
                        this.choseQuarter = this.year + '年' + '第' + '1' + '季度'
                        break
                    case '第二季度':
                        this.choseQuarter = this.year + '年' + '第' + '2' + '季度'
                        break
                    case '第三季度':
                        this.choseQuarter = this.year + '年' + '第' + '3' + '季度'
                        break
                    case '第四季度':
                        this.choseQuarter = this.year + '年' + '第' + '4' + '季度'
                        break
                    case '上半年':
                        this.choseQuarter = this.year + '年' + '第' + '1'
                        break
                    case '下半年':
                        this.choseQuarter = this.year + '年' + '第' + 'H'
                        break
                }
                this.showTime1a = false
            }
        }
    }
</script>

<style scoped lang="scss">
    .select_type{
        height: 40rpx;
        margin-left: 20rpx;
    }
    .select_year{
        border: 1rpx solid lightgray;
        width: 210rpx;
        margin-top: 13rpx;
    }
    .selectMonth{
        margin-left: 15rpx;
        font-size:32rpx ;
    }
    .span-year{
        font-size: 32rpx;
        line-height: 0.2rem;
    }
    .left{
        width: 30rpx;
        height: 30rpx;
    }
    .right{
        width: 30rpx;
        height: 30rpx;
    }
    .input_year{
        margin-left: 50rpx;
        float: left;
    }
</style>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值