uview-plus 3.8.39 → 3.8.49

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.
@@ -72,13 +72,15 @@
72
72
  * @property {Boolean} showToolbar 是否显示顶部的操作栏 ( 默认 true )
73
73
  * @property {String | Number} modelValue 绑定值
74
74
  * @property {String} title 顶部标题
75
- * @property {String} mode 展示格式 mode=date为日期选择,mode=time为时间选择,mode=year-month为年月选择,mode=datetime为日期时间选择 ( 默认 ‘datetime )
75
+ * @property {String} mode 展示格式 mode=date为日期选择,mode=time为时间选择,mode=year-month为年月选择,mode=datetime为日期时间选择,mode=datehour为日期小时选择,mode=timesecond为时分秒选择,mode=datetimesecond为日期时分秒选择 ( 默认 ‘datetime )
76
76
  * @property {Number} maxDate 可选的最大时间 默认值为后10年
77
77
  * @property {Number} minDate 可选的最小时间 默认值为前10年
78
- * @property {Number} minHour 可选的最小小时,仅mode=time有效 ( 默认 0 )
79
- * @property {Number} maxHour 可选的最大小时,仅mode=time有效 ( 默认 23 )
80
- * @property {Number} minMinute 可选的最小分钟,仅mode=time有效 ( 默认 0 )
81
- * @property {Number} maxMinute 可选的最大分钟,仅mode=time有效 ( 默认 59 )
78
+ * @property {Number} minHour 可选的最小小时,仅mode=time/timesecond有效 ( 默认 0 )
79
+ * @property {Number} maxHour 可选的最大小时,仅mode=time/timesecond有效 ( 默认 23 )
80
+ * @property {Number} minMinute 可选的最小分钟,仅mode=time/timesecond有效 ( 默认 0 )
81
+ * @property {Number} maxMinute 可选的最大分钟,仅mode=time/timesecond有效 ( 默认 59 )
82
+ * @property {Number} minSecond 可选的最小秒,仅mode=timesecond有效 ( 默认 0 )
83
+ * @property {Number} maxSecond 可选的最大秒,仅mode=timesecond有效 ( 默认 59 )
82
84
  * @property {Function} filter 选项过滤函数
83
85
  * @property {Function} formatter 选项格式化函数
84
86
  * @property {Boolean} loading 是否显示加载中状态 ( 默认 false )
