uni-calendar-item.vue 5.2 KB

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