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
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { error, priceFormat, timeFormat } from '../../libs/function/index';
|
|
2
|
+
import test from '../../libs/function/test';
|
|
1
3
|
export default {
|
|
2
4
|
computed: {
|
|
3
5
|
// 经处理后需要显示的值
|
|
@@ -12,32 +14,32 @@ export default {
|
|
|
12
14
|
if (mode === 'price') {
|
|
13
15
|
// 如果text不为金额进行提示
|
|
14
16
|
if (!/^\d+(\.\d+)?$/.test(text)) {
|
|
15
|
-
|
|
17
|
+
error('金额模式下,text参数需要为金额格式');
|
|
16
18
|
}
|
|
17
19
|
// 进行格式化,判断用户传入的format参数为正则,或者函数,如果没有传入format,则使用默认的金额格式化处理
|
|
18
|
-
if (
|
|
20
|
+
if (test.func(format)) {
|
|
19
21
|
// 如果用户传入的是函数,使用函数格式化
|
|
20
22
|
return format(text)
|
|
21
23
|
}
|
|
22
24
|
// 如果format非正则,非函数,则使用默认的金额格式化方法进行操作
|
|
23
|
-
return
|
|
25
|
+
return priceFormat(text, 2)
|
|
24
26
|
} if (mode === 'date') {
|
|
25
27
|
// 判断是否合法的日期或者时间戳
|
|
26
|
-
!
|
|
28
|
+
!test.date(text) && error('日期模式下,text参数需要为日期或时间戳格式')
|
|
27
29
|
// 进行格式化,判断用户传入的format参数为正则,或者函数,如果没有传入format,则使用默认的格式化处理
|
|
28
|
-
if (
|
|
30
|
+
if (test.func(format)) {
|
|
29
31
|
// 如果用户传入的是函数,使用函数格式化
|
|
30
32
|
return format(text)
|
|
31
33
|
} if (format) {
|
|
32
34
|
// 如果format非正则,非函数,则使用默认的时间格式化方法进行操作
|
|
33
|
-
return
|
|
35
|
+
return timeFormat(text, format)
|
|
34
36
|
}
|
|
35
37
|
// 如果没有设置format,则设置为默认的时间格式化形式
|
|
36
|
-
return
|
|
38
|
+
return timeFormat(text, 'yyyy-mm-dd')
|
|
37
39
|
} if (mode === 'phone') {
|
|
38
40
|
// 判断是否合法的手机号
|
|
39
|
-
// !
|
|
40
|
-
if (
|
|
41
|
+
// !test.mobile(text) && error('手机号模式下,text参数需要为手机号码格式')
|
|
42
|
+
if (test.func(format)) {
|
|
41
43
|
// 如果用户传入的是函数,使用函数格式化
|
|
42
44
|
return format(text)
|
|
43
45
|
} if (format === 'encrypt') {
|
|
@@ -47,8 +49,8 @@ export default {
|
|
|
47
49
|
return text
|
|
48
50
|
} if (mode === 'name') {
|
|
49
51
|
// 判断是否合法的字符粗
|
|
50
|
-
!(typeof (text) === 'string') &&
|
|
51
|
-
if (
|
|
52
|
+
!(typeof (text) === 'string') && error('姓名模式下,text参数需要为字符串格式')
|
|
53
|
+
if (test.func(format)) {
|
|
52
54
|
// 如果用户传入的是函数,使用函数格式化
|
|
53
55
|
return format(text)
|
|
54
56
|
} if (format === 'encrypt') {
|
|
@@ -58,7 +60,7 @@ export default {
|
|
|
58
60
|
return text
|
|
59
61
|
} if (mode === 'link') {
|
|
60
62
|
// 判断是否合法的字符粗
|
|
61
|
-
!
|
|
63
|
+
!test.url(href) && error('超链接模式下,href参数需要为URL格式')
|
|
62
64
|
return text
|
|
63
65
|
}
|
|
64
66
|
return text
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
<textarea
|
|
4
4
|
class="u-textarea__field"
|
|
5
5
|
:value="innerValue"
|
|
6
|
-
:style="{ height:
|
|
6
|
+
:style="{ height: addUnit(height) }"
|
|
7
7
|
:placeholder="placeholder"
|
|
8
|
-
:placeholder-style="
|
|
8
|
+
:placeholder-style="addStyle(placeholderStyle, 'string')"
|
|
9
9
|
:placeholder-class="placeholderClass"
|
|
10
10
|
:disabled="disabled"
|
|
11
11
|
:focus="focus"
|
|
@@ -44,8 +44,9 @@
|
|
|
44
44
|
|
|
45
45
|
<script>
|
|
46
46
|
import props from "./props.js";
|
|
47
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
48
|
-
import mixin from '../../libs/mixin/mixin
|
|
47
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
48
|
+
import mixin from '../../libs/mixin/mixin';
|
|
49
|
+
import { addStyle, addUnit, deepMerge, formValidate, os } from '../../libs/function/index';
|
|
49
50
|
/**
|
|
50
51
|
* Textarea 文本域
|
|
51
52
|
* @description 文本域此组件满足了可能出现的表单信息补充,编辑等实际逻辑的功能,内置了字数校验等
|
|
@@ -164,20 +165,22 @@ export default {
|
|
|
164
165
|
const style = {};
|
|
165
166
|
// #ifdef APP-NVUE
|
|
166
167
|
// 由于textarea在安卓nvue上的差异性,需要额外再调整其内边距
|
|
167
|
-
if (
|
|
168
|
+
if (os() === "android") {
|
|
168
169
|
style.paddingTop = "6px";
|
|
169
170
|
style.paddingLeft = "9px";
|
|
170
171
|
style.paddingBottom = "3px";
|
|
171
172
|
style.paddingRight = "6px";
|
|
172
173
|
}
|
|
173
174
|
// #endif
|
|
174
|
-
return
|
|
175
|
+
return deepMerge(style, addStyle(this.customStyle));
|
|
175
176
|
},
|
|
176
177
|
},
|
|
177
178
|
// #ifdef VUE3
|
|
178
179
|
emits: ['update:modelValue', 'linechange', 'focus', 'blur', 'change', 'confirm', 'keyboardheightchange'],
|
|
179
180
|
// #endif
|
|
180
181
|
methods: {
|
|
182
|
+
addStyle,
|
|
183
|
+
addUnit,
|
|
181
184
|
// 在微信小程序中,不支持将函数当做props参数,故只能通过ref形式调用
|
|
182
185
|
setFormatter(e) {
|
|
183
186
|
this.innerFormatter = e
|
|
@@ -188,7 +191,7 @@ export default {
|
|
|
188
191
|
onBlur(e) {
|
|
189
192
|
this.$emit("blur", e);
|
|
190
193
|
// 尝试调用u-form的验证方法
|
|
191
|
-
|
|
194
|
+
formValidate(this, "blur");
|
|
192
195
|
},
|
|
193
196
|
onLinechange(e) {
|
|
194
197
|
this.$emit("linechange", e);
|
|
@@ -219,7 +222,7 @@ export default {
|
|
|
219
222
|
this.changeFromInner = true;
|
|
220
223
|
this.$emit("change", value);
|
|
221
224
|
// 尝试调用u-form的验证方法
|
|
222
|
-
|
|
225
|
+
formValidate(this, "change");
|
|
223
226
|
});
|
|
224
227
|
},
|
|
225
228
|
onConfirm(e) {
|
|
@@ -39,8 +39,11 @@
|
|
|
39
39
|
</template>
|
|
40
40
|
|
|
41
41
|
<script>
|
|
42
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
43
|
-
import mixin from '../../libs/mixin/mixin
|
|
42
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
43
|
+
import mixin from '../../libs/mixin/mixin';
|
|
44
|
+
import { os, sys, deepMerge, type2icon } from '../../libs/function/index';
|
|
45
|
+
import color from '../../libs/config/color';
|
|
46
|
+
import { hexToRgb } from '../../libs/function/colorGradient';
|
|
44
47
|
/**
|
|
45
48
|
* toast 消息提示
|
|
46
49
|
* @description 此组件表现形式类似uni的uni.showToastAPI,但也有不同的地方。
|
|
@@ -90,7 +93,7 @@
|
|
|
90
93
|
return '';
|
|
91
94
|
}
|
|
92
95
|
if (['error', 'warning', 'success', 'primary'].includes(this.tmpConfig.type)) {
|
|
93
|
-
return
|
|
96
|
+
return type2icon(this.tmpConfig.type)
|
|
94
97
|
} else {
|
|
95
98
|
return ''
|
|
96
99
|
}
|
|
@@ -111,24 +114,24 @@
|
|
|
111
114
|
style.marginRight = '4px'
|
|
112
115
|
// #ifdef APP-NVUE
|
|
113
116
|
// iOSAPP下,图标有1px的向下偏移,这里进行修正
|
|
114
|
-
if (
|
|
117
|
+
if (os() === 'ios') {
|
|
115
118
|
style.marginTop = '-1px'
|
|
116
119
|
}
|
|
117
120
|
// #endif
|
|
118
121
|
return style
|
|
119
122
|
},
|
|
120
123
|
loadingIconColor() {
|
|
121
|
-
let
|
|
124
|
+
let colorTmp = 'rgb(255, 255, 255)'
|
|
122
125
|
if (['error', 'warning', 'success', 'primary'].includes(this.tmpConfig.type)) {
|
|
123
126
|
// loading-icon组件内部会对color参数进行一个透明度处理,该方法要求传入的颜色值
|
|
124
127
|
// 必须为rgb格式的,所以这里做一个处理
|
|
125
|
-
|
|
128
|
+
colorTmp = hexToRgb(color[this.tmpConfig.type])
|
|
126
129
|
}
|
|
127
|
-
return
|
|
130
|
+
return colorTmp
|
|
128
131
|
},
|
|
129
132
|
// 内容盒子的样式
|
|
130
133
|
contentStyle() {
|
|
131
|
-
const windowHeight =
|
|
134
|
+
const windowHeight = sys().windowHeight, style = {}
|
|
132
135
|
let value = 0
|
|
133
136
|
// 根据top和bottom,对Y轴进行窗体高度的百分比偏移
|
|
134
137
|
if(this.tmpConfig.position === 'top') {
|
|
@@ -153,7 +156,7 @@
|
|
|
153
156
|
// 显示toast组件,由父组件通过this.$refs.xxx.show(options)形式调用
|
|
154
157
|
show(options) {
|
|
155
158
|
// 不将结果合并到this.config变量,避免多次调用u-toast,前后的配置造成混乱
|
|
156
|
-
this.tmpConfig =
|
|
159
|
+
this.tmpConfig = deepMerge(this.config, options)
|
|
157
160
|
// 清除定时器
|
|
158
161
|
this.clearTimer()
|
|
159
162
|
this.isShow = true
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
</template>
|
|
37
37
|
|
|
38
38
|
<script>
|
|
39
|
-
import props from './props
|
|
40
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
41
|
-
import mixin from '../../libs/mixin/mixin
|
|
39
|
+
import props from './props';
|
|
40
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
41
|
+
import mixin from '../../libs/mixin/mixin';
|
|
42
42
|
/**
|
|
43
43
|
* Toolbar 工具条
|
|
44
44
|
* @description
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view
|
|
3
3
|
class="u-tooltip"
|
|
4
|
-
:style="[
|
|
4
|
+
:style="[addStyle(customStyle)]"
|
|
5
5
|
>
|
|
6
6
|
<u-overlay
|
|
7
7
|
:show="showTooltip && tooltipTop !== -10000 && overlay"
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
duration="300"
|
|
28
28
|
:customStyle="{
|
|
29
29
|
position: 'absolute',
|
|
30
|
-
top:
|
|
30
|
+
top: addUnit(tooltipTop),
|
|
31
31
|
zIndex: zIndex,
|
|
32
32
|
...tooltipStyle
|
|
33
33
|
}"
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
hover-class="u-tooltip__wrapper__popup__indicator--hover"
|
|
43
43
|
v-if="showCopy || buttons.length"
|
|
44
44
|
:style="[indicatorStyle, {
|
|
45
|
-
width:
|
|
46
|
-
height:
|
|
45
|
+
width: addUnit(indicatorWidth),
|
|
46
|
+
height: addUnit(indicatorWidth),
|
|
47
47
|
}]"
|
|
48
48
|
>
|
|
49
49
|
<!-- 由于nvue不支持三角形绘制,这里就做一个四方形,再旋转45deg,得到露出的一个三角 -->
|
|
@@ -90,9 +90,10 @@
|
|
|
90
90
|
</template>
|
|
91
91
|
|
|
92
92
|
<script>
|
|
93
|
-
import props from './props
|
|
94
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
95
|
-
import mixin from '../../libs/mixin/mixin
|
|
93
|
+
import props from './props';
|
|
94
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
95
|
+
import mixin from '../../libs/mixin/mixin';
|
|
96
|
+
import { addStyle, addUnit, getPx, guid, toast, sleep, sys } from '../../libs/function/index';
|
|
96
97
|
// #ifdef APP-NVUE
|
|
97
98
|
const dom = uni.requireNativePlugin('dom')
|
|
98
99
|
// #endif
|
|
@@ -123,8 +124,8 @@
|
|
|
123
124
|
// 是否展示气泡
|
|
124
125
|
showTooltip: true,
|
|
125
126
|
// 生成唯一id,防止一个页面多个组件,造成干扰
|
|
126
|
-
textId:
|
|
127
|
-
tooltipId:
|
|
127
|
+
textId: guid(),
|
|
128
|
+
tooltipId: guid(),
|
|
128
129
|
// 初始时甚至为很大的值,让其移到屏幕外面,为了计算元素的尺寸
|
|
129
130
|
tooltipTop: -10000,
|
|
130
131
|
// 气泡的位置信息
|
|
@@ -161,18 +162,16 @@
|
|
|
161
162
|
const style = {
|
|
162
163
|
transform: `translateY(${this.direction === 'top' ? '-100%' : '100%'})`,
|
|
163
164
|
},
|
|
164
|
-
|
|
165
|
-
getPx = uni.$u.getPx,
|
|
166
|
-
addUnit = uni.$u.addUnit
|
|
165
|
+
sysInfo = sys()
|
|
167
166
|
if (this.tooltipInfo.width / 2 > this.textInfo.left + this.textInfo.width / 2 - this.screenGap) {
|
|
168
167
|
this.indicatorStyle = {}
|
|
169
168
|
style.left = `-${addUnit(this.textInfo.left - this.screenGap)}`
|
|
170
169
|
this.indicatorStyle.left = addUnit(this.textInfo.width / 2 - getPx(style.left) - this.indicatorWidth /
|
|
171
170
|
2)
|
|
172
|
-
} else if (this.tooltipInfo.width / 2 >
|
|
171
|
+
} else if (this.tooltipInfo.width / 2 > sysInfo.windowWidth - this.textInfo.right + this.textInfo.width / 2 -
|
|
173
172
|
this.screenGap) {
|
|
174
173
|
this.indicatorStyle = {}
|
|
175
|
-
style.right = `-${addUnit(
|
|
174
|
+
style.right = `-${addUnit(sysInfo.windowWidth - this.textInfo.right - this.screenGap)}`
|
|
176
175
|
this.indicatorStyle.right = addUnit(this.textInfo.width / 2 - getPx(style.right) - this
|
|
177
176
|
.indicatorWidth / 2)
|
|
178
177
|
} else {
|
|
@@ -195,6 +194,8 @@
|
|
|
195
194
|
},
|
|
196
195
|
emits: ["click"],
|
|
197
196
|
methods: {
|
|
197
|
+
addStyle,
|
|
198
|
+
addUnit,
|
|
198
199
|
init() {
|
|
199
200
|
this.getElRect()
|
|
200
201
|
},
|
|
@@ -240,7 +241,7 @@
|
|
|
240
241
|
// 调用之前,先将指示器调整到屏幕外,方便获取尺寸
|
|
241
242
|
this.showTooltip = true
|
|
242
243
|
this.tooltipTop = -10000
|
|
243
|
-
|
|
244
|
+
sleep(500).then(() => {
|
|
244
245
|
this.queryRect(this.tooltipId).then(size => {
|
|
245
246
|
this.tooltipInfo = size
|
|
246
247
|
// 获取气泡尺寸之后,将其隐藏,为了让下次切换气泡显示与隐藏时,有淡入淡出的效果
|
|
@@ -260,10 +261,10 @@
|
|
|
260
261
|
// 优先使用copyText字段,如果没有,则默认使用text字段当做复制的内容
|
|
261
262
|
data: this.copyText || this.text,
|
|
262
263
|
success: () => {
|
|
263
|
-
this.showToast &&
|
|
264
|
+
this.showToast && toast('复制成功')
|
|
264
265
|
},
|
|
265
266
|
fail: () => {
|
|
266
|
-
this.showToast &&
|
|
267
|
+
this.showToast && toast('复制失败')
|
|
267
268
|
},
|
|
268
269
|
complete: () => {
|
|
269
270
|
this.showTooltip = false
|
package/components/u-tr/u-tr.vue
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
7
|
<script>
|
|
8
|
-
import props from './props
|
|
9
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
10
|
-
import mixin from '../../libs/mixin/mixin
|
|
8
|
+
import props from './props';
|
|
9
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
10
|
+
import mixin from '../../libs/mixin/mixin';
|
|
11
11
|
/**
|
|
12
12
|
* Tr
|
|
13
13
|
* @description
|
|
@@ -23,7 +23,7 @@ const getStyle = (name) => animationMap[name]
|
|
|
23
23
|
// #endif
|
|
24
24
|
|
|
25
25
|
import { nextTick } from 'vue'
|
|
26
|
-
|
|
26
|
+
import { sleep } from '../../libs/function/index';
|
|
27
27
|
export default {
|
|
28
28
|
methods: {
|
|
29
29
|
// 组件被点击发出事件
|
|
@@ -44,7 +44,7 @@ export default {
|
|
|
44
44
|
await nextTick();
|
|
45
45
|
{
|
|
46
46
|
// https://github.com/umicro/uView2.0/issues/545
|
|
47
|
-
await
|
|
47
|
+
await sleep(20)
|
|
48
48
|
// 标识动画尚未结束
|
|
49
49
|
this.$emit('enter')
|
|
50
50
|
this.transitionEnded = false
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
</template>
|
|
14
14
|
|
|
15
15
|
<script>
|
|
16
|
-
import props from './props
|
|
17
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
18
|
-
import mixin from '../../libs/mixin/mixin
|
|
16
|
+
import props from './props';
|
|
17
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
18
|
+
import mixin from '../../libs/mixin/mixin';
|
|
19
|
+
import { addStyle } from '../../libs/function/index';
|
|
19
20
|
// 组件的methods方法,由于内容较长,写在外部文件中通过mixin引入
|
|
20
21
|
import transition from "./transition.js";
|
|
21
22
|
/**
|
|
@@ -58,12 +59,12 @@ export default {
|
|
|
58
59
|
transitionTimingFunction: this.timingFunction,
|
|
59
60
|
// #endif
|
|
60
61
|
// 避免自定义样式影响到动画属性,所以写在viewStyle前面
|
|
61
|
-
...
|
|
62
|
+
...addStyle(customStyle),
|
|
62
63
|
...viewStyle
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
},
|
|
66
|
-
// 将mixin
|
|
67
|
+
// 将mixin挂在到组件中,实际上为一个vue格式对象。
|
|
67
68
|
mixins: [mpMixin, mixin, transition, props],
|
|
68
69
|
watch: {
|
|
69
70
|
show: {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { error } from '../../libs/function/index';
|
|
1
2
|
export default {
|
|
2
3
|
watch: {
|
|
3
4
|
// 监听accept的变化,判断是否符合个平台要求
|
|
@@ -7,15 +8,15 @@ export default {
|
|
|
7
8
|
handler(val) {
|
|
8
9
|
// #ifndef MP-WEIXIN
|
|
9
10
|
if (val === 'all' || val === 'media') {
|
|
10
|
-
|
|
11
|
+
error('只有微信小程序才支持把accept配置为all、media之一')
|
|
11
12
|
}
|
|
12
13
|
// #endif
|
|
13
14
|
// #ifndef H5 || MP-WEIXIN
|
|
14
15
|
if (val === 'file') {
|
|
15
|
-
|
|
16
|
+
error('只有微信小程序和H5(HX2.9.9)才支持把accept配置为file')
|
|
16
17
|
}
|
|
17
18
|
// #endif
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
|
-
}
|
|
22
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view class="u-upload" :style="[
|
|
2
|
+
<view class="u-upload" :style="[addStyle(customStyle)]">
|
|
3
3
|
<view class="u-upload__wrap" >
|
|
4
4
|
<template v-if="previewImage">
|
|
5
5
|
<view
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
class="u-upload__wrap__preview__image"
|
|
15
15
|
@tap="onPreviewImage(item)"
|
|
16
16
|
:style="[{
|
|
17
|
-
width:
|
|
18
|
-
height:
|
|
17
|
+
width: addUnit(width),
|
|
18
|
+
height: addUnit(height)
|
|
19
19
|
}]"
|
|
20
20
|
/>
|
|
21
21
|
<view
|
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
@tap="chooseFile"
|
|
105
105
|
:class="[disabled && 'u-upload__button--disabled']"
|
|
106
106
|
:style="[{
|
|
107
|
-
width:
|
|
108
|
-
height:
|
|
107
|
+
width: addUnit(width),
|
|
108
|
+
height: addUnit(height)
|
|
109
109
|
}]"
|
|
110
110
|
>
|
|
111
111
|
<u-icon
|
|
@@ -129,10 +129,11 @@
|
|
|
129
129
|
chooseFile
|
|
130
130
|
} from './utils';
|
|
131
131
|
import mixinUp from './mixin.js';
|
|
132
|
-
import props from './props
|
|
133
|
-
import mpMixin from '../../libs/mixin/mpMixin
|
|
134
|
-
import mixin from '../../libs/mixin/mixin
|
|
135
|
-
|
|
132
|
+
import props from './props';
|
|
133
|
+
import mpMixin from '../../libs/mixin/mpMixin';
|
|
134
|
+
import mixin from '../../libs/mixin/mixin';
|
|
135
|
+
import { addStyle, addUnit, toast } from '../../libs/function/index';
|
|
136
|
+
import test from '../../libs/function/test';
|
|
136
137
|
/**
|
|
137
138
|
* upload 上传
|
|
138
139
|
* @description 该组件用于上传图片场景
|
|
@@ -192,6 +193,8 @@
|
|
|
192
193
|
emits: ['error', 'beforeRead', 'oversize', 'afterRead', 'delete', 'clickPreview'],
|
|
193
194
|
// #endif
|
|
194
195
|
methods: {
|
|
196
|
+
addUnit,
|
|
197
|
+
addStyle,
|
|
195
198
|
formatFileList() {
|
|
196
199
|
const {
|
|
197
200
|
fileList = [], maxCount
|
|
@@ -199,8 +202,8 @@
|
|
|
199
202
|
const lists = fileList.map((item) =>
|
|
200
203
|
Object.assign(Object.assign({}, item), {
|
|
201
204
|
// 如果item.url为本地选择的blob文件的话,无法判断其为video还是image,此处优先通过accept做判断处理
|
|
202
|
-
isImage: this.accept === 'image' ||
|
|
203
|
-
isVideo: this.accept === 'video' ||
|
|
205
|
+
isImage: this.accept === 'image' || test.image(item.url || item.thumb),
|
|
206
|
+
isVideo: this.accept === 'video' || test.video(item.url || item.thumb),
|
|
204
207
|
deletable: typeof(item.deletable) === 'boolean' ? item.deletable : this.deletable,
|
|
205
208
|
})
|
|
206
209
|
);
|
|
@@ -218,7 +221,7 @@
|
|
|
218
221
|
// 如果用户传入的是字符串,需要格式化成数组
|
|
219
222
|
let capture;
|
|
220
223
|
try {
|
|
221
|
-
capture =
|
|
224
|
+
capture = test.array(this.capture) ? this.capture : this.capture.split(',');
|
|
222
225
|
}catch(e) {
|
|
223
226
|
capture = [];
|
|
224
227
|
}
|
|
@@ -250,7 +253,7 @@
|
|
|
250
253
|
} = this;
|
|
251
254
|
let res = true
|
|
252
255
|
// beforeRead是否为一个方法
|
|
253
|
-
if (
|
|
256
|
+
if (test.func(beforeRead)) {
|
|
254
257
|
// 如果用户定义了此方法,则去执行此方法,并传入读取的文件回调
|
|
255
258
|
res = beforeRead(file, this.getDetail());
|
|
256
259
|
}
|
|
@@ -271,7 +274,7 @@
|
|
|
271
274
|
if (!res) {
|
|
272
275
|
return;
|
|
273
276
|
}
|
|
274
|
-
if (
|
|
277
|
+
if (test.promise(res)) {
|
|
275
278
|
res.then((data) => this.onAfterRead(data || file));
|
|
276
279
|
} else {
|
|
277
280
|
this.onAfterRead(file);
|
|
@@ -317,10 +320,10 @@
|
|
|
317
320
|
if (!item.isImage || !this.previewFullImage) return
|
|
318
321
|
uni.previewImage({
|
|
319
322
|
// 先filter找出为图片的item,再返回filter结果中的图片url
|
|
320
|
-
urls: this.lists.filter((item) => this.accept === 'image' ||
|
|
323
|
+
urls: this.lists.filter((item) => this.accept === 'image' || test.image(item.url || item.thumb)).map((item) => item.url || item.thumb),
|
|
321
324
|
current: item.url || item.thumb,
|
|
322
325
|
fail() {
|
|
323
|
-
|
|
326
|
+
toast('预览图片失败')
|
|
324
327
|
},
|
|
325
328
|
});
|
|
326
329
|
},
|
|
@@ -342,7 +345,7 @@
|
|
|
342
345
|
),
|
|
343
346
|
current: index,
|
|
344
347
|
fail() {
|
|
345
|
-
|
|
348
|
+
toast('预览视频失败')
|
|
346
349
|
},
|
|
347
350
|
});
|
|
348
351
|
},
|
package/index.js
CHANGED
|
@@ -81,11 +81,6 @@ const $u = {
|
|
|
81
81
|
uni.$u = $u
|
|
82
82
|
|
|
83
83
|
const install = (Vue) => {
|
|
84
|
-
// 时间格式化,同时两个名称,date和timeFormat
|
|
85
|
-
// Vue.filter('timeFormat', (timestamp, format) => uni.$u.timeFormat(timestamp, format))
|
|
86
|
-
// Vue.filter('date', (timestamp, format) => uni.$u.timeFormat(timestamp, format))
|
|
87
|
-
// // 将多久以前的方法,注入到全局过滤器
|
|
88
|
-
// Vue.filter('timeFrom', (timestamp, format) => uni.$u.timeFrom(timestamp, format))
|
|
89
84
|
// 同时挂载到uni和Vue.prototype中
|
|
90
85
|
// #ifndef APP-NVUE
|
|
91
86
|
// 只有vue,挂载到Vue.prototype才有意义,因为nvue中全局Vue.prototype和Vue.mixin是无效的
|
package/libs/function/index.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
number as testNumber,
|
|
3
|
+
array as testArray,
|
|
4
|
+
empty as testEmpty
|
|
5
|
+
} from './test'
|
|
2
6
|
import { round } from './digit.js'
|
|
7
|
+
import config from '../config/config';
|
|
3
8
|
/**
|
|
4
9
|
* @description 如果value小于min,取min;如果value大于max,取max
|
|
5
10
|
* @param {number} min
|
|
@@ -11,18 +16,18 @@ export function range(min = 0, max = 0, value = 0) {
|
|
|
11
16
|
}
|
|
12
17
|
|
|
13
18
|
/**
|
|
14
|
-
* @description 用于获取用户传递值的px值 如果用户传递了"xxpx"或者"xxrpx",取出其数值部分,如果是"xxxrpx"还需要用过uni.
|
|
19
|
+
* @description 用于获取用户传递值的px值 如果用户传递了"xxpx"或者"xxrpx",取出其数值部分,如果是"xxxrpx"还需要用过uni.rpx2px进行转换
|
|
15
20
|
* @param {number|string} value 用户传递值的px值
|
|
16
21
|
* @param {boolean} unit
|
|
17
22
|
* @returns {number|string}
|
|
18
23
|
*/
|
|
19
24
|
export function getPx(value, unit = false) {
|
|
20
|
-
if (
|
|
25
|
+
if (testNumber(value)) {
|
|
21
26
|
return unit ? `${value}px` : Number(value)
|
|
22
27
|
}
|
|
23
28
|
// 如果带有rpx,先取出其数值部分,再转为px值
|
|
24
29
|
if (/(rpx|upx)$/.test(value)) {
|
|
25
|
-
return unit ? `${uni.
|
|
30
|
+
return unit ? `${uni.rpx2px(parseInt(value))}px` : Number(uni.rpx2px(parseInt(value)))
|
|
26
31
|
}
|
|
27
32
|
return unit ? `${parseInt(value)}px` : parseInt(value)
|
|
28
33
|
}
|
|
@@ -133,7 +138,7 @@ export function $parent(name = undefined) {
|
|
|
133
138
|
*/
|
|
134
139
|
export function addStyle(customStyle, target = 'object') {
|
|
135
140
|
// 字符串转字符串,对象转对象情形,直接返回
|
|
136
|
-
if (
|
|
141
|
+
if (testEmpty(customStyle) || typeof(customStyle) === 'object' && target === 'object' || target === 'string' &&
|
|
137
142
|
typeof(customStyle) === 'string') {
|
|
138
143
|
return customStyle
|
|
139
144
|
}
|
|
@@ -156,10 +161,12 @@ export function addStyle(customStyle, target = 'object') {
|
|
|
156
161
|
}
|
|
157
162
|
// 这里为对象转字符串形式
|
|
158
163
|
let string = ''
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
164
|
+
if (typeof customStyle === 'object') {
|
|
165
|
+
customStyle.forEach((val, i) => {
|
|
166
|
+
// 驼峰转为中划线的形式,否则css内联样式,无法识别驼峰样式属性名
|
|
167
|
+
const key = i.replace(/([A-Z])/g, '-$1').toLowerCase()
|
|
168
|
+
string += `${key}:${val};`
|
|
169
|
+
})
|
|
163
170
|
}
|
|
164
171
|
// 去除两端空格
|
|
165
172
|
return trim(string)
|
|
@@ -172,11 +179,11 @@ export function addStyle(customStyle, target = 'object') {
|
|
|
172
179
|
*/
|
|
173
180
|
export function addUnit(value = 'auto', unit = '') {
|
|
174
181
|
if (!unit) {
|
|
175
|
-
unit =
|
|
182
|
+
unit = config.unit || 'px'
|
|
176
183
|
}
|
|
177
184
|
value = String(value)
|
|
178
185
|
// 用uView内置验证规则中的number判断是否为数值
|
|
179
|
-
return
|
|
186
|
+
return testNumber(value) ? `${value}${unit}` : value
|
|
180
187
|
}
|
|
181
188
|
|
|
182
189
|
/**
|
|
@@ -191,7 +198,7 @@ export function deepClone(obj) {
|
|
|
191
198
|
// 原始类型直接返回
|
|
192
199
|
return obj
|
|
193
200
|
}
|
|
194
|
-
const o =
|
|
201
|
+
const o = testArray(obj) ? [] : {}
|
|
195
202
|
for (const i in obj) {
|
|
196
203
|
if (obj.hasOwnProperty(i)) {
|
|
197
204
|
o[i] = typeof obj[i] === 'object' ? deepClone(obj[i]) : obj[i]
|
|
@@ -206,8 +213,8 @@ export function deepClone(obj) {
|
|
|
206
213
|
* @param {object} source 拷贝的来源对象
|
|
207
214
|
* @returns {object|boolean} 深度合并后的对象或者false(入参有不是对象)
|
|
208
215
|
*/
|
|
209
|
-
export function deepMerge(
|
|
210
|
-
target = deepClone(
|
|
216
|
+
export function deepMerge(targetOrigin = {}, source = {}) {
|
|
217
|
+
let target = deepClone(targetOrigin)
|
|
211
218
|
if (typeof target !== 'object' || typeof source !== 'object') return false
|
|
212
219
|
for (const prop in source) {
|
|
213
220
|
if (!source.hasOwnProperty(prop)) continue
|
|
@@ -591,8 +598,8 @@ export function padZero(value) {
|
|
|
591
598
|
* @param {*} event
|
|
592
599
|
*/
|
|
593
600
|
export function formValidate(instance, event) {
|
|
594
|
-
const formItem =
|
|
595
|
-
const form =
|
|
601
|
+
const formItem = $parent.call(instance, 'u-form-item')
|
|
602
|
+
const form = $parent.call(instance, 'u-form')
|
|
596
603
|
// 如果发生变化的input或者textarea等,其父组件中有u-form-item或者u-form等,就执行form的validate方法
|
|
597
604
|
// 同时将form-item的pros传递给form,让其进行精确对象验证
|
|
598
605
|
if (formItem && form) {
|
|
@@ -607,9 +614,9 @@ export function formValidate(instance, event) {
|
|
|
607
614
|
* @returns {*}
|
|
608
615
|
*/
|
|
609
616
|
export function getProperty(obj, key) {
|
|
610
|
-
if (
|
|
611
|
-
|
|
612
|
-
|
|
617
|
+
if (typeof obj !== 'object' || null == obj) {
|
|
618
|
+
return ''
|
|
619
|
+
}
|
|
613
620
|
if (typeof key !== 'string' || key === '') {
|
|
614
621
|
return ''
|
|
615
622
|
}
|
|
@@ -634,7 +641,7 @@ export function getProperty(obj, key) {
|
|
|
634
641
|
* @param {string} value 设置的值
|
|
635
642
|
*/
|
|
636
643
|
export function setProperty(obj, key, value) {
|
|
637
|
-
if (
|
|
644
|
+
if (typeof obj !== 'object' || null == obj) {
|
|
638
645
|
return
|
|
639
646
|
}
|
|
640
647
|
// 递归赋值
|