dateBox.vue 2.8 KB

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