Blame view

lvdao-miniapp/uni_modules/wu-calendar/components/wu-calendar-block/wu-calendar-block.vue 2.83 KB
0fd8b750   杨鑫   '最新落地1'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
  <template>
  	<view class="wu-calendar-block">
  		<view v-if="showMonth && FoldShowMonth" class="wu-calendar__box-bg">
  			<text class="wu-calendar__box-bg-text">{{month}}</text>
  		</view>
  		<!-- 月或周日历 -->
  		<view class="wu-calendar__weeks" v-for="(item, index) in weeks" :key="index">
  			<template v-for="(weeks, weeksIndex) in item">
  				<wu-calendar-item :key="weeksIndex" v-if="!monthShowCurrentMonth || !weeks.empty" class="wu-calendar-item--hook" :weekItemStyle="weekItemStyle" :weeks="weeks" :calendar="calendar"
  					:selected="selected" :lunar="lunar" @change="choiceDate" :color="color" :actBadgeColor="actBadgeColor"
  					:startText="startText" :endText="endText" :itemHeight="itemHeight - defaultMargin" :todayDefaultStyle="todayDefaultStyle"></wu-calendar-item>
  				<view v-else class="wu-calendar__weeks-item" :style="[weekItemStyle]"></view>
  			</template>
  		</view>
  	</view>
  </template>
  
  <script>
  	import mpMixin from '@/uni_modules/wu-ui-tools/libs/mixin/mpMixin.js';
  	import mixin from '@/uni_modules/wu-ui-tools/libs/mixin/mixin.js';
  	import props from './props.js';
  
  	import {
  		initVueI18n
  	} from '@dcloudio/uni-i18n'
  	import i18nMessages from '../i18n/index.js'
  	const {
  		t
  	} = initVueI18n(i18nMessages)
  
  	export default {
  		emits: ['change'],
  		mixins: [mpMixin, mixin, props],
  		data() {
  			return {
  				FoldShowMonth: false,
  			}
  		},
  		mounted() {
  			this.FoldShowMonth = this.FoldStatus == 'open';
  		},
  		computed: {
  			weekItemStyle() {
  				let weeksLength = Object.keys(this.weeks).length;
  				let calendarHeight = this.FoldStatus === 'open' ? this.itemHeight * 6 : this.itemHeight;
  				let margin = weeksLength && this.weeks[weeksLength - 1][0].empty ? this.itemHeight / (weeksLength - 1) + this.defaultMargin : this.defaultMargin
  				return {
  					marginTop: margin / 2 + 'px',
  					marginBottom: margin / 2 + 'px',
  					height: this.itemHeight - this.defaultMargin + 'px'
  				}
  			}
  		},
  		watch: {
  			FoldStatus(newVal) {
  				this.$nextTick(()=>{
  					this.FoldShowMonth = this.FoldStatus == 'open';
  				})
  			}
  		},
  		methods: {
  			choiceDate(weeks) {
  				this.$emit('change', weeks)
  			}
  		}
  	}
  </script>
  
  <style lang="scss" scoped>
  	$wu-text-color-grey: #999;
  	
  	.wu-calendar-block {
  		.wu-calendar__weeks {
  			position: relative;
  			/* #ifndef APP-NVUE */
  			display: flex;
  			/* #endif */
  			flex-direction: row;
  			padding: 0 8rpx;
  		}
  		
  		.wu-calendar__weeks-item {
  			flex: 1;
  		}
  		
  		.wu-calendar__box-bg {
  			/* #ifndef APP-NVUE */
  			display: flex;
  			/* #endif */
  			justify-content: center;
  			align-items: center;
  			position: absolute;
  			top: 0;
  			left: 0;
  			right: 0;
  			bottom: 0;
  		}
  		
  		.wu-calendar__box-bg-text {
  			font-size: 100rpx;
  			transform: scale(4);
  			font-weight: bold;
  			color: $wu-text-color-grey;
  			opacity: 0.1;
  			text-align: center;
  			/* #ifndef APP-NVUE */
  			line-height: 1;
  			/* #endif */
  		}
  	}
  </style>