calendar-item.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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--today': weeks.isToday}"></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. checkHover: {
  44. type: Boolean,
  45. default: false
  46. }
  47. },
  48. methods: {
  49. choiceDate(weeks) {
  50. this.$emit('change', weeks)
  51. },
  52. handleMousemove(weeks) {
  53. this.$emit('handleMouse', weeks)
  54. }
  55. }
  56. }
  57. </script>
  58. <style lang="scss" >
  59. $uni-primary: #007aff !default;
  60. .uni-calendar-item__weeks-box {
  61. flex: 1;
  62. /* #ifndef APP-NVUE */
  63. display: flex;
  64. /* #endif */
  65. flex-direction: column;
  66. justify-content: center;
  67. align-items: center;
  68. margin: 1px 0;
  69. position: relative;
  70. }
  71. .uni-calendar-item__weeks-box-text {
  72. font-size: 14px;
  73. // font-family: Lato-Bold, Lato;
  74. font-weight: bold;
  75. color: darken($color: $uni-primary, $amount: 40%);
  76. }
  77. .uni-calendar-item__weeks-box-item {
  78. position: relative;
  79. /* #ifndef APP-NVUE */
  80. display: flex;
  81. /* #endif */
  82. flex-direction: column;
  83. justify-content: center;
  84. align-items: center;
  85. width: 40px;
  86. height: 40px;
  87. /* #ifdef H5 */
  88. cursor: pointer;
  89. /* #endif */
  90. }
  91. .uni-calendar-item__weeks-box-circle {
  92. position: absolute;
  93. top: 5px;
  94. right: 5px;
  95. width: 8px;
  96. height: 8px;
  97. border-radius: 8px;
  98. background-color: #dd524d;
  99. }
  100. .uni-calendar-item__weeks-box .uni-calendar-item--disable {
  101. cursor: default;
  102. }
  103. .uni-calendar-item--disable .uni-calendar-item__weeks-box-text-disable {
  104. color: #D1D1D1;
  105. }
  106. .uni-calendar-item--today {
  107. position: absolute;
  108. top: 10px;
  109. right: 17%;
  110. background-color: #dd524d;
  111. width:6px;
  112. height: 6px;
  113. border-radius: 50%;
  114. }
  115. .uni-calendar-item--extra {
  116. color: #dd524d;
  117. opacity: 0.8;
  118. }
  119. .uni-calendar-item__weeks-box .uni-calendar-item--checked {
  120. background-color: $uni-primary;
  121. border-radius: 50%;
  122. box-sizing: border-box;
  123. border: 3px solid #fff;
  124. }
  125. .uni-calendar-item--checked .uni-calendar-item--checked-text {
  126. color: #fff;
  127. }
  128. .uni-calendar-item--multiple .uni-calendar-item--checked-range-text {
  129. color: #333;
  130. }
  131. .uni-calendar-item--multiple {
  132. background-color: #F6F7FC;
  133. // color: #fff;
  134. }
  135. .uni-calendar-item--multiple .uni-calendar-item--before-checked,
  136. .uni-calendar-item--multiple .uni-calendar-item--after-checked {
  137. background-color: $uni-primary;
  138. border-radius: 50%;
  139. box-sizing: border-box;
  140. border: 3px solid #F6F7FC;
  141. }
  142. .uni-calendar-item--before-checked .uni-calendar-item--checked-text,
  143. .uni-calendar-item--after-checked .uni-calendar-item--checked-text {
  144. color: #fff;
  145. }
  146. .uni-calendar-item--before-checked-x {
  147. border-top-left-radius: 50px;
  148. border-bottom-left-radius: 50px;
  149. box-sizing: border-box;
  150. background-color: #F6F7FC;
  151. }
  152. .uni-calendar-item--after-checked-x {
  153. border-top-right-radius: 50px;
  154. border-bottom-right-radius: 50px;
  155. background-color: #F6F7FC;
  156. }
  157. </style>