calendar-item.vue 4.0 KB

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