calendar-item.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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-calendar-item__weeks-box {
  64. flex: 1;
  65. /* #ifndef APP-NVUE */
  66. display: flex;
  67. /* #endif */
  68. flex-direction: column;
  69. justify-content: center;
  70. align-items: center;
  71. margin: 1px 0;
  72. position: relative;
  73. }
  74. .uni-calendar-item__weeks-box-text {
  75. font-size: 14px;
  76. // font-family: Lato-Bold, Lato;
  77. font-weight: bold;
  78. color: #455997;
  79. }
  80. .uni-calendar-item__weeks-lunar-text {
  81. font-size: 12px;
  82. color: #333;
  83. }
  84. .uni-calendar-item__weeks-box-item {
  85. position: relative;
  86. /* #ifndef APP-NVUE */
  87. display: flex;
  88. /* #endif */
  89. flex-direction: column;
  90. justify-content: center;
  91. align-items: center;
  92. width: 40px;
  93. height: 40px;
  94. /* #ifdef H5 */
  95. cursor: pointer;
  96. /* #endif */
  97. }
  98. .uni-calendar-item__weeks-box-circle {
  99. position: absolute;
  100. top: 5px;
  101. right: 5px;
  102. width: 8px;
  103. height: 8px;
  104. border-radius: 8px;
  105. background-color: #dd524d;
  106. }
  107. .uni-calendar-item__weeks-box .uni-calendar-item--disable {
  108. // background-color: rgba(249, 249, 249, $uni-opacity-disabled);
  109. cursor: default;
  110. }
  111. .uni-calendar-item--disable .uni-calendar-item__weeks-box-text-disable {
  112. color: #D1D1D1;
  113. }
  114. .uni-calendar-item--isDay {
  115. position: absolute;
  116. top: 10px;
  117. right: 17%;
  118. background-color: #dd524d;
  119. width:6px;
  120. height: 6px;
  121. border-radius: 50%;
  122. }
  123. .uni-calendar-item--extra {
  124. color: #dd524d;
  125. opacity: 0.8;
  126. }
  127. .uni-calendar-item__weeks-box .uni-calendar-item--checked {
  128. background-color: #007aff;
  129. border-radius: 50%;
  130. box-sizing: border-box;
  131. border: 3px solid #fff;
  132. }
  133. .uni-calendar-item--checked .uni-calendar-item--checked-text {
  134. color: #fff;
  135. }
  136. .uni-calendar-item--multiple .uni-calendar-item--checked-range-text {
  137. color: #333;
  138. }
  139. .uni-calendar-item--multiple {
  140. background-color: #F6F7FC;
  141. // color: #fff;
  142. }
  143. .uni-calendar-item--multiple .uni-calendar-item--before-checked,
  144. .uni-calendar-item--multiple .uni-calendar-item--after-checked {
  145. background-color: #409eff;
  146. border-radius: 50%;
  147. box-sizing: border-box;
  148. border: 3px solid #F6F7FC;
  149. }
  150. .uni-calendar-item--before-checked .uni-calendar-item--checked-text,
  151. .uni-calendar-item--after-checked .uni-calendar-item--checked-text {
  152. color: #fff;
  153. }
  154. .uni-calendar-item--before-checked-x {
  155. border-top-left-radius: 50px;
  156. border-bottom-left-radius: 50px;
  157. box-sizing: border-box;
  158. background-color: #F6F7FC;
  159. }
  160. .uni-calendar-item--after-checked-x {
  161. border-top-right-radius: 50px;
  162. border-bottom-right-radius: 50px;
  163. background-color: #F6F7FC;
  164. }
  165. </style>