|
11 | 11 | <button class="calendar-button" type="button" @click="open">打开日历</button> |
12 | 12 | <text v-if="timeData.lunar" class="calendar-title">已选日期</text> |
13 | 13 | <view v-if="timeData.lunar" class="calendar-info"> |
14 | | - <view>当前选择时间 : {{timeData.fulldate}}</view> |
15 | | - <view v-if="tags['lunar'].checked">农历日期 : {{timeData.year + |
16 | | - '年' + |
17 | | - timeData.month + |
18 | | - '月' + |
19 | | - timeData.date + |
20 | | - '日 (' + |
21 | | - timeData.lunar.astro + |
22 | | - ')'}}</view> |
23 | | - <view v-if="tags['lunar'].checked"> {{ |
24 | | - timeData.lunar.gzYear + |
25 | | - '年' + |
26 | | - timeData.lunar.gzMonth + |
27 | | - '月' + |
28 | | - timeData.lunar.gzDay + |
29 | | - '日 (' + |
30 | | - timeData.lunar.Animal + |
31 | | - '年)' |
32 | | - }} |
33 | | - {{ timeData.lunar.IMonthCn + timeData.lunar.IDayCn }} |
34 | | - {{ timeData.lunar.isTerm ? timeData.lunar.Term : '' }}</view> |
| 14 | + <view>当前选择时间 : {{ timeData.fulldate }}</view> |
| 15 | + <view v-if="tags[0].checked">农历日期 : {{ timeData.year + '年' + timeData.month + '月' + timeData.date + '日 (' + timeData.lunar.astro + ')' }}</view> |
| 16 | + <view v-if="tags[0].checked"> |
| 17 | + {{ timeData.lunar.gzYear + '年' + timeData.lunar.gzMonth + '月' + timeData.lunar.gzDay + '日 (' + timeData.lunar.Animal + '年)' }} |
| 18 | + {{ timeData.lunar.IMonthCn + timeData.lunar.IDayCn }} {{ timeData.lunar.isTerm ? timeData.lunar.Term : '' }} |
| 19 | + </view> |
35 | 20 | </view> |
36 | 21 | <view v-if="show" class="calendar-mask" @click="closeMask"> |
37 | 22 | <view class="calendar-box" @click.stop=""> |
38 | | - <uni-calendar :lunar="tags['lunar'].checked" :fixedHeihgt="tags['fixedHeihgt'].checked" :slide="slide" :disableBefore="tags['disableBefore'].checked" :start-date="startDate" :end-date="endDate" :date="date" @change="change" @to-click="toClick" /> |
| 23 | + <uni-calendar :lunar="tags[0].checked" :fixedHeihgt="tags[1].checked" :slide="slide" :disableBefore="tags[6].checked" :start-date="startDate" :end-date="endDate" :date="date" @change="change" @to-click="toClick" /> |
39 | 24 | <view class="calendar-button-groups"> |
40 | 25 | <button class="calendar-button-confirm" @click="closeMask">取消</button> |
41 | 26 | <button class="calendar-button-confirm" @click="confirm">确认</button> |
|
52 | 37 | components: { |
53 | 38 | uniCalendar |
54 | 39 | }, |
55 | | -
|
56 | 40 | data() { |
57 | 41 | /** |
58 | 42 | * 时间计算 |
|
68 | 52 | let d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate(); // 获取当前几号,不足10补0 |
69 | 53 | return y + '-' + m + '-' + d; |
70 | 54 | } |
71 | | - let tags = { |
72 | | - lunar: { |
| 55 | + let tags = [{ |
| 56 | + id: 0, |
73 | 57 | name: '农历', |
74 | 58 | checked: false, |
75 | 59 | attr: 'lunar' |
76 | 60 | }, |
77 | | - fixedHeihgt: { |
| 61 | + { |
| 62 | + id: 1, |
78 | 63 | name: '固定高度', |
79 | 64 | checked: false, |
80 | 65 | attr: 'fixedHeihgt' |
81 | 66 | }, |
82 | | - vertical: { |
| 67 | + { |
| 68 | + id: 2, |
83 | 69 | name: '垂直滚动', |
84 | 70 | checked: false, |
85 | 71 | attr: 'vertical' |
86 | 72 | }, |
87 | | - horizontal: { |
| 73 | + { |
| 74 | + id: 3, |
88 | 75 | name: '水平滚动', |
89 | 76 | checked: false, |
90 | 77 | attr: 'horizontal' |
91 | 78 | }, |
92 | | - startDate: { |
| 79 | + { |
| 80 | + id: 4, |
93 | 81 | name: '开始日期(' + getDate(new Date(), -1) + ')', |
94 | 82 | checked: false, |
95 | 83 | value: getDate(new Date(), -1), |
96 | 84 | attr: 'startDate' |
97 | 85 | }, |
98 | | - endDate: { |
| 86 | + { |
| 87 | + id: 5, |
99 | 88 | name: '结束日期(' + getDate(new Date(), 2) + ')', |
100 | 89 | value: getDate(new Date(), 2), |
101 | 90 | checked: false, |
102 | 91 | attr: 'endDate' |
103 | 92 | }, |
104 | | - disableBefore: { |
| 93 | + { |
| 94 | + id: 6, |
105 | 95 | name: '禁用今天之前的日期', |
106 | 96 | checked: false, |
107 | 97 | attr: 'disableBefore' |
108 | 98 | }, |
109 | | - date: { |
| 99 | + { |
| 100 | + id: 7, |
110 | 101 | name: '自定义当前日期(' + getDate(new Date(), 1) + ')', |
111 | 102 | value: getDate(new Date(), 1), |
112 | 103 | checked: false, |
113 | 104 | attr: 'date' |
114 | 105 | } |
115 | | - }; |
116 | | -
|
| 106 | + ]; |
117 | 107 |
|
118 | 108 | return { |
119 | 109 | show: false, |
|
133 | 123 | toggle(index, item) { |
134 | 124 | this.tags[index].checked = !item.checked; |
135 | 125 | // item.checked = !item.checked; |
136 | | - if (index === 'horizontal') { |
137 | | - this.tags['vertical'].checked = false; |
| 126 | + console.log(index) |
| 127 | + if (index === 2) { |
| 128 | + this.tags[3].checked = false; |
138 | 129 | } |
139 | | - if (index === 'vertical') { |
140 | | - this.tags['horizontal'].checked = false; |
| 130 | + if (index === 3) { |
| 131 | + this.tags[2].checked = false; |
141 | 132 | } |
142 | 133 | // this.attribute[item.attr] = !item.checked; |
143 | 134 | }, |
144 | 135 | open() { |
145 | | - if (this.tags['horizontal'].checked) { |
| 136 | + if (this.tags[3].checked) { |
146 | 137 | this.slide = 'horizontal'; |
147 | | - } else if (this.tags['vertical'].checked) { |
| 138 | + } else if (this.tags[2].checked) { |
148 | 139 | this.slide = 'vertical'; |
149 | 140 | } else { |
150 | 141 | this.slide = 'none'; |
151 | 142 | } |
152 | | - if (this.tags['startDate'].checked) { |
153 | | - this.startDate = this.tags['startDate'].value; |
| 143 | + if (this.tags[4].checked) { |
| 144 | + this.startDate = this.tags[4].value; |
154 | 145 | } else { |
155 | 146 | this.startDate = ''; |
156 | 147 | } |
157 | | - if (this.tags['endDate'].checked) { |
158 | | - this.endDate = this.tags['endDate'].value; |
| 148 | + if (this.tags[5].checked) { |
| 149 | + this.endDate = this.tags[5].value; |
159 | 150 | } else { |
160 | 151 | this.endDate = ''; |
161 | 152 | } |
162 | | - if (this.tags['date'].checked) { |
163 | | - this.date = this.tags['date'].value; |
| 153 | + if (this.tags[7].checked) { |
| 154 | + this.date = this.tags[7].value; |
164 | 155 | } else { |
165 | 156 | this.date = ''; |
166 | 157 | } |
167 | 158 | this.show = true; |
168 | | - console.log(this.date) |
| 159 | + console.log(this.date); |
169 | 160 | }, |
170 | 161 | change(e) { |
171 | 162 | console.log('change 返回:', e.fulldate); |
|
249 | 240 |
|
250 | 241 | .calendar-tags-item { |
251 | 242 | padding: 10upx 20upx; |
252 | | - border: 1px rgba(0, 0, 0, .2) solid; |
| 243 | + border: 1px rgba(0, 0, 0, 0.2) solid; |
253 | 244 | color: #333; |
254 | 245 | border-radius: 10upx; |
255 | 246 | text-align: center; |
|
263 | 254 |
|
264 | 255 | .checked .calendar-tags-item { |
265 | 256 | background: rgb(0, 122, 255); |
266 | | - ; |
267 | 257 | color: #fff; |
268 | 258 | border: 1px rgba(0, 0, 0, 0.1) solid; |
269 | 259 | } |
|
0 commit comments