calendar-item.vue 4.3 KB

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