@gmcb/uv-ui 0.2.26
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 +295 -0
- package/LICENSE +21 -0
- package/README.md +164 -0
- package/components/uv-action-sheet/props.js +50 -0
- package/components/uv-action-sheet/uv-action-sheet.vue +280 -0
- package/components/uv-album/uv-album.vue +312 -0
- package/components/uv-alert/props.js +45 -0
- package/components/uv-alert/uv-alert.vue +246 -0
- package/components/uv-avatar/props.js +85 -0
- package/components/uv-avatar/uv-avatar.vue +182 -0
- package/components/uv-avatar-group/props.js +53 -0
- package/components/uv-avatar-group/uv-avatar-group.vue +106 -0
- package/components/uv-back-top/props.js +58 -0
- package/components/uv-back-top/uv-back-top.vue +116 -0
- package/components/uv-badge/props.js +73 -0
- package/components/uv-badge/uv-badge.vue +176 -0
- package/components/uv-button/nvue.scss +46 -0
- package/components/uv-button/props.js +163 -0
- package/components/uv-button/uv-button.vue +529 -0
- package/components/uv-button/vue.scss +93 -0
- package/components/uv-calendar/calendar.js +546 -0
- package/components/uv-calendar/header.vue +104 -0
- package/components/uv-calendar/month.vue +616 -0
- package/components/uv-calendar/props.js +145 -0
- package/components/uv-calendar/uv-calendar.vue +390 -0
- package/components/uv-calendars/calendar-body.vue +376 -0
- package/components/uv-calendars/calendar-item.vue +248 -0
- package/components/uv-calendars/calendar.js +546 -0
- package/components/uv-calendars/i18n/en.json +12 -0
- package/components/uv-calendars/i18n/index.js +8 -0
- package/components/uv-calendars/i18n/zh-Hans.json +12 -0
- package/components/uv-calendars/i18n/zh-Hant.json +12 -0
- package/components/uv-calendars/util.js +435 -0
- package/components/uv-calendars/uv-calendars.vue +452 -0
- package/components/uv-cell/props.js +116 -0
- package/components/uv-cell/uv-cell.vue +209 -0
- package/components/uv-cell-group/props.js +15 -0
- package/components/uv-cell-group/uv-cell-group.vue +63 -0
- package/components/uv-checkbox/props.js +70 -0
- package/components/uv-checkbox/uv-checkbox.vue +371 -0
- package/components/uv-checkbox-group/props.js +84 -0
- package/components/uv-checkbox-group/uv-checkbox-group.vue +119 -0
- package/components/uv-code/props.js +35 -0
- package/components/uv-code/uv-code.vue +136 -0
- package/components/uv-code-input/props.js +83 -0
- package/components/uv-code-input/uv-code-input.vue +272 -0
- package/components/uv-col/props.js +30 -0
- package/components/uv-col/uv-col.vue +165 -0
- package/components/uv-collapse/props.js +20 -0
- package/components/uv-collapse/uv-collapse.vue +86 -0
- package/components/uv-collapse-item/props.js +60 -0
- package/components/uv-collapse-item/uv-collapse-item.vue +228 -0
- package/components/uv-column-notice/props.js +61 -0
- package/components/uv-column-notice/uv-column-notice.vue +176 -0
- package/components/uv-count-down/props.js +25 -0
- package/components/uv-count-down/utils.js +62 -0
- package/components/uv-count-down/uv-count-down.vue +169 -0
- package/components/uv-count-to/props.js +60 -0
- package/components/uv-count-to/uv-count-to.vue +187 -0
- package/components/uv-datetime-picker/props.js +130 -0
- package/components/uv-datetime-picker/uv-datetime-picker.vue +355 -0
- package/components/uv-divider/props.js +45 -0
- package/components/uv-divider/uv-divider.vue +113 -0
- package/components/uv-drop-down/uv-drop-down.vue +135 -0
- package/components/uv-drop-down-item/uv-drop-down-item.vue +169 -0
- package/components/uv-drop-down-popup/uv-drop-down-popup.vue +242 -0
- package/components/uv-empty/props.js +60 -0
- package/components/uv-empty/uv-empty.vue +126 -0
- package/components/uv-form/props.js +46 -0
- package/components/uv-form/uv-form.vue +209 -0
- package/components/uv-form/valid.js +1343 -0
- package/components/uv-form-item/props.js +49 -0
- package/components/uv-form-item/uv-form-item.vue +226 -0
- package/components/uv-gap/props.js +25 -0
- package/components/uv-gap/uv-gap.vue +36 -0
- package/components/uv-grid/props.js +20 -0
- package/components/uv-grid/uv-grid.vue +100 -0
- package/components/uv-grid-item/props.js +15 -0
- package/components/uv-grid-item/uv-grid-item.vue +223 -0
- package/components/uv-icon/icons.js +160 -0
- package/components/uv-icon/props.js +90 -0
- package/components/uv-icon/uv-icon.vue +226 -0
- package/components/uv-icon/uvicons.ttf +0 -0
- package/components/uv-image/props.js +100 -0
- package/components/uv-image/uv-image.vue +296 -0
- package/components/uv-index-anchor/props.js +30 -0
- package/components/uv-index-anchor/uv-index-anchor.vue +98 -0
- package/components/uv-index-item/uv-index-item.vue +87 -0
- package/components/uv-index-list/props.js +30 -0
- package/components/uv-index-list/uv-index-list.vue +461 -0
- package/components/uv-input/props.js +175 -0
- package/components/uv-input/uv-input.vue +348 -0
- package/components/uv-keyboard/props.js +95 -0
- package/components/uv-keyboard/uv-keyboard.vue +180 -0
- package/components/uv-keyboard-car/props.js +24 -0
- package/components/uv-keyboard-car/uv-keyboard-car.vue +347 -0
- package/components/uv-keyboard-number/props.js +19 -0
- package/components/uv-keyboard-number/uv-keyboard-number.vue +201 -0
- package/components/uv-line/props.js +34 -0
- package/components/uv-line/uv-line.vue +60 -0
- package/components/uv-line-progress/props.js +29 -0
- package/components/uv-line-progress/uv-line-progress.vue +146 -0
- package/components/uv-link/props.js +40 -0
- package/components/uv-link/uv-link.vue +83 -0
- package/components/uv-list/uv-list.vue +147 -0
- package/components/uv-list-item/uv-list-item.vue +535 -0
- package/components/uv-load-more/props.js +95 -0
- package/components/uv-load-more/uv-load-more.vue +152 -0
- package/components/uv-loading-icon/props.js +67 -0
- package/components/uv-loading-icon/uv-loading-icon.vue +347 -0
- package/components/uv-loading-page/props.js +55 -0
- package/components/uv-loading-page/uv-loading-page.vue +96 -0
- package/components/uv-modal/props.js +90 -0
- package/components/uv-modal/uv-modal.vue +245 -0
- package/components/uv-navbar/props.js +89 -0
- package/components/uv-navbar/uv-navbar.vue +245 -0
- package/components/uv-no-network/props.js +20 -0
- package/components/uv-no-network/uv-no-network.vue +222 -0
- package/components/uv-notice-bar/props.js +76 -0
- package/components/uv-notice-bar/uv-notice-bar.vue +110 -0
- package/components/uv-notify/props.js +45 -0
- package/components/uv-notify/uv-notify.vue +220 -0
- package/components/uv-number-box/props.js +118 -0
- package/components/uv-number-box/uv-number-box.vue +397 -0
- package/components/uv-overlay/props.js +25 -0
- package/components/uv-overlay/uv-overlay.vue +85 -0
- package/components/uv-parse/node/node.vue +576 -0
- package/components/uv-parse/parser.js +1335 -0
- package/components/uv-parse/uv-parse.vue +498 -0
- package/components/uv-pick-color/colors.js +217 -0
- package/components/uv-pick-color/props.js +47 -0
- package/components/uv-pick-color/uv-pick-color.vue +551 -0
- package/components/uv-picker/props.js +95 -0
- package/components/uv-picker/uv-picker.vue +329 -0
- package/components/uv-popup/keypress.js +45 -0
- package/components/uv-popup/uv-popup.vue +537 -0
- package/components/uv-preview-video/uv-preview-video.vue +52 -0
- package/components/uv-qrcode/cache.js +1 -0
- package/components/uv-qrcode/gcanvas/bridge/bridge-weex.js +241 -0
- package/components/uv-qrcode/gcanvas/context-2d/FillStyleLinearGradient.js +18 -0
- package/components/uv-qrcode/gcanvas/context-2d/FillStylePattern.js +8 -0
- package/components/uv-qrcode/gcanvas/context-2d/FillStyleRadialGradient.js +17 -0
- package/components/uv-qrcode/gcanvas/context-2d/RenderingContext.js +666 -0
- package/components/uv-qrcode/gcanvas/context-webgl/ActiveInfo.js +11 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Buffer.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Framebuffer.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/GLenum.js +298 -0
- package/components/uv-qrcode/gcanvas/context-webgl/GLmethod.js +142 -0
- package/components/uv-qrcode/gcanvas/context-webgl/GLtype.js +23 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Program.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Renderbuffer.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/RenderingContext.js +1191 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Shader.js +22 -0
- package/components/uv-qrcode/gcanvas/context-webgl/ShaderPrecisionFormat.js +11 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Texture.js +22 -0
- package/components/uv-qrcode/gcanvas/context-webgl/UniformLocation.js +22 -0
- package/components/uv-qrcode/gcanvas/context-webgl/classUtils.js +3 -0
- package/components/uv-qrcode/gcanvas/env/canvas.js +74 -0
- package/components/uv-qrcode/gcanvas/env/image.js +96 -0
- package/components/uv-qrcode/gcanvas/env/tool.js +24 -0
- package/components/uv-qrcode/gcanvas/index.js +39 -0
- package/components/uv-qrcode/props.js +85 -0
- package/components/uv-qrcode/qrcode.js +34 -0
- package/components/uv-qrcode/queue.js +41 -0
- package/components/uv-qrcode/uv-qrcode.vue +1038 -0
- package/components/uv-radio/props.js +65 -0
- package/components/uv-radio/uv-radio.vue +349 -0
- package/components/uv-radio-group/props.js +89 -0
- package/components/uv-radio-group/uv-radio-group.vue +115 -0
- package/components/uv-rate/props.js +73 -0
- package/components/uv-rate/uv-rate.vue +274 -0
- package/components/uv-read-more/props.js +62 -0
- package/components/uv-read-more/uv-read-more.vue +162 -0
- package/components/uv-row/props.js +20 -0
- package/components/uv-row/uv-row.vue +95 -0
- package/components/uv-row-notice/props.js +40 -0
- package/components/uv-row-notice/uv-row-notice.vue +341 -0
- package/components/uv-safe-bottom/uv-safe-bottom.vue +67 -0
- package/components/uv-scroll-list/nvue.js +29 -0
- package/components/uv-scroll-list/props.js +35 -0
- package/components/uv-scroll-list/scrollWxs.wxs +51 -0
- package/components/uv-scroll-list/uv-scroll-list.vue +218 -0
- package/components/uv-search/props.js +127 -0
- package/components/uv-search/uv-search.vue +311 -0
- package/components/uv-skeleton/props.js +65 -0
- package/components/uv-skeleton/uv-skeleton.vue +250 -0
- package/components/uv-skeletons/uv-skeletons.vue +247 -0
- package/components/uv-slider/props.js +58 -0
- package/components/uv-slider/uv-slider.vue +58 -0
- package/components/uv-status-bar/props.js +8 -0
- package/components/uv-status-bar/uv-status-bar.vue +54 -0
- package/components/uv-steps/props.js +40 -0
- package/components/uv-steps/uv-steps.vue +83 -0
- package/components/uv-steps-item/props.js +25 -0
- package/components/uv-steps-item/uv-steps-item.vue +347 -0
- package/components/uv-sticky/props.js +41 -0
- package/components/uv-sticky/uv-sticky.vue +223 -0
- package/components/uv-subsection/props.js +54 -0
- package/components/uv-subsection/uv-subsection.vue +269 -0
- package/components/uv-swipe-action/props.js +10 -0
- package/components/uv-swipe-action/uv-swipe-action.vue +65 -0
- package/components/uv-swipe-action-item/index - backup.wxs +256 -0
- package/components/uv-swipe-action-item/index.wxs +225 -0
- package/components/uv-swipe-action-item/nvue - backup.js +264 -0
- package/components/uv-swipe-action-item/nvue.js +182 -0
- package/components/uv-swipe-action-item/props.js +40 -0
- package/components/uv-swipe-action-item/uv-swipe-action-item.vue +200 -0
- package/components/uv-swipe-action-item/wxs.js +15 -0
- package/components/uv-swiper/props.js +136 -0
- package/components/uv-swiper/uv-swiper.vue +263 -0
- package/components/uv-swiper-indicator/props.js +30 -0
- package/components/uv-swiper-indicator/uv-swiper-indicator.vue +112 -0
- package/components/uv-switch/props.js +58 -0
- package/components/uv-switch/uv-switch.vue +182 -0
- package/components/uv-tabbar/props.js +50 -0
- package/components/uv-tabbar/uv-tabbar.vue +146 -0
- package/components/uv-tabbar-item/props.js +40 -0
- package/components/uv-tabbar-item/uv-tabbar-item.vue +146 -0
- package/components/uv-tabs/props.js +71 -0
- package/components/uv-tabs/uv-tabs.vue +391 -0
- package/components/uv-tags/props.js +104 -0
- package/components/uv-tags/uv-tags.vue +379 -0
- package/components/uv-text/props.js +113 -0
- package/components/uv-text/uv-text.vue +218 -0
- package/components/uv-text/value.js +87 -0
- package/components/uv-textarea/props.js +138 -0
- package/components/uv-textarea/uv-textarea.vue +238 -0
- package/components/uv-toast/uv-toast.vue +292 -0
- package/components/uv-toolbar/props.js +40 -0
- package/components/uv-toolbar/uv-toolbar.vue +109 -0
- package/components/uv-tooltip/props.js +60 -0
- package/components/uv-tooltip/uv-tooltip.vue +372 -0
- package/components/uv-transition/createAnimation.js +131 -0
- package/components/uv-transition/props.js +31 -0
- package/components/uv-transition/uv-transition.vue +320 -0
- package/components/uv-upload/mixin.js +22 -0
- package/components/uv-upload/props.js +130 -0
- package/components/uv-upload/utils.js +151 -0
- package/components/uv-upload/uv-upload.vue +488 -0
- package/components/uv-vtabs/props.js +79 -0
- package/components/uv-vtabs/uv-vtabs.vue +438 -0
- package/components/uv-vtabs-item/uv-vtabs-item.vue +68 -0
- package/components/uv-waterfall/props.js +69 -0
- package/components/uv-waterfall/uv-waterfall.vue +265 -0
- package/index.js +82 -0
- package/index.scss +7 -0
- package/libs/config/config.js +34 -0
- package/libs/css/color.scss +32 -0
- package/libs/css/common.scss +100 -0
- package/libs/css/components.scss +23 -0
- package/libs/css/variable.scss +111 -0
- package/libs/css/vue.scss +40 -0
- package/libs/function/colorGradient.js +134 -0
- package/libs/function/compress.js +27 -0
- package/libs/function/debounce.js +29 -0
- package/libs/function/digit.js +167 -0
- package/libs/function/index.js +734 -0
- package/libs/function/platform.js +75 -0
- package/libs/function/test.js +287 -0
- package/libs/function/throttle.js +30 -0
- package/libs/luch-request/adapters/index.js +132 -0
- package/libs/luch-request/core/InterceptorManager.js +51 -0
- package/libs/luch-request/core/Request.js +201 -0
- package/libs/luch-request/core/buildFullPath.js +20 -0
- package/libs/luch-request/core/defaults.js +33 -0
- package/libs/luch-request/core/dispatchRequest.js +6 -0
- package/libs/luch-request/core/mergeConfig.js +126 -0
- package/libs/luch-request/core/settle.js +16 -0
- package/libs/luch-request/helpers/buildURL.js +64 -0
- package/libs/luch-request/helpers/combineURLs.js +14 -0
- package/libs/luch-request/helpers/isAbsoluteURL.js +14 -0
- package/libs/luch-request/index.d.ts +197 -0
- package/libs/luch-request/index.js +2 -0
- package/libs/luch-request/utils/clone.js +264 -0
- package/libs/luch-request/utils.js +135 -0
- package/libs/mixin/button.js +13 -0
- package/libs/mixin/mixin.js +172 -0
- package/libs/mixin/mpMixin.js +8 -0
- package/libs/mixin/mpShare.js +13 -0
- package/libs/mixin/openType.js +47 -0
- package/libs/mixin/touch.js +59 -0
- package/libs/util/dayjs.js +216 -0
- package/libs/util/route.js +126 -0
- package/package.json +28 -0
- package/theme.scss +43 -0
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="uv-vtabs"
|
|
4
|
+
:style="[vtabsStyle]"
|
|
5
|
+
>
|
|
6
|
+
<scroll-view
|
|
7
|
+
class="uv-vtabs__bar"
|
|
8
|
+
ref="uv-vtabs__bar"
|
|
9
|
+
:style="[getBarStyle]"
|
|
10
|
+
:scroll-y="barScrollable"
|
|
11
|
+
:scroll-x="scrollX"
|
|
12
|
+
:show-scrollbar="false"
|
|
13
|
+
:scroll-with-animation="true"
|
|
14
|
+
:scroll-top="barScrollTop"
|
|
15
|
+
:scroll-into-view="barScrollToView"
|
|
16
|
+
>
|
|
17
|
+
<view
|
|
18
|
+
:class="[
|
|
19
|
+
'uv-vtabs__bar-item',
|
|
20
|
+
`uv-vtabs__bar-item--${index}`,
|
|
21
|
+
index == activeIndex && 'uv-vtabs__bar-item-active'
|
|
22
|
+
]"
|
|
23
|
+
:ref="`uv-vtabs__bar-item--${index}`"
|
|
24
|
+
v-for="(item,index) in list"
|
|
25
|
+
:key="index"
|
|
26
|
+
:id="`bar_${index}`"
|
|
27
|
+
:style="[itemStyle(index)]"
|
|
28
|
+
@tap.stop="clickHandler(index)"
|
|
29
|
+
>
|
|
30
|
+
<view
|
|
31
|
+
class="uv-vtabs__bar-item--line"
|
|
32
|
+
v-if="index == activeIndex"
|
|
33
|
+
:style="[$uv.addStyle(barItemActiveLineStyle)]"
|
|
34
|
+
></view>
|
|
35
|
+
<text
|
|
36
|
+
:class="[
|
|
37
|
+
'uv-vtabs__bar-item--value',
|
|
38
|
+
index == activeIndex && 'uv-vtabs__bar-item-active--value'
|
|
39
|
+
]"
|
|
40
|
+
:style="[itemStyle(index),textStyle(index)]"
|
|
41
|
+
>{{item[keyName]}}</text>
|
|
42
|
+
<view
|
|
43
|
+
class="uv-vtabs__bar-item--badge"
|
|
44
|
+
:style="[$uv.addStyle(barItemBadgeStyle)]"
|
|
45
|
+
v-if="!!(item.badge && (item.badge.show || item.badge.isDot || item.badge.value))"
|
|
46
|
+
>
|
|
47
|
+
<uv-badge
|
|
48
|
+
:show="!!(item.badge && (item.badge.show || item.badge.isDot || item.badge.value))"
|
|
49
|
+
:isDot="item.badge && item.badge.isDot || propsBadge.isDot"
|
|
50
|
+
:value="item.badge && item.badge.value || propsBadge.value"
|
|
51
|
+
:max="item.badge && item.badge.max || propsBadge.max"
|
|
52
|
+
:type="item.badge && item.badge.type || propsBadge.type"
|
|
53
|
+
:showZero="item.badge && item.badge.showZero || propsBadge.showZero"
|
|
54
|
+
:bgColor="item.badge && item.badge.bgColor || propsBadge.bgColor"
|
|
55
|
+
:color="item.badge && item.badge.color || propsBadge.color"
|
|
56
|
+
:shape="item.badge && item.badge.shape || propsBadge.shape"
|
|
57
|
+
:numberType="item.badge && item.badge.numberType || propsBadge.numberType"
|
|
58
|
+
:inverted="item.badge && item.badge.inverted || propsBadge.inverted"
|
|
59
|
+
></uv-badge>
|
|
60
|
+
</view>
|
|
61
|
+
</view>
|
|
62
|
+
</scroll-view>
|
|
63
|
+
<scroll-view
|
|
64
|
+
class="uv-vtabs__content"
|
|
65
|
+
:style="[getContentStyle,$uv.addStyle(contentStyle)]"
|
|
66
|
+
:scroll-y="true"
|
|
67
|
+
:scroll-x="scrollX"
|
|
68
|
+
:show-scrollbar="false"
|
|
69
|
+
:scroll-top="contentScrollTop"
|
|
70
|
+
:scroll-into-view="contentScrollTo"
|
|
71
|
+
:scroll-with-animation="true"
|
|
72
|
+
@scroll="scrollHandler"
|
|
73
|
+
@scrolltolower="scrolltolower"
|
|
74
|
+
v-if="chain"
|
|
75
|
+
>
|
|
76
|
+
<slot />
|
|
77
|
+
</scroll-view>
|
|
78
|
+
<scroll-view
|
|
79
|
+
v-else
|
|
80
|
+
class="uv-vtabs__content"
|
|
81
|
+
:style="[getContentStyle,$uv.addStyle(contentStyle)]"
|
|
82
|
+
:scroll-y="true"
|
|
83
|
+
:scroll-x="scrollX"
|
|
84
|
+
:show-scrollbar="false"
|
|
85
|
+
:scroll-top="contentScrollTop2"
|
|
86
|
+
@scrolltolower="scrolltolower"
|
|
87
|
+
>
|
|
88
|
+
<slot />
|
|
89
|
+
</scroll-view>
|
|
90
|
+
</view>
|
|
91
|
+
</template>
|
|
92
|
+
<script>
|
|
93
|
+
import mpMixin from '../../libs/mixin/mpMixin.js'
|
|
94
|
+
import mixin from '../../libs/mixin/mixin.js'
|
|
95
|
+
import debounce from '../../libs/function/debounce.js'
|
|
96
|
+
import throttle from '../../libs/function/throttle.js'
|
|
97
|
+
import uvBadgeProps from '../uv-badge/props.js'
|
|
98
|
+
import props from './props.js';
|
|
99
|
+
// #ifdef APP-NVUE
|
|
100
|
+
const dom = uni.requireNativePlugin('dom')
|
|
101
|
+
// #endif
|
|
102
|
+
/**
|
|
103
|
+
* 垂直选项卡
|
|
104
|
+
* @description 该组件兼容所有端,提供了分类展示和联动等功能
|
|
105
|
+
* @tutorial https://www.uvui.cn/components/vtabs.html
|
|
106
|
+
* @property {Array} list 选项数组,元素为对象,如[{name:'uv-ui'}](默认 [] )
|
|
107
|
+
* @property {String} keyName 从list元素对象中读取的键名(默认 name )
|
|
108
|
+
* @property {Number} current 当前选中项,从0开始(默认 0 )
|
|
109
|
+
* @property {Number | String} hdHeight 头部内容的高度,头部有内容必传,否则会有联动误差(默认 0 )
|
|
110
|
+
* @property {Boolean} chain 是否开启联动,开启后右边区域可以滑动查看内容(默认 true )
|
|
111
|
+
* @property {Number|String} height 整个列表的高度,默认auto或空则为屏幕高度(默认 auto屏幕高度 )
|
|
112
|
+
* @property {Number|String} barWidth 左边选项区域的宽度(默认 180rpx )
|
|
113
|
+
* @property {Boolean} barScrollable 左边选项区域是否允许滚动 (默认 true )
|
|
114
|
+
* @property {String} barBgColor 左边选项区域的背景颜色(默认$uv-bg-color)
|
|
115
|
+
* @property {Object} barStyle 左边选项区域的自定义样式 (默认{})
|
|
116
|
+
* @property {Object} barItemStyle 左边选项区域每个选项的自定义样式 (默认{})
|
|
117
|
+
* @property {Object} barItemActiveStyle 左边选项区域选中选项的自定义样式 (默认{})
|
|
118
|
+
* @property {Object} barItemActiveLineStyle 左边选项区域选中选项竖线条的自定义样式 (默认{})
|
|
119
|
+
* @property {Object} barItemBadgeStyle 左边选项区域选中选项徽标的自定义样式,主要用于设置位置 (默认{})
|
|
120
|
+
* @property {Object} contentStyle 右边区域自定义样式 (默认{})
|
|
121
|
+
* @example <uv-vtabs :list="list"><uv-vtabs-item>...</uv-vtabs-item></uv-vtabs>
|
|
122
|
+
*/
|
|
123
|
+
export default {
|
|
124
|
+
name: 'uv-vtabs',
|
|
125
|
+
mixins: [mpMixin, mixin, props],
|
|
126
|
+
created() {
|
|
127
|
+
this.children = []
|
|
128
|
+
},
|
|
129
|
+
mounted() {
|
|
130
|
+
this.$nextTick(()=>{
|
|
131
|
+
this.init(this.current);
|
|
132
|
+
})
|
|
133
|
+
},
|
|
134
|
+
data() {
|
|
135
|
+
return {
|
|
136
|
+
activeIndex: 0,
|
|
137
|
+
// 微信小程序下,scroll-view的scroll-into-view属性无法对slot中的内容的id生效,只能通过设置scrollTop的形式去移动滚动条
|
|
138
|
+
contentScrollTop: 0,
|
|
139
|
+
contentScrollTop2: 0,//针对非联动
|
|
140
|
+
contentScrollTo: '',
|
|
141
|
+
scrolling: false,
|
|
142
|
+
barScrolling: false,
|
|
143
|
+
touching: false,
|
|
144
|
+
hasHeight: 0,
|
|
145
|
+
scrollViewHeight: 0,
|
|
146
|
+
barScrollTop: 0,
|
|
147
|
+
barScrollToView: '',
|
|
148
|
+
timer2: 0
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
computed: {
|
|
152
|
+
scrollX(){
|
|
153
|
+
// #ifdef APP-NVUE
|
|
154
|
+
return true;
|
|
155
|
+
// #endif
|
|
156
|
+
return false;
|
|
157
|
+
},
|
|
158
|
+
vtabsStyle() {
|
|
159
|
+
const style = {};
|
|
160
|
+
style.height = this.getHeight();
|
|
161
|
+
return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle));
|
|
162
|
+
},
|
|
163
|
+
getBarStyle() {
|
|
164
|
+
const style = {};
|
|
165
|
+
style.width = this.$uv.getPx(this.barWidth, true);
|
|
166
|
+
style.background = this.barBgColor;
|
|
167
|
+
style.height = this.getHeight();
|
|
168
|
+
return this.$uv.deepMerge(style, this.$uv.addStyle(this.barStyle));
|
|
169
|
+
},
|
|
170
|
+
itemStyle(){
|
|
171
|
+
return index =>{
|
|
172
|
+
const style = {};
|
|
173
|
+
let barItemInitStyle = this.barItemStyle;
|
|
174
|
+
// 避免在nvue模式下,切换时候上一个选中颜色不变
|
|
175
|
+
if(this.barItemStyle && !this.barItemStyle?.background) {
|
|
176
|
+
barItemInitStyle.background = 'transparent';
|
|
177
|
+
}
|
|
178
|
+
// 是否激活的样式
|
|
179
|
+
const customeStyle = index === this.activeIndex ? this.$uv.addStyle(this.barItemActiveStyle) : this.$uv.addStyle(barItemInitStyle);
|
|
180
|
+
if (this.list[index].disabled) {
|
|
181
|
+
style.color = '#c8c9cc'
|
|
182
|
+
}
|
|
183
|
+
return this.$uv.deepMerge(style, customeStyle);
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
// nvue设置字体样式必须要text标签上进行
|
|
187
|
+
textStyle(){
|
|
188
|
+
return index=>{
|
|
189
|
+
const style = {};
|
|
190
|
+
style.width = this.$uv.getPx(this.barWidth, true);
|
|
191
|
+
return style;
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
getContentStyle() {
|
|
195
|
+
const style = {};
|
|
196
|
+
style.height = this.getHeight();
|
|
197
|
+
return style;
|
|
198
|
+
},
|
|
199
|
+
propsBadge() {
|
|
200
|
+
return uvBadgeProps
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
watch: {
|
|
204
|
+
current(newVal){
|
|
205
|
+
if(!this.touching)
|
|
206
|
+
this.$nextTick(()=>{
|
|
207
|
+
this.init(newVal?newVal:0);
|
|
208
|
+
})
|
|
209
|
+
},
|
|
210
|
+
list(newVal) {
|
|
211
|
+
if (newVal.length) {
|
|
212
|
+
this.$uv.sleep(30).then(res => {
|
|
213
|
+
this.resize();
|
|
214
|
+
})
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
activeIndex(newVal){
|
|
218
|
+
if(!this.chain) {// 解决:非联动,内容过多的情况,滚动一段距离,再切换未滚动到顶部的BUG
|
|
219
|
+
this.contentScrollTop2 = 0 - Math.random() * 4 - 4;
|
|
220
|
+
}
|
|
221
|
+
this.$emit('change',newVal);
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
methods: {
|
|
225
|
+
init(index){
|
|
226
|
+
let num = 0;
|
|
227
|
+
clearInterval(this.timer2);
|
|
228
|
+
this.timer2 = setInterval(async ()=>{
|
|
229
|
+
num++;
|
|
230
|
+
if(num>50) clearInterval(this.timer2);
|
|
231
|
+
if(this.children.length) {
|
|
232
|
+
clearInterval(this.timer2);
|
|
233
|
+
await this.$uv.sleep(300);
|
|
234
|
+
this.clickHandler(index);
|
|
235
|
+
}
|
|
236
|
+
},100)
|
|
237
|
+
},
|
|
238
|
+
// 内容滚动到底部触发
|
|
239
|
+
scrolltolower(){
|
|
240
|
+
this.$emit('scrolltolower',this.activeIndex);
|
|
241
|
+
},
|
|
242
|
+
async resize() {
|
|
243
|
+
// 如果list数组长度为0就不处理 || 选中目标未变则不处理
|
|
244
|
+
if (this.list.length == 0 || !this.barScrollable) return;
|
|
245
|
+
// 避免滑太快,修复位置
|
|
246
|
+
Promise.all([this.getTabsRect(), this.getAllItemRect()]).then(([tabsRect, itemRect = []]) => {
|
|
247
|
+
this.tabsRect = tabsRect;
|
|
248
|
+
this.scrollViewHeight = 0
|
|
249
|
+
itemRect.map((item, index) => {
|
|
250
|
+
this.scrollViewHeight += item.height;
|
|
251
|
+
this.list[index].rect = item;
|
|
252
|
+
})
|
|
253
|
+
this.setBarScrollTop();
|
|
254
|
+
})
|
|
255
|
+
},
|
|
256
|
+
// 设置左边菜单滚动条的位置,目标:将当前的选项移到中间位置
|
|
257
|
+
setBarScrollTop() {
|
|
258
|
+
const tabRect = this.list[this.activeIndex];
|
|
259
|
+
const offsetTop = this.list
|
|
260
|
+
.slice(0, this.activeIndex)
|
|
261
|
+
.reduce((total, item) => {
|
|
262
|
+
return total + item.rect.height;
|
|
263
|
+
}, 0);
|
|
264
|
+
const scrollViewHeight = this.$uv.getPx(this.getHeight());
|
|
265
|
+
let barScrollTop = tabRect.rect.height / 2 + offsetTop - scrollViewHeight / 2;
|
|
266
|
+
// 先给一点随机值,避免出现不能滚动的BUG
|
|
267
|
+
barScrollTop = Math.min(barScrollTop, this.scrollViewHeight - this.tabsRect.height);
|
|
268
|
+
this.barScrollTop = Math.max(0, barScrollTop);
|
|
269
|
+
// 已经不能滚动的时候,就使用scroll-into-view的方式进行定位,避免失效
|
|
270
|
+
if(barScrollTop>=(this.scrollViewHeight - this.tabsRect.height)) {
|
|
271
|
+
this.timer && clearTimeout(this.timer);
|
|
272
|
+
this.timer = setTimeout(()=>{
|
|
273
|
+
this.barScrollToView = `bar_${this.activeIndex}`;
|
|
274
|
+
},400)
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
// 左边菜单点击
|
|
278
|
+
async clickHandler(currentIndex) {
|
|
279
|
+
if (currentIndex == this.activeIndex) return;
|
|
280
|
+
this.touching = true;
|
|
281
|
+
this.activeIndex = currentIndex;
|
|
282
|
+
if(this.chain) {
|
|
283
|
+
// 给一点随机值,避免出现不能滚动的BUG。微信端必须用此方法
|
|
284
|
+
this.contentScrollTop = this.children[currentIndex].top - this.$uv.getPx(this.hdHeight) - Math.random() * 4 - 4;
|
|
285
|
+
// #ifndef MP-WEIXIN
|
|
286
|
+
this.contentScrollTo = `content_${currentIndex}`;
|
|
287
|
+
// #endif
|
|
288
|
+
}
|
|
289
|
+
this.timer && clearTimeout(this.timer);
|
|
290
|
+
throttle(()=>{
|
|
291
|
+
this.resize();
|
|
292
|
+
},300,false)
|
|
293
|
+
debounce(() => {
|
|
294
|
+
this.touching = false;
|
|
295
|
+
}, 900)
|
|
296
|
+
},
|
|
297
|
+
// 内容滚动
|
|
298
|
+
scrollHandler(e) {
|
|
299
|
+
if (this.touching || this.scrolling) return;
|
|
300
|
+
// 每过一定时间取样一次,减少资源损耗以及可能带来的卡顿
|
|
301
|
+
this.scrolling = true;
|
|
302
|
+
this.$uv.sleep(80).then(() => {
|
|
303
|
+
this.scrolling = false;
|
|
304
|
+
})
|
|
305
|
+
const scrollTop = e.detail.scrollTop;
|
|
306
|
+
let children = this.children;
|
|
307
|
+
const len = children.length;
|
|
308
|
+
let top = 0;
|
|
309
|
+
let activeIndex = 0;
|
|
310
|
+
children = this.children.map((item, index) => {
|
|
311
|
+
if (item.height > 0) this.hasHeight = item.height;
|
|
312
|
+
item.height = item.height > 0 ? item.height : this.hasHeight;
|
|
313
|
+
const child = {
|
|
314
|
+
height: item.height,
|
|
315
|
+
top
|
|
316
|
+
}
|
|
317
|
+
// 进行累加,给下一个item提供计算依据
|
|
318
|
+
top += item.height;
|
|
319
|
+
return child;
|
|
320
|
+
})
|
|
321
|
+
for (let i = 0; i < len; i++) {
|
|
322
|
+
const item = children[i];
|
|
323
|
+
const nextItem = children[i + 1];
|
|
324
|
+
// 如果滚动条高度小于第一个item的top值,此时无需设置任意字母为高亮
|
|
325
|
+
if (scrollTop <= children[0].top) {
|
|
326
|
+
activeIndex = 0;
|
|
327
|
+
break
|
|
328
|
+
} else if (!nextItem) {
|
|
329
|
+
// 当不存在下一个item时,意味着历遍到了最后一个
|
|
330
|
+
activeIndex = len - 1;
|
|
331
|
+
break
|
|
332
|
+
} else if (scrollTop > item.top && scrollTop < nextItem.top) {
|
|
333
|
+
activeIndex = i;
|
|
334
|
+
break
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
this.activeIndex = activeIndex;
|
|
338
|
+
// 当前选中项索引必然来源于前后两个索引,满足才执行,避免闪烁的bug
|
|
339
|
+
this.timer4 && clearTimeout(this.timer4);
|
|
340
|
+
this.timer4 = setTimeout(()=>{
|
|
341
|
+
this.resize();
|
|
342
|
+
},100)
|
|
343
|
+
},
|
|
344
|
+
// 设置高度
|
|
345
|
+
getHeight() {
|
|
346
|
+
let height = 0;
|
|
347
|
+
const isEmpty = this.$uv.test.empty(this.height);
|
|
348
|
+
if (isEmpty || this.height=='auto') height = this.$uv.addUnit(this.$uv.sys().windowHeight);
|
|
349
|
+
else height = this.$uv.getPx(this.height, true);
|
|
350
|
+
return height;
|
|
351
|
+
},
|
|
352
|
+
// 获取导航菜单的尺寸
|
|
353
|
+
getTabsRect() {
|
|
354
|
+
return new Promise(resolve => {
|
|
355
|
+
this.queryRect('uv-vtabs__bar').then(size => resolve(size))
|
|
356
|
+
})
|
|
357
|
+
},
|
|
358
|
+
// 获取所有标签的尺寸
|
|
359
|
+
getAllItemRect() {
|
|
360
|
+
return new Promise(resolve => {
|
|
361
|
+
const promiseAllArr = this.list.map((item, index) => this.queryRect(
|
|
362
|
+
`uv-vtabs__bar-item--${index}`, true))
|
|
363
|
+
Promise.all(promiseAllArr).then(sizes => resolve(sizes))
|
|
364
|
+
})
|
|
365
|
+
},
|
|
366
|
+
// 获取各个标签的尺寸
|
|
367
|
+
queryRect(el, item) {
|
|
368
|
+
// #ifndef APP-NVUE
|
|
369
|
+
// $uvGetRect为uv-ui自带的节点查询简化方法,详见文档介绍:https://www.uvui.cn/js/getRect.html
|
|
370
|
+
// 组件内部一般用this.$uvGetRect,对外的为getRect,二者功能一致,名称不同
|
|
371
|
+
return new Promise(resolve => {
|
|
372
|
+
this.$uvGetRect(`.${el}`).then(size => {
|
|
373
|
+
resolve(size)
|
|
374
|
+
})
|
|
375
|
+
})
|
|
376
|
+
// #endif
|
|
377
|
+
// #ifdef APP-NVUE
|
|
378
|
+
// nvue下,使用dom模块查询元素高度
|
|
379
|
+
// 返回一个promise,让调用此方法的主体能使用then回调
|
|
380
|
+
return new Promise(resolve => {
|
|
381
|
+
dom.getComponentRect(item ? this.$refs[el][0] : this.$refs[el], res => {
|
|
382
|
+
resolve(res.size)
|
|
383
|
+
})
|
|
384
|
+
})
|
|
385
|
+
// #endif
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
</script>
|
|
390
|
+
<style scoped lang="scss">
|
|
391
|
+
@import '../../libs/css/components.scss';
|
|
392
|
+
@import '../../libs/css/color.scss';
|
|
393
|
+
.uv-vtabs {
|
|
394
|
+
@include flex;
|
|
395
|
+
&__bar {
|
|
396
|
+
background: $uv-bg-color;
|
|
397
|
+
&-item {
|
|
398
|
+
position: relative;
|
|
399
|
+
@include flex;
|
|
400
|
+
align-items: center;
|
|
401
|
+
justify-content: center;
|
|
402
|
+
padding: 35rpx 12rpx 35rpx 20rpx;
|
|
403
|
+
&--value {
|
|
404
|
+
/* #ifdef APP-NVUE */
|
|
405
|
+
padding: 0 12rpx;
|
|
406
|
+
/* #endif */
|
|
407
|
+
font-size: 14px;
|
|
408
|
+
color: $uv-content-color;
|
|
409
|
+
}
|
|
410
|
+
&-active {
|
|
411
|
+
background: #fff;
|
|
412
|
+
&--value {
|
|
413
|
+
color: $uv-primary;
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
&--line {
|
|
417
|
+
position: absolute;
|
|
418
|
+
width: 2px;
|
|
419
|
+
left: 0;
|
|
420
|
+
top: 0;
|
|
421
|
+
bottom: 0;
|
|
422
|
+
z-index: 1;
|
|
423
|
+
background-color: $uv-primary;
|
|
424
|
+
}
|
|
425
|
+
&--badge {
|
|
426
|
+
position: absolute;
|
|
427
|
+
top: 4px;
|
|
428
|
+
right: 10px;
|
|
429
|
+
z-index: 1;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
&__content {
|
|
434
|
+
flex: 1;
|
|
435
|
+
background: #fff;
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
</style>
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="uv-vtabs-item"
|
|
4
|
+
:id="`content_${index}`"
|
|
5
|
+
ref="uv-vtabs-item"
|
|
6
|
+
>
|
|
7
|
+
<slot />
|
|
8
|
+
</view>
|
|
9
|
+
</template>
|
|
10
|
+
<script>
|
|
11
|
+
import mpMixin from '../../libs/mixin/mpMixin.js';
|
|
12
|
+
import mixin from '../../libs/mixin/mixin.js';
|
|
13
|
+
// #ifdef APP-NVUE
|
|
14
|
+
const dom = uni.requireNativePlugin('dom');
|
|
15
|
+
// #endif
|
|
16
|
+
export default {
|
|
17
|
+
name: 'uv-vtabs-item',
|
|
18
|
+
mixins: [mpMixin, mixin],
|
|
19
|
+
props: {
|
|
20
|
+
index: {
|
|
21
|
+
type: [Number,String],
|
|
22
|
+
default: 0
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
data(){
|
|
26
|
+
return {
|
|
27
|
+
// 记录item的离顶部的距离
|
|
28
|
+
top: 0,
|
|
29
|
+
// 记录item的高度
|
|
30
|
+
height: 0
|
|
31
|
+
// 是否为联动
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
mounted() {
|
|
35
|
+
this.init();
|
|
36
|
+
},
|
|
37
|
+
methods: {
|
|
38
|
+
async init(){
|
|
39
|
+
this.getParentData('uv-vtabs');
|
|
40
|
+
if (!this.parent) {
|
|
41
|
+
return this.$uv.error('uv-vtabs必须要搭配uv-vtabs-item组件使用')
|
|
42
|
+
}
|
|
43
|
+
if(!this.parent.chain) return;
|
|
44
|
+
await this.$uv.sleep();
|
|
45
|
+
this.getItemRect().then(size=>{
|
|
46
|
+
// 由于对象的引用特性,此处会同时生效到父组件的children数组的本实例的top属性中,供父组件判断读取
|
|
47
|
+
this.top = size.top;
|
|
48
|
+
this.height = size.height;
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
getItemRect(){
|
|
52
|
+
return new Promise(resolve => {
|
|
53
|
+
// #ifndef APP-NVUE
|
|
54
|
+
this.$uvGetRect('.uv-vtabs-item').then(size => {
|
|
55
|
+
resolve(size)
|
|
56
|
+
})
|
|
57
|
+
// #endif
|
|
58
|
+
// #ifdef APP-NVUE
|
|
59
|
+
const ref = this.$refs['uv-vtabs-item']
|
|
60
|
+
dom.getComponentRect(ref, res => {
|
|
61
|
+
resolve(res.size)
|
|
62
|
+
})
|
|
63
|
+
// #endif
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
</script>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
// 瀑布流数据
|
|
4
|
+
// #ifdef VUE2
|
|
5
|
+
value: {
|
|
6
|
+
type: Array,
|
|
7
|
+
default: () => []
|
|
8
|
+
},
|
|
9
|
+
// #endif
|
|
10
|
+
// #ifdef VUE3
|
|
11
|
+
modelValue: {
|
|
12
|
+
type: Array,
|
|
13
|
+
default: () => []
|
|
14
|
+
},
|
|
15
|
+
// #endif
|
|
16
|
+
// 数据的id值,根据id值对数据执行删除操作
|
|
17
|
+
// 如数据为:{id: 1, name: 'uv-ui'},那么该值设置为id
|
|
18
|
+
idKey: {
|
|
19
|
+
type: String,
|
|
20
|
+
default: 'id'
|
|
21
|
+
},
|
|
22
|
+
// 每次插入数据的事件间隔,间隔越长能保证两列高度相近,但是用户体验不好,单位ms
|
|
23
|
+
addTime: {
|
|
24
|
+
type: Number,
|
|
25
|
+
default: 200
|
|
26
|
+
},
|
|
27
|
+
// 瀑布流的列数,默认2,最高为5
|
|
28
|
+
columnCount: {
|
|
29
|
+
type: [Number, String],
|
|
30
|
+
default: 2
|
|
31
|
+
},
|
|
32
|
+
// 列与列的间隙,默认20
|
|
33
|
+
columnGap: {
|
|
34
|
+
type: [Number, String],
|
|
35
|
+
default: 20
|
|
36
|
+
},
|
|
37
|
+
// 左边和列表的间隙
|
|
38
|
+
leftGap: {
|
|
39
|
+
type: [Number, String],
|
|
40
|
+
default: 0
|
|
41
|
+
},
|
|
42
|
+
// 右边和列表的间隙
|
|
43
|
+
rightGap: {
|
|
44
|
+
type: [Number, String],
|
|
45
|
+
default: 0
|
|
46
|
+
},
|
|
47
|
+
// 是否显示滚动条,仅nvue生效
|
|
48
|
+
showScrollbar: {
|
|
49
|
+
type: [Boolean],
|
|
50
|
+
default: false
|
|
51
|
+
},
|
|
52
|
+
// 列宽,nvue生效
|
|
53
|
+
columnWidth: {
|
|
54
|
+
type: [Number, String],
|
|
55
|
+
default: 'auto'
|
|
56
|
+
},
|
|
57
|
+
// 瀑布流的宽度,nvue生效
|
|
58
|
+
width: {
|
|
59
|
+
type: [Number, String],
|
|
60
|
+
default: ''
|
|
61
|
+
},
|
|
62
|
+
// 瀑布流的高度,nvue生效
|
|
63
|
+
height: {
|
|
64
|
+
type: [Number, String],
|
|
65
|
+
default: ''
|
|
66
|
+
},
|
|
67
|
+
...uni.$uv?.props?.waterfall
|
|
68
|
+
}
|
|
69
|
+
}
|