calendar-item.vue 4.6 KB

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