dateBox.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. import {
  22. mapState,
  23. } from 'vuex'
  24. export default {
  25. computed: {
  26. ...mapState('m_children', ['records']),
  27. },
  28. props: {
  29. dates: {
  30. type: Array, //日期列表
  31. default: []
  32. },
  33. cellHeight: { // 一列的高度
  34. type: Number,
  35. default: 75
  36. },
  37. dateActiveColor: { // 日期选中颜色
  38. type: String,
  39. default: '#4169E1'
  40. },
  41. swiperMode: { // 日历显示模式
  42. type: String,
  43. default: 'open'
  44. }
  45. },
  46. methods: {
  47. //选择时间
  48. chooseDate(dateInfo, dateIndex) {
  49. this.$emit('chooseDate', dateInfo, dateIndex)
  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.3;
  89. }
  90. /* 圆点 */
  91. .calendar_date .cirle_attend {
  92. width: 9rpx;
  93. height: 9rpx;
  94. border-radius: 50%;
  95. margin-top: 5rpx;
  96. background-color: #4169E1;
  97. }
  98. .calendar_date .cirle_noattend {
  99. width: 9rpx;
  100. height: 9rpx;
  101. border-radius: 50%;
  102. margin-top: 5rpx;
  103. background-color: #ff5959;
  104. }
  105. .calendar_date .cirle_arrive_weekend {
  106. width: 9rpx;
  107. height: 9rpx;
  108. border-radius: 50%;
  109. margin-top: 5rpx;
  110. background-color: #FFFFFF;
  111. }
  112. /* 日历轮播 */
  113. </style>