uview-plus 3.2.7 → 3.2.9
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.
- package/changelog.md +7 -0
- package/components/u--form/u--form.vue +7 -7
- package/components/u--image/u--image.vue +3 -3
- package/components/u--input/u--input.vue +9 -9
- package/components/u--textarea/u--textarea.vue +3 -3
- package/components/u-action-sheet/u-action-sheet.vue +5 -4
- package/components/u-album/u-album.vue +9 -7
- package/components/u-alert/u-alert.vue +9 -6
- package/components/u-avatar/props.js +2 -1
- package/components/u-avatar/u-avatar.vue +15 -11
- package/components/u-avatar-group/u-avatar-group.vue +9 -5
- package/components/u-back-top/u-back-top.vue +9 -8
- package/components/u-badge/u-badge.vue +10 -6
- package/components/u-button/u-button.vue +13 -9
- package/components/u-calendar/header.vue +3 -3
- package/components/u-calendar/month.vue +17 -15
- package/components/u-calendar/u-calendar.vue +10 -8
- package/components/u-car-keyboard/u-car-keyboard.vue +7 -6
- package/components/u-cell/u-cell.vue +9 -6
- package/components/u-cell-group/u-cell-group.vue +8 -4
- package/components/u-checkbox/u-checkbox.vue +13 -11
- package/components/u-checkbox-group/u-checkbox-group.vue +3 -3
- package/components/u-circle-progress/u-circle-progress.vue +5 -4
- package/components/u-code/u-code.vue +3 -3
- package/components/u-code-input/u-code-input.vue +9 -8
- package/components/u-col/u-col.vue +9 -8
- package/components/u-collapse/u-collapse.vue +3 -3
- package/components/u-collapse-item/u-collapse-item.vue +32 -15
- package/components/u-column-notice/u-column-notice.vue +8 -6
- package/components/u-count-down/u-count-down.vue +3 -3
- package/components/u-count-to/u-count-to.vue +6 -4
- package/components/u-datetime-picker/u-datetime-picker.vue +15 -15
- package/components/u-divider/u-divider.vue +7 -5
- package/components/u-dropdown/u-dropdown.vue +12 -10
- package/components/u-dropdown-item/u-dropdown-item.vue +7 -5
- package/components/u-empty/u-empty.vue +12 -8
- package/components/u-form/u-form.vue +12 -10
- package/components/u-form-item/u-form-item.vue +17 -11
- package/components/u-gap/u-gap.vue +3 -3
- package/components/u-grid/u-grid.vue +18 -7
- package/components/u-grid-item/u-grid-item.vue +14 -9
- package/components/u-icon/u-icon.vue +21 -19
- package/components/u-image/u-image.vue +18 -16
- package/components/u-index-anchor/u-index-anchor.vue +11 -9
- package/components/u-index-item/u-index-item.vue +6 -5
- package/components/u-index-list/u-index-list.vue +20 -18
- package/components/u-input/u-input.vue +12 -11
- package/components/u-keyboard/u-keyboard.vue +3 -3
- package/components/u-line/u-line.vue +7 -6
- package/components/u-line-progress/u-line-progress.vue +11 -8
- package/components/u-link/u-link.vue +9 -8
- package/components/u-list/u-list.vue +9 -9
- package/components/u-list-item/u-list-item.vue +5 -4
- package/components/u-loading-icon/u-loading-icon.vue +14 -10
- package/components/u-loading-page/u-loading-page.vue +10 -7
- package/components/u-loadmore/u-loadmore.vue +12 -10
- package/components/u-modal/u-modal.vue +7 -5
- package/components/u-navbar/u-navbar.vue +12 -7
- package/components/u-no-network/u-no-network.vue +6 -6
- package/components/u-notice-bar/u-notice-bar.vue +6 -5
- package/components/u-notify/u-notify.vue +19 -15
- package/components/u-number-box/u-number-box.vue +8 -7
- package/components/u-number-keyboard/u-number-keyboard.vue +7 -7
- package/components/u-overlay/u-overlay.vue +5 -5
- package/components/u-picker/u-picker.vue +19 -15
- package/components/u-picker-column/u-picker-column.vue +3 -3
- package/components/u-popup/u-popup.vue +13 -13
- package/components/u-radio/u-radio.vue +12 -12
- package/components/u-radio-group/u-radio-group.vue +3 -3
- package/components/u-rate/u-rate.vue +16 -14
- package/components/u-read-more/u-read-more.vue +9 -7
- package/components/u-row/u-row.vue +8 -7
- package/components/u-row-notice/u-row-notice.vue +14 -12
- package/components/u-safe-bottom/u-safe-bottom.vue +5 -4
- package/components/u-scroll-list/nvue.js +4 -4
- package/components/u-scroll-list/u-scroll-list.vue +13 -10
- package/components/u-search/u-search.vue +8 -6
- package/components/u-skeleton/u-skeleton.vue +20 -17
- package/components/u-slider/mpwxs.js +3 -2
- package/components/u-slider/nvue - /345/211/257/346/234/254.js" +2 -2
- package/components/u-slider/nvue.js +2 -2
- package/components/u-slider/u-slider.vue +8 -5
- package/components/u-status-bar/u-status-bar.vue +6 -5
- package/components/u-steps/u-steps.vue +5 -4
- package/components/u-steps-item/u-steps-item.vue +9 -7
- package/components/u-sticky/u-sticky.vue +12 -10
- package/components/u-subsection/u-subsection.vue +8 -6
- package/components/u-swipe-action/u-swipe-action.vue +3 -3
- package/components/u-swipe-action-item/nvue - backup.js +3 -3
- package/components/u-swipe-action-item/nvue.js +3 -3
- package/components/u-swipe-action-item/u-swipe-action-item.vue +8 -5
- package/components/u-swiper/u-swiper.vue +35 -24
- package/components/u-swiper-indicator/u-swiper-indicator.vue +10 -7
- package/components/u-switch/u-switch.vue +15 -13
- package/components/u-tabbar/u-tabbar.vue +6 -5
- package/components/u-tabbar-item/u-tabbar-item.vue +7 -5
- package/components/u-table/u-table.vue +3 -3
- package/components/u-tabs/u-tabs.vue +18 -14
- package/components/u-tabs-item/u-tabs-item.vue +3 -3
- package/components/u-tag/props.js +2 -2
- package/components/u-tag/u-tag.vue +6 -4
- package/components/u-td/u-td.vue +3 -3
- package/components/u-text/u-text.vue +12 -10
- package/components/u-text/value.js +14 -12
- package/components/u-textarea/u-textarea.vue +11 -8
- package/components/u-toast/u-toast.vue +12 -9
- package/components/u-toolbar/u-toolbar.vue +3 -3
- package/components/u-tooltip/u-tooltip.vue +18 -17
- package/components/u-tr/u-tr.vue +3 -3
- package/components/u-transition/transition.js +2 -2
- package/components/u-transition/u-transition.vue +6 -5
- package/components/u-upload/mixin.js +4 -3
- package/components/u-upload/u-upload.vue +20 -17
- package/index.js +0 -5
- package/libs/function/index.js +27 -20
- package/libs/function/throttle.js +2 -2
- package/libs/mixin/mixin.js +14 -6
- package/libs/mixin/style.js +23 -4
- package/libs/util/route.js +6 -6
- package/package.json +1 -1
|
@@ -39,12 +39,12 @@
|
|
|
39
39
|
}
|
|
40
40
|
return result
|
|
41
41
|
}
|
|
42
|
-
import props from './props
|
|
43
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
44
|
-
import mixin from '../../libs/mixin/mixin
|
|
45
|
-
|
|
46
|
-
import
|
|
47
|
-
|
|
42
|
+
import props from './props';
|
|
43
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
44
|
+
import mixin from '../../libs/mixin/mixin';
|
|
45
|
+
import dayjs from 'dayjs/esm/index';
|
|
46
|
+
import { range, error, padZero } from '../../libs/function/index';
|
|
47
|
+
import test from '../../libs/function/test';
|
|
48
48
|
/**
|
|
49
49
|
* DatetimePicker 时间日期选择器
|
|
50
50
|
* @description 此选择器用于时间日期
|
|
@@ -201,12 +201,12 @@
|
|
|
201
201
|
let judge = e.match(/\d+/g)
|
|
202
202
|
//判断是否掺杂数字
|
|
203
203
|
if(judge.length>1){
|
|
204
|
-
|
|
204
|
+
error("请勿在过滤或格式化函数时添加数字")
|
|
205
205
|
return 0
|
|
206
206
|
}else if(type&&judge[0].length==4){//判断是否是年份
|
|
207
207
|
return judge[0]
|
|
208
208
|
}else if(judge[0].length>2){
|
|
209
|
-
|
|
209
|
+
error("请勿在过滤或格式化函数时添加数字")
|
|
210
210
|
return 0
|
|
211
211
|
}else{
|
|
212
212
|
return judge[0]
|
|
@@ -268,7 +268,7 @@
|
|
|
268
268
|
updateIndexs(value) {
|
|
269
269
|
let values = []
|
|
270
270
|
const formatter = this.formatter || this.innerFormatter
|
|
271
|
-
const padZero =
|
|
271
|
+
const padZero = padZero
|
|
272
272
|
if (this.mode === 'time') {
|
|
273
273
|
// 将time模式的时间用:分隔成数组
|
|
274
274
|
const timeArr = value.split(':')
|
|
@@ -310,7 +310,7 @@
|
|
|
310
310
|
const results = this.getRanges().map(({ type, range }) => {
|
|
311
311
|
let values = times(range[1] - range[0] + 1, (index) => {
|
|
312
312
|
let value = range[0] + index
|
|
313
|
-
value = type === 'year' ? `${value}` :
|
|
313
|
+
value = type === 'year' ? `${value}` : padZero(value)
|
|
314
314
|
return value
|
|
315
315
|
})
|
|
316
316
|
// 进行过滤
|
|
@@ -335,20 +335,20 @@
|
|
|
335
335
|
// 得出合法的时间
|
|
336
336
|
correctValue(value) {
|
|
337
337
|
const isDateMode = this.mode !== 'time'
|
|
338
|
-
if (isDateMode && !
|
|
338
|
+
if (isDateMode && !test.date(value)) {
|
|
339
339
|
// 如果是日期类型,但是又没有设置合法的当前时间的话,使用最小时间为当前时间
|
|
340
340
|
value = this.minDate
|
|
341
341
|
} else if (!isDateMode && !value) {
|
|
342
342
|
// 如果是时间类型,而又没有默认值的话,就用最小时间
|
|
343
|
-
value = `${
|
|
343
|
+
value = `${padZero(this.minHour)}:${padZero(this.minMinute)}`
|
|
344
344
|
}
|
|
345
345
|
// 时间类型
|
|
346
346
|
if (!isDateMode) {
|
|
347
|
-
if (String(value).indexOf(':') === -1) return
|
|
347
|
+
if (String(value).indexOf(':') === -1) return error('时间错误,请传递如12:24的格式')
|
|
348
348
|
let [hour, minute] = value.split(':')
|
|
349
349
|
// 对时间补零,同时控制在最小值和最大值之间
|
|
350
|
-
hour =
|
|
351
|
-
minute =
|
|
350
|
+
hour = padZero(range(this.minHour, this.maxHour, Number(hour)))
|
|
351
|
+
minute = padZero(range(this.minMinute, this.maxMinute, Number(minute)))
|
|
352
352
|
return `${ hour }:${ minute }`
|
|
353
353
|
} else {
|
|
354
354
|
// 如果是日期格式,控制在最小日期和最大日期之间
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view
|
|
3
3
|
class="u-divider"
|
|
4
|
-
:style="[
|
|
4
|
+
:style="[addStyle(customStyle)]"
|
|
5
5
|
@tap="click"
|
|
6
6
|
>
|
|
7
7
|
<u-line
|
|
@@ -29,9 +29,10 @@
|
|
|
29
29
|
</template>
|
|
30
30
|
|
|
31
31
|
<script>
|
|
32
|
-
import props from './props
|
|
33
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
34
|
-
import mixin from '../../libs/mixin/mixin
|
|
32
|
+
import props from './props';
|
|
33
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
34
|
+
import mixin from '../../libs/mixin/mixin';
|
|
35
|
+
import { addStyle, addUnit } from '../../libs/function/index';
|
|
35
36
|
/**
|
|
36
37
|
* divider 分割线
|
|
37
38
|
* @description 区隔内容的分割线,一般用于页面底部"没有更多"的提示。
|
|
@@ -55,7 +56,7 @@
|
|
|
55
56
|
computed: {
|
|
56
57
|
textStyle() {
|
|
57
58
|
const style = {}
|
|
58
|
-
style.fontSize =
|
|
59
|
+
style.fontSize = addUnit(this.textSize)
|
|
59
60
|
style.color = this.textColor
|
|
60
61
|
return style
|
|
61
62
|
},
|
|
@@ -84,6 +85,7 @@
|
|
|
84
85
|
},
|
|
85
86
|
emits: ["click"],
|
|
86
87
|
methods: {
|
|
88
|
+
addStyle,
|
|
87
89
|
// divider组件被点击时触发
|
|
88
90
|
click() {
|
|
89
91
|
this.$emit('click');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view class="u-dropdown">
|
|
3
3
|
<view class="u-dropdown__menu" :style="{
|
|
4
|
-
height:
|
|
4
|
+
height: addUnit(height)
|
|
5
5
|
}" :class="{
|
|
6
6
|
'u-border-bottom': borderBottom
|
|
7
7
|
}">
|
|
@@ -9,19 +9,19 @@
|
|
|
9
9
|
<view class="u-flex u-flex-row">
|
|
10
10
|
<text class="u-dropdown__menu__item__text" :style="{
|
|
11
11
|
color: item.disabled ? '#c0c4cc' : (index === current || highlightIndex == index) ? activeColor : inactiveColor,
|
|
12
|
-
fontSize:
|
|
12
|
+
fontSize: addUnit(titleSize)
|
|
13
13
|
}">{{item.title}}</text>
|
|
14
14
|
<view class="u-dropdown__menu__item__arrow" :class="{
|
|
15
15
|
'u-dropdown__menu__item__arrow--rotate': index === current
|
|
16
16
|
}">
|
|
17
|
-
<u-icon :custom-style="{display: 'flex'}" :name="menuIcon" :size="
|
|
17
|
+
<u-icon :custom-style="{display: 'flex'}" :name="menuIcon" :size="addUnit(menuIconSize)" :color="index === current || highlightIndex == index ? activeColor : '#c0c4cc'"></u-icon>
|
|
18
18
|
</view>
|
|
19
19
|
</view>
|
|
20
20
|
</view>
|
|
21
21
|
</view>
|
|
22
22
|
<view class="u-dropdown__content" :style="[contentStyle, {
|
|
23
23
|
transition: `opacity ${duration / 1000}s linear`,
|
|
24
|
-
top:
|
|
24
|
+
top: addUnit(height),
|
|
25
25
|
height: contentHeight + 'px'
|
|
26
26
|
}]"
|
|
27
27
|
@tap="maskClick" @touchmove.stop.prevent>
|
|
@@ -34,9 +34,10 @@
|
|
|
34
34
|
</template>
|
|
35
35
|
|
|
36
36
|
<script>
|
|
37
|
-
import props from './props
|
|
38
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
39
|
-
import mixin from '../../libs/mixin/mixin
|
|
37
|
+
import props from './props';
|
|
38
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
39
|
+
import mixin from '../../libs/mixin/mixin';
|
|
40
|
+
import { addUnit, sys} from '../../libs/function/index';
|
|
40
41
|
/**
|
|
41
42
|
* dropdown 下拉菜单
|
|
42
43
|
* @description 该组件一般用于向下展开菜单,同时可切换多个选项卡的场景
|
|
@@ -82,7 +83,7 @@
|
|
|
82
83
|
// 进行Y轴位移,展开状态时,恢复原位。收齐状态时,往上位移100%,进行隐藏
|
|
83
84
|
style.transform = `translateY(${this.active ? 0 : '-100%'})`
|
|
84
85
|
style['transition-duration'] = this.duration / 1000 + 's';
|
|
85
|
-
style.borderRadius = `0 0 ${
|
|
86
|
+
style.borderRadius = `0 0 ${addUnit(this.borderRadius)} ${addUnit(this.borderRadius)}`;
|
|
86
87
|
return style;
|
|
87
88
|
}
|
|
88
89
|
},
|
|
@@ -95,6 +96,7 @@
|
|
|
95
96
|
},
|
|
96
97
|
emits: ['open', 'close'],
|
|
97
98
|
methods: {
|
|
99
|
+
addUnit,
|
|
98
100
|
init() {
|
|
99
101
|
// 当某个子组件内容变化时,触发父组件的init,父组件再让每一个子组件重新初始化一遍
|
|
100
102
|
// 以保证数据的正确性
|
|
@@ -164,8 +166,8 @@
|
|
|
164
166
|
getContentHeight() {
|
|
165
167
|
// 这里的原理为,因为dropdown组件是相对定位的,它的下拉出来的内容,必须给定一个高度
|
|
166
168
|
// 才能让遮罩占满菜单一下,直到屏幕底部的高度
|
|
167
|
-
//
|
|
168
|
-
let windowHeight =
|
|
169
|
+
// sys()为uview-plus封装的获取设备信息的方法
|
|
170
|
+
let windowHeight = sys().windowHeight;
|
|
169
171
|
this.$uGetRect('.u-dropdown__menu').then(res => {
|
|
170
172
|
// 这里获取的是dropdown的尺寸,在H5上,uniapp获取尺寸是有bug的(以前提出修复过,后来又出现了此bug,目前hx2.8.11版本)
|
|
171
173
|
// H5端bug表现为元素尺寸的top值为导航栏底部到到元素的上边沿的距离,但是元素的bottom值确是导航栏顶部到元素底部的距离
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<view class="u-dropdown-item" v-if="active" @touchmove.stop.prevent="() => {}" @tap.stop.prevent="() => {}">
|
|
3
3
|
<block v-if="!$slots.default && !$slots.$default">
|
|
4
4
|
<scroll-view class="u-dropdown-item__scroll" scroll-y="true" :style="{
|
|
5
|
-
height:
|
|
5
|
+
height: addUnit(height)
|
|
6
6
|
}">
|
|
7
7
|
<view class="u-dropdown-item__options">
|
|
8
8
|
<up-cell-group>
|
|
@@ -21,9 +21,10 @@
|
|
|
21
21
|
</template>
|
|
22
22
|
|
|
23
23
|
<script>
|
|
24
|
-
import props from './props
|
|
25
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
26
|
-
import mixin from '../../libs/mixin/mixin
|
|
24
|
+
import props from './props';
|
|
25
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
26
|
+
import mixin from '../../libs/mixin/mixin';
|
|
27
|
+
import { addUnit, $parent } from '../../libs/function/index';
|
|
27
28
|
/**
|
|
28
29
|
* dropdown-item 下拉菜单
|
|
29
30
|
* @description 该组件一般用于向下展开菜单,同时可切换多个选项卡的场景
|
|
@@ -68,9 +69,10 @@
|
|
|
68
69
|
},
|
|
69
70
|
emits: ['update:modelValue', 'change'],
|
|
70
71
|
methods: {
|
|
72
|
+
addUnit,
|
|
71
73
|
init() {
|
|
72
74
|
// 获取父组件u-dropdown
|
|
73
|
-
let parent =
|
|
75
|
+
let parent = $parent.call(this, 'u-dropdown');
|
|
74
76
|
if (parent) {
|
|
75
77
|
this.parent = parent;
|
|
76
78
|
// 将子组件的激活颜色配置为父组件设置的激活和未激活时的颜色
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
<image
|
|
15
15
|
v-else
|
|
16
16
|
:style="{
|
|
17
|
-
width:
|
|
18
|
-
height:
|
|
17
|
+
width: addUnit(width),
|
|
18
|
+
height: addUnit(height),
|
|
19
19
|
}"
|
|
20
20
|
:src="icon"
|
|
21
21
|
mode="widthFix"
|
|
@@ -31,9 +31,10 @@
|
|
|
31
31
|
</template>
|
|
32
32
|
|
|
33
33
|
<script>
|
|
34
|
-
import props from './props
|
|
35
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
36
|
-
import mixin from '../../libs/mixin/mixin
|
|
34
|
+
import props from './props';
|
|
35
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
36
|
+
import mixin from '../../libs/mixin/mixin';
|
|
37
|
+
import { addUnit, addStyle, deepMerge } from '../../libs/function/index';
|
|
37
38
|
/**
|
|
38
39
|
* empty 内容为空
|
|
39
40
|
* @description 该组件用于需要加载内容,但是加载的第一页数据就为空,提示一个"没有内容"的场景, 我们精心挑选了十几个场景的图标,方便您使用。
|
|
@@ -83,21 +84,24 @@
|
|
|
83
84
|
// 组件样式
|
|
84
85
|
emptyStyle() {
|
|
85
86
|
const style = {}
|
|
86
|
-
style.marginTop =
|
|
87
|
+
style.marginTop = addUnit(this.marginTop)
|
|
87
88
|
// 合并customStyle样式,此参数通过mixin中的props传递
|
|
88
|
-
return
|
|
89
|
+
return deepMerge(addStyle(this.customStyle), style)
|
|
89
90
|
},
|
|
90
91
|
// 文本样式
|
|
91
92
|
textStyle() {
|
|
92
93
|
const style = {}
|
|
93
94
|
style.color = this.textColor
|
|
94
|
-
style.fontSize =
|
|
95
|
+
style.fontSize = addUnit(this.textSize)
|
|
95
96
|
return style
|
|
96
97
|
},
|
|
97
98
|
// 判断icon是否图片路径
|
|
98
99
|
isSrc() {
|
|
99
100
|
return this.icon.indexOf('/') >= 0
|
|
100
101
|
}
|
|
102
|
+
},
|
|
103
|
+
methods: {
|
|
104
|
+
addUnit
|
|
101
105
|
}
|
|
102
106
|
}
|
|
103
107
|
</script>
|
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
<script>
|
|
8
8
|
import props from "./props.js";
|
|
9
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
10
|
-
import mixin from '../../libs/mixin/mixin
|
|
9
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
10
|
+
import mixin from '../../libs/mixin/mixin';
|
|
11
11
|
import Schema from "../../libs/util/async-validator";
|
|
12
|
+
import { toast, getProperty, setProperty, deepClone, error } from '../../libs/function/index';
|
|
13
|
+
import test from '../../libs/function/test';
|
|
12
14
|
// 去除警告信息
|
|
13
15
|
Schema.warning = function() {};
|
|
14
16
|
/**
|
|
@@ -65,7 +67,7 @@
|
|
|
65
67
|
immediate: true,
|
|
66
68
|
handler(n) {
|
|
67
69
|
if (!this.originalModel) {
|
|
68
|
-
this.originalModel =
|
|
70
|
+
this.originalModel = deepClone(n);
|
|
69
71
|
}
|
|
70
72
|
},
|
|
71
73
|
},
|
|
@@ -93,7 +95,7 @@
|
|
|
93
95
|
// 判断是否有规则
|
|
94
96
|
if (Object.keys(rules).length === 0) return;
|
|
95
97
|
if (process.env.NODE_ENV === 'development' && Object.keys(this.model).length === 0) {
|
|
96
|
-
|
|
98
|
+
error('设置rules,model必须设置!如果已经设置,请刷新页面。');
|
|
97
99
|
return;
|
|
98
100
|
};
|
|
99
101
|
this.formRules = rules;
|
|
@@ -109,8 +111,8 @@
|
|
|
109
111
|
// 历遍所有u-form-item,根据其prop属性,还原model的原始快照
|
|
110
112
|
this.children.map((child) => {
|
|
111
113
|
const prop = child?.prop;
|
|
112
|
-
const value =
|
|
113
|
-
|
|
114
|
+
const value = getProperty(this.originalModel, prop);
|
|
115
|
+
setProperty(this.model, prop, value);
|
|
114
116
|
});
|
|
115
117
|
},
|
|
116
118
|
// 清空校验结果
|
|
@@ -137,7 +139,7 @@
|
|
|
137
139
|
const childErrors = [];
|
|
138
140
|
if (value.includes(child.prop)) {
|
|
139
141
|
// 获取对应的属性,通过类似'a.b.c'的形式
|
|
140
|
-
const propertyVal =
|
|
142
|
+
const propertyVal = getProperty(
|
|
141
143
|
this.model,
|
|
142
144
|
child.prop
|
|
143
145
|
);
|
|
@@ -167,7 +169,7 @@
|
|
|
167
169
|
[propertyName]: propertyVal,
|
|
168
170
|
},
|
|
169
171
|
(errors, fields) => {
|
|
170
|
-
if (
|
|
172
|
+
if (test.array(errors)) {
|
|
171
173
|
errorsRes.push(...errors);
|
|
172
174
|
childErrors.push(...errors);
|
|
173
175
|
}
|
|
@@ -186,7 +188,7 @@
|
|
|
186
188
|
validate(callback) {
|
|
187
189
|
// 开发环境才提示,生产环境不会提示
|
|
188
190
|
if (process.env.NODE_ENV === 'development' && Object.keys(this.formRules).length === 0) {
|
|
189
|
-
|
|
191
|
+
error('未设置rules,请看文档说明!如果已经设置,请刷新页面。');
|
|
190
192
|
return;
|
|
191
193
|
}
|
|
192
194
|
return new Promise((resolve, reject) => {
|
|
@@ -199,7 +201,7 @@
|
|
|
199
201
|
this.validateField(formItemProps, (errors) => {
|
|
200
202
|
if(errors.length) {
|
|
201
203
|
// 如果错误提示方式为toast,则进行提示
|
|
202
|
-
this.errorType === 'toast' &&
|
|
204
|
+
this.errorType === 'toast' && toast(errors[0].message)
|
|
203
205
|
reject(errors)
|
|
204
206
|
} else {
|
|
205
207
|
resolve(true)
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<view
|
|
4
4
|
class="u-form-item__body"
|
|
5
5
|
@tap="clickHandler"
|
|
6
|
-
:style="[
|
|
6
|
+
:style="[addStyle(customStyle), {
|
|
7
7
|
flexDirection: (labelPosition || parentData.labelPosition) === 'left' ? 'row' : 'column'
|
|
8
8
|
}]"
|
|
9
9
|
>
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
class="u-form-item__body__left"
|
|
15
15
|
v-if="required || leftIcon || label"
|
|
16
16
|
:style="{
|
|
17
|
-
width:
|
|
17
|
+
width: addUnit(labelWidth || parentData.labelWidth),
|
|
18
18
|
marginBottom: parentData.labelPosition === 'left' ? 0 : '5px',
|
|
19
19
|
}"
|
|
20
20
|
>
|
|
@@ -62,22 +62,25 @@
|
|
|
62
62
|
v-if="!!message && parentData.errorType === 'message'"
|
|
63
63
|
class="u-form-item__body__right__message"
|
|
64
64
|
:style="{
|
|
65
|
-
marginLeft:
|
|
65
|
+
marginLeft: addUnit(parentData.labelPosition === 'top' ? 0 : (labelWidth || parentData.labelWidth))
|
|
66
66
|
}"
|
|
67
67
|
>{{ message }}</text>
|
|
68
68
|
</slot>
|
|
69
69
|
<u-line
|
|
70
70
|
v-if="borderBottom"
|
|
71
|
-
:color="message && parentData.errorType === 'border-bottom' ?
|
|
71
|
+
:color="message && parentData.errorType === 'border-bottom' ? color.error : propsLine.color"
|
|
72
72
|
:customStyle="`margin-top: ${message && parentData.errorType === 'message' ? '5px' : 0}`"
|
|
73
73
|
></u-line>
|
|
74
74
|
</view>
|
|
75
75
|
</template>
|
|
76
76
|
|
|
77
77
|
<script>
|
|
78
|
-
import props from './props
|
|
79
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
80
|
-
import mixin from '../../libs/mixin/mixin
|
|
78
|
+
import props from './props';
|
|
79
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
80
|
+
import mixin from '../../libs/mixin/mixin';
|
|
81
|
+
import defProps from '../../libs/config/props.js';
|
|
82
|
+
import color from '../../libs/config/color';
|
|
83
|
+
import { addStyle, addUnit, getProperty, setProperty, error } from '../../libs/function/index';
|
|
81
84
|
/**
|
|
82
85
|
* Form 表单
|
|
83
86
|
* @description 此组件一般用于表单场景,可以配置Input输入框,Select弹出框,进行表单验证等。
|
|
@@ -118,7 +121,7 @@
|
|
|
118
121
|
// 组件创建完成时,将当前实例保存到u-form中
|
|
119
122
|
computed: {
|
|
120
123
|
propsLine() {
|
|
121
|
-
return
|
|
124
|
+
return defProps.line
|
|
122
125
|
}
|
|
123
126
|
},
|
|
124
127
|
mounted() {
|
|
@@ -126,11 +129,14 @@
|
|
|
126
129
|
},
|
|
127
130
|
emits: ["click"],
|
|
128
131
|
methods: {
|
|
132
|
+
addStyle,
|
|
133
|
+
addUnit,
|
|
134
|
+
color,
|
|
129
135
|
init() {
|
|
130
136
|
// 父组件的实例
|
|
131
137
|
this.updateParentData()
|
|
132
138
|
if (!this.parent) {
|
|
133
|
-
|
|
139
|
+
error('u-form-item需要结合u-form组件使用')
|
|
134
140
|
}
|
|
135
141
|
},
|
|
136
142
|
// 获取父组件的参数
|
|
@@ -145,9 +151,9 @@
|
|
|
145
151
|
// 清空当前的组件的校验结果,并重置为初始值
|
|
146
152
|
resetField() {
|
|
147
153
|
// 找到原始值
|
|
148
|
-
const value =
|
|
154
|
+
const value = getProperty(this.parent.originalModel, this.prop)
|
|
149
155
|
// 将u-form的model的prop属性链还原原始值
|
|
150
|
-
|
|
156
|
+
setProperty(this.parent.model, this.prop, value)
|
|
151
157
|
// 移除校验结果
|
|
152
158
|
this.message = null
|
|
153
159
|
},
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
5
|
<script>
|
|
6
|
-
import props from './props
|
|
7
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
8
|
-
import mixin from '../../libs/mixin/mixin
|
|
6
|
+
import props from './props';
|
|
7
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
8
|
+
import mixin from '../../libs/mixin/mixin';
|
|
9
9
|
import { addStyle, addUnit, deepMerge } from '../../libs/function/index.js';
|
|
10
10
|
/**
|
|
11
11
|
* gap 间隔槽
|
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
</template>
|
|
10
10
|
|
|
11
11
|
<script>
|
|
12
|
-
import props from './props
|
|
13
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
14
|
-
import mixin from '../../libs/mixin/mixin
|
|
12
|
+
import props from './props';
|
|
13
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
14
|
+
import mixin from '../../libs/mixin/mixin';
|
|
15
|
+
import { addStyle, deepMerge } from '../../libs/function/index';
|
|
15
16
|
/**
|
|
16
17
|
* grid 宫格布局
|
|
17
18
|
* @description 宫格组件一般用于同时展示多个同类项目的场景,可以给宫格的项目设置徽标组件(badge),或者图标等,也可以扩展为左右滑动的轮播形式。
|
|
@@ -68,12 +69,16 @@
|
|
|
68
69
|
default:
|
|
69
70
|
style.justifyContent = 'flex-start';
|
|
70
71
|
};
|
|
71
|
-
return
|
|
72
|
+
return deepMerge(style, addStyle(this.customStyle));
|
|
72
73
|
}
|
|
73
74
|
},
|
|
74
|
-
emits: ['click'], // 防止事件执行两次
|
|
75
|
+
emits: ['click'], // 防止事件执行两次
|
|
76
|
+
// 20240409发现抖音小程序如果开启virtualHost会出现严重问题,几乎所有事件包括created等生命周期事件全部失效。
|
|
77
|
+
// #ifdef MP-WEIXIN
|
|
78
|
+
options: {
|
|
75
79
|
// virtualHost: true ,//将自定义节点设置成虚拟的,更加接近Vue组件的表现。我们不希望自定义组件的这个节点本身可以设置样式、响应 flex 布局等
|
|
76
|
-
},
|
|
80
|
+
},
|
|
81
|
+
// #endif
|
|
77
82
|
methods: {
|
|
78
83
|
// 此方法由u-grid-item触发,用于在u-grid发出事件
|
|
79
84
|
childClick(name) {
|
|
@@ -97,6 +102,12 @@
|
|
|
97
102
|
justify-content: center;
|
|
98
103
|
@include flex;
|
|
99
104
|
flex-wrap: wrap;
|
|
100
|
-
align-items: center;
|
|
105
|
+
align-items: center;
|
|
106
|
+
// 在uni-app中应尽量避免使用flex布局以外的方式,因为nvue/uvue等方案都支持flex布局
|
|
107
|
+
// 这里使用grid布局使用为目前20240409uni-app在抖音小程序开启virtualHost时有bug,存在事件失效问题。
|
|
108
|
+
/* #ifdef MP-TOUTIAO */
|
|
109
|
+
display: grid;
|
|
110
|
+
grid-template-columns: repeat(v-bind(col), 1fr);
|
|
111
|
+
/* #endif */
|
|
101
112
|
}
|
|
102
113
|
</style>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<!-- #ifndef APP-NVUE -->
|
|
3
|
-
<view
|
|
2
|
+
<!-- #ifndef APP-NVUE -->
|
|
3
|
+
<view
|
|
4
|
+
v-if="parentData.col > 0"
|
|
4
5
|
class="u-grid-item"
|
|
5
6
|
hover-class="u-grid-item--hover-class"
|
|
6
7
|
:hover-stay-time="200"
|
|
@@ -25,9 +26,10 @@
|
|
|
25
26
|
</template>
|
|
26
27
|
|
|
27
28
|
<script>
|
|
28
|
-
import props from './props
|
|
29
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
30
|
-
import mixin from '../../libs/mixin/mixin
|
|
29
|
+
import props from './props';
|
|
30
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
31
|
+
import mixin from '../../libs/mixin/mixin';
|
|
32
|
+
import { addStyle, deepMerge } from '../../libs/function/index';
|
|
31
33
|
/**
|
|
32
34
|
* gridItem 提示
|
|
33
35
|
* @description 宫格组件一般用于同时展示多个同类项目的场景,可以给宫格的项目设置徽标组件(badge),或者图标等,也可以扩展为左右滑动的轮播形式。搭配u-grid使用
|
|
@@ -49,7 +51,8 @@
|
|
|
49
51
|
},
|
|
50
52
|
// #ifdef APP-NVUE
|
|
51
53
|
width: 0, // nvue下才这么计算,vue下放到computed中,否则会因为延时造成闪烁
|
|
52
|
-
// #endif
|
|
54
|
+
// #endif
|
|
55
|
+
// #ifdef MP-TOUTIAO
|
|
53
56
|
width: '100%',
|
|
54
57
|
// #endif
|
|
55
58
|
classes: [], // 类名集合,用于判断是否显示右边和下边框
|
|
@@ -60,9 +63,11 @@
|
|
|
60
63
|
},
|
|
61
64
|
emits: ['click'],
|
|
62
65
|
// 微信小程序中 options 选项
|
|
63
|
-
// #ifdef MP-WEIXIN
|
|
66
|
+
// #ifdef MP-WEIXIN
|
|
67
|
+
options: {
|
|
64
68
|
virtualHost: true ,//将自定义节点设置成虚拟的,更加接近Vue组件的表现。我们不希望自定义组件的这个节点本身可以设置样式、响应 flex 布局等
|
|
65
|
-
},
|
|
69
|
+
},
|
|
70
|
+
// #endif
|
|
66
71
|
computed: {
|
|
67
72
|
// #ifndef APP-NVUE || MP-TOUTIAO
|
|
68
73
|
// vue下放到computed中,否则会因为延时造成闪烁
|
|
@@ -79,7 +84,7 @@
|
|
|
79
84
|
background: this.bgColor,
|
|
80
85
|
width: this.width
|
|
81
86
|
}
|
|
82
|
-
return
|
|
87
|
+
return deepMerge(style, addStyle(this.customStyle))
|
|
83
88
|
}
|
|
84
89
|
},
|
|
85
90
|
methods: {
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
v-if="isImg"
|
|
10
10
|
:src="name"
|
|
11
11
|
:mode="imgMode"
|
|
12
|
-
:style="[imgStyle,
|
|
12
|
+
:style="[imgStyle, addStyle(customStyle)]"
|
|
13
13
|
></image>
|
|
14
14
|
<text
|
|
15
15
|
v-else
|
|
16
16
|
class="u-icon__icon"
|
|
17
17
|
:class="uClasses"
|
|
18
|
-
:style="[iconStyle,
|
|
18
|
+
:style="[iconStyle, addStyle(customStyle)]"
|
|
19
19
|
:hover-class="hoverClass"
|
|
20
20
|
>{{icon}}</text>
|
|
21
21
|
<!-- 这里进行空字符串判断,如果仅仅是v-if="label",可能会出现传递0的时候,结果也无法显示 -->
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
class="u-icon__label"
|
|
25
25
|
:style="{
|
|
26
26
|
color: labelColor,
|
|
27
|
-
fontSize:
|
|
28
|
-
marginLeft: labelPos == 'right' ?
|
|
29
|
-
marginTop: labelPos == 'bottom' ?
|
|
30
|
-
marginRight: labelPos == 'left' ?
|
|
31
|
-
marginBottom: labelPos == 'top' ?
|
|
27
|
+
fontSize: addUnit(labelSize),
|
|
28
|
+
marginLeft: labelPos == 'right' ? addUnit(space) : 0,
|
|
29
|
+
marginTop: labelPos == 'bottom' ? addUnit(space) : 0,
|
|
30
|
+
marginRight: labelPos == 'left' ? addUnit(space) : 0,
|
|
31
|
+
marginBottom: labelPos == 'top' ? addUnit(space) : 0,
|
|
32
32
|
}"
|
|
33
33
|
>{{ label }}</text>
|
|
34
34
|
</view>
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
|
|
49
49
|
// 引入图标名称,已经对应的unicode
|
|
50
50
|
import icons from './icons'
|
|
51
|
-
|
|
52
|
-
import
|
|
53
|
-
import
|
|
54
|
-
import
|
|
55
|
-
|
|
51
|
+
import props from './props';
|
|
52
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
53
|
+
import mixin from '../../libs/mixin/mixin';
|
|
54
|
+
import { addUnit, addStyle } from '../../libs/function/index';
|
|
55
|
+
import config from '../../libs/config/config';
|
|
56
56
|
/**
|
|
57
57
|
* icon 图标
|
|
58
58
|
* @description 基于字体的图标集,包含了大多数常见场景的图标。
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
classes.push(this.customPrefix)
|
|
101
101
|
}
|
|
102
102
|
// 主题色,通过类配置
|
|
103
|
-
if (this.color &&
|
|
103
|
+
if (this.color && config.type.includes(this.color)) classes.push('u-icon__icon--' + this.color)
|
|
104
104
|
// 阿里,头条,百度小程序通过数组绑定类名时,无法直接使用[a, b, c]的形式,否则无法识别
|
|
105
105
|
// 故需将其拆成一个字符串的形式,通过空格隔开各个类名
|
|
106
106
|
//#ifdef MP-ALIPAY || MP-TOUTIAO || MP-BAIDU
|
|
@@ -111,14 +111,14 @@
|
|
|
111
111
|
iconStyle() {
|
|
112
112
|
let style = {}
|
|
113
113
|
style = {
|
|
114
|
-
fontSize:
|
|
115
|
-
lineHeight:
|
|
114
|
+
fontSize: addUnit(this.size),
|
|
115
|
+
lineHeight: addUnit(this.size),
|
|
116
116
|
fontWeight: this.bold ? 'bold' : 'normal',
|
|
117
117
|
// 某些特殊情况需要设置一个到顶部的距离,才能更好的垂直居中
|
|
118
|
-
top:
|
|
118
|
+
top: addUnit(this.top)
|
|
119
119
|
}
|
|
120
120
|
// 非主题色值时,才当作颜色值
|
|
121
|
-
if (this.color && !
|
|
121
|
+
if (this.color && !config.type.includes(this.color)) style.color = this.color
|
|
122
122
|
|
|
123
123
|
return style
|
|
124
124
|
},
|
|
@@ -129,8 +129,8 @@
|
|
|
129
129
|
imgStyle() {
|
|
130
130
|
let style = {}
|
|
131
131
|
// 如果设置width和height属性,则优先使用,否则使用size属性
|
|
132
|
-
style.width = this.width ?
|
|
133
|
-
style.height = this.height ?
|
|
132
|
+
style.width = this.width ? addUnit(this.width) : addUnit(this.size)
|
|
133
|
+
style.height = this.height ? addUnit(this.height) : addUnit(this.size)
|
|
134
134
|
return style
|
|
135
135
|
},
|
|
136
136
|
// 通过图标名,查找对应的图标
|
|
@@ -142,6 +142,8 @@
|
|
|
142
142
|
}
|
|
143
143
|
},
|
|
144
144
|
methods: {
|
|
145
|
+
addStyle,
|
|
146
|
+
addUnit,
|
|
145
147
|
clickHandler(e) {
|
|
146
148
|
this.$emit('click', this.index)
|
|
147
149
|
// 是否阻止事件冒泡
|