uview-plus 3.7.0 → 3.7.13
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 +40 -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-checkbox-group/u-checkbox-group.vue +4 -1
- package/components/u-qrcode/u-qrcode.vue +1 -1
- package/components/u-select/u-select.vue +3 -0
- 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-tabs/u-tabs.vue +83 -95
- package/libs/css/flex.scss +2 -1
- 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';
|
|
@@ -3,49 +3,28 @@
|
|
|
3
3
|
<view class="u-tabs__wrapper">
|
|
4
4
|
<slot name="left" />
|
|
5
5
|
<view class="u-tabs__wrapper__scroll-view-wrapper">
|
|
6
|
-
<scroll-view
|
|
7
|
-
:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
:show-scrollbar="false"
|
|
12
|
-
ref="u-tabs__wrapper__scroll-view"
|
|
13
|
-
>
|
|
14
|
-
<view
|
|
15
|
-
class="u-tabs__wrapper__nav"
|
|
16
|
-
ref="u-tabs__wrapper__nav"
|
|
17
|
-
>
|
|
18
|
-
<view
|
|
19
|
-
class="u-tabs__wrapper__nav__item"
|
|
20
|
-
v-for="(item, index) in list"
|
|
21
|
-
:key="index"
|
|
22
|
-
@tap="clickHandler(item, index)"
|
|
23
|
-
@longpress="longPressHandler(item,index)"
|
|
6
|
+
<scroll-view :scroll-x="scrollable" :scroll-left="scrollLeft" scroll-with-animation
|
|
7
|
+
class="u-tabs__wrapper__scroll-view" :show-scrollbar="false" ref="u-tabs__wrapper__scroll-view">
|
|
8
|
+
<view class="u-tabs__wrapper__nav" ref="u-tabs__wrapper__nav">
|
|
9
|
+
<view class="u-tabs__wrapper__nav__item" v-for="(item, index) in tabList" :key="index"
|
|
10
|
+
@tap="clickHandler(item, index)" @longpress="longPressHandler(item,index)"
|
|
24
11
|
:ref="`u-tabs__wrapper__nav__item-${index}`"
|
|
25
|
-
:style="[addStyle(itemStyle), {flex: scrollable ? '' : 1}]"
|
|
26
|
-
:class="[`u-tabs__wrapper__nav__item-${index}`,
|
|
12
|
+
:style="[addStyle(itemStyle), {flex: scrollable ? '' : 1}]" :class="[`u-tabs__wrapper__nav__item-${index}`,
|
|
27
13
|
item.disabled && 'u-tabs__wrapper__nav__item--disabled',
|
|
28
|
-
innerCurrent == index ? 'u-tabs__wrapper__nav__item-active' : '']"
|
|
29
|
-
>
|
|
14
|
+
innerCurrent == index ? 'u-tabs__wrapper__nav__item-active' : '']">
|
|
30
15
|
<slot v-if="$slots.icon" name="icon" :item="item" :keyName="keyName" :index="index" />
|
|
31
16
|
<template v-else>
|
|
32
17
|
<view class="u-tabs__wrapper__nav__item__prefix-icon" v-if="item.icon">
|
|
33
|
-
<up-icon
|
|
34
|
-
:name="item.icon"
|
|
35
|
-
:customStyle="addStyle(iconStyle)"
|
|
36
|
-
></up-icon>
|
|
18
|
+
<up-icon :name="item.icon" :customStyle="addStyle(iconStyle)"></up-icon>
|
|
37
19
|
</view>
|
|
38
20
|
</template>
|
|
39
21
|
<slot v-if="$slots.content" name="content" :item="item" :keyName="keyName" :index="index" />
|
|
40
|
-
<slot v-else-if="!$slots.content && ($slots.default || $slots.$default)"
|
|
41
|
-
:
|
|
42
|
-
<text v-else
|
|
43
|
-
:class="[item.disabled && 'u-tabs__wrapper__nav__item__text--disabled']"
|
|
22
|
+
<slot v-else-if="!$slots.content && ($slots.default || $slots.$default)" :item="item"
|
|
23
|
+
:keyName="keyName" :index="index" />
|
|
24
|
+
<text v-else :class="[item.disabled && 'u-tabs__wrapper__nav__item__text--disabled']"
|
|
44
25
|
class="u-tabs__wrapper__nav__item__text"
|
|
45
|
-
:style="[textStyle(index)]"
|
|
46
|
-
|
|
47
|
-
<u-badge
|
|
48
|
-
:show="!!(item.badge && (item.badge.show || item.badge.isDot || item.badge.value))"
|
|
26
|
+
:style="[textStyle(index)]">{{ item[keyName] }}</text>
|
|
27
|
+
<u-badge :show="!!(item.badge && (item.badge.show || item.badge.isDot || item.badge.value))"
|
|
49
28
|
:isDot="item.badge && item.badge.isDot || propsBadge.isDot"
|
|
50
29
|
:value="item.badge && item.badge.value || propsBadge.value"
|
|
51
30
|
:max="item.badge && item.badge.max || propsBadge.max"
|
|
@@ -56,35 +35,28 @@
|
|
|
56
35
|
:shape="item.badge && item.badge.shape || propsBadge.shape"
|
|
57
36
|
:numberType="item.badge && item.badge.numberType || propsBadge.numberType"
|
|
58
37
|
:inverted="item.badge && item.badge.inverted || propsBadge.inverted"
|
|
59
|
-
customStyle="margin-left: 4px;"
|
|
60
|
-
></u-badge>
|
|
38
|
+
customStyle="margin-left: 4px;"></u-badge>
|
|
61
39
|
</view>
|
|
62
40
|
<!-- #ifdef APP-NVUE -->
|
|
63
|
-
<view
|
|
64
|
-
class="u-tabs__wrapper__nav__line"
|
|
65
|
-
ref="u-tabs__wrapper__nav__line"
|
|
66
|
-
:style="[{
|
|
41
|
+
<view class="u-tabs__wrapper__nav__line" ref="u-tabs__wrapper__nav__line" :style="[{
|
|
67
42
|
width: addUnit(lineWidth),
|
|
68
43
|
height: addUnit(lineHeight),
|
|
69
44
|
background: lineColor,
|
|
70
45
|
backgroundSize: lineBgSize,
|
|
71
|
-
}]"
|
|
72
|
-
>
|
|
46
|
+
}]">
|
|
73
47
|
</view>
|
|
74
48
|
<!-- #endif -->
|
|
75
49
|
<!-- #ifndef APP-NVUE -->
|
|
76
|
-
<view
|
|
77
|
-
class="u-tabs__wrapper__nav__line"
|
|
78
|
-
ref="u-tabs__wrapper__nav__line"
|
|
50
|
+
<view class="u-tabs__wrapper__nav__line" ref="u-tabs__wrapper__nav__line"
|
|
79
51
|
:style="[{
|
|
80
52
|
width: addUnit(lineWidth),
|
|
81
53
|
transform: `translate(${lineOffsetLeft}px)`,
|
|
82
|
-
transitionDuration: `${
|
|
54
|
+
transitionDuration: `${duration}ms`,
|
|
83
55
|
height: addUnit(lineHeight),
|
|
84
56
|
background: lineColor,
|
|
85
57
|
backgroundSize: lineBgSize,
|
|
86
|
-
|
|
87
|
-
|
|
58
|
+
display: lineShow ? 'block': 'none'
|
|
59
|
+
}]">
|
|
88
60
|
</view>
|
|
89
61
|
<!-- #endif -->
|
|
90
62
|
</view>
|
|
@@ -100,11 +72,25 @@
|
|
|
100
72
|
const animation = uni.requireNativePlugin('animation')
|
|
101
73
|
const dom = uni.requireNativePlugin('dom')
|
|
102
74
|
// #endif
|
|
103
|
-
import {
|
|
104
|
-
|
|
105
|
-
|
|
75
|
+
import {
|
|
76
|
+
props
|
|
77
|
+
} from './props';
|
|
78
|
+
import {
|
|
79
|
+
mpMixin
|
|
80
|
+
} from '../../libs/mixin/mpMixin';
|
|
81
|
+
import {
|
|
82
|
+
mixin
|
|
83
|
+
} from '../../libs/mixin/mixin';
|
|
106
84
|
import defProps from '../../libs/config/props.js'
|
|
107
|
-
import {
|
|
85
|
+
import {
|
|
86
|
+
addUnit,
|
|
87
|
+
addStyle,
|
|
88
|
+
deepMerge,
|
|
89
|
+
deepClone,
|
|
90
|
+
getPx,
|
|
91
|
+
sleep,
|
|
92
|
+
getWindowInfo
|
|
93
|
+
} from '../../libs/function/index';
|
|
108
94
|
/**
|
|
109
95
|
* Tabs 标签
|
|
110
96
|
* @description tabs标签组件,在标签多的时候,可以配置为左右滑动,标签少的时候,可以禁止滑动。 该组件的一个特点是配置为滚动模式时,激活的tab会自动移动到组件的中间位置。
|
|
@@ -122,10 +108,11 @@
|
|
|
122
108
|
mixins: [mpMixin, mixin, props],
|
|
123
109
|
data() {
|
|
124
110
|
return {
|
|
125
|
-
|
|
111
|
+
tabList: [],
|
|
126
112
|
scrollLeft: 0,
|
|
127
113
|
scrollViewWidth: 0,
|
|
128
114
|
lineOffsetLeft: 0,
|
|
115
|
+
lineShow: false,
|
|
129
116
|
tabsRect: {
|
|
130
117
|
left: 0
|
|
131
118
|
},
|
|
@@ -136,7 +123,7 @@
|
|
|
136
123
|
watch: {
|
|
137
124
|
current: {
|
|
138
125
|
immediate: true,
|
|
139
|
-
handler
|
|
126
|
+
handler(newValue, oldValue) {
|
|
140
127
|
// 内外部值不相等时,才尝试移动滑块
|
|
141
128
|
if (newValue !== this.innerCurrent) {
|
|
142
129
|
if (typeof newValue == 'string') {
|
|
@@ -151,10 +138,16 @@
|
|
|
151
138
|
}
|
|
152
139
|
},
|
|
153
140
|
// list变化时,重新渲染list各项信息
|
|
154
|
-
list
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
141
|
+
list: {
|
|
142
|
+
handler(newValue, oldValue) {
|
|
143
|
+
// 重新拷贝一份list用于增加其他额外信息处理后导致重复监听的死循环
|
|
144
|
+
this.tabList = deepClone(newValue);
|
|
145
|
+
this.$nextTick(() => {
|
|
146
|
+
this.resize()
|
|
147
|
+
})
|
|
148
|
+
},
|
|
149
|
+
immediate: true,
|
|
150
|
+
deep: true,
|
|
158
151
|
}
|
|
159
152
|
},
|
|
160
153
|
computed: {
|
|
@@ -162,11 +155,11 @@
|
|
|
162
155
|
return index => {
|
|
163
156
|
const style = {}
|
|
164
157
|
// 取当期是否激活的样式
|
|
165
|
-
const customeStyle = (index == this.innerCurrent)
|
|
166
|
-
|
|
167
|
-
|
|
158
|
+
const customeStyle = (index == this.innerCurrent) ?
|
|
159
|
+
addStyle(this.activeStyle) :
|
|
160
|
+
addStyle(this.inactiveStyle)
|
|
168
161
|
// 如果当前菜单被禁用,则加上对应颜色,需要在此做处理,是因为nvue下,无法在style样式中通过!import覆盖标签的内联样式
|
|
169
|
-
if (this.
|
|
162
|
+
if (this.tabList[index].disabled) {
|
|
170
163
|
style.color = '#c8c9cc'
|
|
171
164
|
}
|
|
172
165
|
return deepMerge(customeStyle, style)
|
|
@@ -178,42 +171,37 @@
|
|
|
178
171
|
},
|
|
179
172
|
async mounted() {
|
|
180
173
|
this.init()
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
174
|
+
this.windowResizeCallback = (res) => {
|
|
175
|
+
this.init()
|
|
176
|
+
}
|
|
177
|
+
uni.onWindowResize(this.windowResizeCallback)
|
|
178
|
+
},
|
|
179
|
+
beforeUnmount() {
|
|
180
|
+
uni.offWindowResize(this.windowResizeCallback)
|
|
185
181
|
},
|
|
186
|
-
beforeUnmount() {
|
|
187
|
-
uni.offWindowResize(this.windowResizeCallback)
|
|
188
|
-
},
|
|
189
182
|
emits: ['click', 'longPress', 'change', 'update:current'],
|
|
190
183
|
methods: {
|
|
191
184
|
addStyle,
|
|
192
185
|
addUnit,
|
|
193
186
|
setLineLeft() {
|
|
194
|
-
const tabItem = this.
|
|
187
|
+
const tabItem = this.tabList[this.innerCurrent];
|
|
195
188
|
if (!tabItem) {
|
|
196
189
|
return;
|
|
197
190
|
}
|
|
198
191
|
// 获取滑块该移动的位置
|
|
199
|
-
let lineOffsetLeft = this.
|
|
192
|
+
let lineOffsetLeft = this.tabList
|
|
200
193
|
.slice(0, this.innerCurrent)
|
|
201
194
|
.reduce((total, curr) => total + curr.rect.width, 0);
|
|
202
|
-
|
|
195
|
+
// 获取下划线的数值px表示法
|
|
203
196
|
const lineWidth = getPx(this.lineWidth);
|
|
204
197
|
this.lineOffsetLeft = lineOffsetLeft + (tabItem.rect.width - lineWidth) / 2
|
|
205
198
|
// #ifdef APP-NVUE
|
|
206
199
|
// 第一次移动滑块,无需过渡时间
|
|
207
|
-
this.animation(this.lineOffsetLeft,
|
|
200
|
+
this.animation(this.lineOffsetLeft, parseInt(this.duration))
|
|
208
201
|
// #endif
|
|
209
202
|
|
|
210
|
-
//
|
|
211
|
-
|
|
212
|
-
if (this.firstTime) {
|
|
213
|
-
setTimeout(() => {
|
|
214
|
-
this.firstTime = false
|
|
215
|
-
}, 10);
|
|
216
|
-
}
|
|
203
|
+
// 如果是第一次执行此方法,滑块默认不显示,在加载完成后进行显示
|
|
204
|
+
if (!this.lineShow) this.lineShow = true;
|
|
217
205
|
},
|
|
218
206
|
// nvue下设置滑块的位置
|
|
219
207
|
animation(x, duration = 0) {
|
|
@@ -239,9 +227,9 @@
|
|
|
239
227
|
// 如果点击当前不触发change
|
|
240
228
|
if (this.innerCurrent == index) return
|
|
241
229
|
this.innerCurrent = index
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
230
|
+
this.$nextTick(() => {
|
|
231
|
+
this.resize()
|
|
232
|
+
})
|
|
245
233
|
this.$emit('update:current', index)
|
|
246
234
|
this.$emit('change', {
|
|
247
235
|
...item,
|
|
@@ -263,11 +251,11 @@
|
|
|
263
251
|
setScrollLeft() {
|
|
264
252
|
// 当前活动tab的布局信息,有tab菜单的width和left(为元素左边界到父元素左边界的距离)等信息
|
|
265
253
|
if (this.innerCurrent < 0) {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
const tabRect = this.
|
|
254
|
+
this.innerCurrent = 0;
|
|
255
|
+
}
|
|
256
|
+
const tabRect = this.tabList[this.innerCurrent]
|
|
269
257
|
// 累加得到当前item到左边的距离
|
|
270
|
-
const offsetLeft = this.
|
|
258
|
+
const offsetLeft = this.tabList
|
|
271
259
|
.slice(0, this.innerCurrent)
|
|
272
260
|
.reduce((total, curr) => {
|
|
273
261
|
return total + curr.rect.width
|
|
@@ -284,13 +272,14 @@
|
|
|
284
272
|
// 获取所有标签的尺寸
|
|
285
273
|
resize() {
|
|
286
274
|
// 如果不存在list,则不处理
|
|
287
|
-
if(this.
|
|
275
|
+
if (this.tabList.length === 0) {
|
|
288
276
|
return
|
|
289
277
|
}
|
|
290
278
|
Promise.all([this.getTabsRect(), this.getAllItemRect()]).then(([tabsRect, itemRect = []]) => {
|
|
291
279
|
// 兼容在swiper组件中使用
|
|
292
280
|
if (tabsRect.left > tabsRect.width) {
|
|
293
|
-
tabsRect.right = tabsRect.right - Math.floor(tabsRect.left / tabsRect.width) * tabsRect
|
|
281
|
+
tabsRect.right = tabsRect.right - Math.floor(tabsRect.left / tabsRect.width) * tabsRect
|
|
282
|
+
.width
|
|
294
283
|
tabsRect.left = tabsRect.left % tabsRect.width
|
|
295
284
|
}
|
|
296
285
|
// console.log(tabsRect)
|
|
@@ -300,7 +289,7 @@
|
|
|
300
289
|
// 计算scroll-view的宽度,这里
|
|
301
290
|
this.scrollViewWidth += item.width
|
|
302
291
|
// 另外计算每一个item的中心点X轴坐标
|
|
303
|
-
this.
|
|
292
|
+
this.tabList[index].rect = item
|
|
304
293
|
})
|
|
305
294
|
// 获取了tabs的尺寸之后,设置滑块的位置
|
|
306
295
|
this.setLineLeft()
|
|
@@ -316,9 +305,9 @@
|
|
|
316
305
|
// 获取所有标签的尺寸
|
|
317
306
|
getAllItemRect() {
|
|
318
307
|
return new Promise(resolve => {
|
|
319
|
-
const promiseAllArr = this.
|
|
320
|
-
`u-tabs__wrapper__nav__item-${index}`, true))
|
|
321
|
-
Promise.all(promiseAllArr).then(sizes => resolve(sizes))
|
|
308
|
+
const promiseAllArr = this.tabList.map((item, index) => this.queryRect(
|
|
309
|
+
`u-tabs__wrapper__nav__item-${index}`, true));
|
|
310
|
+
Promise.all(promiseAllArr).then(sizes => resolve(sizes));
|
|
322
311
|
})
|
|
323
312
|
},
|
|
324
313
|
// 获取各个标签的尺寸
|
|
@@ -348,7 +337,6 @@
|
|
|
348
337
|
</script>
|
|
349
338
|
|
|
350
339
|
<style lang="scss" scoped>
|
|
351
|
-
|
|
352
340
|
.u-tabs {
|
|
353
341
|
|
|
354
342
|
&__wrapper {
|
|
@@ -389,7 +377,7 @@
|
|
|
389
377
|
&__text {
|
|
390
378
|
font-size: 15px;
|
|
391
379
|
color: $u-content-color;
|
|
392
|
-
|
|
380
|
+
white-space: nowrap !important;
|
|
393
381
|
|
|
394
382
|
&--disabled {
|
|
395
383
|
color: $u-disabled-color !important;
|
package/libs/css/flex.scss
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "uview-plus",
|
|
3
3
|
"name": "uview-plus",
|
|
4
4
|
"displayName": "零云®uview-plus3.0重磅发布,全面的Vue3鸿蒙跨端移动组件库,组件丰富维护更新稳定。",
|
|
5
|
-
"version": "3.7.
|
|
5
|
+
"version": "3.7.13",
|
|
6
6
|
"description": "零云®uview-plus已兼容vue3支持多语言,120+全面的组件和便捷的工具会让您信手拈来。近期新增拖动排序、条码、图片裁剪、下拉刷新、虚拟列表、签名、Markdown等。",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"uview",
|
|
@@ -102,8 +102,6 @@
|
|
|
102
102
|
}
|
|
103
103
|
},
|
|
104
104
|
"dependencies": {
|
|
105
|
-
"clipboard": "^2.0.11",
|
|
106
|
-
"dayjs": "^1.11.3"
|
|
107
105
|
},
|
|
108
106
|
"publishConfig": {
|
|
109
107
|
"registry": "https://registry.npmjs.org/"
|