@kengic/uni 0.3.2-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (166) hide show
  1. package/README.md +1 -0
  2. package/dist/index.css +1 -0
  3. package/dist/kengic-uni.js +5 -0
  4. package/dist/src/consts/i18n/en.d.ts +45 -0
  5. package/dist/src/consts/i18n/index.d.ts +90 -0
  6. package/dist/src/consts/i18n/zh_CN.d.ts +45 -0
  7. package/dist/src/consts/index.d.ts +1 -0
  8. package/dist/src/index.d.ts +2 -0
  9. package/dist/src/utils/index.d.ts +1 -0
  10. package/dist/src/utils/kg.util.d.ts +5 -0
  11. package/dist/uni-ui/index.ts +11 -0
  12. package/dist/uni-ui/uni-badge/uni-badge.vue +253 -0
  13. package/dist/uni-ui/uni-breadcrumb/uni-breadcrumb.vue +41 -0
  14. package/dist/uni-ui/uni-breadcrumb-item/uni-breadcrumb-item.vue +121 -0
  15. package/dist/uni-ui/uni-calendar/calendar.js +546 -0
  16. package/dist/uni-ui/uni-calendar/i18n/en.json +12 -0
  17. package/dist/uni-ui/uni-calendar/i18n/index.js +8 -0
  18. package/dist/uni-ui/uni-calendar/i18n/zh-Hans.json +12 -0
  19. package/dist/uni-ui/uni-calendar/i18n/zh-Hant.json +12 -0
  20. package/dist/uni-ui/uni-calendar/uni-calendar-item.vue +187 -0
  21. package/dist/uni-ui/uni-calendar/uni-calendar.vue +566 -0
  22. package/dist/uni-ui/uni-calendar/util.js +360 -0
  23. package/dist/uni-ui/uni-card/uni-card.vue +281 -0
  24. package/dist/uni-ui/uni-col/uni-col.vue +317 -0
  25. package/dist/uni-ui/uni-collapse/uni-collapse.vue +147 -0
  26. package/dist/uni-ui/uni-collapse-item/uni-collapse-item.vue +402 -0
  27. package/dist/uni-ui/uni-combox/uni-combox.vue +294 -0
  28. package/dist/uni-ui/uni-countdown/i18n/en.json +6 -0
  29. package/dist/uni-ui/uni-countdown/i18n/index.js +8 -0
  30. package/dist/uni-ui/uni-countdown/i18n/zh-Hans.json +6 -0
  31. package/dist/uni-ui/uni-countdown/i18n/zh-Hant.json +6 -0
  32. package/dist/uni-ui/uni-countdown/uni-countdown.vue +267 -0
  33. package/dist/uni-ui/uni-data-checkbox/uni-data-checkbox.vue +821 -0
  34. package/dist/uni-ui/uni-data-picker/keypress.js +45 -0
  35. package/dist/uni-ui/uni-data-picker/uni-data-picker.vue +551 -0
  36. package/dist/uni-ui/uni-data-pickerview/uni-data-picker.js +622 -0
  37. package/dist/uni-ui/uni-data-pickerview/uni-data-pickerview.vue +323 -0
  38. package/dist/uni-ui/uni-data-select/uni-data-select.vue +517 -0
  39. package/dist/uni-ui/uni-dateformat/date-format.js +200 -0
  40. package/dist/uni-ui/uni-dateformat/uni-dateformat.vue +88 -0
  41. package/dist/uni-ui/uni-datetime-picker/calendar-item.vue +177 -0
  42. package/dist/uni-ui/uni-datetime-picker/calendar.vue +928 -0
  43. package/dist/uni-ui/uni-datetime-picker/i18n/en.json +22 -0
  44. package/dist/uni-ui/uni-datetime-picker/i18n/index.js +8 -0
  45. package/dist/uni-ui/uni-datetime-picker/i18n/zh-Hans.json +22 -0
  46. package/dist/uni-ui/uni-datetime-picker/i18n/zh-Hant.json +22 -0
  47. package/dist/uni-ui/uni-datetime-picker/time-picker.vue +934 -0
  48. package/dist/uni-ui/uni-datetime-picker/uni-datetime-picker.vue +1026 -0
  49. package/dist/uni-ui/uni-datetime-picker/util.js +403 -0
  50. package/dist/uni-ui/uni-drawer/keypress.js +45 -0
  51. package/dist/uni-ui/uni-drawer/uni-drawer.vue +181 -0
  52. package/dist/uni-ui/uni-easyinput/common.js +56 -0
  53. package/dist/uni-ui/uni-easyinput/uni-easyinput.vue +660 -0
  54. package/dist/uni-ui/uni-fab/uni-fab.vue +491 -0
  55. package/dist/uni-ui/uni-fav/i18n/en.json +4 -0
  56. package/dist/uni-ui/uni-fav/i18n/index.js +8 -0
  57. package/dist/uni-ui/uni-fav/i18n/zh-Hans.json +4 -0
  58. package/dist/uni-ui/uni-fav/i18n/zh-Hant.json +4 -0
  59. package/dist/uni-ui/uni-fav/uni-fav.vue +161 -0
  60. package/dist/uni-ui/uni-file-picker/choose-and-upload-file.js +224 -0
  61. package/dist/uni-ui/uni-file-picker/uni-file-picker.vue +667 -0
  62. package/dist/uni-ui/uni-file-picker/upload-file.vue +325 -0
  63. package/dist/uni-ui/uni-file-picker/upload-image.vue +292 -0
  64. package/dist/uni-ui/uni-file-picker/utils.js +109 -0
  65. package/dist/uni-ui/uni-forms/uni-forms.vue +398 -0
  66. package/dist/uni-ui/uni-forms/utils.js +293 -0
  67. package/dist/uni-ui/uni-forms/validate.js +486 -0
  68. package/dist/uni-ui/uni-forms-item/uni-forms-item.vue +601 -0
  69. package/dist/uni-ui/uni-goods-nav/i18n/en.json +6 -0
  70. package/dist/uni-ui/uni-goods-nav/i18n/index.js +8 -0
  71. package/dist/uni-ui/uni-goods-nav/i18n/zh-Hans.json +6 -0
  72. package/dist/uni-ui/uni-goods-nav/i18n/zh-Hant.json +6 -0
  73. package/dist/uni-ui/uni-goods-nav/uni-goods-nav.vue +229 -0
  74. package/dist/uni-ui/uni-grid/uni-grid.vue +143 -0
  75. package/dist/uni-ui/uni-grid-item/uni-grid-item.vue +129 -0
  76. package/dist/uni-ui/uni-group/uni-group.vue +134 -0
  77. package/dist/uni-ui/uni-icons/icons.js +1169 -0
  78. package/dist/uni-ui/uni-icons/uni-icons.vue +96 -0
  79. package/dist/uni-ui/uni-icons/uniicons.css +663 -0
  80. package/dist/uni-ui/uni-icons/uniicons.ttf +0 -0
  81. package/dist/uni-ui/uni-indexed-list/uni-indexed-list-item.vue +144 -0
  82. package/dist/uni-ui/uni-indexed-list/uni-indexed-list.vue +367 -0
  83. package/dist/uni-ui/uni-link/uni-link.vue +128 -0
  84. package/dist/uni-ui/uni-list/uni-list.vue +123 -0
  85. package/dist/uni-ui/uni-list/uni-refresh.vue +65 -0
  86. package/dist/uni-ui/uni-list/uni-refresh.wxs +87 -0
  87. package/dist/uni-ui/uni-list-ad/uni-list-ad.vue +107 -0
  88. package/dist/uni-ui/uni-list-chat/uni-list-chat.scss +58 -0
  89. package/dist/uni-ui/uni-list-chat/uni-list-chat.vue +593 -0
  90. package/dist/uni-ui/uni-list-item/uni-list-item.vue +534 -0
  91. package/dist/uni-ui/uni-load-more/i18n/en.json +5 -0
  92. package/dist/uni-ui/uni-load-more/i18n/index.js +8 -0
  93. package/dist/uni-ui/uni-load-more/i18n/zh-Hans.json +5 -0
  94. package/dist/uni-ui/uni-load-more/i18n/zh-Hant.json +5 -0
  95. package/dist/uni-ui/uni-load-more/uni-load-more.vue +399 -0
  96. package/dist/uni-ui/uni-nav-bar/uni-nav-bar.vue +357 -0
  97. package/dist/uni-ui/uni-nav-bar/uni-status-bar.vue +24 -0
  98. package/dist/uni-ui/uni-notice-bar/uni-notice-bar.vue +426 -0
  99. package/dist/uni-ui/uni-number-box/uni-number-box.vue +221 -0
  100. package/dist/uni-ui/uni-pagination/i18n/en.json +5 -0
  101. package/dist/uni-ui/uni-pagination/i18n/es.json +5 -0
  102. package/dist/uni-ui/uni-pagination/i18n/fr.json +5 -0
  103. package/dist/uni-ui/uni-pagination/i18n/index.js +12 -0
  104. package/dist/uni-ui/uni-pagination/i18n/zh-Hans.json +5 -0
  105. package/dist/uni-ui/uni-pagination/i18n/zh-Hant.json +5 -0
  106. package/dist/uni-ui/uni-pagination/uni-pagination.vue +465 -0
  107. package/dist/uni-ui/uni-popup/i18n/en.json +7 -0
  108. package/dist/uni-ui/uni-popup/i18n/index.js +9 -0
  109. package/dist/uni-ui/uni-popup/i18n/zh-Hans.json +7 -0
  110. package/dist/uni-ui/uni-popup/i18n/zh-Hant.json +7 -0
  111. package/dist/uni-ui/uni-popup/keypress.js +45 -0
  112. package/dist/uni-ui/uni-popup/popup.js +23 -0
  113. package/dist/uni-ui/uni-popup/uni-popup.vue +464 -0
  114. package/dist/uni-ui/uni-popup-dialog/keypress.js +45 -0
  115. package/dist/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +275 -0
  116. package/dist/uni-ui/uni-popup-message/uni-popup-message.vue +143 -0
  117. package/dist/uni-ui/uni-popup-share/uni-popup-share.vue +187 -0
  118. package/dist/uni-ui/uni-rate/uni-rate.vue +365 -0
  119. package/dist/uni-ui/uni-row/uni-row.vue +190 -0
  120. package/dist/uni-ui/uni-scss/changelog.md +8 -0
  121. package/dist/uni-ui/uni-scss/index.scss +1 -0
  122. package/dist/uni-ui/uni-scss/package.json +82 -0
  123. package/dist/uni-ui/uni-scss/readme.md +4 -0
  124. package/dist/uni-ui/uni-scss/styles/index.scss +7 -0
  125. package/dist/uni-ui/uni-scss/styles/setting/_border.scss +3 -0
  126. package/dist/uni-ui/uni-scss/styles/setting/_color.scss +66 -0
  127. package/dist/uni-ui/uni-scss/styles/setting/_radius.scss +55 -0
  128. package/dist/uni-ui/uni-scss/styles/setting/_space.scss +56 -0
  129. package/dist/uni-ui/uni-scss/styles/setting/_styles.scss +167 -0
  130. package/dist/uni-ui/uni-scss/styles/setting/_text.scss +24 -0
  131. package/dist/uni-ui/uni-scss/styles/setting/_variables.scss +146 -0
  132. package/dist/uni-ui/uni-scss/styles/tools/functions.scss +19 -0
  133. package/dist/uni-ui/uni-scss/theme.scss +31 -0
  134. package/dist/uni-ui/uni-scss/variables.scss +62 -0
  135. package/dist/uni-ui/uni-search-bar/i18n/en.json +4 -0
  136. package/dist/uni-ui/uni-search-bar/i18n/index.js +8 -0
  137. package/dist/uni-ui/uni-search-bar/i18n/zh-Hans.json +4 -0
  138. package/dist/uni-ui/uni-search-bar/i18n/zh-Hant.json +4 -0
  139. package/dist/uni-ui/uni-search-bar/uni-search-bar.vue +298 -0
  140. package/dist/uni-ui/uni-section/uni-section.vue +167 -0
  141. package/dist/uni-ui/uni-segmented-control/uni-segmented-control.vue +145 -0
  142. package/dist/uni-ui/uni-steps/uni-steps.vue +269 -0
  143. package/dist/uni-ui/uni-swipe-action/uni-swipe-action.vue +60 -0
  144. package/dist/uni-ui/uni-swipe-action-item/bindingx.js +302 -0
  145. package/dist/uni-ui/uni-swipe-action-item/isPC.js +12 -0
  146. package/dist/uni-ui/uni-swipe-action-item/mpalipay.js +195 -0
  147. package/dist/uni-ui/uni-swipe-action-item/mpother.js +260 -0
  148. package/dist/uni-ui/uni-swipe-action-item/mpwxs.js +84 -0
  149. package/dist/uni-ui/uni-swipe-action-item/render.js +270 -0
  150. package/dist/uni-ui/uni-swipe-action-item/uni-swipe-action-item.vue +347 -0
  151. package/dist/uni-ui/uni-swipe-action-item/wx.wxs +341 -0
  152. package/dist/uni-ui/uni-swiper-dot/uni-swiper-dot.vue +218 -0
  153. package/dist/uni-ui/uni-table/uni-table.vue +455 -0
  154. package/dist/uni-ui/uni-tag/uni-tag.vue +252 -0
  155. package/dist/uni-ui/uni-tbody/uni-tbody.vue +29 -0
  156. package/dist/uni-ui/uni-td/uni-td.vue +90 -0
  157. package/dist/uni-ui/uni-th/filter-dropdown.vue +511 -0
  158. package/dist/uni-ui/uni-th/uni-th.vue +285 -0
  159. package/dist/uni-ui/uni-thead/uni-thead.vue +129 -0
  160. package/dist/uni-ui/uni-title/uni-title.vue +171 -0
  161. package/dist/uni-ui/uni-tooltip/uni-tooltip.vue +68 -0
  162. package/dist/uni-ui/uni-tr/table-checkbox.vue +179 -0
  163. package/dist/uni-ui/uni-tr/uni-tr.vue +171 -0
  164. package/dist/uni-ui/uni-transition/createAnimation.js +131 -0
  165. package/dist/uni-ui/uni-transition/uni-transition.vue +281 -0
  166. package/package.json +90 -0
