123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <template>
- <!-- 日期显示 -->
- <view class="date_box">
- <view v-for="(dateInfo, dateIndex) in dates" :key="dateIndex" class="calendar_date__box">
- <!-- 选择圆背景 -->
- <view class="calendar_date" :class="{ isSelected: dateInfo.isSelected }" :style="{height: cellHeight + 'rpx',width: cellHeight + 'rpx',color: dateInfo.type === 'cur' ? '#3B4144' : '#aaaaaa' ,backgroundColor: dateInfo.isSelected ? dateActiveColor : ''}" @tap="chooseDate(dateInfo, dateIndex)">
- <!-- 数字 -->
- <view class="calendar_date__number">{{ dateInfo.date }}</view>
- <!-- 今天 -->
- <view class="calendar_date__isToday" v-if="dateInfo.isToday"
- :style="{ backgroundColor: dateActiveColor }"></view>
- <!-- 圆点 -->
- <view class="cirle_attend" v-show="dateInfo.isAttend === 1" ></view>
- <view class="cirle_noattend" v-show="dateInfo.isAttend === 0" ></view>
- <view class="cirle_arrive_weekend" v-show="dateInfo.isAttend === -1 || dateInfo.isAttend === 7" ></view>
-
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- props: {
- dates: {
- type: Array, //日期列表
- default: []
- },
- cellHeight: { // 一列的高度
- type: Number,
- default: 75
- },
- dateActiveColor: { // 日期选中颜色
- type: String,
- default: '#4169E1'
- },
- swiperMode: { // 日历显示模式
- type: String,
- default: 'open'
- }
- },
- methods: {
- //选择时间
- chooseDate(dateInfo, dateIndex) {
- this.$emit('chooseDate', dateInfo, dateIndex)
- },
- },
- }
- </script>
- <style>
- /* 日历轮播 */
- .date_box {
- display: flex;
- flex-wrap: wrap;
- justify-content: space-between;
- }
- .date_box .calendar_date__box {
- width: calc(100% / 7);
- margin-top: 20rpx;
- }
- .calendar_date__box .calendar_date {
- text-align: center;
- margin: 0 auto;
- font-weight: bold;
- font-size: 28rpx;
- border-radius: 50%;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- position: relative;
- }
- .calendar_date__box .calendar_date.isSelected {
- color: #FFFFFF !important;
- }
- .calendar_date .calendar_date__isToday {
- width: 100%;
- height: 100%;
- position: absolute;
- top: 0;
- left: 0;
- border-radius: 50%;
- z-index: -1;
- opacity: 0.3;
- }
- /* 圆点 */
- .calendar_date .cirle_attend {
- width: 9rpx;
- height: 9rpx;
- border-radius: 50%;
- margin-top: 5rpx;
- background-color: #4169E1;
- }
- .calendar_date .cirle_noattend {
- width: 9rpx;
- height: 9rpx;
- border-radius: 50%;
- margin-top: 5rpx;
- background-color: #ff5959;
- }
- .calendar_date .cirle_arrive_weekend {
- width: 9rpx;
- height: 9rpx;
- border-radius: 50%;
- margin-top: 5rpx;
- background-color: #FFFFFF;
- }
- /* 日历轮播 */
- </style>
|