jufubao-forms 1.0.0-beta1

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 (70) hide show
  1. package/README.md +27 -0
  2. package/commands.js +84 -0
  3. package/commands.update.change.js +176 -0
  4. package/file.config.js +16 -0
  5. package/get.package.path.js +22 -0
  6. package/get.package.path.js.tpl +22 -0
  7. package/package.json +119 -0
  8. package/src/CreateClientID.js +16 -0
  9. package/src/ICONS.js +1148 -0
  10. package/src/common/authorize.js +261 -0
  11. package/src/common/getBusinessImageUrl.js +39 -0
  12. package/src/common/getServiceUrl.js +38 -0
  13. package/src/common/paysdk/jweixin.js +98 -0
  14. package/src/components/CusCouponChose/CusCouponChose.vue +1024 -0
  15. package/src/components/CusCouponItem/CusCouponItem.vue +298 -0
  16. package/src/components/CusEnter/CusEnter.vue +333 -0
  17. package/src/components/CusPoster/CusPoster.vue +213 -0
  18. package/src/components/CusPoster/CusSwiperDot.vue +234 -0
  19. package/src/components/CusProduct/CusProduct.vue +362 -0
  20. package/src/components/CusSwiperDot/CusSwiperDot.vue +234 -0
  21. package/src/components/CusTab/CusTab.vue +411 -0
  22. package/src/components/CusVideo/CusVideo.vue +170 -0
  23. package/src/components/JfbFormsDynamicForm/Api.js +66 -0
  24. package/src/components/JfbFormsDynamicForm/Attr.js +35 -0
  25. package/src/components/JfbFormsDynamicForm/JfbFormsDynamicForm.vue +767 -0
  26. package/src/components/JfbFormsDynamicForm/JfbFormsDynamicFormLess.less +79 -0
  27. package/src/components/JfbFormsDynamicForm/JfbFormsDynamicFormMixin.js +30 -0
  28. package/src/components/JfbFormsDynamicForm/Mock.js +194 -0
  29. package/src/components/JfbFormsDynamicForm/XdFormDate.vue +71 -0
  30. package/src/components/JfbFormsDynamicForm/ld-select/ld-select.vue +329 -0
  31. package/src/components/JfbFormsDynamicForm/uni-datetime-picker/calendar-item.vue +177 -0
  32. package/src/components/JfbFormsDynamicForm/uni-datetime-picker/calendar.vue +930 -0
  33. package/src/components/JfbFormsDynamicForm/uni-datetime-picker/i18n/en.json +22 -0
  34. package/src/components/JfbFormsDynamicForm/uni-datetime-picker/i18n/index.js +8 -0
  35. package/src/components/JfbFormsDynamicForm/uni-datetime-picker/i18n/zh-Hans.json +22 -0
  36. package/src/components/JfbFormsDynamicForm/uni-datetime-picker/i18n/zh-Hant.json +22 -0
  37. package/src/components/JfbFormsDynamicForm/uni-datetime-picker/time-picker.vue +934 -0
  38. package/src/components/JfbFormsDynamicForm/uni-datetime-picker/uni-datetime-picker.vue +1042 -0
  39. package/src/components/JfbFormsDynamicForm/uni-datetime-picker/util.js +403 -0
  40. package/src/components/JfbFormsList/Api.js +20 -0
  41. package/src/components/JfbFormsList/Attr.js +70 -0
  42. package/src/components/JfbFormsList/JfbFormsList.vue +228 -0
  43. package/src/components/JfbFormsList/JfbFormsListLess.less +79 -0
  44. package/src/components/JfbFormsList/JfbFormsListMixin.js +30 -0
  45. package/src/components/JfbFormsList/Mock.js +38 -0
  46. package/src/components/JfbFormsQuestionAndAnswer/Api.js +43 -0
  47. package/src/components/JfbFormsQuestionAndAnswer/Attr.js +14 -0
  48. package/src/components/JfbFormsQuestionAndAnswer/JfbFormsQuestionAndAnswer.vue +506 -0
  49. package/src/components/JfbFormsQuestionAndAnswer/JfbFormsQuestionAndAnswerLess.less +79 -0
  50. package/src/components/JfbFormsQuestionAndAnswer/JfbFormsQuestionAndAnswerMixin.js +30 -0
  51. package/src/components/JfbFormsQuestionAndAnswer/Mock.js +144 -0
  52. package/src/components/SkeProduct/SkeProduct.vue +241 -0
  53. package/src/config.app.plus.js +6 -0
  54. package/src/config.h5.js +13 -0
  55. package/src/config.mp.weixin.js +13 -0
  56. package/src/config.project.js +15 -0
  57. package/src/mixins/cardListMixins.js +187 -0
  58. package/src/mixins/colorCardMixins.js +122 -0
  59. package/src/mixins/componentsMixins.js +900 -0
  60. package/src/mixins/extsMixins.js +3 -0
  61. package/src/mixins/locationMixins.js +119 -0
  62. package/src/mixins/newLocaltionMixins.js +754 -0
  63. package/src/mixins/openDebuggerMixins.js +74 -0
  64. package/src/mixins/pageEditx.js +347 -0
  65. package/src/mixins/pageEvent.js +311 -0
  66. package/src/mixins/pageMain.js +120 -0
  67. package/src/mixins/pageUitls.js +738 -0
  68. package/src/mixins/posterMixins.js +122 -0
  69. package/src/mixins/scrollListFixedHeigthMixins.js +174 -0
  70. package/src/mocks.js +4 -0
