uni-calendar-item.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <view class="uni-calendar-item__weeks-box" :class="{
  3. 'uni-calendar-item--disable':weeks.disable,
  4. 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
  5. 'uni-calendar-item--checked':(calendar.fullDate === weeks.fullDate && !weeks.isDay) ,
  6. 'uni-calendar-item--before-checked':weeks.beforeMultiple,
  7. 'uni-calendar-item--multiple': weeks.multiple,
  8. 'uni-calendar-item--after-checked':weeks.afterMultiple,
  9. }"
  10. @click="choiceDate(weeks)">
  11. <view class="uni-calendar-item__weeks-box-item">
  12. <text v-if="selected&&weeks.extraInfo" class="uni-calendar-item__weeks-box-circle"></text>
  13. <text class="uni-calendar-item__weeks-box-text" :class="{
  14. 'uni-calendar-item--isDay-text': weeks.isDay,
  15. 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
  16. 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
  17. 'uni-calendar-item--before-checked':weeks.beforeMultiple,
  18. 'uni-calendar-item--multiple': weeks.multiple,
  19. 'uni-calendar-item--after-checked':weeks.afterMultiple,
  20. 'uni-calendar-item--disable':weeks.disable,
  21. }">
  22. <text
  23. style="display: block;
  24. text-align: center;"
  25. >
  26. {{ weeks.isDay ? $t('今') : weeks.date}}
  27. </text>
  28. <text
  29. v-if="calendar.fullDate === weeks.fullDate"
  30. style="display: block;
  31. font-size: 20rpx;"
  32. >
  33. {{ toText }}
  34. </text>
  35. </text>
  36. <!-- <text v-if="!lunar&&!weeks.extraInfo && weeks.isDay" class="uni-calendar-item__weeks-lunar-text" :class="{
  37. 'uni-calendar-item--isDay-text':weeks.isDay,
  38. 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
  39. 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
  40. 'uni-calendar-item--before-checked':weeks.beforeMultiple,
  41. 'uni-calendar-item--multiple': weeks.multiple,
  42. 'uni-calendar-item--after-checked':weeks.afterMultiple,
  43. }">{{todayText}}</text> -->
  44. <text v-if="lunar&&!weeks.extraInfo" class="uni-calendar-item__weeks-lunar-text" :class="{
  45. 'uni-calendar-item--isDay-text':weeks.isDay,
  46. 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
  47. 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
  48. 'uni-calendar-item--before-checked':weeks.beforeMultiple,
  49. 'uni-calendar-item--multiple': weeks.multiple,
  50. 'uni-calendar-item--after-checked':weeks.afterMultiple,
  51. 'uni-calendar-item--disable':weeks.disable,
  52. }">{{weeks.isDay ? todayText : (weeks.lunar.IDayCn === '初一'?weeks.lunar.IMonthCn:weeks.lunar.IDayCn)}}</text>
  53. <text v-if="weeks.extraInfo&&weeks.extraInfo.info" class="uni-calendar-item__weeks-lunar-text" :class="{
  54. 'uni-calendar-item--extra':weeks.extraInfo.info,
  55. 'uni-calendar-item--isDay-text':weeks.isDay,
  56. 'uni-calendar-item--isDay':calendar.fullDate === weeks.fullDate && weeks.isDay,
  57. 'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && !weeks.isDay,
  58. 'uni-calendar-item--before-checked':weeks.beforeMultiple,
  59. 'uni-calendar-item--multiple': weeks.multiple,
  60. 'uni-calendar-item--after-checked':weeks.afterMultiple,
  61. 'uni-calendar-item--disable':weeks.disable,
  62. }">{{weeks.extraInfo.info}}</text>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. export default {
  68. emits:['change'],
  69. props: {
  70. weeks: {
  71. type: Object,
  72. default () {
  73. return {}
  74. }
  75. },
  76. calendar: {
  77. type: Object,
  78. default: () => {
  79. return {}
  80. }
  81. },
  82. selected: {
  83. type: Array,
  84. default: () => {
  85. return []
  86. }
  87. },
  88. lunar: {
  89. type: Boolean,
  90. default: false
  91. },
  92. toText: {
  93. type: String,
  94. default: ''
  95. }
  96. },
  97. computed: {
  98. todayText() {
  99. return this.$t('今日')
  100. },
  101. },
  102. methods: {
  103. choiceDate(weeks) {
  104. this.$emit('change', weeks)
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. $uni-font-size-base:32rpx;
  111. $uni-text-color:#020202;
  112. $uni-font-size-sm:12px;
  113. $uni-color-error: #e43d33;
  114. $uni-opacity-disabled: 0.3;
  115. $uni-text-color-disable:#9FA7B7;
  116. $uni-primary: #0074FF !default;
  117. .uni-calendar-item__weeks-box {
  118. flex: 1;
  119. /* #ifndef APP-NVUE */
  120. display: flex;
  121. /* #endif */
  122. flex-direction: column;
  123. justify-content: center;
  124. align-items: center;
  125. }
  126. .uni-calendar-item__weeks-box-text {
  127. font-size: $uni-font-size-base;
  128. color: #2A3A5A;
  129. font-family: DIN, DIN;
  130. font-weight: bold;
  131. }
  132. .uni-calendar-item__weeks-lunar-text {
  133. font-size: $uni-font-size-sm;
  134. color: $uni-text-color;
  135. font-family: DIN, DIN;
  136. }
  137. .uni-calendar-item__weeks-box-item {
  138. position: relative;
  139. /* #ifndef APP-NVUE */
  140. display: flex;
  141. /* #endif */
  142. flex-direction: column;
  143. justify-content: center;
  144. align-items: center;
  145. width: 96rpx;
  146. height: 72rpx;
  147. }
  148. .uni-calendar-item__weeks-box-circle {
  149. position: absolute;
  150. top: 5px;
  151. right: 5px;
  152. width: 8px;
  153. height: 8px;
  154. border-radius: 8px;
  155. background-color: $uni-color-error;
  156. }
  157. .uni-calendar-item--disable {
  158. // background-color: rgba(249, 249, 249, $uni-opacity-disabled);
  159. background: none;
  160. color: $uni-text-color-disable;
  161. }
  162. .uni-calendar-item--isDay-text {
  163. color: $uni-primary;
  164. }
  165. .uni-calendar-item--isDay {
  166. background-color: $uni-primary;
  167. border-radius: 16rpx;
  168. // opacity: 0.8;
  169. color: #fff;
  170. }
  171. .uni-calendar-item--extra {
  172. color: $uni-color-error;
  173. opacity: 0.8;
  174. }
  175. .uni-calendar-item--checked {
  176. background-color: $uni-primary;
  177. color: #fff;
  178. // opacity: 0.8;
  179. border-radius: 16rpx;
  180. }
  181. .uni-calendar-item--multiple {
  182. background-color: $uni-primary;
  183. color: #fff;
  184. opacity: 0.8;
  185. }
  186. .uni-calendar-item--before-checked {
  187. background-color: #ff5a5f;
  188. color: #fff;
  189. }
  190. .uni-calendar-item--after-checked {
  191. background-color: #ff5a5f;
  192. color: #fff;
  193. }
  194. </style>