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