dateBox.vue 2.5 KB

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