calendar-item.vue 4.4 KB
Newer Older
DCloud_JSON's avatar
DCloud_JSON 已提交
1 2 3 4 5 6 7 8
<template>
	<view class="uni-calendar-item__weeks-box" :class="{
		'uni-calendar-item--disable':weeks.disable,
		'uni-calendar-item--before-checked-x':weeks.beforeMultiple,
		'uni-calendar-item--multiple': weeks.multiple,
		'uni-calendar-item--after-checked-x':weeks.afterMultiple,
		}" @click="choiceDate(weeks)" @mouseenter="handleMousemove(weeks)">
		<view class="uni-calendar-item__weeks-box-item" :class="{
9
				'uni-calendar-item--checked':calendar.fullDate === weeks.fullDate && (calendar.userChecked || !checkHover),
DCloud_JSON's avatar
DCloud_JSON 已提交
10 11 12 13 14
				'uni-calendar-item--checked-range-text': checkHover,
				'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,
15
				}">
DCloud_JSON's avatar
DCloud_JSON 已提交
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>
DCloud_JSON's avatar
DCloud_JSON 已提交
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
	</view>
</template>

<script>
	export default {
		props: {
			weeks: {
				type: Object,
				default () {
					return {}
				}
			},
			calendar: {
				type: Object,
				default: () => {
					return {}
				}
			},
			selected: {
				type: Array,
				default: () => {
					return []
				}
			},
			lunar: {
				type: Boolean,
				default: false
47 48 49 50
			},
			checkHover: {
				type: Boolean,
				default: false
DCloud_JSON's avatar
DCloud_JSON 已提交
51 52 53 54 55
			}
		},
		methods: {
			choiceDate(weeks) {
				this.$emit('change', weeks)
56 57 58
			},
			handleMousemove(weeks) {
				this.$emit('handleMouse', weeks)
DCloud_JSON's avatar
DCloud_JSON 已提交
59 60 61 62 63
			}
		}
	}
</script>

64 65 66
<style lang="scss" >
	$uni-primary: #007aff !default;

DCloud_JSON's avatar
DCloud_JSON 已提交
67 68 69 70 71 72 73
	.uni-calendar-item__weeks-box {
		flex: 1;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: center;
74
		align-items: center;
75
		margin: 1px 0;
76
		position: relative;
DCloud_JSON's avatar
DCloud_JSON 已提交
77 78 79
	}

	.uni-calendar-item__weeks-box-text {
80 81 82 83
		font-size: 14px;
		// font-family: Lato-Bold, Lato;
		font-weight: bold;
		color: darken($color: $uni-primary, $amount: 40%);
DCloud_JSON's avatar
DCloud_JSON 已提交
84 85 86
	}

	.uni-calendar-item__weeks-lunar-text {
87 88
		font-size: 12px;
		color: #333;
DCloud_JSON's avatar
DCloud_JSON 已提交
89 90 91 92 93 94 95 96 97 98
	}

	.uni-calendar-item__weeks-box-item {
		position: relative;
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: column;
		justify-content: center;
		align-items: center;
99 100
		width: 40px;
		height: 40px;
DCloud_JSON's avatar
DCloud_JSON 已提交
101 102 103
		/* #ifdef H5 */
		cursor: pointer;
		/* #endif */
104 105
	}

DCloud_JSON's avatar
DCloud_JSON 已提交
106 107 108 109 110 111 112 113

	.uni-calendar-item__weeks-box-circle {
		position: absolute;
		top: 5px;
		right: 5px;
		width: 8px;
		height: 8px;
		border-radius: 8px;
114
		background-color: #dd524d;
DCloud_JSON's avatar
DCloud_JSON 已提交
115 116 117 118 119 120 121 122

	}

	.uni-calendar-item__weeks-box .uni-calendar-item--disable {
		// background-color: rgba(249, 249, 249, $uni-opacity-disabled);
		cursor: default;
	}

123 124 125 126 127 128 129
	.uni-calendar-item--disable .uni-calendar-item__weeks-box-text-disable {
		color: #D1D1D1;
	}

	.uni-calendar-item--isDay {
		position: absolute;
		top: 10px;
130
		right: 17%;
131 132 133
		background-color: #dd524d;
		width:6px;
		height: 6px;
134
		border-radius: 50%;
DCloud_JSON's avatar
DCloud_JSON 已提交
135 136 137
	}

	.uni-calendar-item--extra {
138
		color: #dd524d;
DCloud_JSON's avatar
DCloud_JSON 已提交
139 140 141
		opacity: 0.8;
	}

142
	.uni-calendar-item__weeks-box .uni-calendar-item--checked {
143
		background-color: $uni-primary;
144
		border-radius: 50%;
145
		box-sizing: border-box;
146
		border: 3px solid #fff;
147 148 149 150
	}

	.uni-calendar-item--checked .uni-calendar-item--checked-text {
		color: #fff;
151 152 153 154
	}

	.uni-calendar-item--multiple .uni-calendar-item--checked-range-text {
		color: #333;
DCloud_JSON's avatar
DCloud_JSON 已提交
155 156 157
	}

	.uni-calendar-item--multiple {
158
		background-color:  #F6F7FC;
DCloud_JSON's avatar
DCloud_JSON 已提交
159 160 161
		// color: #fff;
	}

162
	.uni-calendar-item--multiple .uni-calendar-item--before-checked,
DCloud_JSON's avatar
DCloud_JSON 已提交
163
	.uni-calendar-item--multiple .uni-calendar-item--after-checked {
164
		background-color: $uni-primary;
165
		border-radius: 50%;
166
		box-sizing: border-box;
167
		border: 3px solid #F6F7FC;
168 169 170 171 172
	}

	.uni-calendar-item--before-checked .uni-calendar-item--checked-text,
	.uni-calendar-item--after-checked .uni-calendar-item--checked-text {
		color: #fff;
173 174 175
	}

	.uni-calendar-item--before-checked-x {
176
		border-top-left-radius: 50px;
177 178
		border-bottom-left-radius: 50px;
		box-sizing: border-box;
179
		background-color: #F6F7FC;
180 181 182
	}

	.uni-calendar-item--after-checked-x {
183
		border-top-right-radius: 50px;
184
		border-bottom-right-radius: 50px;
185
		background-color: #F6F7FC;
186 187
	}
</style>