luanqing-single-selector-item.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <view class="uni-calendar-item__weeks-box" :class="{
  3. 'uni-calendar-item--disable': weeks.disable,
  4. 'uni-calendar-item--before-checked':weeks.beforeMultiple,
  5. 'uni-calendar-item--multiple': weeks.multiple,
  6. 'uni-calendar-item--after-checked':weeks.afterMultiple,
  7. }"
  8. @click.stop="onCheckDate(weeks)"
  9. >
  10. <view :class="weeks.extraInfo ? 'uni-calendar-checked':'uni-calendar-item__weeks-box-item'">
  11. <text v-if="!weeks.disable" :class="weeks.extraInfo ? 'luanqing_date_text_selected':'luanqing_date_text'">{{weeks.date}}</text>
  12. <text v-if="!weeks.disable" :class="weeks.extraInfo ? 'luanqing_lanur_text_selected':'luanqing_lanur_text'" style="margin-top: 2rpx;">{{weeks.isDay ? todayText : (weeks.lunar.IDayCn === '初一'?weeks.lunar.IMonthCn:weeks.lunar.IDayCn)}}</text>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import {
  18. initVueI18n
  19. } from '@dcloudio/uni-i18n'
  20. import messages from './i18n/index.js'
  21. const { t } = initVueI18n(messages)
  22. export default {
  23. emits:['change'],
  24. props: {
  25. themeColor:{
  26. type: String,
  27. default: '#E00300'
  28. },
  29. isAbleSelectFutureDate:{
  30. type: Boolean,
  31. default: true
  32. },
  33. curYear:{
  34. type: Number,
  35. default: 2022
  36. },
  37. curMonth:{
  38. type: Number,
  39. default: 7
  40. },
  41. curDate:{
  42. type: Number,
  43. default: 14
  44. },
  45. weeks: {
  46. type: Object,
  47. default () {
  48. return {}
  49. }
  50. },
  51. calendar: {
  52. type: Object,
  53. default: () => {
  54. return {}
  55. }
  56. },
  57. selected: {
  58. type: Array,
  59. default: () => {
  60. return []
  61. }
  62. },
  63. lunar: {
  64. type: Boolean,
  65. default: false
  66. }
  67. },
  68. computed: {
  69. todayText() {
  70. return t("uni-calender.today")
  71. },
  72. },
  73. methods: {
  74. onCheckDate(weeks){
  75. if(!this.$props.isAbleSelectFutureDate){
  76. if((weeks.lunar.cYear < this.$props.curYear)
  77. || (weeks.lunar.cYear === this.$props.curYear && weeks.lunar.cMonth < this.$props.curMonth)
  78. || (weeks.lunar.cYear === this.$props.curYear && weeks.lunar.cMonth === this.$props.curMonth && weeks.lunar.cDay <= this.$props.curDate)){
  79. this.$emit('change', weeks);
  80. }
  81. }else{
  82. this.$emit('change', weeks);
  83. }
  84. },
  85. }
  86. }
  87. </script>
  88. <style lang="scss" scoped>
  89. .selected{
  90. width: 22rpx;
  91. height: 22rpx;
  92. background-color: #E00300;
  93. margin-top: 6rpx;
  94. display: flex;
  95. justify-content: center;
  96. align-items: center;
  97. .icon{
  98. width: 20rpx;
  99. height: 20rpx;
  100. }
  101. }
  102. .unselected{
  103. width: 20rpx;
  104. height: 20rpx;
  105. border: 1rpx solid #999999;
  106. margin-top: 6rpx;
  107. }
  108. .uni-calendar-item__weeks-box {
  109. flex: 1;
  110. /* #ifndef APP-NVUE */
  111. display: flex;
  112. /* #endif */
  113. flex-direction: column;
  114. justify-content: center;
  115. align-items: center;
  116. }
  117. .luanqing_lanur_text{
  118. font-size: 20rpx;
  119. font-weight: 400;
  120. color: #999999;
  121. }
  122. .luanqing_lanur_text_selected{
  123. font-size: 20rpx;
  124. font-weight: 400;
  125. color: #E00300;
  126. }
  127. .luanqing_date_text_single{
  128. font-weight: 500;
  129. font-size: 28rpx;
  130. color: #999999;
  131. }
  132. .luanqing_date_text_selected_single{
  133. font-weight: 500;
  134. font-size: 28rpx;
  135. color: #E00300;
  136. }
  137. .luanqing_date_text{
  138. font-weight: 500;
  139. font-size: 28rpx;
  140. color: #333333;
  141. }
  142. .luanqing_date_text_selected{
  143. font-weight: 500;
  144. font-size: 28rpx;
  145. color: #E00300;
  146. }
  147. .uni-calendar-item__weeks-box-text {
  148. font-size: $uni-font-size-base;
  149. color: $uni-text-color;
  150. }
  151. .uni-calendar-item__weeks-lunar-text {
  152. font-size: $uni-font-size-sm;
  153. color: $uni-text-color;
  154. }
  155. .uni-calendar-item__weeks-box-item {
  156. position: relative;
  157. /* #ifndef APP-NVUE */
  158. display: flex;
  159. /* #endif */
  160. flex-direction: column;
  161. justify-content: flex-start;
  162. align-items: center;
  163. width: 104rpx;
  164. height: 120rpx;
  165. }
  166. .uni-calendar-checked{
  167. position: relative;
  168. /* #ifndef APP-NVUE */
  169. display: flex;
  170. /* #endif */
  171. flex-direction: column;
  172. justify-content: flex-start;
  173. align-items: center;
  174. width: 102rpx;
  175. height: 118rpx;
  176. border: 1rpx solid #E00300;
  177. }
  178. .uni-calendar-item__weeks-box-circle {
  179. position: absolute;
  180. top: 5px;
  181. right: 5px;
  182. width: 8px;
  183. height: 8px;
  184. border-radius: 8px;
  185. background-color: $uni-color-error;
  186. }
  187. .uni-calendar-item--disable {
  188. background-color: rgba(249, 249, 249, $uni-opacity-disabled);
  189. }
  190. .uni-calendar-item--isDay-text {
  191. color: $uni-color-primary;
  192. }
  193. .uni-calendar-item--isDay {
  194. background-color: $uni-color-primary;
  195. opacity: 0.8;
  196. }
  197. .uni-calendar-item--extra {
  198. color: $uni-color-error;
  199. opacity: 0.8;
  200. }
  201. .uni-calendar-item--checked {
  202. background: #FBEDED;
  203. border-radius: 4rpx;
  204. border: 2rpx solid #E00300;
  205. opacity: 0.8;
  206. }
  207. .uni-calendar-item--multiple {
  208. background-color: $uni-color-primary;
  209. opacity: 0.8;
  210. }
  211. .uni-calendar-item--before-checked {
  212. background-color: #ff5a5f;
  213. }
  214. .uni-calendar-item--after-checked {
  215. background-color: #ff5a5f;
  216. }
  217. </style>