uview-plus 3.1.51 → 3.2.3
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 +47 -0
- package/components/u-action-sheet/u-action-sheet.vue +1 -1
- package/components/u-album/u-album.vue +261 -261
- package/components/u-avatar/u-avatar.vue +3 -2
- package/components/u-avatar-group/u-avatar-group.vue +106 -106
- package/components/u-button/u-button.vue +12 -7
- package/components/u-calendar/u-calendar.vue +4 -3
- package/components/u-cell/u-cell.vue +6 -3
- package/components/u-checkbox/props.js +5 -0
- package/components/u-checkbox/u-checkbox.vue +27 -15
- package/components/u-code/u-code.vue +1 -1
- package/components/u-copy/u-copy.vue +70 -0
- package/components/u-dropdown/props.js +8 -14
- package/components/u-dropdown/u-dropdown.vue +202 -77
- package/components/u-dropdown-item/props.js +45 -36
- package/components/u-dropdown-item/u-dropdown-item.vue +121 -148
- package/components/u-form/u-form.vue +1 -1
- package/components/u-form-item/props.js +6 -1
- package/components/u-form-item/u-form-item.vue +1 -1
- package/components/u-gap/u-gap.vue +5 -4
- package/components/u-grid/u-grid.vue +4 -2
- package/components/u-grid-item/u-grid-item.vue +8 -7
- package/components/u-input/u-input.vue +1 -1
- package/components/u-lazy-load/u-lazy-load.vue +251 -0
- package/components/u-picker/u-picker.vue +4 -1
- package/components/u-popup/u-popup.vue +1 -1
- package/components/u-read-more/u-read-more.vue +164 -160
- package/components/u-slider/u-slider.vue +6 -6
- package/components/u-steps-item/u-steps-item.vue +318 -318
- package/components/u-subsection/u-subsection.vue +14 -8
- package/components/u-swiper/u-swiper.vue +6 -8
- package/components/u-tabs/u-tabs.vue +1 -0
- package/components/u-tag/props.js +5 -2
- package/components/u-text/u-text.vue +226 -226
- package/components/u-textarea/u-textarea.vue +275 -275
- package/components/u-transition/u-transition.vue +1 -1
- package/components/u-waterfall/u-waterfall.vue +225 -0
- package/index.js +5 -1
- package/libs/config/props/formItem.js +1 -0
- package/libs/config/props/tag.js +30 -29
- package/libs/css/common.scss +1 -1
- package/libs/css/components.scss +5 -5
- package/libs/function/colorGradient.js +8 -8
- package/libs/function/debounce.js +2 -2
- package/libs/function/digit.js +5 -5
- package/libs/function/index.js +29 -29
- package/libs/function/test.js +28 -28
- package/libs/function/throttle.js +2 -2
- package/libs/mixin/mixin.js +2 -2
- package/package.json +2 -2
|
@@ -1,127 +1,252 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<view class="u-
|
|
3
|
-
<view
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class="u-dropdown__menu__item__content__text"
|
|
19
|
-
:style="[index === current ? activeStyle : inactiveStyle]"
|
|
20
|
-
>{{item.title}}</text>
|
|
21
|
-
<view
|
|
22
|
-
class="u-dropdown__menu__item__content__arrow"
|
|
23
|
-
:class="[index === current && 'u-dropdown__menu__item__content__arrow--rotate']"
|
|
24
|
-
>
|
|
25
|
-
<u-icon
|
|
26
|
-
:name="menuIcon"
|
|
27
|
-
:size="$u.addUnit(menuIconSize)"
|
|
28
|
-
></u-icon>
|
|
2
|
+
<view class="u-dropdown">
|
|
3
|
+
<view class="u-dropdown__menu" :style="{
|
|
4
|
+
height: $u.addUnit(height)
|
|
5
|
+
}" :class="{
|
|
6
|
+
'u-border-bottom': borderBottom
|
|
7
|
+
}">
|
|
8
|
+
<view class="u-dropdown__menu__item" v-for="(item, index) in menuList" :key="index" @tap.stop="menuClick(index)">
|
|
9
|
+
<view class="u-flex u-flex-row">
|
|
10
|
+
<text class="u-dropdown__menu__item__text" :style="{
|
|
11
|
+
color: item.disabled ? '#c0c4cc' : (index === current || highlightIndex == index) ? activeColor : inactiveColor,
|
|
12
|
+
fontSize: $u.addUnit(titleSize)
|
|
13
|
+
}">{{item.title}}</text>
|
|
14
|
+
<view class="u-dropdown__menu__item__arrow" :class="{
|
|
15
|
+
'u-dropdown__menu__item__arrow--rotate': index === current
|
|
16
|
+
}">
|
|
17
|
+
<u-icon :custom-style="{display: 'flex'}" :name="menuIcon" :size="$u.addUnit(menuIconSize)" :color="index === current || highlightIndex == index ? activeColor : '#c0c4cc'"></u-icon>
|
|
29
18
|
</view>
|
|
30
19
|
</view>
|
|
31
20
|
</view>
|
|
32
21
|
</view>
|
|
33
|
-
<view class="u-dropdown__content"
|
|
34
|
-
|
|
22
|
+
<view class="u-dropdown__content" :style="[contentStyle, {
|
|
23
|
+
transition: `opacity ${duration / 1000}s linear`,
|
|
24
|
+
top: $u.addUnit(height),
|
|
25
|
+
height: contentHeight + 'px'
|
|
26
|
+
}]"
|
|
27
|
+
@tap="maskClick" @touchmove.stop.prevent>
|
|
28
|
+
<view @tap.stop.prevent class="u-dropdown__content__popup" :style="[popupStyle]">
|
|
29
|
+
<slot></slot>
|
|
30
|
+
</view>
|
|
31
|
+
<view class="u-dropdown__content__mask"></view>
|
|
35
32
|
</view>
|
|
36
33
|
</view>
|
|
37
34
|
</template>
|
|
38
35
|
|
|
39
36
|
<script>
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
import props from './props.js';
|
|
38
|
+
import mpMixin from '../../libs/mixin/mpMixin.js';
|
|
42
39
|
import mixin from '../../libs/mixin/mixin.js';
|
|
43
40
|
/**
|
|
44
|
-
*
|
|
45
|
-
* @description
|
|
46
|
-
* @tutorial
|
|
47
|
-
* @property {String}
|
|
48
|
-
* @
|
|
49
|
-
* @
|
|
41
|
+
* dropdown 下拉菜单
|
|
42
|
+
* @description 该组件一般用于向下展开菜单,同时可切换多个选项卡的场景
|
|
43
|
+
* @tutorial https://ijry.github.io/uview-plus/components/dropdown.html
|
|
44
|
+
* @property {String} active-color 标题和选项卡选中的颜色(默认#2979ff)
|
|
45
|
+
* @property {String} inactive-color 标题和选项卡未选中的颜色(默认#606266)
|
|
46
|
+
* @property {Boolean} close-on-click-mask 点击遮罩是否关闭菜单(默认true)
|
|
47
|
+
* @property {Boolean} close-on-click-self 点击当前激活项标题是否关闭菜单(默认true)
|
|
48
|
+
* @property {String | Number} duration 选项卡展开和收起的过渡时间,单位ms(默认300)
|
|
49
|
+
* @property {String | Number} height 标题菜单的高度,单位任意(默认80)
|
|
50
|
+
* @property {String | Number} border-radius 菜单展开内容下方的圆角值,单位任意(默认0)
|
|
51
|
+
* @property {Boolean} border-bottom 标题菜单是否显示下边框(默认false)
|
|
52
|
+
* @property {String | Number} title-size 标题的字体大小,单位任意,数值默认为rpx单位(默认28)
|
|
53
|
+
* @event {Function} open 下拉菜单被打开时触发
|
|
54
|
+
* @event {Function} close 下拉菜单被关闭时触发
|
|
55
|
+
* @example <u-dropdown></u-dropdown>
|
|
50
56
|
*/
|
|
51
57
|
export default {
|
|
52
58
|
name: 'u-dropdown',
|
|
53
|
-
|
|
59
|
+
mixins: [mpMixin, mixin, props],
|
|
54
60
|
data() {
|
|
55
61
|
return {
|
|
56
|
-
|
|
57
|
-
|
|
62
|
+
showDropdown: true, // 是否打开下来菜单,
|
|
63
|
+
menuList: [], // 显示的菜单
|
|
64
|
+
active: false, // 下拉菜单的状态
|
|
65
|
+
// 当前是第几个菜单处于激活状态,小程序中此处不能写成false或者"",否则后续将current赋值为0,
|
|
66
|
+
// 无能的TX没有使用===而是使用==判断,导致程序认为前后二者没有变化,从而不会触发视图更新
|
|
67
|
+
current: 99999,
|
|
68
|
+
// 外层内容的样式,初始时处于底层,且透明
|
|
69
|
+
contentStyle: {
|
|
70
|
+
zIndex: -1,
|
|
71
|
+
opacity: 0
|
|
72
|
+
},
|
|
73
|
+
// 让某个菜单保持高亮的状态
|
|
74
|
+
highlightIndex: 99999,
|
|
75
|
+
contentHeight: 0
|
|
58
76
|
}
|
|
59
77
|
},
|
|
60
78
|
computed: {
|
|
61
|
-
|
|
79
|
+
// 下拉出来部分的样式
|
|
80
|
+
popupStyle() {
|
|
81
|
+
let style = {};
|
|
82
|
+
// 进行Y轴位移,展开状态时,恢复原位。收齐状态时,往上位移100%,进行隐藏
|
|
83
|
+
style.transform = `translateY(${this.active ? 0 : '-100%'})`
|
|
84
|
+
style['transition-duration'] = this.duration / 1000 + 's';
|
|
85
|
+
style.borderRadius = `0 0 ${this.$u.addUnit(this.borderRadius)} ${this.$u.addUnit(this.borderRadius)}`;
|
|
86
|
+
return style;
|
|
87
|
+
}
|
|
62
88
|
},
|
|
63
89
|
created() {
|
|
90
|
+
// 引用所有子组件(u-dropdown-item)的this,不能在data中声明变量,否则在微信小程序会造成循环引用而报错
|
|
64
91
|
this.children = [];
|
|
65
92
|
},
|
|
66
|
-
|
|
93
|
+
mounted() {
|
|
94
|
+
this.getContentHeight();
|
|
95
|
+
},
|
|
96
|
+
emits: ['open', 'close'],
|
|
67
97
|
methods: {
|
|
68
|
-
|
|
98
|
+
init() {
|
|
99
|
+
// 当某个子组件内容变化时,触发父组件的init,父组件再让每一个子组件重新初始化一遍
|
|
100
|
+
// 以保证数据的正确性
|
|
101
|
+
this.menuList = [];
|
|
69
102
|
this.children.map(child => {
|
|
70
|
-
|
|
71
|
-
// this.queryRect('u-dropdown__menu').then(size => {
|
|
72
|
-
child.$emit('click')
|
|
73
|
-
child.setContentAnimate(child.show ? 0 : 300)
|
|
74
|
-
child.show = !child.show
|
|
75
|
-
// })
|
|
76
|
-
} else {
|
|
77
|
-
child.show = false
|
|
78
|
-
child.setContentAnimate(0)
|
|
79
|
-
}
|
|
103
|
+
child.init();
|
|
80
104
|
})
|
|
81
105
|
},
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
this
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
106
|
+
// 点击菜单
|
|
107
|
+
menuClick(index) {
|
|
108
|
+
// 判断是否被禁用
|
|
109
|
+
if (this.menuList[index].disabled) return;
|
|
110
|
+
// 如果点击时的索引和当前激活项索引相同,意味着点击了激活项,需要收起下拉菜单
|
|
111
|
+
if (index === this.current && this.closeOnClickSelf) {
|
|
112
|
+
this.close();
|
|
113
|
+
// 等动画结束后,再移除下拉菜单中的内容,否则直接移除,也就没有下拉菜单收起的效果了
|
|
114
|
+
setTimeout(() => {
|
|
115
|
+
this.children[index].active = false;
|
|
116
|
+
}, this.duration)
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
this.open(index);
|
|
120
|
+
},
|
|
121
|
+
// 打开下拉菜单
|
|
122
|
+
open(index) {
|
|
123
|
+
// 嵌套popup使用时可能获取不到正确的高度,重新计算
|
|
124
|
+
if (this.contentHeight < 1) this.getContentHeight()
|
|
125
|
+
// 重置高亮索引,否则会造成多个菜单同时高亮
|
|
126
|
+
// this.highlightIndex = 9999;
|
|
127
|
+
// 展开时,设置下拉内容的样式
|
|
128
|
+
this.contentStyle = {
|
|
129
|
+
zIndex: 11,
|
|
130
|
+
}
|
|
131
|
+
// 标记展开状态以及当前展开项的索引
|
|
132
|
+
this.active = true;
|
|
133
|
+
this.current = index;
|
|
134
|
+
// 历遍所有的子元素,将索引匹配的项标记为激活状态,因为子元素是通过v-if控制切换的
|
|
135
|
+
// 之所以不是因display: none,是因为nvue没有display这个属性
|
|
136
|
+
this.children.map((val, idx) => {
|
|
137
|
+
val.active = index == idx ? true : false;
|
|
100
138
|
})
|
|
101
|
-
|
|
139
|
+
this.$emit('open', this.current);
|
|
102
140
|
},
|
|
103
|
-
|
|
141
|
+
// 设置下拉菜单处于收起状态
|
|
142
|
+
close() {
|
|
143
|
+
this.$emit('close', this.current);
|
|
144
|
+
// 设置为收起状态,同时current归位,设置为空字符串
|
|
145
|
+
this.active = false;
|
|
146
|
+
this.current = 99999;
|
|
147
|
+
// 下拉内容的样式进行调整,不透明度设置为0
|
|
148
|
+
this.contentStyle = {
|
|
149
|
+
zIndex: -1,
|
|
150
|
+
opacity: 0
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
// 点击遮罩
|
|
154
|
+
maskClick() {
|
|
155
|
+
// 如果不允许点击遮罩,直接返回
|
|
156
|
+
if (!this.closeOnClickMask) return;
|
|
157
|
+
this.close();
|
|
158
|
+
},
|
|
159
|
+
// 外部手动设置某个菜单高亮
|
|
160
|
+
highlight(index = undefined) {
|
|
161
|
+
this.highlightIndex = index !== undefined ? index : 99999;
|
|
162
|
+
},
|
|
163
|
+
// 获取下拉菜单内容的高度
|
|
164
|
+
getContentHeight() {
|
|
165
|
+
// 这里的原理为,因为dropdown组件是相对定位的,它的下拉出来的内容,必须给定一个高度
|
|
166
|
+
// 才能让遮罩占满菜单一下,直到屏幕底部的高度
|
|
167
|
+
// this.$u.sys()为uView封装的获取设备信息的方法
|
|
168
|
+
let windowHeight = this.$u.sys().windowHeight;
|
|
169
|
+
this.$uGetRect('.u-dropdown__menu').then(res => {
|
|
170
|
+
// 这里获取的是dropdown的尺寸,在H5上,uniapp获取尺寸是有bug的(以前提出修复过,后来又出现了此bug,目前hx2.8.11版本)
|
|
171
|
+
// H5端bug表现为元素尺寸的top值为导航栏底部到到元素的上边沿的距离,但是元素的bottom值确是导航栏顶部到元素底部的距离
|
|
172
|
+
// 二者是互相矛盾的,本质原因是H5端导航栏非原生,uni的开发者大意造成
|
|
173
|
+
// 这里取菜单栏的botton值合理的,不能用res.top,否则页面会造成滚动
|
|
174
|
+
this.contentHeight = windowHeight - res.bottom;
|
|
175
|
+
})
|
|
176
|
+
}
|
|
177
|
+
}
|
|
104
178
|
}
|
|
105
179
|
</script>
|
|
106
180
|
|
|
107
|
-
<style lang="scss">
|
|
108
|
-
@import
|
|
181
|
+
<style scoped lang="scss">
|
|
182
|
+
@import "../../libs/css/components.scss";
|
|
109
183
|
|
|
110
184
|
.u-dropdown {
|
|
185
|
+
flex: 1;
|
|
186
|
+
width: 100%;
|
|
187
|
+
position: relative;
|
|
111
188
|
|
|
112
189
|
&__menu {
|
|
113
190
|
@include flex;
|
|
191
|
+
position: relative;
|
|
192
|
+
z-index: 11;
|
|
193
|
+
height: 80rpx;
|
|
114
194
|
|
|
115
195
|
&__item {
|
|
116
196
|
flex: 1;
|
|
117
197
|
@include flex;
|
|
118
198
|
justify-content: center;
|
|
199
|
+
align-items: center;
|
|
119
200
|
|
|
120
|
-
|
|
121
|
-
|
|
201
|
+
.u-flex-row {
|
|
202
|
+
flex-direction: row;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
&__text {
|
|
206
|
+
font-size: 28rpx;
|
|
207
|
+
color: $u-content-color;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
&__arrow {
|
|
211
|
+
margin-left: 6rpx;
|
|
212
|
+
transition: transform .3s;
|
|
122
213
|
align-items: center;
|
|
214
|
+
@include flex;
|
|
215
|
+
|
|
216
|
+
&--rotate {
|
|
217
|
+
transform: rotate(180deg);
|
|
218
|
+
}
|
|
123
219
|
}
|
|
124
220
|
}
|
|
125
221
|
}
|
|
222
|
+
|
|
223
|
+
&__content {
|
|
224
|
+
position: absolute;
|
|
225
|
+
z-index: 8;
|
|
226
|
+
width: 100%;
|
|
227
|
+
left: 0px;
|
|
228
|
+
bottom: 0;
|
|
229
|
+
overflow: hidden;
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
&__mask {
|
|
233
|
+
position: absolute;
|
|
234
|
+
z-index: 9;
|
|
235
|
+
background: rgba(0, 0, 0, .3);
|
|
236
|
+
width: 100%;
|
|
237
|
+
left: 0;
|
|
238
|
+
top: 0;
|
|
239
|
+
bottom: 0;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
&__popup {
|
|
243
|
+
position: relative;
|
|
244
|
+
z-index: 10;
|
|
245
|
+
transition: all 0.3s;
|
|
246
|
+
transform: translate3D(0, -100%, 0);
|
|
247
|
+
overflow: hidden;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
126
251
|
}
|
|
127
252
|
</style>
|
|
@@ -1,36 +1,45 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
props: {
|
|
3
|
-
//
|
|
4
|
-
value
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
// #ifdef VUE3
|
|
4
|
+
// 当前选中项的value值
|
|
5
|
+
modelValue: {
|
|
6
|
+
type: [Number, String, Array],
|
|
7
|
+
default: ''
|
|
8
|
+
},
|
|
9
|
+
// #endif
|
|
10
|
+
// #ifdef VUE2
|
|
11
|
+
// 当前选中项的value值
|
|
12
|
+
value: {
|
|
13
|
+
type: [Number, String, Array],
|
|
14
|
+
default: ''
|
|
15
|
+
},
|
|
16
|
+
// #endif
|
|
17
|
+
// 菜单项标题
|
|
18
|
+
title: {
|
|
19
|
+
type: [String, Number],
|
|
20
|
+
default: ''
|
|
21
|
+
},
|
|
22
|
+
// 选项数据,如果传入了默认slot,此参数无效
|
|
23
|
+
options: {
|
|
24
|
+
type: Array,
|
|
25
|
+
default() {
|
|
26
|
+
return []
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
// 是否禁用此菜单项
|
|
30
|
+
disabled: {
|
|
31
|
+
type: Boolean,
|
|
32
|
+
default: false
|
|
33
|
+
},
|
|
34
|
+
// 下拉弹窗的高度
|
|
35
|
+
height: {
|
|
36
|
+
type: [Number, String],
|
|
37
|
+
default: 'auto'
|
|
38
|
+
},
|
|
39
|
+
// 点击遮罩是否可以收起弹窗
|
|
40
|
+
closeOnClickOverlay: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
default: true
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|