| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- <template>
- <view
- class="uni-calendar-item__weeks-box"
- :class="{
- 'uni-calendar-item--disable': weeks.disable,
- 'uni-calendar-item--isDay': calendar.fullDate === weeks.fullDate && weeks.isDay,
- 'uni-calendar-item--checked': calendar.fullDate === weeks.fullDate && !weeks.isDay,
- 'uni-calendar-item--before-checked': weeks.beforeMultiple,
- 'uni-calendar-item--multiple': weeks.multiple,
- 'uni-calendar-item--after-checked': weeks.afterMultiple,
- }"
- @click="choiceDate(weeks)"
- >
- <view class="uni-calendar-item__weeks-box-item">
- <!-- 右上角打点 -->
- <text
- v-if="selected && weeks.extraInfo"
- class="uni-calendar-item__weeks-box-circle"
- :class="{
- 'uni-calendar-item--workday-dot': weeks.extraInfo.info === '工作日',
- 'uni-calendar-item--restday-dot': weeks.extraInfo.info === '休息日',
- }"
- ></text>
- <!-- 日期文字 -->
- <text
- class="uni-calendar-item__weeks-box-text"
- :class="{
- 'uni-calendar-item--isDay-text': weeks.isDay,
- 'uni-calendar-item--isDay': calendar.fullDate === weeks.fullDate && weeks.isDay,
- 'uni-calendar-item--checked': calendar.fullDate === weeks.fullDate && !weeks.isDay,
- 'uni-calendar-item--before-checked': weeks.beforeMultiple,
- 'uni-calendar-item--multiple': weeks.multiple,
- 'uni-calendar-item--after-checked': weeks.afterMultiple,
- 'uni-calendar-item--disable': weeks.disable,
- 'uni-calendar-item--workday-text': weeks.extraInfo && weeks.extraInfo.info === '工作日',
- 'uni-calendar-item--restday-text': weeks.extraInfo && weeks.extraInfo.info === '休息日',
- }"
- >{{ weeks.date }}</text>
- <!-- 农历或今日文字 -->
- <text
- v-if="!lunar && !weeks.extraInfo && weeks.isDay"
- class="uni-calendar-item__weeks-lunar-text"
- :class="{
- 'uni-calendar-item--isDay-text': weeks.isDay,
- 'uni-calendar-item--isDay': calendar.fullDate === weeks.fullDate && weeks.isDay,
- 'uni-calendar-item--checked': calendar.fullDate === weeks.fullDate && !weeks.isDay,
- 'uni-calendar-item--before-checked': weeks.beforeMultiple,
- 'uni-calendar-item--multiple': weeks.multiple,
- 'uni-calendar-item--after-checked': weeks.afterMultiple,
- }"
- >{{ todayText }}</text>
- <!-- 农历文字 -->
- <text
- v-if="lunar && !weeks.extraInfo"
- class="uni-calendar-item__weeks-lunar-text"
- :class="{
- 'uni-calendar-item--isDay-text': weeks.isDay,
- 'uni-calendar-item--isDay': calendar.fullDate === weeks.fullDate && weeks.isDay,
- 'uni-calendar-item--checked': calendar.fullDate === weeks.fullDate && !weeks.isDay,
- 'uni-calendar-item--before-checked': weeks.beforeMultiple,
- 'uni-calendar-item--multiple': weeks.multiple,
- 'uni-calendar-item--after-checked': weeks.afterMultiple,
- 'uni-calendar-item--disable': weeks.disable,
- }"
- >{{ weeks.isDay ? todayText : (weeks.lunar.IDayCn === '初一' ? weeks.lunar.IMonthCn : weeks.lunar.IDayCn) }}</text>
- <!-- 额外信息 -->
- <text
- v-if="weeks.extraInfo && weeks.extraInfo.info"
- class="uni-calendar-item__weeks-lunar-text"
- :class="{
- 'uni-calendar-item--extra': weeks.extraInfo.info,
- 'uni-calendar-item--isDay-text': weeks.isDay,
- 'uni-calendar-item--isDay': calendar.fullDate === weeks.fullDate && weeks.isDay,
- 'uni-calendar-item--checked': calendar.fullDate === weeks.fullDate && !weeks.isDay,
- 'uni-calendar-item--before-checked': weeks.beforeMultiple,
- 'uni-calendar-item--multiple': weeks.multiple,
- 'uni-calendar-item--after-checked': weeks.afterMultiple,
- 'uni-calendar-item--disable': weeks.disable,
- 'uni-calendar-item--workday-texts': weeks.extraInfo && weeks.extraInfo.info === '工作日',
- 'uni-calendar-item--restday-texts': weeks.extraInfo && weeks.extraInfo.info === '休息日'
- }"
- >{{ weeks.extraInfo.info }}</text>
- </view>
- </view>
- </template>
-
- <script>
- import { initVueI18n } from '@dcloudio/uni-i18n';
- import i18nMessages from './i18n/index.js';
- const { t } = initVueI18n(i18nMessages);
-
- export default {
- emits: ['change'],
- props: {
- weeks: {
- type: Object,
- default() {
- return {};
- },
- },
- calendar: {
- type: Object,
- default: () => {
- return {};
- },
- },
- selected: {
- type: Array,
- default: () => {
- return [];
- },
- },
- lunar: {
- type: Boolean,
- default: false,
- },
- },
- computed: {
- todayText() {
- return t('uni-calender.today');
- },
- },
- methods: {
- choiceDate(weeks) {
- this.$emit('change', weeks);
- },
- },
- };
- </script>
-
- <style lang="scss" scoped>
- $uni-font-size-base: 14px;
- $uni-text-color: #333;
- $uni-font-size-sm: 12px;
- $uni-color-error: #e43d33;
- $uni-opacity-disabled: 0.3;
- $uni-text-color-disable: #c0c0c0;
- $uni-primary: #2979ff !default;
- $uni-workday-color: #007545; // 工作日字体颜色
- $uni-restday-color: #e43d33; // 休息日字体颜色
- $uni-workday-dot: #007545; // 工作日打点颜色
- $uni-restday-dot: #e43d33; // 休息日打点颜色
-
- .uni-calendar-item__weeks-box {
- flex: 1;
- /* #ifndef APP-NVUE */
- display: flex;
- /* #endif */
- flex-direction: column;
- justify-content: center;
- align-items: center;
- }
-
- .uni-calendar-item__weeks-box-text {
- font-size: $uni-font-size-base;
- color: $uni-text-color;
- }
-
- .uni-calendar-item__weeks-lunar-text {
- font-size: $uni-font-size-sm;
- color: $uni-text-color;
- }
-
- .uni-calendar-item__weeks-box-item {
- position: relative;
- /* #ifndef APP-NVUE */
- display: flex;
- /* #endif */
- flex-direction: column;
- justify-content: center;
- align-items: center;
- width: 100rpx;
- height: 100rpx;
- }
-
- .uni-calendar-item__weeks-box-circle {
- position: absolute;
- top: 5px;
- right: 5px;
- width: 8px;
- height: 8px;
- border-radius: 8px;
- }
-
- .uni-calendar-item--workday-dot {
- background-color: $uni-workday-dot; // 工作日打点颜色
- }
-
- .uni-calendar-item--restday-dot {
- background-color: $uni-restday-dot; // 休息日打点颜色
- }
-
- .uni-calendar-item--disable {
- color: $uni-text-color-disable;
- }
-
- .uni-calendar-item--isDay-text {
- color: $uni-primary;
- }
-
- .uni-calendar-item--isDay {
- // color: #fff;
- color: #2979ff;
- }
-
- .uni-calendar-item--checked {
- // color: #e96900 !important;
- }
-
- .uni-calendar-item--multiple {
- color: #fff;
- }
-
- .uni-calendar-item--before-checked {
- color: #fff;
- }
-
- .uni-calendar-item--after-checked {
- color: #fff;
- }
-
- .uni-calendar-item--workday-text {
- color: $uni-workday-color; // 工作日字体颜色
- }
-
- .uni-calendar-item--restday-text {
- color: $uni-restday-color; // 休息日字体颜色
- }
- .uni-calendar-item--workday-texts {
- color: $uni-text-color-disable; // 工作日字体颜色
- }
-
- .uni-calendar-item--restday-texts {
- color: $uni-text-color-disable; // 休息日字体颜色
- }
- </style>
|