uni-calendar-item.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <view class="uni-calendar-item__weeks-box" :class="{
  3. 'uni-calendar-item--disable':weeks.disable,
  4. 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
  5. 'uni-calendar-item--checked':(calendar.fullDate === weeks.fullDate && !weeks.isDay) ,
  6. 'uni-calendar-item--multiple': weeks.multiple
  7. }" @click="choiceDate(weeks)">
  8. <view class="uni-calendar-item__weeks-box-item">
  9. <text v-if="selected&&weeks.extraInfo" class="uni-calendar-item__weeks-box-circle"></text>
  10. <text class="uni-calendar-item__weeks-box-text" :class="{
  11. 'uni-calendar-item--isDay-text': weeks.isDay,
  12. 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
  13. 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
  14. 'uni-calendar-item--multiple': weeks.multiple,
  15. 'uni-calendar-item--disable':weeks.disable,
  16. }">{{weeks.date}}</text>
  17. <text v-if="!lunar&&!weeks.extraInfo && weeks.isDay" class="uni-calendar-item__weeks-lunar-text" :class="{
  18. 'uni-calendar-item--isDay-text':weeks.isDay,
  19. 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
  20. 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
  21. 'uni-calendar-item--multiple': weeks.multiple,
  22. }">今天</text>
  23. <text v-if="lunar&&!weeks.extraInfo" class="uni-calendar-item__weeks-lunar-text" :class="{
  24. 'uni-calendar-item--isDay-text':weeks.isDay,
  25. 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
  26. 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
  27. 'uni-calendar-item--multiple': weeks.multiple,
  28. 'uni-calendar-item--disable':weeks.disable,
  29. }">{{weeks.isDay?'今天': (weeks.lunar.IDayCn === '初一'?weeks.lunar.IMonthCn:weeks.lunar.IDayCn)}}</text>
  30. <text v-if="weeks.extraInfo&&weeks.extraInfo.info" class="uni-calendar-item__weeks-lunar-text" :class="{
  31. 'uni-calendar-item--extra':weeks.extraInfo.info,
  32. 'uni-calendar-item--isDay-text':weeks.isDay,
  33. 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
  34. 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
  35. 'uni-calendar-item--multiple': weeks.multiple,
  36. 'uni-calendar-item--disable':weeks.disable,
  37. }">{{weeks.extraInfo.info}}</text>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. export default {
  43. props: {
  44. weeks: {
  45. type: Object,
  46. default () {
  47. return {}
  48. }
  49. },
  50. calendar: {
  51. type: Object,
  52. default: () => {
  53. return {}
  54. }
  55. },
  56. selected: {
  57. type: Array,
  58. default: () => {
  59. return []
  60. }
  61. },
  62. lunar: {
  63. type: Boolean,
  64. default: false
  65. }
  66. },
  67. methods: {
  68. choiceDate(weeks) {
  69. this.$emit('change', weeks)
  70. }
  71. }
  72. }
  73. </script>
  74. <style scoped>
  75. .uni-calendar-item__weeks-box {
  76. flex: 1;
  77. /* #ifndef APP-NVUE */
  78. display: flex;
  79. /* #endif */
  80. flex-direction: column;
  81. justify-content: center;
  82. align-items: center;
  83. }
  84. .uni-calendar-item__weeks-box-text {
  85. font-size: 14px;
  86. color: #333;
  87. }
  88. .uni-calendar-item__weeks-lunar-text {
  89. font-size: 12px;
  90. color: #333;
  91. }
  92. .uni-calendar-item__weeks-box-item {
  93. position: relative;
  94. /* #ifndef APP-NVUE */
  95. display: flex;
  96. /* #endif */
  97. flex-direction: column;
  98. justify-content: center;
  99. align-items: center;
  100. width: 100rpx;
  101. height: 100rpx;
  102. }
  103. .uni-calendar-item__weeks-box-circle {
  104. position: absolute;
  105. top: 5px;
  106. right: 5px;
  107. width: 8px;
  108. height: 8px;
  109. border-radius: 8px;
  110. background-color: #dd524d;
  111. }
  112. .uni-calendar-item--disable {
  113. background-color: rgba(249, 249, 249, 0.3);
  114. color: #c0c0c0;
  115. }
  116. .uni-calendar-item--isDay-text {
  117. color: #007aff;
  118. }
  119. .uni-calendar-item--isDay {
  120. background-color: #007aff;
  121. opacity: 0.8;
  122. color: #fff;
  123. }
  124. .uni-calendar-item--extra {
  125. color: #dd524d;
  126. opacity: 0.8;
  127. }
  128. .uni-calendar-item--checked {
  129. background-color: #007aff;
  130. color: #fff;
  131. opacity: 0.8;
  132. }
  133. .uni-calendar-item--multiple {
  134. background-color: #007aff;
  135. color: #fff;
  136. opacity: 0.8;
  137. }
  138. </style>