uni-calendar-item.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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--isDay-text': weeks.isDay,
  10. 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
  11. 'uni-calendar-item--checked-range-text': checkHover,
  12. 'uni-calendar-item--before-checked':weeks.beforeMultiple,
  13. 'uni-calendar-item--multiple': weeks.multiple,
  14. 'uni-calendar-item--after-checked':weeks.afterMultiple,
  15. 'uni-calendar-item--disable':weeks.disable,
  16. }">
  17. <text v-if="selected&&weeks.extraInfo" class="uni-calendar-item__weeks-box-circle"></text>
  18. <text class="uni-calendar-item__weeks-box-text">{{weeks.date}}</text>
  19. <!-- <text v-if="!lunar&&!weeks.extraInfo && weeks.isDay" class="uni-calendar-item__weeks-lunar-text">今天</text>
  20. <text v-if="lunar&&!weeks.extraInfo" class="uni-calendar-item__weeks-lunar-text" >{{weeks.isDay?'今天': (weeks.lunar.IDayCn === '初一'?weeks.lunar.IMonthCn:weeks.lunar.IDayCn)}}</text> -->
  21. <!-- <text v-if="weeks.extraInfo&&weeks.extraInfo.info" class="uni-calendar-item__weeks-lunar-text">{{weeks.extraInfo.info}}</text> -->
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. props: {
  28. weeks: {
  29. type: Object,
  30. default () {
  31. return {}
  32. }
  33. },
  34. calendar: {
  35. type: Object,
  36. default: () => {
  37. return {}
  38. }
  39. },
  40. selected: {
  41. type: Array,
  42. default: () => {
  43. return []
  44. }
  45. },
  46. lunar: {
  47. type: Boolean,
  48. default: false
  49. },
  50. checkHover: {
  51. type: Boolean,
  52. default: false
  53. }
  54. },
  55. methods: {
  56. choiceDate(weeks) {
  57. this.$emit('change', weeks)
  58. },
  59. handleMousemove(weeks) {
  60. this.$emit('handleMouse', weeks)
  61. }
  62. }
  63. }
  64. </script>
  65. <style lang="scss" scoped>
  66. .uni-calendar-item__weeks-box {
  67. flex: 1;
  68. /* #ifndef APP-NVUE */
  69. display: flex;
  70. /* #endif */
  71. flex-direction: column;
  72. justify-content: center;
  73. align-items: center;
  74. margin: 3px 0;
  75. }
  76. .uni-calendar-item__weeks-box-text {
  77. font-size: $uni-font-size-base;
  78. // color: $uni-text-color;
  79. }
  80. .uni-calendar-item__weeks-lunar-text {
  81. font-size: $uni-font-size-sm;
  82. color: $uni-text-color;
  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: 100rpx;
  93. height: 100rpx;
  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: $uni-color-error;
  106. }
  107. .uni-calendar-item__weeks-box .uni-calendar-item--disable {
  108. // background-color: rgba(249, 249, 249, $uni-opacity-disabled);
  109. color: $uni-text-color-disable;
  110. cursor: default;
  111. }
  112. .uni-calendar-item--isDay-text {
  113. color: $uni-color-primary !important;
  114. }
  115. .uni-calendar-item--isDay {
  116. background-color: $uni-color-primary;
  117. opacity: 0.8;
  118. color: #fff;
  119. }
  120. .uni-calendar-item--extra {
  121. color: $uni-color-error;
  122. opacity: 0.8;
  123. }
  124. .uni-calendar-item--checked {
  125. background-color: $uni-color-primary;
  126. // border-radius: 50%;
  127. box-sizing: border-box;
  128. border: 6px solid #f2f6fc;
  129. color: #fff;
  130. opacity: 0.8;
  131. }
  132. .uni-calendar-item--multiple .uni-calendar-item--checked-range-text {
  133. color: #333;
  134. }
  135. .uni-calendar-item--multiple {
  136. background-color: #f2f6fc;
  137. // color: #fff;
  138. opacity: 0.8;
  139. }
  140. .uni-calendar-item--multiple .uni-calendar-item--before-checked {
  141. background-color: #409eff;
  142. color: #fff;
  143. // border-radius: 50%;
  144. box-sizing: border-box;
  145. border: 6px solid #f2f6fc;
  146. }
  147. .uni-calendar-item--multiple .uni-calendar-item--after-checked {
  148. background-color: #409eff;;
  149. color: #fff;
  150. // border-radius: 50%;
  151. box-sizing: border-box;
  152. border: 6px solid #f2f6fc;
  153. }
  154. .uni-calendar-item--before-checked-x {
  155. // border-top-left-radius: 25px;
  156. // border-bottom-left-radius: 25px;
  157. background-color: #f2f6fc;
  158. }
  159. .uni-calendar-item--after-checked-x {
  160. // border-top-right-radius: 25px;
  161. // border-bottom-right-radius: 25px;
  162. background-color: #f2f6fc;
  163. }
  164. </style>