dateBox.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <!-- 日期显示 -->
  3. <view class="date_box">
  4. <view v-for="(dateInfo, dateIndex) in dates" :key="dateIndex" class="calendar_date__box">
  5. <!-- <view class="attendance_box" :style="{backgroundColor: dateAttendanceColor}"> -->
  6. <view class="calendar_date" :class="{ isSelected: dateInfo.isSelected }" :style="{
  7. height: cellHeight + 'rpx',
  8. width: cellHeight + 'rpx',
  9. color: swiperMode === 'open' ? dateInfo.type === 'cur' ? '#2C2C2C' : '#959595' : '#2C2C2C',
  10. backgroundColor: dateInfo.isSelected ? dateActiveColor : ''
  11. }" @tap="chooseDate(dateInfo, dateIndex)">
  12. <view class="calendar_date__number">{{ dateInfo.date }}</view>
  13. <view class="calendar_date__isToday" v-if="dateInfo.isToday"
  14. :style="{ backgroundColor: dateActiveColor }"></view>
  15. <view class="calendar_date__cricle"></view>
  16. </view>
  17. <!-- </view> -->
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. props: {
  24. dates: {
  25. type: Array,
  26. default: []
  27. },
  28. cellHeight: { // 一列的高度
  29. type: Number,
  30. default: 75
  31. },
  32. dateAttendanceColor: {
  33. type: String,
  34. default: '#89d0ff'
  35. },
  36. dateActiveColor: { // 日期选中颜色
  37. type: String,
  38. default: '#3C9CFF'
  39. },
  40. swiperMode: { // 日历显示模式
  41. type: String,
  42. default: 'open'
  43. }
  44. },
  45. methods: {
  46. chooseDate(dateInfo, dateIndex) {
  47. this.$emit('chooseDate', dateInfo, dateIndex)
  48. }
  49. }
  50. }
  51. </script>
  52. <style>
  53. /* 日历轮播 */
  54. .date_box {
  55. display: flex;
  56. flex-wrap: wrap;
  57. justify-content: space-between;
  58. }
  59. .date_box .calendar_date__box {
  60. width: calc(100% / 7);
  61. margin-top: 20rpx;
  62. }
  63. .date_box .attendance_box{
  64. border-radius: 50%;
  65. }
  66. .calendar_date__box .calendar_date {
  67. text-align: center;
  68. margin: 0 auto;
  69. font-weight: bold;
  70. font-size: 28rpx;
  71. border-radius: 50%;
  72. display: flex;
  73. flex-direction: column;
  74. align-items: center;
  75. justify-content: center;
  76. position: relative;
  77. }
  78. .calendar_date__box .calendar_date.isSelected {
  79. color: #FFFFFF !important;
  80. }
  81. .calendar_date .calendar_date__isToday {
  82. width: 100%;
  83. height: 100%;
  84. position: absolute;
  85. top: 0;
  86. left: 0;
  87. border-radius: 50%;
  88. z-index: -1;
  89. opacity: 0.4;
  90. }
  91. .calendar_date .calendar_date__cricle {
  92. width: 9rpx;
  93. height: 9rpx;
  94. border-radius: 50%;
  95. margin-top: 5rpx;
  96. background-color: #FFFFFF;
  97. }
  98. /* 日历轮播 */
  99. </style>