uni-calendar-item.vue 4.2 KB

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