@@ -0,0 +1,1042 @@
1
+ <template>
2
+ <view class="uni-date">
3
+ <view class="uni-date-editor" @click="show">
4
+ <slot>
5
+ <view
6
+ class="uni-date-editor--x"
7
+ :class="{'uni-date-editor--x__disabled': disabled,'uni-date-x--border': border}"
8
+ >
9
+ <view v-if="!isRange" class="uni-date-x uni-date-single">
10
+ <image src="//img6.jufubao.cn/common/form/icon_date.png" mode="widthFix" class="input_icon"></image>
11
+ <!-- <xd-font-icon class="icon-calendar" icon="iconriqi" color="#5C5C66"></xd-font-icon> -->
12
+ <view class="uni-date__x-input">{{ displayValue || singlePlaceholderText }}</view>
13
+ </view>
14
+
15
+ <view v-else class="uni-date-x uni-date-range">
16
+ <xd-font-icon class="icon-calendar" icon="iconriqi" color="#5C5C66"></xd-font-icon>
17
+ <view class="uni-date__x-input text-center">{{ displayRangeValue.startDate || startPlaceholderText }}</view>
18
+
19
+ <view class="range-separator">{{rangeSeparator}}</view>
20
+
21
+ <view class="uni-date__x-input text-center">{{ displayRangeValue.endDate || endPlaceholderText }}</view>
22
+ </view>
23
+
24
+ <view v-if="showClearIcon" class="uni-date__icon-clear" @click.stop="clear">
25
+ <xd-font-icon icon="clear" color="#c0c4cc" size="22"></xd-font-icon>
26
+ </view>
27
+ </view>
28
+ </slot>
29
+ </view>
30
+
31
+ <view v-show="pickerVisible" class="uni-date-mask--pc" @click="close"></view>
32
+
33
+ <view v-if="!isPhone" v-show="pickerVisible" ref="datePicker" class="uni-date-picker__container">
34
+ <view v-if="!isRange" class="uni-date-single--x" :style="pickerPositionStyle">
35
+ <view class="uni-popper__arrow"></view>
36
+
37
+ <view v-if="hasTime" class="uni-date-changed popup-x-header">
38
+ <input class="uni-date__input text-center" type="text" v-model="inputDate"
39
+ :placeholder="selectDateText" />
40
+
41
+ <time-picker type="time" v-model="pickerTime" :border="false" :disabled="!inputDate"
42
+ :start="timepickerStartTime" :end="timepickerEndTime" :hideSecond="hideSecond" style="width: 100%;">
43
+ <input class="uni-date__input text-center" type="text" v-model="pickerTime" :placeholder="selectTimeText"
44
+ :disabled="!inputDate" />
45
+ </time-picker>
46
+ </view>
47
+
48
+ <Calendar ref="pcSingle" :showMonth="false" :start-date="calendarRange.startDate"
49
+ :end-date="calendarRange.endDate" :date="calendarDate" @change="singleChange"
50
+ :default-value="defaultValue"
51
+ style="padding: 0 8px;" />
52
+
53
+ <view v-if="hasTime" class="popup-x-footer">
54
+ <text class="confirm-text" @click="confirmSingleChange">{{okText}}</text>
55
+ </view>
56
+ </view>
57
+
58
+ <view v-else class="uni-date-range--x" :style="pickerPositionStyle">
59
+ <view class="uni-popper__arrow"></view>
60
+ <view v-if="hasTime" class="popup-x-header uni-date-changed">
61
+ <view class="popup-x-header--datetime">
62
+ <input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.startDate"
63
+ :placeholder="startDateText" />
64
+
65
+ <time-picker type="time" v-model="tempRange.startTime" :start="timepickerStartTime" :border="false"
66
+ :disabled="!tempRange.startDate" :hideSecond="hideSecond">
67
+ <input class="uni-date__input uni-date-range__input" type="text"
68
+ v-model="tempRange.startTime" :placeholder="startTimeText"
69
+ :disabled="!tempRange.startDate" />
70
+ </time-picker>
71
+ </view>
72
+
73
+ <xd-font-icon icon="arrowthinright" color="#999" style="line-height: 40px;"></xd-font-icon>
74
+
75
+ <view class="popup-x-header--datetime">
76
+ <input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.endDate"
77
+ :placeholder="endDateText" />
78
+
79
+ <time-picker type="time" v-model="tempRange.endTime" :end="timepickerEndTime" :border="false"
80
+ :disabled="!tempRange.endDate" :hideSecond="hideSecond">
81
+ <input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.endTime"
82
+ :placeholder="endTimeText" :disabled="!tempRange.endDate" />
83
+ </time-picker>
84
+ </view>
85
+ </view>
86
+
87
+ <view class="popup-x-body">
88
+ <Calendar ref="left" :showMonth="false" :start-date="calendarRange.startDate"
89
+ :end-date="calendarRange.endDate" :range="true" :pleStatus="endMultipleStatus"
90
+ @change="leftChange" @firstEnterCale="updateRightCale" style="padding: 0 8px;" />
91
+ <Calendar ref="right" :showMonth="false" :start-date="calendarRange.startDate"
92
+ :end-date="calendarRange.endDate" :range="true" @change="rightChange"
93
+ :pleStatus="startMultipleStatus" @firstEnterCale="updateLeftCale"
94
+ style="padding: 0 8px;border-left: 1px solid #F1F1F1;" />
95
+ </view>
96
+
97
+ <view v-if="hasTime" class="popup-x-footer">
98
+ <text @click="clear">{{clearText}}</text>
99
+ <text class="confirm-text" @click="confirmRangeChange">{{okText}}</text>
100
+ </view>
101
+ </view>
102
+ </view>
103
+
104
+ <Calendar v-if="isPhone" ref="mobile" :clearDate="false" :date="calendarDate" :defTime="mobileCalendarTime"
105
+ :start-date="calendarRange.startDate" :end-date="calendarRange.endDate" :selectableTimes="mobSelectableTime"
106
+ :startPlaceholder="startPlaceholder" :endPlaceholder="endPlaceholder"
107
+ :default-value="defaultValue"
108
+ :pleStatus="endMultipleStatus" :showMonth="false" :range="isRange" :hasTime="hasTime" :insert="false"
109
+ :hideSecond="hideSecond" @confirm="mobileChange" @maskClose="close" />
110
+ </view>
111
+ </template>
112
+ <script>
113
+ /**
114
+ * DatetimePicker 时间选择器
115
+ * @description 同时支持 PC 和移动端使用日历选择日期和日期范围
116
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=3962
117
+ * @property {String} type 选择器类型
118
+ * @property {String|Number|Array|Date} value 绑定值
119
+ * @property {String} placeholder 单选择时的占位内容
120
+ * @property {String} start 起始时间
121
+ * @property {String} end 终止时间
122
+ * @property {String} start-placeholder 范围选择时开始日期的占位内容
123
+ * @property {String} end-placeholder 范围选择时结束日期的占位内容
124
+ * @property {String} range-separator 选择范围时的分隔符
125
+ * @property {Boolean} border = [true|false] 是否有边框
126
+ * @property {Boolean} disabled = [true|false] 是否禁用
127
+ * @property {Boolean} clearIcon = [true|false] 是否显示清除按钮(仅PC端适用)
128
+ * @property {[String} defaultValue 选择器打开时默认显示的时间
129
+ * @event {Function} change 确定日期时触发的事件
130
+ * @event {Function} maskClick 点击遮罩层触发的事件
131
+ * @event {Function} show 打开弹出层
132
+ * @event {Function} close 关闭弹出层
133
+ * @event {Function} clear 清除上次选中的状态和值
134
+ **/
135
+ import Calendar from './calendar.vue'
136
+ import TimePicker from './time-picker.vue'
137
+ import { initVueI18n } from '@dcloudio/uni-i18n'
138
+ import i18nMessages from './i18n/index.js'
139
+ import XdFontIcon from "@/components/XdFontIcon/XdFontIcon"
140
+ import { getDateTime, getDate, getTime, getDefaultSecond, dateCompare, checkDate, fixIosDateFormat } from './util'
141
+
142
+ export default {
143
+ name: 'UniDatetimePicker',
144
+ options: {
145
+ virtualHost: true
146
+ },
147
+ components: {
148
+ Calendar,
149
+ TimePicker,
150
+ XdFontIcon
151
+ },
152
+ data() {
153
+ return {
154
+ isRange: false,
155
+ hasTime: false,
156
+ displayValue: '',
157
+ inputDate: '',
158
+ calendarDate: '',
159
+ pickerTime: '',
160
+ calendarRange: {
161
+ startDate: '',
162
+ startTime: '',
163
+ endDate: '',
164
+ endTime: ''
165
+ },
166
+ displayRangeValue: {
167
+ startDate: '',
168
+ endDate: '',
169
+ },
170
+ tempRange: {
171
+ startDate: '',
172
+ startTime: '',
173
+ endDate: '',
174
+ endTime: ''
175
+ },
176
+ // 左右日历同步数据
177
+ startMultipleStatus: {
178
+ before: '',
179
+ after: '',
180
+ data: [],
181
+ fulldate: ''
182
+ },
183
+ endMultipleStatus: {
184
+ before: '',
185
+ after: '',
186
+ data: [],
187
+ fulldate: ''
188
+ },
189
+ pickerVisible: false,
190
+ pickerPositionStyle: null,
191
+ isEmitValue: false,
192
+ isPhone: false,
193
+ isFirstShow: true,
194
+ i18nT: () => {}
195
+ }
196
+ },
197
+ props: {
198
+ type: {
199
+ type: String,
200
+ default: 'datetime'
201
+ },
202
+ value: {
203
+ type: [String, Number, Array, Date],
204
+ default: ''
205
+ },
206
+ modelValue: {
207
+ type: [String, Number, Array, Date],
208
+ default: ''
209
+ },
210
+ start: {
211
+ type: [Number, String],
212
+ default: ''
213
+ },
214
+ end: {
215
+ type: [Number, String],
216
+ default: ''
217
+ },
218
+ returnType: {
219
+ type: String,
220
+ default: 'string'
221
+ },
222
+ placeholder: {
223
+ type: String,
224
+ default: ''
225
+ },
226
+ startPlaceholder: {
227
+ type: String,
228
+ default: ''
229
+ },
230
+ endPlaceholder: {
231
+ type: String,
232
+ default: ''
233
+ },
234
+ rangeSeparator: {
235
+ type: String,
236
+ default: '-'
237
+ },
238
+ border: {
239
+ type: [Boolean],
240
+ default: true
241
+ },
242
+ disabled: {
243
+ type: [Boolean],
244
+ default: false
245
+ },
246
+ clearIcon: {
247
+ type: [Boolean],
248
+ default: true
249
+ },
250
+ hideSecond: {
251
+ type: [Boolean],
252
+ default: false
253
+ },
254
+ defaultValue: {
255
+ type: [String, Object, Array],
256
+ default: ''
257
+ }
258
+ },
259
+ watch: {
260
+ type: {
261
+ immediate: true,
262
+ handler(newVal) {
263
+ this.hasTime = newVal.indexOf('time') !== -1
264
+ this.isRange = newVal.indexOf('range') !== -1
265
+ }
266
+ },
267
+ // #ifndef VUE3
268
+ value: {
269
+ immediate: true,
270
+ handler(newVal) {
271
+ if (this.isEmitValue) {
272
+ this.isEmitValue = false
273
+ return
274
+ }
275
+ this.initPicker(newVal)
276
+ }
277
+ },
278
+ // #endif
279
+ // #ifdef VUE3
280
+ modelValue: {
281
+ immediate: true,
282
+ handler(newVal) {
283
+ if (this.isEmitValue) {
284
+ this.isEmitValue = false
285
+ return
286
+ }
287
+ this.initPicker(newVal)
288
+ }
289
+ },
290
+ // #endif
291
+ start: {
292
+ immediate: true,
293
+ handler(newVal) {
294
+ if (!newVal) return
295
+ this.calendarRange.startDate = getDate(newVal)
296
+ if (this.hasTime) {
297
+ this.calendarRange.startTime = getTime(newVal)
298
+ }
299
+ }
300
+ },
301
+ end: {
302
+ immediate: true,
303
+ handler(newVal) {
304
+ if (!newVal) return
305
+ this.calendarRange.endDate = getDate(newVal)
306
+ if (this.hasTime) {
307
+ this.calendarRange.endTime = getTime(newVal, this.hideSecond)
308
+ }
309
+ }
310
+ },
311
+ },
312
+ computed: {
313
+ timepickerStartTime() {
314
+ const activeDate = this.isRange ? this.tempRange.startDate : this.inputDate
315
+ return activeDate === this.calendarRange.startDate ? this.calendarRange.startTime : ''
316
+ },
317
+ timepickerEndTime() {
318
+ const activeDate = this.isRange ? this.tempRange.endDate : this.inputDate
319
+ return activeDate === this.calendarRange.endDate ? this.calendarRange.endTime : ''
320
+ },
321
+ mobileCalendarTime() {
322
+ const timeRange = {
323
+ start: this.tempRange.startTime,
324
+ end: this.tempRange.endTime
325
+ }
326
+ return this.isRange ? timeRange : this.pickerTime
327
+ },
328
+ mobSelectableTime() {
329
+ return {
330
+ start: this.calendarRange.startTime,
331
+ end: this.calendarRange.endTime
332
+ }
333
+ },
334
+ datePopupWidth() {
335
+ // todo
336
+ return this.isRange ? 653 : 301
337
+ },
338
+
339
+ /**
340
+ * for i18n
341
+ */
342
+ singlePlaceholderText() {
343
+ return this.placeholder || (this.type === 'date' ? this.selectDateText : this.selectDateTimeText)
344
+ },
345
+ startPlaceholderText() {
346
+ return this.startPlaceholder || this.startDateText
347
+ },
348
+ endPlaceholderText() {
349
+ return this.endPlaceholder || this.endDateText
350
+ },
351
+ selectDateText() {
352
+ return this.i18nT("uni-datetime-picker.selectDate")
353
+ },
354
+ selectDateTimeText() {
355
+ return this.i18nT("uni-datetime-picker.selectDateTime")
356
+ },
357
+ selectTimeText() {
358
+ return this.i18nT("uni-datetime-picker.selectTime")
359
+ },
360
+ startDateText() {
361
+ return this.startPlaceholder || this.i18nT("uni-datetime-picker.startDate")
362
+ },
363
+ startTimeText() {
364
+ return this.i18nT("uni-datetime-picker.startTime")
365
+ },
366
+ endDateText() {
367
+ return this.endPlaceholder || this.i18nT("uni-datetime-picker.endDate")
368
+ },
369
+ endTimeText() {
370
+ return this.i18nT("uni-datetime-picker.endTime")
371
+ },
372
+ okText() {
373
+ return this.i18nT("uni-datetime-picker.ok")
374
+ },
375
+ clearText() {
376
+ return this.i18nT("uni-datetime-picker.clear")
377
+ },
378
+ showClearIcon() {
379
+ return this.clearIcon && !this.disabled && (this.displayValue || (this.displayRangeValue.startDate && this.displayRangeValue.endDate))
380
+ }
381
+ },
382
+ created() {
383
+ this.initI18nT()
384
+ this.platform()
385
+ },
386
+ methods: {
387
+ initI18nT() {
388
+ const vueI18n = initVueI18n(i18nMessages)
389
+ this.i18nT = vueI18n.t
390
+ },
391
+ initPicker(newVal) {
392
+ if ((!newVal && !this.defaultValue) || Array.isArray(newVal) && !newVal.length) {
393
+ this.$nextTick(() => {
394
+ this.clear(false)
395
+ })
396
+ return
397
+ }
398
+
399
+ if (!Array.isArray(newVal) && !this.isRange) {
400
+ if(newVal){
401
+ this.displayValue = this.inputDate = this.calendarDate = getDate(newVal)
402
+ if (this.hasTime) {
403
+ this.pickerTime = getTime(newVal, this.hideSecond)
404
+ this.displayValue = `${this.displayValue} ${this.pickerTime}`
405
+ }
406
+ }else if(this.defaultValue){
407
+ this.inputDate = this.calendarDate = getDate(this.defaultValue)
408
+ if(this.hasTime){
409
+ this.pickerTime = getTime(this.defaultValue, this.hideSecond)
410
+ }
411
+ }
412
+ } else {
413
+ const [before, after] = newVal
414
+ if (!before && !after) return
415
+ const beforeDate = getDate(before)
416
+ const beforeTime = getTime(before, this.hideSecond)
417
+
418
+ const afterDate = getDate(after)
419
+ const afterTime = getTime(after, this.hideSecond)
420
+ const startDate = beforeDate
421
+ const endDate = afterDate
422
+ this.displayRangeValue.startDate = this.tempRange.startDate = startDate
423
+ this.displayRangeValue.endDate = this.tempRange.endDate = endDate
424
+
425
+ if (this.hasTime) {
426
+ this.displayRangeValue.startDate = `${beforeDate} ${beforeTime}`
427
+ this.displayRangeValue.endDate = `${afterDate} ${afterTime}`
428
+ this.tempRange.startTime = beforeTime
429
+ this.tempRange.endTime = afterTime
430
+ }
431
+ const defaultRange = {
432
+ before: beforeDate,
433
+ after: afterDate
434
+ }
435
+ this.startMultipleStatus = Object.assign({}, this.startMultipleStatus, defaultRange, {
436
+ which: 'right'
437
+ })
438
+ this.endMultipleStatus = Object.assign({}, this.endMultipleStatus, defaultRange, {
439
+ which: 'left'
440
+ })
441
+ }
442
+ },
443
+ updateLeftCale(e) {
444
+ const left = this.$refs.left
445
+ // 设置范围选
446
+ left.cale.setHoverMultiple(e.after)
447
+ left.setDate(this.$refs.left.nowDate.fullDate)
448
+ },
449
+ updateRightCale(e) {
450
+ const right = this.$refs.right
451
+ // 设置范围选
452
+ right.cale.setHoverMultiple(e.after)
453
+ right.setDate(this.$refs.right.nowDate.fullDate)
454
+ },
455
+ platform() {
456
+ if(typeof navigator !== "undefined"){
457
+ this.isPhone = navigator.userAgent.toLowerCase().indexOf('mobile') !== -1
458
+ return
459
+ }
460
+ const { windowWidth } = uni.getSystemInfoSync()
461
+ this.isPhone = windowWidth <= 500
462
+ this.windowWidth = windowWidth
463
+ },
464
+ show() {
465
+ if (this.disabled) {
466
+ return
467
+ }
468
+ this.platform()
469
+ if (this.isPhone) {
470
+ setTimeout(() => {
471
+ this.$refs.mobile.open()
472
+ }, 0);
473
+ return
474
+ }
475
+ this.pickerPositionStyle = {
476
+ top: '10px'
477
+ }
478
+ const dateEditor = uni.createSelectorQuery().in(this).select(".uni-date-editor")
479
+ dateEditor.boundingClientRect(rect => {
480
+ if (this.windowWidth - rect.left < this.datePopupWidth) {
481
+ this.pickerPositionStyle.right = 0
482
+ }
483
+ }).exec()
484
+ setTimeout(() => {
485
+ this.pickerVisible = !this.pickerVisible
486
+ if (!this.isPhone && this.isRange && this.isFirstShow) {
487
+ this.isFirstShow = false
488
+ const {
489
+ startDate,
490
+ endDate
491
+ } = this.calendarRange
492
+ if (startDate && endDate) {
493
+ if (this.diffDate(startDate, endDate) < 30) {
494
+ this.$refs.right.changeMonth('pre')
495
+ }
496
+ } else {
497
+ this.$refs.right.changeMonth('next')
498
+ if(this.isPhone){
499
+ this.$refs.right.cale.lastHover = false;
500
+ }
501
+ }
502
+ }
503
+
504
+ }, 50)
505
+ },
506
+ close() {
507
+ setTimeout(() => {
508
+ this.pickerVisible = false
509
+ this.$emit('maskClick', this.value)
510
+ this.$refs.mobile && this.$refs.mobile.close()
511
+ }, 20)
512
+ },
513
+ setEmit(value) {
514
+ if (this.returnType === "timestamp" || this.returnType === "date") {
515
+ if (!Array.isArray(value)) {
516
+ if (!this.hasTime) {
517
+ value = value + ' ' + '00:00:00'
518
+ }
519
+ value = this.createTimestamp(value)
520
+ if (this.returnType === "date") {
521
+ value = new Date(value)
522
+ }
523
+ } else {
524
+ if (!this.hasTime) {
525
+ value[0] = value[0] + ' ' + '00:00:00'
526
+ value[1] = value[1] + ' ' + '00:00:00'
527
+ }
528
+ value[0] = this.createTimestamp(value[0])
529
+ value[1] = this.createTimestamp(value[1])
530
+ if (this.returnType === "date") {
531
+ value[0] = new Date(value[0])
532
+ value[1] = new Date(value[1])
533
+ }
534
+ }
535
+ }
536
+
537
+ this.$emit('update:modelValue', value)
538
+ this.$emit('input', value)
539
+ this.$emit('change', value)
540
+ this.isEmitValue = true
541
+ },
542
+ createTimestamp(date) {
543
+ date = fixIosDateFormat(date)
544
+ return Date.parse(new Date(date))
545
+ },
546
+ singleChange(e) {
547
+ this.calendarDate = this.inputDate = e.fulldate
548
+ if (this.hasTime) return
549
+ this.confirmSingleChange()
550
+ },
551
+ confirmSingleChange() {
552
+ if(!checkDate(this.inputDate)){
553
+ const now = new Date()
554
+ this.calendarDate = this.inputDate = getDate(now)
555
+ this.pickerTime = getTime(now, this.hideSecond)
556
+ }
557
+
558
+ let startLaterInputDate = false
559
+ let startDate, startTime
560
+ if(this.start) {
561
+ let startString = this.start
562
+ if(typeof this.start === 'number'){
563
+ startString = getDateTime(this.start, this.hideSecond)
564
+ }
565
+ [startDate, startTime] = startString.split(' ')
566
+ if(this.start && !dateCompare(startDate, this.inputDate)) {
567
+ startLaterInputDate = true
568
+ this.inputDate = startDate
569
+ }
570
+ }
571
+
572
+ let endEarlierInputDate = false
573
+ let endDate, endTime
574
+ if(this.end) {
575
+ let endString = this.end
576
+ if(typeof this.end === 'number'){
577
+ endString = getDateTime(this.end, this.hideSecond)
578
+ }
579
+ [endDate, endTime] = endString.split(' ')
580
+ if(this.end && !dateCompare(this.inputDate, endDate)) {
581
+ endEarlierInputDate = true
582
+ this.inputDate = endDate
583
+ }
584
+ }
585
+ if (this.hasTime) {
586
+ if(startLaterInputDate){
587
+ this.pickerTime = startTime || getDefaultSecond(this.hideSecond)
588
+ }
589
+ if(endEarlierInputDate){
590
+ this.pickerTime = endTime || getDefaultSecond(this.hideSecond)
591
+ }
592
+ if(!this.pickerTime){
593
+ this.pickerTime = getTime(Date.now(), this.hideSecond)
594
+ }
595
+ this.displayValue = `${this.inputDate} ${this.pickerTime}`
596
+ } else {
597
+ this.displayValue = this.inputDate
598
+ }
599
+ this.setEmit(this.displayValue)
600
+ this.pickerVisible = false
601
+ },
602
+ leftChange(e) {
603
+ const {
604
+ before,
605
+ after
606
+ } = e.range
607
+ this.rangeChange(before, after)
608
+ const obj = {
609
+ before: e.range.before,
610
+ after: e.range.after,
611
+ data: e.range.data,
612
+ fulldate: e.fulldate
613
+ }
614
+ this.startMultipleStatus = Object.assign({}, this.startMultipleStatus, obj)
615
+ },
616
+ rightChange(e) {
617
+ const {
618
+ before,
619
+ after
620
+ } = e.range
621
+ this.rangeChange(before, after)
622
+ const obj = {
623
+ before: e.range.before,
624
+ after: e.range.after,
625
+ data: e.range.data,
626
+ fulldate: e.fulldate
627
+ }
628
+ this.endMultipleStatus = Object.assign({}, this.endMultipleStatus, obj)
629
+ },
630
+ mobileChange(e) {
631
+ if (this.isRange) {
632
+ const {before, after} = e.range
633
+
634
+ if(!before || !after){
635
+ return
636
+ }
637
+
638
+ this.handleStartAndEnd(before, after, true)
639
+ if (this.hasTime) {
640
+ const {
641
+ startTime,
642
+ endTime
643
+ } = e.timeRange
644
+ this.tempRange.startTime = startTime
645
+ this.tempRange.endTime = endTime
646
+ }
647
+ this.confirmRangeChange()
648
+ } else {
649
+ if (this.hasTime) {
650
+ this.displayValue = e.fulldate + ' ' + e.time
651
+ } else {
652
+ this.displayValue = e.fulldate
653
+ }
654
+ this.setEmit(this.displayValue)
655
+ }
656
+ this.$refs.mobile.close()
657
+ },
658
+ rangeChange(before, after) {
659
+ if (!(before && after)) return
660
+ this.handleStartAndEnd(before, after, true)
661
+ if (this.hasTime) return
662
+ this.confirmRangeChange()
663
+ },
664
+ confirmRangeChange() {
665
+ if (!this.tempRange.startDate || !this.tempRange.endDate) {
666
+ this.pickerVisible = false
667
+ return
668
+ }
669
+ if(!checkDate(this.tempRange.startDate)){
670
+ this.tempRange.startDate = getDate(Date.now())
671
+ }
672
+ if(!checkDate(this.tempRange.endDate)){
673
+ this.tempRange.endDate = getDate(Date.now())
674
+ }
675
+
676
+ let start, end
677
+
678
+ let startDateLaterRangeStartDate = false
679
+ let startDateLaterRangeEndDate = false
680
+ let startDate, startTime
681
+ if(this.start) {
682
+ let startString = this.start
683
+ if(typeof this.start === 'number'){
684
+ startString = getDateTime(this.start, this.hideSecond)
685
+ }
686
+ [startDate,startTime] = startString.split(' ')
687
+ if(this.start && !dateCompare(this.start, this.tempRange.startDate)) {
688
+ startDateLaterRangeStartDate = true
689
+ this.tempRange.startDate = startDate
690
+ }
691
+ if(this.start && !dateCompare(this.start, this.tempRange.endDate)) {
692
+ startDateLaterRangeEndDate = true
693
+ this.tempRange.endDate = startDate
694
+ }
695
+ }
696
+ let endDateEarlierRangeStartDate = false
697
+ let endDateEarlierRangeEndDate = false
698
+ let endDate, endTime
699
+ if(this.end) {
700
+ let endString = this.end
701
+ if(typeof this.end === 'number'){
702
+ endString = getDateTime(this.end, this.hideSecond)
703
+ }
704
+ [endDate,endTime] = endString.split(' ')
705
+
706
+ if(this.end && !dateCompare(this.tempRange.startDate, this.end)) {
707
+ endDateEarlierRangeStartDate = true
708
+ this.tempRange.startDate = endDate
709
+ }
710
+ if(this.end && !dateCompare(this.tempRange.endDate, this.end)) {
711
+ endDateEarlierRangeEndDate = true
712
+ this.tempRange.endDate = endDate
713
+ }
714
+ }
715
+ if (!this.hasTime) {
716
+ start = this.displayRangeValue.startDate = this.tempRange.startDate
717
+ end = this.displayRangeValue.endDate = this.tempRange.endDate
718
+ } else {
719
+ if(startDateLaterRangeStartDate){
720
+ this.tempRange.startTime = startTime || getDefaultSecond(this.hideSecond)
721
+ }else if(endDateEarlierRangeStartDate){
722
+ this.tempRange.startTime = endTime || getDefaultSecond(this.hideSecond)
723
+ }
724
+ if(!this.tempRange.startTime){
725
+ this.tempRange.startTime = getTime(Date.now(), this.hideSecond)
726
+ }
727
+
728
+ if(startDateLaterRangeEndDate){
729
+ this.tempRange.endTime = startTime || getDefaultSecond(this.hideSecond)
730
+ }else if(endDateEarlierRangeEndDate){
731
+ this.tempRange.endTime = endTime || getDefaultSecond(this.hideSecond)
732
+ }
733
+ if(!this.tempRange.endTime){
734
+ this.tempRange.endTime = getTime(Date.now(), this.hideSecond)
735
+ }
736
+ start = this.displayRangeValue.startDate = `${this.tempRange.startDate} ${this.tempRange.startTime}`
737
+ end = this.displayRangeValue.endDate = `${this.tempRange.endDate} ${this.tempRange.endTime}`
738
+ }
739
+ if(!dateCompare(start,end)){
740
+ [start, end] = [end, start]
741
+ }
742
+ this.displayRangeValue.startDate = start
743
+ this.displayRangeValue.endDate = end
744
+ const displayRange = [start, end]
745
+ this.setEmit(displayRange)
746
+ this.pickerVisible = false
747
+ },
748
+ handleStartAndEnd(before, after, temp = false) {
749
+ if (!(before && after)) return
750
+
751
+ const type = temp ? 'tempRange' : 'range'
752
+ const isStartEarlierEnd = dateCompare(before, after)
753
+ this[type].startDate = isStartEarlierEnd ? before : after
754
+ this[type].endDate = isStartEarlierEnd ? after : before
755
+ },
756
+ /**
757
+ * 比较时间大小
758
+ */
759
+ dateCompare(startDate, endDate) {
760
+ // 计算截止时间
761
+ startDate = new Date(startDate.replace('-', '/').replace('-', '/'))
762
+ // 计算详细项的截止时间
763
+ endDate = new Date(endDate.replace('-', '/').replace('-', '/'))
764
+ return startDate <= endDate
765
+ },
766
+
767
+ /**
768
+ * 比较时间差
769
+ */
770
+ diffDate(startDate, endDate) {
771
+ // 计算截止时间
772
+ startDate = new Date(startDate.replace('-', '/').replace('-', '/'))
773
+ // 计算详细项的截止时间
774
+ endDate = new Date(endDate.replace('-', '/').replace('-', '/'))
775
+ const diff = (endDate - startDate) / (24 * 60 * 60 * 1000)
776
+ return Math.abs(diff)
777
+ },
778
+
779
+ clear(needEmit = true) {
780
+ if (!this.isRange) {
781
+ this.displayValue = ''
782
+ this.inputDate = ''
783
+ this.pickerTime = ''
784
+ if (this.isPhone) {
785
+ this.$refs.mobile && this.$refs.mobile.clearCalender()
786
+ } else {
787
+ this.$refs.pcSingle && this.$refs.pcSingle.clearCalender()
788
+ }
789
+ if (needEmit) {
790
+ this.$emit('change', '')
791
+ this.$emit('input', '')
792
+ this.$emit('update:modelValue', '')
793
+ }
794
+ } else {
795
+ this.displayRangeValue.startDate = ''
796
+ this.displayRangeValue.endDate = ''
797
+ this.tempRange.startDate = ''
798
+ this.tempRange.startTime = ''
799
+ this.tempRange.endDate = ''
800
+ this.tempRange.endTime = ''
801
+ if (this.isPhone) {
802
+ this.$refs.mobile && this.$refs.mobile.clearCalender()
803
+ } else {
804
+ this.$refs.left && this.$refs.left.clearCalender()
805
+ this.$refs.right && this.$refs.right.clearCalender()
806
+ this.$refs.right && this.$refs.right.changeMonth('next')
807
+ }
808
+ if (needEmit) {
809
+ this.$emit('change', [])
810
+ this.$emit('input', [])
811
+ this.$emit('update:modelValue', [])
812
+ }
813
+ }
814
+ }
815
+ }
816
+ }
817
+ </script>
818
+
819
+ <style lang="scss">
820
+ $uni-primary: #007aff !default;
821
+
822
+ .uni-date {
823
+ width: 100%;
824
+ flex: 1;
825
+ }
826
+ .uni-date-x {
827
+ display: flex;
828
+ flex-direction: row;
829
+ align-items: center;
830
+ justify-content: center;
831
+ border-radius: 4px;
832
+ background-color: #fff;
833
+ color: #666;
834
+ font-size: 14px;
835
+ flex: 1;
836
+
837
+ .icon-calendar{
838
+ // padding-left: 3px;
839
+ }
840
+ .range-separator{
841
+ height: 35px;
842
+ /* #ifndef MP */
843
+ padding: 0 2px;
844
+ /* #endif */
845
+ line-height: 35px;
846
+ }
847
+ }
848
+
849
+ .uni-date-x--border {
850
+ box-sizing: border-box;
851
+ border-radius: 4px;
852
+ border: 1px solid #e5e5e5;
853
+ }
854
+
855
+ .uni-date-editor--x {
856
+ display: flex;
857
+ align-items: center;
858
+ position: relative;
859
+ }
860
+
861
+ .uni-date-editor--x .uni-date__icon-clear {
862
+ padding-right: 3px;
863
+ display: flex;
864
+ align-items: center;
865
+ /* #ifdef H5 */
866
+ cursor: pointer;
867
+ /* #endif */
868
+ }
869
+
870
+ .uni-date__x-input {
871
+ width: auto;
872
+ height: 35px;
873
+ /* #ifndef MP */
874
+ padding-left: 20rpx;
875
+ /* #endif */
876
+ position: relative;
877
+ flex: 1;
878
+ line-height: 35px;
879
+ font-size: 14px;
880
+ overflow: hidden;
881
+ }
882
+
883
+ .text-center {
884
+ text-align: center;
885
+ }
886
+
887
+ .uni-date__input {
888
+ height: 40px;
889
+ width: 100%;
890
+ line-height: 40px;
891
+ font-size: 14px;
892
+ }
893
+
894
+ .uni-date-range__input {
895
+ text-align: center;
896
+ max-width: 142px;
897
+ }
898
+
899
+ .uni-date-picker__container {
900
+ position: relative;
901
+ }
902
+
903
+ .uni-date-mask--pc {
904
+ position: fixed;
905
+ bottom: 0px;
906
+ top: 0px;
907
+ left: 0px;
908
+ right: 0px;
909
+ background-color: rgba(0, 0, 0, 0);
910
+ transition-duration: 0.3s;
911
+ z-index: 996;
912
+ }
913
+ .input_icon{
914
+ width: 48rpx;
915
+ image{
916
+ width: 100%;
917
+ }
918
+ }
919
+ .uni-date-single--x {
920
+ background-color: #fff;
921
+ position: absolute;
922
+ top: 0;
923
+ z-index: 999;
924
+ border: 1px solid #EBEEF5;
925
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
926
+ border-radius: 4px;
927
+ }
928
+
929
+ .uni-date-range--x {
930
+ background-color: #fff;
931
+ position: absolute;
932
+ top: 0;
933
+ z-index: 999;
934
+ border: 1px solid #EBEEF5;
935
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
936
+ border-radius: 4px;
937
+ }
938
+
939
+ .uni-date-editor--x__disabled {
940
+ opacity: 0.4;
941
+ cursor: default;
942
+ }
943
+
944
+ .uni-date-editor--logo {
945
+ width: 16px;
946
+ height: 16px;
947
+ vertical-align: middle;
948
+ }
949
+
950
+ /* 添加时间 */
951
+ .popup-x-header {
952
+ /* #ifndef APP-NVUE */
953
+ display: flex;
954
+ /* #endif */
955
+ flex-direction: row;
956
+ }
957
+
958
+ .popup-x-header--datetime {
959
+ /* #ifndef APP-NVUE */
960
+ display: flex;
961
+ /* #endif */
962
+ flex-direction: row;
963
+ flex: 1;
964
+ }
965
+
966
+ .popup-x-body {
967
+ display: flex;
968
+ }
969
+
970
+ .popup-x-footer {
971
+ padding: 0 15px;
972
+ border-top-color: #F1F1F1;
973
+ border-top-style: solid;
974
+ border-top-width: 1px;
975
+ line-height: 40px;
976
+ text-align: right;
977
+ color: #666;
978
+ }
979
+
980
+ .popup-x-footer text:hover {
981
+ color: $uni-primary;
982
+ cursor: pointer;
983
+ opacity: 0.8;
984
+ }
985
+
986
+ .popup-x-footer .confirm-text {
987
+ margin-left: 20px;
988
+ color: $uni-primary;
989
+ }
990
+
991
+ .uni-date-changed {
992
+ text-align: center;
993
+ color: #333;
994
+ border-bottom-color: #F1F1F1;
995
+ border-bottom-style: solid;
996
+ border-bottom-width: 1px;
997
+ }
998
+
999
+ .uni-date-changed--time text {
1000
+ height: 50px;
1001
+ line-height: 50px;
1002
+ }
1003
+
1004
+ .uni-date-changed .uni-date-changed--time {
1005
+ flex: 1;
1006
+ }
1007
+
1008
+ .uni-date-changed--time-date {
1009
+ color: #333;
1010
+ opacity: 0.6;
1011
+ }
1012
+
1013
+ .mr-50 {
1014
+ margin-right: 50px;
1015
+ }
1016
+
1017
+ /* picker 弹出层通用的指示小三角, todo:扩展至上下左右方向定位 */
1018
+ .uni-popper__arrow,
1019
+ .uni-popper__arrow::after {
1020
+ position: absolute;
1021
+ display: block;
1022
+ width: 0;
1023
+ height: 0;
1024
+ border: 6px solid transparent;
1025
+ border-top-width: 0;
1026
+ }
1027
+
1028
+ .uni-popper__arrow {
1029
+ filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.03));
1030
+ top: -6px;
1031
+ left: 10%;
1032
+ margin-right: 3px;
1033
+ border-bottom-color: #EBEEF5;
1034
+ }
1035
+
1036
+ .uni-popper__arrow::after {
1037
+ content: " ";
1038
+ top: 1px;
1039
+ margin-left: -6px;
1040
+ border-bottom-color: #fff;
1041
+ }
1042
+ </style>