uview-plus 3.7.0 → 3.7.28
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 +82 -0
- package/components/u-action-sheet/actionSheet.js +2 -0
- package/components/u-action-sheet/props.js +10 -0
- package/components/u-action-sheet/u-action-sheet.vue +3 -3
- package/components/u-box/box.js +24 -0
- package/components/u-box/props.js +37 -7
- package/components/u-box/u-box.vue +29 -14
- package/components/u-canvas/u-canvas.vue +301 -24
- package/components/u-cascader/u-cascader.vue +1 -0
- package/components/u-checkbox-group/u-checkbox-group.vue +4 -1
- package/components/u-copy/u-copy.vue +1 -1
- package/components/u-coupon/u-coupon.vue +1 -2
- package/components/u-form/u-form.vue +2 -2
- package/components/u-form-item/u-form-item.vue +6 -6
- package/components/u-loading-icon/u-loading-icon.vue +2 -1
- package/components/u-qrcode/u-qrcode.vue +1 -1
- package/components/u-select/u-select.vue +198 -178
- package/components/u-signature/u-signature.vue +137 -137
- package/components/u-slider/props.js +17 -2
- package/components/u-slider/slider.js +6 -3
- package/components/u-slider/u-slider.vue +112 -35
- package/components/u-steps/u-steps.vue +1 -1
- package/components/u-switch/props.js +10 -0
- package/components/u-switch/switch.js +2 -0
- package/components/u-switch/u-switch.vue +15 -13
- package/components/u-table2/u-table2.vue +266 -110
- package/components/u-tabs/u-tabs.vue +83 -95
- package/libs/css/flex.scss +2 -1
- package/libs/util/gcanvas/bridge/bridge-weex.js +0 -0
- package/libs/util/gcanvas/context-2d/FillStyleLinearGradient.js +0 -0
- package/libs/util/gcanvas/context-2d/FillStylePattern.js +0 -0
- package/libs/util/gcanvas/context-2d/FillStyleRadialGradient.js +0 -0
- package/libs/util/gcanvas/context-2d/RenderingContext.js +0 -0
- package/libs/util/gcanvas/context-webgl/ActiveInfo.js +0 -0
- package/libs/util/gcanvas/context-webgl/Buffer.js +0 -0
- package/libs/util/gcanvas/context-webgl/Framebuffer.js +0 -0
- package/libs/util/gcanvas/context-webgl/GLenum.js +0 -0
- package/libs/util/gcanvas/context-webgl/GLmethod.js +0 -0
- package/libs/util/gcanvas/context-webgl/GLtype.js +0 -0
- package/libs/util/gcanvas/context-webgl/Program.js +0 -0
- package/libs/util/gcanvas/context-webgl/Renderbuffer.js +0 -0
- package/libs/util/gcanvas/context-webgl/RenderingContext.js +0 -0
- package/libs/util/gcanvas/context-webgl/Shader.js +0 -0
- package/libs/util/gcanvas/context-webgl/ShaderPrecisionFormat.js +0 -0
- package/libs/util/gcanvas/context-webgl/Texture.js +0 -0
- package/libs/util/gcanvas/context-webgl/UniformLocation.js +0 -0
- package/libs/util/gcanvas/context-webgl/classUtils.js +0 -0
- package/libs/util/gcanvas/env/canvas.js +0 -0
- package/libs/util/gcanvas/env/image.js +0 -0
- package/libs/util/gcanvas/env/tool.js +0 -0
- package/libs/util/gcanvas/index.js +0 -0
- package/package.json +1 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view
|
|
3
3
|
class="u-slider"
|
|
4
|
-
:style="[addStyle(customStyle)]"
|
|
4
|
+
:style="[addStyle(customStyle), {width: vertical ? addUnit(this.blockSize): ''}]"
|
|
5
5
|
>
|
|
6
6
|
<template v-if="!useNative || isRange">
|
|
7
7
|
<view ref="u-slider-inner" class="u-slider-inner" @click="onClick"
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
class="u-slider__base"
|
|
14
14
|
:style="[
|
|
15
15
|
{
|
|
16
|
-
|
|
16
|
+
width: vertical ? addUnit(sizeLocal) : addUnit(length),
|
|
17
|
+
height: vertical ? addUnit(length) : addUnit(sizeLocal),
|
|
17
18
|
backgroundColor: inactiveColor
|
|
18
19
|
}
|
|
19
20
|
]"
|
|
@@ -25,8 +26,6 @@
|
|
|
25
26
|
:style="[
|
|
26
27
|
barStyle,
|
|
27
28
|
{
|
|
28
|
-
height: height,
|
|
29
|
-
marginTop: '-' + height,
|
|
30
29
|
backgroundColor: activeColor
|
|
31
30
|
}
|
|
32
31
|
]"
|
|
@@ -37,8 +36,6 @@
|
|
|
37
36
|
:style="[
|
|
38
37
|
barStyle0,
|
|
39
38
|
{
|
|
40
|
-
height: height,
|
|
41
|
-
marginTop: '-' + height,
|
|
42
39
|
backgroundColor: inactiveColor
|
|
43
40
|
}
|
|
44
41
|
]"
|
|
@@ -55,7 +52,7 @@
|
|
|
55
52
|
<template v-if="isRange">
|
|
56
53
|
<view class="u-slider__button-wrap u-slider__button-wrap-0" @touchstart="onTouchStart($event, 0)"
|
|
57
54
|
@touchmove="onTouchMove($event, 0)" @touchend="onTouchEnd($event, 0)"
|
|
58
|
-
@touchcancel="onTouchEnd($event, 0)" :style="
|
|
55
|
+
@touchcancel="onTouchEnd($event, 0)" :style="touchButtonStyle(barStyle0)">
|
|
59
56
|
<slot name="min" v-if="$slots.min || $slots.$min"/>
|
|
60
57
|
<view v-else class="u-slider__button" :style="[blockStyle, {
|
|
61
58
|
height: getPx(blockSize, true),
|
|
@@ -66,7 +63,7 @@
|
|
|
66
63
|
</template>
|
|
67
64
|
<view class="u-slider__button-wrap" @touchstart="onTouchStart"
|
|
68
65
|
@touchmove="onTouchMove" @touchend="onTouchEnd"
|
|
69
|
-
@touchcancel="onTouchEnd" :style="
|
|
66
|
+
@touchcancel="onTouchEnd" :style="touchButtonStyle(barStyle)">
|
|
70
67
|
<slot name="max" v-if="isRange && ($slots.max || $slots.$max)"/>
|
|
71
68
|
<slot v-else-if="$slots.default || $slots.$default"/>
|
|
72
69
|
<view v-else class="u-slider__button" :style="[blockStyle, {
|
|
@@ -76,7 +73,9 @@
|
|
|
76
73
|
}]"></view>
|
|
77
74
|
</view>
|
|
78
75
|
</view>
|
|
79
|
-
<view class="u-slider__show-value" v-if="showValue && !isRange">
|
|
76
|
+
<view class="u-slider__show-value" v-if="showValue && !isRange">
|
|
77
|
+
{{ modelValue }}
|
|
78
|
+
</view>
|
|
80
79
|
</template>
|
|
81
80
|
<slider
|
|
82
81
|
class="u-slider__native"
|
|
@@ -98,10 +97,10 @@
|
|
|
98
97
|
</template>
|
|
99
98
|
|
|
100
99
|
<script>
|
|
101
|
-
import { props } from './props'
|
|
102
|
-
import { mpMixin } from '../../libs/mixin/mpMixin'
|
|
103
|
-
import { mixin } from '../../libs/mixin/mixin'
|
|
104
|
-
import { addStyle, getPx, sleep } from '../../libs/function/index.js'
|
|
100
|
+
import { props } from './props'
|
|
101
|
+
import { mpMixin } from '../../libs/mixin/mpMixin'
|
|
102
|
+
import { mixin } from '../../libs/mixin/mixin'
|
|
103
|
+
import { addUnit, addStyle, getPx, sleep } from '../../libs/function/index.js'
|
|
105
104
|
// #ifdef APP-NVUE
|
|
106
105
|
const dom = uni.requireNativePlugin('dom')
|
|
107
106
|
// #endif
|
|
@@ -130,17 +129,22 @@
|
|
|
130
129
|
data() {
|
|
131
130
|
return {
|
|
132
131
|
startX: 0,
|
|
132
|
+
startY: 0,
|
|
133
133
|
status: 'end',
|
|
134
134
|
newValue: 0,
|
|
135
135
|
distanceX: 0,
|
|
136
|
+
distanceY: 0,
|
|
136
137
|
startValue0: 0,
|
|
137
138
|
startValue: 0,
|
|
138
139
|
barStyle0: {},
|
|
139
140
|
barStyle: {},
|
|
140
141
|
sliderRect: {
|
|
141
142
|
left: 0,
|
|
142
|
-
|
|
143
|
-
|
|
143
|
+
top: 0,
|
|
144
|
+
width: 0,
|
|
145
|
+
height: 0
|
|
146
|
+
},
|
|
147
|
+
sizeLocal: '2px'
|
|
144
148
|
};
|
|
145
149
|
},
|
|
146
150
|
watch: {
|
|
@@ -173,12 +177,41 @@
|
|
|
173
177
|
deep:true
|
|
174
178
|
}
|
|
175
179
|
},
|
|
176
|
-
|
|
180
|
+
mounted() {
|
|
181
|
+
if (this.height != '') {
|
|
182
|
+
this.sizeLocal = val
|
|
183
|
+
} else {
|
|
184
|
+
this.sizeLocal = this.size
|
|
185
|
+
}
|
|
177
186
|
},
|
|
178
187
|
computed: {
|
|
188
|
+
touchButtonStyle() {
|
|
189
|
+
return (barStyle) => {
|
|
190
|
+
let style = {}
|
|
191
|
+
if (this.blockSize) {
|
|
192
|
+
if (this.vertical) {
|
|
193
|
+
style.top = (getPx(barStyle.height) ) + 'px'
|
|
194
|
+
} else {
|
|
195
|
+
if (barStyle.width) {
|
|
196
|
+
style.left = (getPx(barStyle.width) + getPx(this.blockSize)/2) + 'px'
|
|
197
|
+
// console.log(style)
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return style
|
|
202
|
+
}
|
|
203
|
+
},
|
|
179
204
|
innerStyleCpu() {
|
|
180
|
-
let style = this.innerStyle;
|
|
181
|
-
|
|
205
|
+
let style = {...this.innerStyle};
|
|
206
|
+
if (this.vertical) {
|
|
207
|
+
style.flexDirection = 'row'
|
|
208
|
+
style.height = this.length
|
|
209
|
+
style.padding = '0'
|
|
210
|
+
style.width = (this.isRange && this.showValue) ? (getPx(this.blockSize) + 24) + 'px' : (getPx(this.blockSize)) + 'px';
|
|
211
|
+
} else {
|
|
212
|
+
style.flexDirection = 'column'
|
|
213
|
+
style.height = (this.isRange && this.showValue) ? (getPx(this.blockSize) + 24) + 'px' : (getPx(this.blockSize)) + 'px';
|
|
214
|
+
}
|
|
182
215
|
return style;
|
|
183
216
|
}
|
|
184
217
|
},
|
|
@@ -202,8 +235,10 @@
|
|
|
202
235
|
dom.getComponentRect(ref, (res) => {
|
|
203
236
|
// console.log(res)
|
|
204
237
|
this.sliderRect = {
|
|
238
|
+
top: res.size.top,
|
|
205
239
|
left: res.size.left,
|
|
206
|
-
width: res.size.width
|
|
240
|
+
width: res.size.width,
|
|
241
|
+
height: res.size.height
|
|
207
242
|
};
|
|
208
243
|
this.init()
|
|
209
244
|
})
|
|
@@ -211,6 +246,7 @@
|
|
|
211
246
|
}
|
|
212
247
|
},
|
|
213
248
|
methods: {
|
|
249
|
+
addUnit,
|
|
214
250
|
addStyle,
|
|
215
251
|
getPx,
|
|
216
252
|
init() {
|
|
@@ -259,10 +295,12 @@
|
|
|
259
295
|
onTouchStart(event, index = 1) {
|
|
260
296
|
if (this.disabled) return;
|
|
261
297
|
this.startX = 0;
|
|
298
|
+
this.startY = 0;
|
|
262
299
|
// 触摸点集
|
|
263
300
|
let touches = event.touches[0];
|
|
264
301
|
// 触摸点到屏幕左边的距离
|
|
265
302
|
this.startX = touches.clientX;
|
|
303
|
+
this.startY = touches.clientY;
|
|
266
304
|
// 此处的this.modelValue虽为props值,但是通过$emit('update:modelValue')进行了修改
|
|
267
305
|
if (this.isRange) {
|
|
268
306
|
this.startValue0 = this.format(this.rangeValue[0], 0);
|
|
@@ -277,18 +315,30 @@
|
|
|
277
315
|
}
|
|
278
316
|
// 标示当前的状态为开始触摸滑动
|
|
279
317
|
this.status = 'start';
|
|
318
|
+
// console.log('start', this.startValue)
|
|
280
319
|
|
|
281
320
|
let clientX = 0;
|
|
321
|
+
let clientY = 0;
|
|
282
322
|
// #ifndef APP-NVUE
|
|
283
323
|
clientX = touches.clientX;
|
|
324
|
+
clientY = touches.clientY;
|
|
284
325
|
// #endif
|
|
285
326
|
// #ifdef APP-NVUE
|
|
286
327
|
clientX = touches.screenX;
|
|
328
|
+
clientY = touches.screenY;
|
|
287
329
|
// #endif
|
|
288
|
-
this.
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
330
|
+
if (this.vertical) {
|
|
331
|
+
this.distanceY = clientY - this.sliderRect.top;
|
|
332
|
+
// 获得移动距离对整个滑块的值,此为带有多位小数的值,不能用此更新视图
|
|
333
|
+
// 否则造成通信阻塞,需要每改变一个step值时修改一次视图
|
|
334
|
+
this.newValue = ((this.distanceY / this.sliderRect.height) * (this.max - this.min)) + parseFloat(this.min);
|
|
335
|
+
} else {
|
|
336
|
+
this.distanceX = clientX - this.sliderRect.left;
|
|
337
|
+
// 获得移动距离对整个滑块的值,此为带有多位小数的值,不能用此更新视图
|
|
338
|
+
// 否则造成通信阻塞,需要每改变一个step值时修改一次视图
|
|
339
|
+
this.newValue = ((this.distanceX / this.sliderRect.width) * (this.max - this.min)) + parseFloat(this.min);
|
|
340
|
+
}
|
|
341
|
+
|
|
292
342
|
this.status = 'moving';
|
|
293
343
|
// 发出moving事件
|
|
294
344
|
let $crtFmtValue = this.updateValue(this.newValue, true, index);
|
|
@@ -303,16 +353,26 @@
|
|
|
303
353
|
// console.log('touchs', touches)
|
|
304
354
|
// 滑块的左边不一定跟屏幕左边接壤,所以需要减去最外层父元素的左边值
|
|
305
355
|
let clientX = 0;
|
|
356
|
+
let clientY = 0;
|
|
306
357
|
// #ifndef APP-NVUE
|
|
307
358
|
clientX = touches.clientX;
|
|
359
|
+
clientY = touches.clientY;
|
|
308
360
|
// #endif
|
|
309
361
|
// #ifdef APP-NVUE
|
|
310
362
|
clientX = touches.screenX;
|
|
363
|
+
clientY = touches.screenY;
|
|
311
364
|
// #endif
|
|
312
|
-
this.
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
365
|
+
if (this.vertical) {
|
|
366
|
+
this.distanceY = clientY - this.sliderRect.top;
|
|
367
|
+
// 获得移动距离对整个滑块的值,此为带有多位小数的值,不能用此更新视图
|
|
368
|
+
// 否则造成通信阻塞,需要每改变一个step值时修改一次视图
|
|
369
|
+
this.newValue = ((this.distanceY / this.sliderRect.height) * (this.max - this.min)) + parseFloat(this.min);
|
|
370
|
+
} else {
|
|
371
|
+
this.distanceX = clientX - this.sliderRect.left;
|
|
372
|
+
// 获得移动距离对整个滑块的值,此为带有多位小数的值,不能用此更新视图
|
|
373
|
+
// 否则造成通信阻塞,需要每改变一个step值时修改一次视图
|
|
374
|
+
this.newValue = ((this.distanceX / this.sliderRect.width) * (this.max - this.min)) + parseFloat(this.min);
|
|
375
|
+
}
|
|
316
376
|
this.status = 'moving';
|
|
317
377
|
// 发出moving事件
|
|
318
378
|
let $crtFmtValue = this.updateValue(this.newValue, true, index);
|
|
@@ -348,23 +408,40 @@
|
|
|
348
408
|
// console.log('click', event)
|
|
349
409
|
// #ifndef APP-NVUE
|
|
350
410
|
// nvue下暂时无法获取坐标
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
411
|
+
if (this.vertical) {
|
|
412
|
+
let clientY = event.detail.y - this.sliderRect.top
|
|
413
|
+
// console.log(this.sliderRect.top, event.detail.y)
|
|
414
|
+
this.newValue = ((clientY / this.sliderRect.height) * (this.max - this.min)) + parseFloat(this.min)
|
|
415
|
+
this.updateValue(this.newValue, false, 1)
|
|
416
|
+
} else {
|
|
417
|
+
let clientX = event.detail.x - this.sliderRect.left
|
|
418
|
+
this.newValue = ((clientX / this.sliderRect.width) * (this.max - this.min)) + parseFloat(this.min)
|
|
419
|
+
this.updateValue(this.newValue, false, 1)
|
|
420
|
+
}
|
|
354
421
|
// #endif
|
|
355
422
|
},
|
|
356
423
|
updateValue(value, drag, index = 1) {
|
|
357
424
|
// 去掉小数部分,同时也是对step步进的处理
|
|
358
|
-
let valueFormat = this.format(value, index)
|
|
425
|
+
let valueFormat = this.format(value, index)
|
|
359
426
|
// 不允许滑动的值超过max最大值
|
|
360
427
|
if(valueFormat > this.max ) {
|
|
361
428
|
valueFormat = this.max
|
|
362
429
|
}
|
|
363
430
|
// 设置移动的距离,不能用百分比,因为NVUE不支持。
|
|
364
|
-
let
|
|
365
|
-
let barStyle = {
|
|
366
|
-
|
|
367
|
-
|
|
431
|
+
let sliderLength = 0
|
|
432
|
+
let barStyle = {}
|
|
433
|
+
if (this.vertical) {
|
|
434
|
+
sliderLength = Math.min((valueFormat - this.min) / (this.max - this.min) * this.sliderRect.height, this.sliderRect.height)
|
|
435
|
+
barStyle['height'] = addUnit(sliderLength)
|
|
436
|
+
barStyle['width'] = addUnit(this.sizeLocal)
|
|
437
|
+
barStyle['marginLeft'] = '-' + getPx(this.sizeLocal, true)
|
|
438
|
+
} else {
|
|
439
|
+
sliderLength = Math.min((valueFormat - this.min) / (this.max - this.min) * this.sliderRect.width, this.sliderRect.width)
|
|
440
|
+
barStyle['width'] = addUnit(sliderLength)
|
|
441
|
+
barStyle['height'] = addUnit(this.sizeLocal)
|
|
442
|
+
barStyle['marginTop'] = '-' + getPx(this.sizeLocal, true)
|
|
443
|
+
}
|
|
444
|
+
|
|
368
445
|
// 移动期间无需过渡动画
|
|
369
446
|
if (drag == true) {
|
|
370
447
|
barStyle.transition = 'none';
|
|
@@ -27,6 +27,16 @@ export const props = defineMixin({
|
|
|
27
27
|
type: String,
|
|
28
28
|
default: () => defProps.switch.inactiveColor
|
|
29
29
|
},
|
|
30
|
+
// 打开时圆点的颜色
|
|
31
|
+
dotActiveColor: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: () => defProps.switch.dotActiveColor
|
|
34
|
+
},
|
|
35
|
+
// 关闭时圆点的颜色
|
|
36
|
+
dotInactiveColor: {
|
|
37
|
+
type: String,
|
|
38
|
+
default: () => defProps.switch.dotInactiveColor
|
|
39
|
+
},
|
|
30
40
|
// 通过v-model双向绑定的值
|
|
31
41
|
// #ifdef VUE3
|
|
32
42
|
modelValue: {
|
|
@@ -46,17 +46,19 @@
|
|
|
46
46
|
* switch 开关选择器
|
|
47
47
|
* @description 选择开关一般用于只有两个选择,且只能选其一的场景。
|
|
48
48
|
* @tutorial https://uview-plus.jiangruyi.com/components/switch.html
|
|
49
|
-
* @property {Boolean} loading
|
|
50
|
-
* @property {Boolean} disabled
|
|
51
|
-
* @property {String | Number} size
|
|
52
|
-
* @property {String} activeColor
|
|
53
|
-
* @property {String} inactiveColor
|
|
54
|
-
* @property {
|
|
55
|
-
* @property {
|
|
56
|
-
* @property {Boolean | String | Number}
|
|
57
|
-
* @property {Boolean}
|
|
58
|
-
* @property {String | Number}
|
|
59
|
-
* @property {
|
|
49
|
+
* @property {Boolean} loading 是否处于加载中(默认 false )
|
|
50
|
+
* @property {Boolean} disabled 是否禁用(默认 false )
|
|
51
|
+
* @property {String | Number} size 开关尺寸,单位px (默认 25 )
|
|
52
|
+
* @property {String} activeColor 打开时的背景色 (默认 '#2979ff' )
|
|
53
|
+
* @property {String} inactiveColor 关闭时的背景色 (默认 '#ffffff' )
|
|
54
|
+
* @property {String} dotActiveColor 打开时圆点的颜色 (默认 '#ffffff' )
|
|
55
|
+
* @property {String} dotInactiveColor 关闭时圆点的颜色 (默认 '#ffffff' )
|
|
56
|
+
* @property {Boolean | String | Number} value 通过v-model双向绑定的值 (默认 false )
|
|
57
|
+
* @property {Boolean | String | Number} activeValue 打开选择器时通过change事件发出的值 (默认 true )
|
|
58
|
+
* @property {Boolean | String | Number} inactiveValue 关闭选择器时通过change事件发出的值 (默认 false )
|
|
59
|
+
* @property {Boolean} asyncChange 是否开启异步变更,开启后需要手动控制输入值 (默认 false )
|
|
60
|
+
* @property {String | Number} space 圆点与外边框的距离 (默认 0 )
|
|
61
|
+
* @property {Object} customStyle 定义需要用到的外部样式
|
|
60
62
|
*
|
|
61
63
|
* @event {Function} change 在switch打开或关闭时触发
|
|
62
64
|
* @example <u-switch v-model="checked" active-color="red" inactive-color="#eee"></u-switch>
|
|
@@ -121,6 +123,7 @@
|
|
|
121
123
|
style.height = addUnit(this.size - this.space)
|
|
122
124
|
const translateX = this.isActive ? addUnit(this.space) : addUnit(this.size);
|
|
123
125
|
style.transform = `translateX(-${translateX})`
|
|
126
|
+
style.backgroundColor = this.isActive ? this.dotActiveColor : this.dotInactiveColor
|
|
124
127
|
return style
|
|
125
128
|
},
|
|
126
129
|
bgStyle() {
|
|
@@ -190,9 +193,8 @@
|
|
|
190
193
|
justify-content: center;
|
|
191
194
|
border-radius: 100px;
|
|
192
195
|
background-color: #fff;
|
|
193
|
-
border-radius: 100px;
|
|
194
196
|
box-shadow: 1px 1px 1px 0 rgba(0, 0, 0, 0.25);
|
|
195
|
-
transition-property: transform;
|
|
197
|
+
transition-property: transform, background-color;
|
|
196
198
|
transition-duration: 0.4s;
|
|
197
199
|
transition-timing-function: cubic-bezier(0.3, 1.05, 0.4, 1.05);
|
|
198
200
|
}
|