calendar-item.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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 class="uni-calendar-item__weeks-box-text uni-calendar-item__weeks-box-text-disable uni-calendar-item--checked-text">{{weeks.date}}</text>
  18. </view>
  19. <view :class="{'uni-calendar-item--isDay': weeks.isDay}"></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" >
  63. $uni-primary: #007aff !default;
  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: darken($color: $uni-primary, $amount: 40%);
  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: #D1D1D1;
  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: $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. </style>