calendar-item.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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--checked':calendar.fullDate === weeks.fullDate && (calendar.userChecked || !checkHover),
  10. 'uni-calendar-item--checked-range-text': checkHover,
  11. 'uni-calendar-item--before-checked':weeks.beforeMultiple,
  12. 'uni-calendar-item--multiple': weeks.multiple,
  13. 'uni-calendar-item--after-checked':weeks.afterMultiple,
  14. 'uni-calendar-item--disable':weeks.disable,
  15. }">
  16. <text v-if="selected&&weeks.extraInfo" class="uni-calendar-item__weeks-box-circle"></text>
  17. <text
  18. class="uni-calendar-item__weeks-box-text uni-calendar-item__weeks-box-text-disable uni-calendar-item--checked-text">{{weeks.date}}</text>
  19. </view>
  20. <view :class="{'uni-calendar-item--isDay': weeks.isDay}"></view>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. props: {
  26. weeks: {
  27. type: Object,
  28. default () {
  29. return {}
  30. }
  31. },
  32. calendar: {
  33. type: Object,
  34. default: () => {
  35. return {}
  36. }
  37. },
  38. selected: {
  39. type: Array,
  40. default: () => {
  41. return []
  42. }
  43. },
  44. lunar: {
  45. type: Boolean,
  46. default: false
  47. },
  48. checkHover: {
  49. type: Boolean,
  50. default: false
  51. }
  52. },
  53. methods: {
  54. choiceDate(weeks) {
  55. this.$emit('change', weeks)
  56. },
  57. handleMousemove(weeks) {
  58. this.$emit('handleMouse', weeks)
  59. }
  60. }
  61. }
  62. </script>
  63. <style lang="scss">
  64. .uni-calendar-item__weeks-box {
  65. flex: 1;
  66. /* #ifndef APP-NVUE */
  67. display: flex;
  68. /* #endif */
  69. flex-direction: column;
  70. justify-content: center;
  71. align-items: center;
  72. margin: 1px 0;
  73. position: relative;
  74. }
  75. .uni-calendar-item__weeks-box-text {
  76. font-size: 14px;
  77. // font-family: Lato-Bold, Lato;
  78. font-weight: bold;
  79. color: #0A1F44;
  80. }
  81. .uni-calendar-item__weeks-lunar-text {
  82. font-size: 12px;
  83. color: #333;
  84. }
  85. .uni-calendar-item__weeks-box-item {
  86. position: relative;
  87. /* #ifndef APP-NVUE */
  88. display: flex;
  89. /* #endif */
  90. flex-direction: column;
  91. justify-content: center;
  92. align-items: center;
  93. width: 40px;
  94. height: 40px;
  95. /* #ifdef H5 */
  96. cursor: pointer;
  97. /* #endif */
  98. }
  99. .uni-calendar-item__weeks-box-circle {
  100. position: absolute;
  101. top: 5px;
  102. right: 5px;
  103. width: 8px;
  104. height: 8px;
  105. border-radius: 8px;
  106. background-color: #dd524d;
  107. }
  108. .uni-calendar-item__weeks-box .uni-calendar-item--disable {
  109. // background-color: rgba(249, 249, 249, $uni-opacity-disabled);
  110. cursor: default;
  111. }
  112. .uni-calendar-item--disable .uni-calendar-item__weeks-box-text-disable {
  113. color: #8A94A6;
  114. }
  115. .uni-calendar-item--isDay {
  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: #0FB160;
  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: #F7F9FE;
  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: #0FB160;
  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. </style>