@@ -0,0 +1,928 @@
1
+ <template>
2
+ <view class="uni-calendar" @mouseleave="leaveCale">
3
+
4
+ <view v-if="!insert && show" class="uni-calendar__mask" :class="{'uni-calendar--mask-show':aniMaskShow}"
5
+ @click="maskClick"></view>
6
+
7
+ <view v-if="insert || show" class="uni-calendar__content"
8
+ :class="{'uni-calendar--fixed':!insert,'uni-calendar--ani-show':aniMaskShow, 'uni-calendar__content-mobile': aniMaskShow}">
9
+ <view class="uni-calendar__header" :class="{'uni-calendar__header-mobile' :!insert}">
10
+
11
+ <view class="uni-calendar__header-btn-box" @click.stop="changeMonth('pre')">
12
+ <view class="uni-calendar__header-btn uni-calendar--left"></view>
13
+ </view>
14
+
15
+ <picker mode="date" :value="date" fields="month" @change="bindDateChange">
16
+ <text
17
+ class="uni-calendar__header-text">{{ (nowDate.year||'') + yearText + ( nowDate.month||'') + monthText}}</text>
18
+ </picker>
19
+
20
+ <view class="uni-calendar__header-btn-box" @click.stop="changeMonth('next')">
21
+ <view class="uni-calendar__header-btn uni-calendar--right"></view>
22
+ </view>
23
+
24
+ <view v-if="!insert" class="dialog-close" @click="close">
25
+ <view class="dialog-close-plus" data-id="close"></view>
26
+ <view class="dialog-close-plus dialog-close-rotate" data-id="close"></view>
27
+ </view>
28
+ </view>
29
+ <view class="uni-calendar__box">
30
+
31
+ <view v-if="showMonth" class="uni-calendar__box-bg">
32
+ <text class="uni-calendar__box-bg-text">{{nowDate.month}}</text>
33
+ </view>
34
+
35
+ <view class="uni-calendar__weeks" style="padding-bottom: 7px;">
36
+ <view class="uni-calendar__weeks-day">
37
+ <text class="uni-calendar__weeks-day-text">{{SUNText}}</text>
38
+ </view>
39
+ <view class="uni-calendar__weeks-day">
40
+ <text class="uni-calendar__weeks-day-text">{{MONText}}</text>
41
+ </view>
42
+ <view class="uni-calendar__weeks-day">
43
+ <text class="uni-calendar__weeks-day-text">{{TUEText}}</text>
44
+ </view>
45
+ <view class="uni-calendar__weeks-day">
46
+ <text class="uni-calendar__weeks-day-text">{{WEDText}}</text>
47
+ </view>
48
+ <view class="uni-calendar__weeks-day">
49
+ <text class="uni-calendar__weeks-day-text">{{THUText}}</text>
50
+ </view>
51
+ <view class="uni-calendar__weeks-day">
52
+ <text class="uni-calendar__weeks-day-text">{{FRIText}}</text>
53
+ </view>
54
+ <view class="uni-calendar__weeks-day">
55
+ <text class="uni-calendar__weeks-day-text">{{SATText}}</text>
56
+ </view>
57
+ </view>
58
+
59
+ <view class="uni-calendar__weeks" v-for="(item,weekIndex) in weeks" :key="weekIndex">
60
+ <view class="uni-calendar__weeks-item" v-for="(weeks,weeksIndex) in item" :key="weeksIndex">
61
+ <calendar-item class="uni-calendar-item--hook" :weeks="weeks" :calendar="calendar"
62
+ :selected="selected" :checkHover="range" @change="choiceDate"
63
+ @handleMouse="handleMouse">
64
+ </calendar-item>
65
+ </view>
66
+ </view>
67
+ </view>
68
+
69
+ <view v-if="!insert && !range && hasTime" class="uni-date-changed uni-calendar--fixed-top"
70
+ style="padding: 0 80px;">
71
+ <view class="uni-date-changed--time-date">{{tempSingleDate ? tempSingleDate : selectDateText}}</view>
72
+ <time-picker type="time" :start="timepickerStartTime" :end="timepickerEndTime" v-model="time"
73
+ :disabled="!tempSingleDate" :border="false" :hide-second="hideSecond" class="time-picker-style">
74
+ </time-picker>
75
+ </view>
76
+
77
+ <view v-if="!insert && range && hasTime" class="uni-date-changed uni-calendar--fixed-top">
78
+ <view class="uni-date-changed--time-start">
79
+ <view class="uni-date-changed--time-date">{{tempRange.before ? tempRange.before : startDateText}}
80
+ </view>
81
+ <time-picker type="time" :start="timepickerStartTime" v-model="timeRange.startTime" :border="false"
82
+ :hide-second="hideSecond" :disabled="!tempRange.before" class="time-picker-style">
83
+ </time-picker>
84
+ </view>
85
+ <view style="line-height: 50px;">
86
+ <uni-icons type="arrowthinright" color="#999"></uni-icons>
87
+ </view>
88
+ <view class="uni-date-changed--time-end">
89
+ <view class="uni-date-changed--time-date">{{tempRange.after ? tempRange.after : endDateText}}</view>
90
+ <time-picker type="time" :end="timepickerEndTime" v-model="timeRange.endTime" :border="false"
91
+ :hide-second="hideSecond" :disabled="!tempRange.after" class="time-picker-style">
92
+ </time-picker>
93
+ </view>
94
+ </view>
95
+
96
+ <view v-if="!insert" class="uni-date-changed uni-date-btn--ok">
97
+ <view class="uni-datetime-picker--btn" @click="confirm">{{confirmText}}</view>
98
+ </view>
99
+ </view>
100
+ </view>
101
+ </template>
102
+
103
+ <script>
104
+ import { Calendar, getDate, getTime } from './util.js';
105
+ import calendarItem from './calendar-item.vue'
106
+ import timePicker from './time-picker.vue'
107
+
108
+ import { initVueI18n } from '@dcloudio/uni-i18n'
109
+ import i18nMessages from './i18n'
110
+ const { t } = initVueI18n(i18nMessages)
111
+
112
+ /**
113
+ * Calendar 日历
114
+ * @description 日历组件可以查看日期,选择任意范围内的日期,打点操作。常用场景如:酒店日期预订、火车机票选择购买日期、上下班打卡等
115
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=56
116
+ * @property {String} date 自定义当前时间,默认为今天
117
+ * @property {String} startDate 日期选择范围-开始日期
118
+ * @property {String} endDate 日期选择范围-结束日期
119
+ * @property {Boolean} range 范围选择
120
+ * @property {Boolean} insert = [true|false] 插入模式,默认为false
121
+ * @value true 弹窗模式
122
+ * @value false 插入模式
123
+ * @property {Boolean} clearDate = [true|false] 弹窗模式是否清空上次选择内容
124
+ * @property {Array} selected 打点,期待格式[{date: '2019-06-27', info: '签到', data: { custom: '自定义信息', name: '自定义消息头',xxx:xxx... }}]
125
+ * @property {Boolean} showMonth 是否选择月份为背景
126
+ * @property {[String} defaultValue 选择器打开时默认显示的时间
127
+ * @event {Function} change 日期改变,`insert :ture` 时生效
128
+ * @event {Function} confirm 确认选择`insert :false` 时生效
129
+ * @event {Function} monthSwitch 切换月份时触发
130
+ * @example <uni-calendar :insert="true" :start-date="'2019-3-2'":end-date="'2019-5-20'"@change="change" />
131
+ */
132
+ export default {
133
+ components: {
134
+ calendarItem,
135
+ timePicker
136
+ },
137
+ props: {
138
+ date: {
139
+ type: String,
140
+ default: ''
141
+ },
142
+ defTime: {
143
+ type: [String, Object],
144
+ default: ''
145
+ },
146
+ selectableTimes: {
147
+ type: [Object],
148
+ default () {
149
+ return {}
150
+ }
151
+ },
152
+ selected: {
153
+ type: Array,
154
+ default () {
155
+ return []
156
+ }
157
+ },
158
+ startDate: {
159
+ type: String,
160
+ default: ''
161
+ },
162
+ endDate: {
163
+ type: String,
164
+ default: ''
165
+ },
166
+ startPlaceholder: {
167
+ type: String,
168
+ default: ''
169
+ },
170
+ endPlaceholder: {
171
+ type: String,
172
+ default: ''
173
+ },
174
+ range: {
175
+ type: Boolean,
176
+ default: false
177
+ },
178
+ hasTime: {
179
+ type: Boolean,
180
+ default: false
181
+ },
182
+ insert: {
183
+ type: Boolean,
184
+ default: true
185
+ },
186
+ showMonth: {
187
+ type: Boolean,
188
+ default: true
189
+ },
190
+ clearDate: {
191
+ type: Boolean,
192
+ default: true
193
+ },
194
+ checkHover: {
195
+ type: Boolean,
196
+ default: true
197
+ },
198
+ hideSecond: {
199
+ type: [Boolean],
200
+ default: false
201
+ },
202
+ pleStatus: {
203
+ type: Object,
204
+ default () {
205
+ return {
206
+ before: '',
207
+ after: '',
208
+ data: [],
209
+ fulldate: ''
210
+ }
211
+ }
212
+ },
213
+ defaultValue: {
214
+ type: [String, Object, Array],
215
+ default: ''
216
+ }
217
+ },
218
+ data() {
219
+ return {
220
+ show: false,
221
+ weeks: [],
222
+ calendar: {},
223
+ nowDate: {},
224
+ aniMaskShow: false,
225
+ firstEnter: true,
226
+ time: '',
227
+ timeRange: {
228
+ startTime: '',
229
+ endTime: ''
230
+ },
231
+ tempSingleDate: '',
232
+ tempRange: {
233
+ before: '',
234
+ after: ''
235
+ }
236
+ }
237
+ },
238
+ watch: {
239
+ date: {
240
+ immediate: true,
241
+ handler(newVal) {
242
+ if (!this.range) {
243
+ this.tempSingleDate = newVal
244
+ setTimeout(() => {
245
+ this.init(newVal)
246
+ }, 100)
247
+ }
248
+ }
249
+ },
250
+ defTime: {
251
+ immediate: true,
252
+ handler(newVal) {
253
+ if (!this.range) {
254
+ this.time = newVal
255
+ } else {
256
+ this.timeRange.startTime = newVal.start
257
+ this.timeRange.endTime = newVal.end
258
+ }
259
+ }
260
+ },
261
+ startDate(val) {
262
+ // 字节小程序 watch 早于 created
263
+ if(!this.cale){
264
+ return
265
+ }
266
+ this.cale.setStartDate(val)
267
+ this.cale.setDate(this.nowDate.fullDate)
268
+ this.weeks = this.cale.weeks
269
+ },
270
+ endDate(val) {
271
+ // 字节小程序 watch 早于 created
272
+ if(!this.cale){
273
+ return
274
+ }
275
+ this.cale.setEndDate(val)
276
+ this.cale.setDate(this.nowDate.fullDate)
277
+ this.weeks = this.cale.weeks
278
+ },
279
+ selected(newVal) {
280
+ // 字节小程序 watch 早于 created
281
+ if(!this.cale){
282
+ return
283
+ }
284
+ this.cale.setSelectInfo(this.nowDate.fullDate, newVal)
285
+ this.weeks = this.cale.weeks
286
+ },
287
+ pleStatus: {
288
+ immediate: true,
289
+ handler(newVal) {
290
+ const {
291
+ before,
292
+ after,
293
+ fulldate,
294
+ which
295
+ } = newVal
296
+ this.tempRange.before = before
297
+ this.tempRange.after = after
298
+ setTimeout(() => {
299
+ if (fulldate) {
300
+ this.cale.setHoverMultiple(fulldate)
301
+ if (before && after) {
302
+ this.cale.lastHover = true
303
+ if (this.rangeWithinMonth(after, before)) return
304
+ this.setDate(before)
305
+ } else {
306
+ this.cale.setMultiple(fulldate)
307
+ this.setDate(this.nowDate.fullDate)
308
+ this.calendar.fullDate = ''
309
+ this.cale.lastHover = false
310
+ }
311
+ } else {
312
+ // 字节小程序 watch 早于 created
313
+ if(!this.cale){
314
+ return
315
+ }
316
+
317
+ this.cale.setDefaultMultiple(before, after)
318
+ if (which === 'left' && before) {
319
+ this.setDate(before)
320
+ this.weeks = this.cale.weeks
321
+ } else if(after) {
322
+ this.setDate(after)
323
+ this.weeks = this.cale.weeks
324
+ }
325
+ this.cale.lastHover = true
326
+ }
327
+ }, 16)
328
+ }
329
+ }
330
+ },
331
+ computed: {
332
+ timepickerStartTime() {
333
+ const activeDate = this.range ? this.tempRange.before : this.calendar.fullDate
334
+ return activeDate === this.startDate ? this.selectableTimes.start : ''
335
+ },
336
+ timepickerEndTime() {
337
+ const activeDate = this.range ? this.tempRange.after : this.calendar.fullDate
338
+ return activeDate === this.endDate ? this.selectableTimes.end : ''
339
+ },
340
+ /**
341
+ * for i18n
342
+ */
343
+ selectDateText() {
344
+ return t("uni-datetime-picker.selectDate")
345
+ },
346
+ startDateText() {
347
+ return this.startPlaceholder || t("uni-datetime-picker.startDate")
348
+ },
349
+ endDateText() {
350
+ return this.endPlaceholder || t("uni-datetime-picker.endDate")
351
+ },
352
+ okText() {
353
+ return t("uni-datetime-picker.ok")
354
+ },
355
+ yearText() {
356
+ return t("uni-datetime-picker.year")
357
+ },
358
+ monthText() {
359
+ return t("uni-datetime-picker.month")
360
+ },
361
+ MONText() {
362
+ return t("uni-calender.MON")
363
+ },
364
+ TUEText() {
365
+ return t("uni-calender.TUE")
366
+ },
367
+ WEDText() {
368
+ return t("uni-calender.WED")
369
+ },
370
+ THUText() {
371
+ return t("uni-calender.THU")
372
+ },
373
+ FRIText() {
374
+ return t("uni-calender.FRI")
375
+ },
376
+ SATText() {
377
+ return t("uni-calender.SAT")
378
+ },
379
+ SUNText() {
380
+ return t("uni-calender.SUN")
381
+ },
382
+ confirmText() {
383
+ return t("uni-calender.confirm")
384
+ },
385
+ },
386
+ created() {
387
+ // 获取日历方法实例
388
+ this.cale = new Calendar({
389
+ selected: this.selected,
390
+ startDate: this.startDate,
391
+ endDate: this.endDate,
392
+ range: this.range,
393
+ })
394
+ // 选中某一天
395
+ this.init(this.date)
396
+ },
397
+ methods: {
398
+ leaveCale() {
399
+ this.firstEnter = true
400
+ },
401
+ handleMouse(weeks) {
402
+ if (weeks.disable) return
403
+ if (this.cale.lastHover) return
404
+ let {
405
+ before,
406
+ after
407
+ } = this.cale.multipleStatus
408
+ if (!before) return
409
+ this.calendar = weeks
410
+ // 设置范围选
411
+ this.cale.setHoverMultiple(this.calendar.fullDate)
412
+ this.weeks = this.cale.weeks
413
+ // hover时,进入一个日历,更新另一个
414
+ if (this.firstEnter) {
415
+ this.$emit('firstEnterCale', this.cale.multipleStatus)
416
+ this.firstEnter = false
417
+ }
418
+ },
419
+ rangeWithinMonth(A, B) {
420
+ const [yearA, monthA] = A.split('-')
421
+ const [yearB, monthB] = B.split('-')
422
+ return yearA === yearB && monthA === monthB
423
+ },
424
+ // 蒙版点击事件
425
+ maskClick() {
426
+ this.close()
427
+ this.$emit('maskClose')
428
+ },
429
+
430
+ clearCalender() {
431
+ if (this.range) {
432
+ this.timeRange.startTime = ''
433
+ this.timeRange.endTime = ''
434
+ this.tempRange.before = ''
435
+ this.tempRange.after = ''
436
+ this.cale.multipleStatus.before = ''
437
+ this.cale.multipleStatus.after = ''
438
+ this.cale.multipleStatus.data = []
439
+ this.cale.lastHover = false
440
+ } else {
441
+ this.time = ''
442
+ this.tempSingleDate = ''
443
+ }
444
+ this.calendar.fullDate = ''
445
+ this.setDate(new Date())
446
+ },
447
+
448
+ bindDateChange(e) {
449
+ const value = e.detail.value + '-1'
450
+ this.setDate(value)
451
+ },
452
+ /**
453
+ * 初始化日期显示
454
+ * @param {Object} date
455
+ */
456
+ init(date) {
457
+ // 字节小程序 watch 早于 created
458
+ if(!this.cale){
459
+ return
460
+ }
461
+ this.cale.setDate(date || new Date())
462
+ this.weeks = this.cale.weeks
463
+ this.nowDate = this.cale.getInfo(date)
464
+ this.calendar = {...this.nowDate}
465
+ if(!date){
466
+ // 优化date为空默认不选中今天
467
+ this.calendar.fullDate = ''
468
+ if(this.defaultValue && !this.range){
469
+ // 暂时只支持移动端非范围选择
470
+ const defaultDate = new Date(this.defaultValue)
471
+ const fullDate = getDate(defaultDate)
472
+ const year = defaultDate.getFullYear()
473
+ const month = defaultDate.getMonth()+1
474
+ const date = defaultDate.getDate()
475
+ const day = defaultDate.getDay()
476
+ this.calendar = {
477
+ fullDate,
478
+ year,
479
+ month,
480
+ date,
481
+ day
482
+ },
483
+ this.tempSingleDate = fullDate
484
+ this.time = getTime(defaultDate, this.hideSecond)
485
+ }
486
+ }
487
+ },
488
+ /**
489
+ * 打开日历弹窗
490
+ */
491
+ open() {
492
+ // 弹窗模式并且清理数据
493
+ if (this.clearDate && !this.insert) {
494
+ this.cale.cleanMultipleStatus()
495
+ this.init(this.date)
496
+ }
497
+ this.show = true
498
+ this.$nextTick(() => {
499
+ setTimeout(() => {
500
+ this.aniMaskShow = true
501
+ }, 50)
502
+ })
503
+ },
504
+ /**
505
+ * 关闭日历弹窗
506
+ */
507
+ close() {
508
+ this.aniMaskShow = false
509
+ this.$nextTick(() => {
510
+ setTimeout(() => {
511
+ this.show = false
512
+ this.$emit('close')
513
+ }, 300)
514
+ })
515
+ },
516
+ /**
517
+ * 确认按钮
518
+ */
519
+ confirm() {
520
+ this.setEmit('confirm')
521
+ this.close()
522
+ },
523
+ /**
524
+ * 变化触发
525
+ */
526
+ change() {
527
+ if (!this.insert) return
528
+ this.setEmit('change')
529
+ },
530
+ /**
531
+ * 选择月份触发
532
+ */
533
+ monthSwitch() {
534
+ let {
535
+ year,
536
+ month
537
+ } = this.nowDate
538
+ this.$emit('monthSwitch', {
539
+ year,
540
+ month: Number(month)
541
+ })
542
+ },
543
+ /**
544
+ * 派发事件
545
+ * @param {Object} name
546
+ */
547
+ setEmit(name) {
548
+ if(!this.range){
549
+ if(!this.calendar.fullDate){
550
+ this.calendar = this.cale.getInfo(new Date())
551
+ this.tempSingleDate = this.calendar.fullDate
552
+ }
553
+ if(this.hasTime && !this.time) {
554
+ this.time = getTime(new Date(), this.hideSecond)
555
+ }
556
+ }
557
+ let {
558
+ year,
559
+ month,
560
+ date,
561
+ fullDate,
562
+ extraInfo
563
+ } = this.calendar
564
+ this.$emit(name, {
565
+ range: this.cale.multipleStatus,
566
+ year,
567
+ month,
568
+ date,
569
+ time: this.time,
570
+ timeRange: this.timeRange,
571
+ fulldate: fullDate,
572
+ extraInfo: extraInfo || {}
573
+ })
574
+ },
575
+ /**
576
+ * 选择天触发
577
+ * @param {Object} weeks
578
+ */
579
+ choiceDate(weeks) {
580
+ if (weeks.disable) return
581
+ this.calendar = weeks
582
+ this.calendar.userChecked = true
583
+ // 设置多选
584
+ this.cale.setMultiple(this.calendar.fullDate, true)
585
+ this.weeks = this.cale.weeks
586
+ this.tempSingleDate = this.calendar.fullDate
587
+ const beforeDate = new Date(this.cale.multipleStatus.before).getTime()
588
+ const afterDate = new Date(this.cale.multipleStatus.after).getTime()
589
+ if (beforeDate > afterDate && afterDate) {
590
+ this.tempRange.before = this.cale.multipleStatus.after
591
+ this.tempRange.after = this.cale.multipleStatus.before
592
+ } else {
593
+ this.tempRange.before = this.cale.multipleStatus.before
594
+ this.tempRange.after = this.cale.multipleStatus.after
595
+ }
596
+ this.change()
597
+ },
598
+ changeMonth(type) {
599
+ let newDate
600
+ if(type === 'pre') {
601
+ newDate = this.cale.getPreMonthObj(this.nowDate.fullDate).fullDate
602
+ } else if(type === 'next') {
603
+ newDate = this.cale.getNextMonthObj(this.nowDate.fullDate).fullDate
604
+ }
605
+
606
+ this.setDate(newDate)
607
+ this.monthSwitch()
608
+ },
609
+ /**
610
+ * 设置日期
611
+ * @param {Object} date
612
+ */
613
+ setDate(date) {
614
+ this.cale.setDate(date)
615
+ this.weeks = this.cale.weeks
616
+ this.nowDate = this.cale.getInfo(date)
617
+ }
618
+ }
619
+ }
620
+ </script>
621
+
622
+ <style lang="scss" >
623
+ $uni-primary: #007aff !default;
624
+
625
+ .uni-calendar {
626
+ /* #ifndef APP-NVUE */
627
+ display: flex;
628
+ /* #endif */
629
+ flex-direction: column;
630
+ }
631
+
632
+ .uni-calendar__mask {
633
+ position: fixed;
634
+ bottom: 0;
635
+ top: 0;
636
+ left: 0;
637
+ right: 0;
638
+ background-color: rgba(0, 0, 0, 0.4);
639
+ transition-property: opacity;
640
+ transition-duration: 0.3s;
641
+ opacity: 0;
642
+ /* #ifndef APP-NVUE */
643
+ z-index: 99;
644
+ /* #endif */
645
+ }
646
+
647
+ .uni-calendar--mask-show {
648
+ opacity: 1
649
+ }
650
+
651
+ .uni-calendar--fixed {
652
+ position: fixed;
653
+ bottom: calc(var(--window-bottom));
654
+ left: 0;
655
+ right: 0;
656
+ transition-property: transform;
657
+ transition-duration: 0.3s;
658
+ transform: translateY(460px);
659
+ /* #ifndef APP-NVUE */
660
+ z-index: 99;
661
+ /* #endif */
662
+ }
663
+
664
+ .uni-calendar--ani-show {
665
+ transform: translateY(0);
666
+ }
667
+
668
+ .uni-calendar__content {
669
+ background-color: #fff;
670
+ }
671
+
672
+ .uni-calendar__content-mobile {
673
+ border-top-left-radius: 10px;
674
+ border-top-right-radius: 10px;
675
+ box-shadow: 0px 0px 5px 3px rgba(0, 0, 0, 0.1);
676
+ }
677
+
678
+ .uni-calendar__header {
679
+ position: relative;
680
+ /* #ifndef APP-NVUE */
681
+ display: flex;
682
+ /* #endif */
683
+ flex-direction: row;
684
+ justify-content: center;
685
+ align-items: center;
686
+ height: 50px;
687
+ }
688
+
689
+ .uni-calendar__header-mobile {
690
+ padding: 10px;
691
+ padding-bottom: 0;
692
+ }
693
+
694
+ .uni-calendar--fixed-top {
695
+ /* #ifndef APP-NVUE */
696
+ display: flex;
697
+ /* #endif */
698
+ flex-direction: row;
699
+ justify-content: space-between;
700
+ border-top-color: rgba(0, 0, 0, 0.4);
701
+ border-top-style: solid;
702
+ border-top-width: 1px;
703
+ }
704
+
705
+ .uni-calendar--fixed-width {
706
+ width: 50px;
707
+ }
708
+
709
+ .uni-calendar__backtoday {
710
+ position: absolute;
711
+ right: 0;
712
+ top: 25rpx;
713
+ padding: 0 5px;
714
+ padding-left: 10px;
715
+ height: 25px;
716
+ line-height: 25px;
717
+ font-size: 12px;
718
+ border-top-left-radius: 25px;
719
+ border-bottom-left-radius: 25px;
720
+ color: #fff;
721
+ background-color: #f1f1f1;
722
+ }
723
+
724
+ .uni-calendar__header-text {
725
+ text-align: center;
726
+ width: 100px;
727
+ font-size: 15px;
728
+ color: #666;
729
+ }
730
+
731
+ .uni-calendar__button-text {
732
+ text-align: center;
733
+ width: 100px;
734
+ font-size: 14px;
735
+ color: $uni-primary;
736
+ /* #ifndef APP-NVUE */
737
+ letter-spacing: 3px;
738
+ /* #endif */
739
+ }
740
+
741
+ .uni-calendar__header-btn-box {
742
+ /* #ifndef APP-NVUE */
743
+ display: flex;
744
+ /* #endif */
745
+ flex-direction: row;
746
+ align-items: center;
747
+ justify-content: center;
748
+ width: 50px;
749
+ height: 50px;
750
+ }
751
+
752
+ .uni-calendar__header-btn {
753
+ width: 9px;
754
+ height: 9px;
755
+ border-left-color: #808080;
756
+ border-left-style: solid;
757
+ border-left-width: 1px;
758
+ border-top-color: #555555;
759
+ border-top-style: solid;
760
+ border-top-width: 1px;
761
+ }
762
+
763
+ .uni-calendar--left {
764
+ transform: rotate(-45deg);
765
+ }
766
+
767
+ .uni-calendar--right {
768
+ transform: rotate(135deg);
769
+ }
770
+
771
+
772
+ .uni-calendar__weeks {
773
+ position: relative;
774
+ /* #ifndef APP-NVUE */
775
+ display: flex;
776
+ /* #endif */
777
+ flex-direction: row;
778
+ }
779
+
780
+ .uni-calendar__weeks-item {
781
+ flex: 1;
782
+ }
783
+
784
+ .uni-calendar__weeks-day {
785
+ flex: 1;
786
+ /* #ifndef APP-NVUE */
787
+ display: flex;
788
+ /* #endif */
789
+ flex-direction: column;
790
+ justify-content: center;
791
+ align-items: center;
792
+ height: 40px;
793
+ border-bottom-color: #F5F5F5;
794
+ border-bottom-style: solid;
795
+ border-bottom-width: 1px;
796
+ }
797
+
798
+ .uni-calendar__weeks-day-text {
799
+ font-size: 12px;
800
+ color: #B2B2B2;
801
+ }
802
+
803
+ .uni-calendar__box {
804
+ position: relative;
805
+ // padding: 0 10px;
806
+ padding-bottom: 7px;
807
+ }
808
+
809
+ .uni-calendar__box-bg {
810
+ /* #ifndef APP-NVUE */
811
+ display: flex;
812
+ /* #endif */
813
+ justify-content: center;
814
+ align-items: center;
815
+ position: absolute;
816
+ top: 0;
817
+ left: 0;
818
+ right: 0;
819
+ bottom: 0;
820
+ }
821
+
822
+ .uni-calendar__box-bg-text {
823
+ font-size: 200px;
824
+ font-weight: bold;
825
+ color: #999;
826
+ opacity: 0.1;
827
+ text-align: center;
828
+ /* #ifndef APP-NVUE */
829
+ line-height: 1;
830
+ /* #endif */
831
+ }
832
+
833
+ .uni-date-changed {
834
+ padding: 0 10px;
835
+ // line-height: 50px;
836
+ text-align: center;
837
+ color: #333;
838
+ border-top-color: #DCDCDC;
839
+ ;
840
+ border-top-style: solid;
841
+ border-top-width: 1px;
842
+ flex: 1;
843
+ }
844
+
845
+ .uni-date-btn--ok {
846
+ padding: 20px 15px;
847
+ }
848
+
849
+ .uni-date-changed--time-start {
850
+ /* #ifndef APP-NVUE */
851
+ display: flex;
852
+ /* #endif */
853
+ align-items: center;
854
+ }
855
+
856
+ .uni-date-changed--time-end {
857
+ /* #ifndef APP-NVUE */
858
+ display: flex;
859
+ /* #endif */
860
+ align-items: center;
861
+ }
862
+
863
+ .uni-date-changed--time-date {
864
+ color: #999;
865
+ line-height: 50px;
866
+ /* #ifdef MP-TOUTIAO */
867
+ font-size: 16px;
868
+ /* #endif */
869
+ margin-right: 5px;
870
+ // opacity: 0.6;
871
+ }
872
+
873
+ .time-picker-style {
874
+ // width: 62px;
875
+ /* #ifndef APP-NVUE */
876
+ display: flex;
877
+ /* #endif */
878
+ justify-content: center;
879
+ align-items: center
880
+ }
881
+
882
+ .mr-10 {
883
+ margin-right: 10px;
884
+ }
885
+
886
+ .dialog-close {
887
+ position: absolute;
888
+ top: 0;
889
+ right: 0;
890
+ bottom: 0;
891
+ /* #ifndef APP-NVUE */
892
+ display: flex;
893
+ /* #endif */
894
+ flex-direction: row;
895
+ align-items: center;
896
+ padding: 0 25px;
897
+ margin-top: 10px;
898
+ }
899
+
900
+ .dialog-close-plus {
901
+ width: 16px;
902
+ height: 2px;
903
+ background-color: #737987;
904
+ border-radius: 2px;
905
+ transform: rotate(45deg);
906
+ }
907
+
908
+ .dialog-close-rotate {
909
+ position: absolute;
910
+ transform: rotate(-45deg);
911
+ }
912
+
913
+ .uni-datetime-picker--btn {
914
+ border-radius: 100px;
915
+ height: 40px;
916
+ line-height: 40px;
917
+ background-color: $uni-primary;
918
+ color: #fff;
919
+ font-size: 16px;
920
+ letter-spacing: 2px;
921
+ }
922
+
923
+ /* #ifndef APP-NVUE */
924
+ .uni-datetime-picker--btn:active {
925
+ opacity: 0.7;
926
+ }
927
+ /* #endif */
928
+ </style>