@@ -143,7 +145,7 @@
143
145
  computed: {
144
146
  // 如果以下这些变量发生了变化,意味着需要重新初始化各列的值
145
147
  propsChange() {
146
- return [this.mode, this.maxDate, this.minDate, this.minHour, this.maxHour, this.minMinute, this.maxMinute, this.filter, this.modelValue]
148
+ return [this.mode, this.maxDate, this.minDate, this.minHour, this.maxHour, this.minMinute, this.maxMinute, this.minSecond, this.maxSecond, this.filter, this.modelValue]
147
149
  },
148
150
  resolvedMaskStyle() {
149
151
  if (this.upHasProp('maskStyle')) {
@@ -169,6 +171,13 @@
169
171
  },
170
172
  mounted() {
171
173
  this.init()
174
+ // pageInline模式下picker-view常驻显示,在原生端(Android/HarmonyOS)需要
175
+ // 等待原生picker-view组件完成初始化后再重新设置选中值,否则滚动位置可能不生效
176
+ if (this.pageInline) {
177
+ setTimeout(() => {
178
+ this.updateIndexs(this.innerValue)
179
+ }, 200)
180
+ }
172
181
  },
173
182
  // #ifdef VUE3
174
183
  emits: ['close', 'cancel', 'confirm', 'change', 'update:modelValue'],
@@ -193,7 +202,7 @@
193
202
  this.inputValue = ''
194
203
  return
195
204
  }
196
- if (this.mode == 'time') {
205
+ if (this.mode === 'time' || this.mode === 'timesecond') {
197
206
  this.inputValue = newValue
198
207
  } else {
199
208
  if (this.format) {
@@ -213,9 +222,15 @@
213
222
  case 'datetime':
214
223
  format = 'YYYY-MM-DD HH:mm'
215
224
  break;
225
+ case 'datetimesecond':
226
+ format = 'YYYY-MM-DD HH:mm:ss'
227
+ break;
216
228
  case 'time':
217
229
  format = 'HH:mm'
218
230
  break;
231
+ case 'timesecond':
232
+ format = 'HH:mm:ss'
233
+ break;
219
234
  default:
220
235
  break;
221
236
  }
@@ -241,6 +256,9 @@
241
256
  },
242
257
  // 关闭选择器
243
258
  close() {
259
+ if (this.hasInput) {
260
+ this.showByClickInput = false
261
+ }
244
262
  if (this.closeOnClickOverlay) {
245
263
  if (this.hasInput) {
246
264
  this.showByClickInput = false
@@ -299,15 +317,21 @@
299
317
  const { indexs, values } = e
300
318
  const safeValues = Array.isArray(values) ? values : []
301
319
  let selectValue = ''
302
- if(this.mode === 'time') {
320
+ if (this.mode === 'time' || this.mode === 'timesecond') {
303
321
  // 根据value各列索引,从各列数组中,取出当前时间的选中值
304
322
  const hourText = this.safeColumnValue(safeValues, 0, indexs[0], padZero(this.minHour))
305
323
  const minuteText = this.safeColumnValue(safeValues, 1, indexs[1], padZero(this.minMinute))
306
324
  let hour = this.toInt(this.intercept(hourText), this.minHour)
307
325
  let minute = this.toInt(this.intercept(minuteText), this.minMinute)
326
+ let second = this.minSecond
308
327
  hour = range(this.minHour, this.maxHour, hour)
309
328
  minute = range(this.minMinute, this.maxMinute, minute)
310
329
  selectValue = `${padZero(hour)}:${padZero(minute)}`
330
+ if (this.mode === 'timesecond') {
331
+ const secondText = this.safeColumnValue(safeValues, 2, indexs[2], padZero(this.minSecond))
332
+ second = range(this.minSecond, this.maxSecond, this.toInt(this.intercept(secondText), this.minSecond))
333
+ selectValue = `${selectValue}:${padZero(second)}`
334
+ }
311
335
  } else {
312
336
  const validCurrent = dayjs(this.innerValue).isValid() ? dayjs(this.innerValue) : dayjs(this.minDate)
313
337
  const currentYear = validCurrent.year()
@@ -315,13 +339,14 @@
315
339
  const currentDate = validCurrent.date()
316
340
  const currentHour = validCurrent.hour()
317
341
  const currentMinute = validCurrent.minute()
342
+ const currentSecond = validCurrent.second()
318
343
 
319
344
  const yearText = this.safeColumnValue(safeValues, 0, indexs[0], `${currentYear}`)
320
345
  const monthText = this.safeColumnValue(safeValues, 1, indexs[1], padZero(currentMonth))
321
346
  // 将选择的值转为数值,比如'03'转为数值的3,'2019'转为数值的2019
322
347
  let year = this.toInt(this.intercept(yearText, 'year'), currentYear)
323
348
  let month = this.toInt(this.intercept(monthText), currentMonth)
324
- let hour = 0, minute = 0
349
+ let hour = 0, minute = 0, second = 0
325
350
  month = range(1, 12, month)
326
351
  // 此月份的最大天数
327
352
  const maxDate = dayjs(`${year}-${month}`).daysInMonth()
@@ -333,14 +358,20 @@
333
358
  }
334
359
  // 不允许超过maxDate值
335
360
  date = range(1, maxDate, date)
336
- if (this.mode === 'datetime') {
361
+ if (this.mode === 'datehour' || this.mode === 'datetime' || this.mode === 'datetimesecond') {
337
362
  const hourText = this.safeColumnValue(safeValues, 3, indexs[3], padZero(currentHour))
338
- const minuteText = this.safeColumnValue(safeValues, 4, indexs[4], padZero(currentMinute))
339
363
  hour = range(0, 23, this.toInt(this.intercept(hourText), currentHour))
364
+ }
365
+ if (this.mode === 'datetime' || this.mode === 'datetimesecond') {
366
+ const minuteText = this.safeColumnValue(safeValues, 4, indexs[4], padZero(currentMinute))
340
367
  minute = range(0, 59, this.toInt(this.intercept(minuteText), currentMinute))
341
368
  }
369
+ if (this.mode === 'datetimesecond') {
370
+ const secondText = this.safeColumnValue(safeValues, 5, indexs[5], padZero(currentSecond))
371
+ second = range(0, 59, this.toInt(this.intercept(secondText), currentSecond))
372
+ }
342
373
  // 转为时间模式
343
- selectValue = Number(new Date(year, month - 1, date, hour, minute))
374
+ selectValue = Number(new Date(year, month - 1, date, hour, minute, second))
344
375
  if (!Number.isFinite(selectValue)) {
345
376
  selectValue = this.correctValue(this.innerValue)
346
377
  }
@@ -364,33 +395,44 @@
364
395
  this.innerValue = value
365
396
  this.updateColumns()
366
397
  // 延迟执行,等待u-picker组件列数据更新完后再设置选中值索引
367
- setTimeout(() => {
368
- this.updateIndexs(value)
369
- }, 0);
398
+ // pageInline模式下picker-view常驻显示,需额外等待原生组件滚动到位
399
+ this.$nextTick(() => {
400
+ setTimeout(() => {
401
+ this.updateIndexs(value)
402
+ }, this.pageInline ? 100 : 0)
403
+ })
370
404
  },
371
405
  // 更新索引
372
406
  updateIndexs(value) {
373
407
  let values = []
374
408
  const formatter = this.formatter || this.innerFormatter
375
- if (this.mode === 'time') {
409
+ if (this.mode === 'time' || this.mode === 'timesecond') {
376
410
  // 将time模式的时间用:分隔成数组
377
411
  const timeArr = value.split(':')
378
412
  // 使用formatter格式化方法进行管道处理
379
413
  values = [formatter('hour', timeArr[0]), formatter('minute', timeArr[1])]
414
+ if (this.mode === 'timesecond') {
415
+ values.push(formatter('second', timeArr[2]))
416
+ }
380
417
  } else {
381
- const date = new Date(value)
382
418
  values = [
383
419
  formatter('year', `${dayjs(value).year()}`),
384
420
  // 月份补0
385
421
  formatter('month', padZero(dayjs(value).month() + 1))
386
422
  ]
387
- if (this.mode === 'date') {
423
+ if (this.mode === 'date' || this.mode === 'datehour' || this.mode === 'datetime' || this.mode === 'datetimesecond') {
388
424
  // date模式,需要添加天列
389
425
  values.push(formatter('day', padZero(dayjs(value).date())))
390
426
  }
391
- if (this.mode === 'datetime') {
427
+ if (this.mode === 'datehour' || this.mode === 'datetime' || this.mode === 'datetimesecond') {
428
+ values.push(formatter('hour', padZero(dayjs(value).hour())))
429
+ }
430
+ if (this.mode === 'datetime' || this.mode === 'datetimesecond') {
392
431
  // 数组的push方法,可以写入多个参数
393
- values.push(formatter('day', padZero(dayjs(value).date())), formatter('hour', padZero(dayjs(value).hour())), formatter('minute', padZero(dayjs(value).minute())))
432
+ values.push(formatter('minute', padZero(dayjs(value).minute())))
433
+ }
434
+ if (this.mode === 'datetimesecond') {
435
+ values.push(formatter('second', padZero(dayjs(value).second())))
394
436
  }
395
437
  }
396
438
 
@@ -438,23 +480,35 @@
438
480
  },
439
481
  // 得出合法的时间
440
482
  correctValue(value) {
441
- const isDateMode = this.mode !== 'time'
483
+ const isDateMode = !['time', 'timesecond'].includes(this.mode)
442
484
  // if (isDateMode && !test.date(value)) {
443
485
  if (isDateMode && !dayjs.unix(value).isValid()) {
444
486
  // 如果是日期类型,但是又没有设置合法的当前时间的话,使用最小时间为当前时间
445
487
  value = this.minDate
446
488
  } else if (!isDateMode && !value) {
447
489
  // 如果是时间类型,而又没有默认值的话,就用最小时间
448
- value = `${padZero(this.minHour)}:${padZero(this.minMinute)}`
490
+ value = this.mode === 'timesecond'
491
+ ? `${padZero(this.minHour)}:${padZero(this.minMinute)}:${padZero(this.minSecond)}`
492
+ : `${padZero(this.minHour)}:${padZero(this.minMinute)}`
449
493
  }
450
494
  // 时间类型
451
495
  if (!isDateMode) {
452
496
  if (String(value).indexOf(':') === -1) return error('时间错误,请传递如12:24的格式')
453
- let [hour, minute] = value.split(':')
497
+ const timeArr = String(value).split(':')
498
+ let hour = timeArr[0]
499
+ let minute = timeArr[1]
500
+ let second = timeArr[2]
454
501
  // 对时间补零,同时控制在最小值和最大值之间
455
- hour = padZero(range(this.minHour, this.maxHour, Number(hour)))
456
- minute = padZero(range(this.minMinute, this.maxMinute, Number(minute)))
457
- return `${ hour }:${ minute }`
502
+ const hourNum = Number(hour)
503
+ const minuteNum = Number(minute)
504
+ hour = padZero(range(this.minHour, this.maxHour, Number.isNaN(hourNum) ? this.minHour : hourNum))
505
+ minute = padZero(range(this.minMinute, this.maxMinute, Number.isNaN(minuteNum) ? this.minMinute : minuteNum))
506
+ if (this.mode === 'timesecond') {
507
+ const secondNum = Number(second)
508
+ second = padZero(range(this.minSecond, this.maxSecond, Number.isNaN(secondNum) ? this.minSecond : secondNum))
509
+ return `${hour}:${minute}:${second}`
510
+ }
511
+ return `${hour}:${minute}`
458
512
  } else {
459
513
  // 如果是日期格式,控制在最小日期和最大日期之间
460
514
  value = dayjs(value).isBefore(dayjs(this.minDate)) ? this.minDate : value
@@ -464,20 +518,27 @@
464
518
  },
465
519
  // 获取每列的最大和最小值
466
520
  getRanges() {
467
- if (this.mode === 'time') {
468
- return [
469
- {
470
- type: 'hour',
471
- range: [this.minHour, this.maxHour],
472
- },
473
- {
474
- type: 'minute',
475
- range: [this.minMinute, this.maxMinute],
476
- },
477
- ];
521
+ if (this.mode === 'time' || this.mode === 'timesecond') {
522
+ const timeColumns = [
523
+ {
524
+ type: 'hour',
525
+ range: [this.minHour, this.maxHour],
526
+ },
527
+ {
528
+ type: 'minute',
529
+ range: [this.minMinute, this.maxMinute],
530
+ }
531
+ ]
532
+ if (this.mode === 'timesecond') {
533
+ timeColumns.push({
534
+ type: 'second',
535
+ range: [this.minSecond, this.maxSecond],
536
+ })
537
+ }
538
+ return timeColumns
478
539
  }
479
- const { maxYear, maxDate, maxMonth, maxHour, maxMinute, } = this.getBoundary('max', this.innerValue);
480
- const { minYear, minDate, minMonth, minHour, minMinute, } = this.getBoundary('min', this.innerValue);
540
+ const { maxYear, maxDate, maxMonth, maxHour, maxMinute, maxSecond } = this.getBoundary('max', this.innerValue);
541
+ const { minYear, minDate, minMonth, minHour, minMinute, minSecond } = this.getBoundary('min', this.innerValue);
481
542
  const result = [
482
543
  {
483
544
  type: 'year',
@@ -499,6 +560,10 @@
499
560
  type: 'minute',
500
561
  range: [minMinute, maxMinute],
501
562
  },
563
+ {
564
+ type: 'second',
565
+ range: [minSecond, maxSecond],
566
+ },
502
567
  ];
503
568
  // 兜底:防止边界计算异常导致日列出现空范围(快速滚动场景)
504
569
  if (result[2] && result[2].type === 'day') {
@@ -510,9 +575,13 @@
510
575
  }
511
576
  }
512
577
  if (this.mode === 'date')
513
- result.splice(3, 2);
578
+ result.splice(3, 3);
579
+ if (this.mode === 'datehour')
580
+ result.splice(4, 2);
581
+ if (this.mode === 'datetime')
582
+ result.splice(5, 1);
514
583
  if (this.mode === 'year-month')
515
- result.splice(2, 3);
584
+ result.splice(2, 4);
516
585
  return result;
517
586
  },
518
587
  // 根据minDate、maxDate、minHour、maxHour等边界值,判断各列的开始和结束边界值
@@ -527,12 +596,14 @@
527
596
  let date = 1
528
597
  let hour = 0
529
598
  let minute = 0
599
+ let second = 0
530
600
  if (type === 'max') {
531
601
  month = 12
532
602
  // 月份的天数
533
603
  date = dayjs(value).daysInMonth()
534
604
  hour = 23
535
605
  minute = 59
606
+ second = 59
536
607
  }
537
608
  // 获取边界值,逻辑是:当年达到了边界值(最大或最小年),就检查月允许的最大和最小值,以此类推
538
609
  if (dayjs(value).year() === year) {
@@ -543,6 +614,9 @@
543
614
  hour = dayjs(boundary).hour()
544
615
  if (dayjs(value).hour() === hour) {
545
616
  minute = dayjs(boundary).minute()
617
+ if (dayjs(value).minute() === minute) {
618
+ second = dayjs(boundary).second()
619
+ }
546
620
  }
547
621
  }
548
622
  }
@@ -552,7 +626,8 @@
552
626
  [`${type}Month`]: month,
553
627
  [`${type}Date`]: date,
554
628
  [`${type}Hour`]: hour,
555
- [`${type}Minute`]: minute
629
+ [`${type}Minute`]: minute,
630
+ [`${type}Second`]: second
556
631
  }
557
632
  },
558
633
  onShowByClickInput(){
@@ -0,0 +1,16 @@
1
+ export default {
2
+ // guide 组件
3
+ guide: {
4
+ show: false,
5
+ list: [],
6
+ storageKey: 'up-guide-default',
7
+ once: true,
8
+ showSkip: true,
9
+ skipText: '跳过',
10
+ nextText: '下一步',
11
+ finishText: '立即体验',
12
+ indicator: true,
13
+ bgColor: '#111111',
14
+ zIndex: 10075
15
+ }
16
+ }
@@ -0,0 +1,51 @@
1
+ import { defineMixin } from '../../libs/vue'
2
+ import defProps from '../../libs/config/props.js'
3
+
4
+ export const props = defineMixin({
5
+ props: {
6
+ show: {
7
+ type: Boolean,
8
+ default: () => defProps.guide.show
9
+ },
10
+ list: {
11
+ type: Array,
12
+ default: () => defProps.guide.list
13
+ },
14
+ storageKey: {
15
+ type: String,
16
+ default: () => defProps.guide.storageKey
17
+ },
18
+ once: {
19
+ type: Boolean,
20
+ default: () => defProps.guide.once
21
+ },
22
+ showSkip: {
23
+ type: Boolean,
24
+ default: () => defProps.guide.showSkip
25
+ },
26
+ skipText: {
27
+ type: String,
28
+ default: () => defProps.guide.skipText
29
+ },
30
+ nextText: {
31
+ type: String,
32
+ default: () => defProps.guide.nextText
33
+ },
34
+ finishText: {
35
+ type: String,
36
+ default: () => defProps.guide.finishText
37
+ },
38
+ indicator: {
39
+ type: Boolean,
40
+ default: () => defProps.guide.indicator
41
+ },
42
+ bgColor: {
43
+ type: String,
44
+ default: () => defProps.guide.bgColor
45
+ },
46
+ zIndex: {
47
+ type: [String, Number],
48
+ default: () => defProps.guide.zIndex
49
+ }
50
+ }
51
+ })
@@ -0,0 +1,259 @@
1
+ <template>
2
+ <view
3
+ v-if="innerShow && pageList.length"
4
+ class="up-guide"
5
+ :style="{ zIndex: `${zIndex}` }"
6
+ @touchmove.stop.prevent
7
+ >
8
+ <swiper
9
+ class="up-guide__swiper"
10
+ :current="current"
11
+ @change="onSwiperChange"
12
+ >
13
+ <swiper-item v-for="(item, index) in pageList" :key="index">
14
+ <view class="up-guide__page" :style="{ backgroundColor: item.backgroundColor || bgColor }">
15
+ <template v-if="item.image">
16
+ <image class="up-guide__image" :src="item.image" mode="aspectFit"></image>
17
+ </template>
18
+ <view v-else class="up-guide__placeholder">暂无引导图</view>
19
+ <text v-if="item.title" class="up-guide__title">{{ item.title }}</text>
20
+ <text v-if="item.desc" class="up-guide__desc">{{ item.desc }}</text>
21
+ </view>
22
+ </swiper-item>
23
+ </swiper>
24
+
25
+ <view class="up-guide__footer">
26
+ <view v-if="indicator" class="up-guide__dots">
27
+ <view
28
+ v-for="(_, dotIndex) in pageList"
29
+ :key="dotIndex"
30
+ class="up-guide__dot"
31
+ :class="{ 'up-guide__dot--active': dotIndex === current }"
32
+ ></view>
33
+ </view>
34
+ <view class="up-guide__actions">
35
+ <view v-if="showSkip" class="up-guide__btn up-guide__btn--ghost" @tap="onSkip">
36
+ {{ skipText }}
37
+ </view>
38
+ <view class="up-guide__btn up-guide__btn--primary" @tap="onPrimaryAction">
39
+ {{ isLastPage() ? finishText : nextText }}
40
+ </view>
41
+ </view>
42
+ </view>
43
+ </view>
44
+ </template>
45
+
46
+ <script>
47
+ import { props } from './props';
48
+ import { mpMixin } from '../../libs/mixin/mpMixin';
49
+ import { mixin } from '../../libs/mixin/mixin';
50
+
51
+ /**
52
+ * Guide 首屏引导
53
+ * @description 全屏首屏引导组件,支持一次性记忆与多页滑动
54
+ */
55
+ export default {
56
+ name: 'up-guide',
57
+ mixins: [mpMixin, mixin, props],
58
+ emits: ['update:show', 'change', 'skip', 'finish', 'close'],
59
+ data() {
60
+ return {
61
+ innerShow: false,
62
+ current: 0,
63
+ closing: false
64
+ }
65
+ },
66
+ computed: {
67
+ pageList() {
68
+ return Array.isArray(this.list) ? this.list : []
69
+ },
70
+ resolvedStorageKey() {
71
+ return this.storageKey || 'up-guide-default'
72
+ }
73
+ },
74
+ watch: {
75
+ show(value) {
76
+ this.innerShow = !!value
77
+ }
78
+ },
79
+ mounted() {
80
+ this.bootstrap()
81
+ },
82
+ methods: {
83
+ bootstrap() {
84
+ if (!this.pageList.length) {
85
+ if (process.env.NODE_ENV !== 'production') {
86
+ console.warn('[up-guide] list is empty')
87
+ }
88
+ return
89
+ }
90
+ if (this.once && this.readRemembered()) {
91
+ this.innerShow = false
92
+ this.$emit('update:show', false)
93
+ return
94
+ }
95
+ this.innerShow = !!this.show
96
+ },
97
+ isLastPage() {
98
+ return this.current >= this.pageList.length - 1
99
+ },
100
+ onSwiperChange(event) {
101
+ const next = Number(event?.detail?.current ?? 0)
102
+ this.current = next
103
+ this.$emit('change', { current: next })
104
+ },
105
+ onPrimaryAction() {
106
+ if (this.isLastPage()) {
107
+ this.$emit('finish')
108
+ this.close(true)
109
+ return
110
+ }
111
+ this.current += 1
112
+ this.$emit('change', { current: this.current })
113
+ },
114
+ onSkip() {
115
+ this.$emit('skip')
116
+ this.close(true)
117
+ },
118
+ open() {
119
+ this.current = 0
120
+ this.innerShow = true
121
+ this.$emit('update:show', true)
122
+ },
123
+ close(remember = true) {
124
+ if (this.closing) return
125
+ this.closing = true
126
+ if (remember && this.once) {
127
+ this.writeRemembered()
128
+ }
129
+ this.innerShow = false
130
+ this.$emit('update:show', false)
131
+ this.$emit('close')
132
+ this.$nextTick(() => {
133
+ this.closing = false
134
+ })
135
+ },
136
+ reset() {
137
+ try {
138
+ uni.removeStorageSync(this.resolvedStorageKey)
139
+ } catch (error) {}
140
+ },
141
+ readRemembered() {
142
+ try {
143
+ const value = uni.getStorageSync(this.resolvedStorageKey)
144
+ return value === true || value === 1 || value === '1'
145
+ } catch (error) {
146
+ return false
147
+ }
148
+ },
149
+ writeRemembered() {
150
+ try {
151
+ uni.setStorageSync(this.resolvedStorageKey, 1)
152
+ } catch (error) {}
153
+ }
154
+ }
155
+ }
156
+ </script>
157
+
158
+ <style lang="scss" scoped>
159
+ .up-guide {
160
+ position: fixed;
161
+ left: 0;
162
+ top: 0;
163
+ right: 0;
164
+ bottom: 0;
165
+ display: flex;
166
+ flex-direction: column;
167
+ }
168
+
169
+ .up-guide__swiper {
170
+ flex: 1;
171
+ }
172
+
173
+ .up-guide__page {
174
+ height: 100%;
175
+ padding: 120rpx 40rpx 40rpx;
176
+ box-sizing: border-box;
177
+ display: flex;
178
+ flex-direction: column;
179
+ align-items: center;
180
+ color: #ffffff;
181
+ }
182
+
183
+ .up-guide__image {
184
+ width: 560rpx;
185
+ height: 560rpx;
186
+ }
187
+
188
+ .up-guide__placeholder {
189
+ width: 560rpx;
190
+ height: 560rpx;
191
+ border-radius: 24rpx;
192
+ background: rgba(255, 255, 255, 0.12);
193
+ display: flex;
194
+ align-items: center;
195
+ justify-content: center;
196
+ }
197
+
198
+ .up-guide__title {
199
+ margin-top: 48rpx;
200
+ font-size: 40rpx;
201
+ font-weight: 600;
202
+ }
203
+
204
+ .up-guide__desc {
205
+ margin-top: 18rpx;
206
+ font-size: 28rpx;
207
+ opacity: 0.85;
208
+ text-align: center;
209
+ }
210
+
211
+ .up-guide__footer {
212
+ padding: 24rpx 32rpx calc(24rpx + env(safe-area-inset-bottom));
213
+ }
214
+
215
+ .up-guide__dots {
216
+ display: flex;
217
+ justify-content: center;
218
+ gap: 12rpx;
219
+ margin-bottom: 26rpx;
220
+ }
221
+
222
+ .up-guide__dot {
223
+ width: 14rpx;
224
+ height: 14rpx;
225
+ border-radius: 999px;
226
+ background: rgba(255, 255, 255, 0.35);
227
+ }
228
+
229
+ .up-guide__dot--active {
230
+ width: 34rpx;
231
+ background: #ffffff;
232
+ }
233
+
234
+ .up-guide__actions {
235
+ display: flex;
236
+ gap: 16rpx;
237
+ }
238
+
239
+ .up-guide__btn {
240
+ flex: 1;
241
+ height: 84rpx;
242
+ border-radius: 42rpx;
243
+ display: flex;
244
+ align-items: center;
245
+ justify-content: center;
246
+ font-size: 28rpx;
247
+ }
248
+
249
+ .up-guide__btn--ghost {
250
+ color: #ffffff;
251
+ border: 2rpx solid rgba(255, 255, 255, 0.42);
252
+ }
253
+
254
+ .up-guide__btn--primary {
255
+ color: #111111;
256
+ background: #ffffff;
257
+ font-weight: 600;
258
+ }
259
+ </style>
@@ -309,8 +309,12 @@
309
309
  },
310
310
  // 输入框失去焦点
311
311
  onBlur(event) {
312
- // 对输入值进行格式化
313
- const value = this.format(event.detail.value)
312
+ // 对输入值进行格式化,失焦时强制修正到合法范围(如最小值)
313
+ const raw = event.detail.value
314
+ const value = (raw === '' || raw === null || raw === undefined)
315
+ ? this.min
316
+ : this.format(raw)
317
+ this.emitChange(value)
314
318
  // 发出blur事件
315
319
  this.$emit(
316
320
  'blur',{
@@ -324,10 +328,9 @@
324
328
  const {
325
329
  value = ''
326
330
  } = e.detail || {}
327
- // 为空返回
331
+ // 为空时不立即修正,等失焦时再处理,允许用户清空后输入新值
328
332
  if (value === '') {
329
- // 为空自动设为最小值
330
- this.emitChange(this.min)
333
+ this.currentValue = ''
331
334
  return
332
335
  }
333
336
  let formatted = this.filter(value)