@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,341 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="uv-notice"
|
|
4
|
+
@tap="clickHandler"
|
|
5
|
+
>
|
|
6
|
+
<slot name="icon">
|
|
7
|
+
<view
|
|
8
|
+
class="uv-notice__left-icon"
|
|
9
|
+
v-if="icon"
|
|
10
|
+
>
|
|
11
|
+
<uv-icon
|
|
12
|
+
:name="icon"
|
|
13
|
+
:color="color"
|
|
14
|
+
size="19"
|
|
15
|
+
></uv-icon>
|
|
16
|
+
</view>
|
|
17
|
+
</slot>
|
|
18
|
+
<view
|
|
19
|
+
class="uv-notice__content"
|
|
20
|
+
ref="uv-notice__content"
|
|
21
|
+
>
|
|
22
|
+
<view
|
|
23
|
+
ref="uv-notice__content__text"
|
|
24
|
+
class="uv-notice__content__text"
|
|
25
|
+
:style="[animationStyle]"
|
|
26
|
+
>
|
|
27
|
+
<text
|
|
28
|
+
v-for="(item, index) in innerText"
|
|
29
|
+
:key="index"
|
|
30
|
+
:style="[textStyle]"
|
|
31
|
+
>{{item}}</text>
|
|
32
|
+
</view>
|
|
33
|
+
</view>
|
|
34
|
+
<view
|
|
35
|
+
class="uv-notice__right-icon"
|
|
36
|
+
v-if="['link', 'closable'].includes(mode)"
|
|
37
|
+
>
|
|
38
|
+
<uv-icon
|
|
39
|
+
v-if="mode === 'link'"
|
|
40
|
+
name="arrow-right"
|
|
41
|
+
:size="17"
|
|
42
|
+
:color="color"
|
|
43
|
+
></uv-icon>
|
|
44
|
+
<uv-icon
|
|
45
|
+
v-if="mode === 'closable'"
|
|
46
|
+
@click="close"
|
|
47
|
+
name="close"
|
|
48
|
+
:size="16"
|
|
49
|
+
:color="color"
|
|
50
|
+
></uv-icon>
|
|
51
|
+
</view>
|
|
52
|
+
</view>
|
|
53
|
+
</template>
|
|
54
|
+
<script>
|
|
55
|
+
import mpMixin from '../../libs/mixin/mpMixin.js'
|
|
56
|
+
import mixin from '../../libs/mixin/mixin.js'
|
|
57
|
+
import props from './props.js';
|
|
58
|
+
// #ifdef APP-NVUE
|
|
59
|
+
const animation = uni.requireNativePlugin('animation')
|
|
60
|
+
const dom = uni.requireNativePlugin('dom')
|
|
61
|
+
// #endif
|
|
62
|
+
/**
|
|
63
|
+
* RowNotice 滚动通知中的水平滚动模式
|
|
64
|
+
* @description 水平滚动
|
|
65
|
+
* @tutorial https://www.uvui.cn/components/noticeBar.html
|
|
66
|
+
* @property {String | Number} text 显示的内容,字符串
|
|
67
|
+
* @property {String} icon 是否显示左侧的音量图标 (默认 'volume' )
|
|
68
|
+
* @property {String} mode 通告模式,link-显示右箭头,closable-显示右侧关闭图标
|
|
69
|
+
* @property {String} color 文字颜色,各图标也会使用文字颜色 (默认 '#f9ae3d' )
|
|
70
|
+
* @property {String} bgColor 背景颜色 (默认 ''#fdf6ec' )
|
|
71
|
+
* @property {String | Number} fontSize 字体大小,单位px (默认 14 )
|
|
72
|
+
* @property {String | Number} speed 水平滚动时的滚动速度,即每秒滚动多少px(rpx),这有利于控制文字无论多少时,都能有一个恒定的速度 (默认 80 )
|
|
73
|
+
*
|
|
74
|
+
* @event {Function} click 点击通告文字触发
|
|
75
|
+
* @event {Function} close 点击右侧关闭图标触发
|
|
76
|
+
* @example
|
|
77
|
+
*/
|
|
78
|
+
export default {
|
|
79
|
+
name: 'uv-row-notice',
|
|
80
|
+
emits: ['click','close'],
|
|
81
|
+
mixins: [mpMixin, mixin, props],
|
|
82
|
+
data() {
|
|
83
|
+
return {
|
|
84
|
+
animationDuration: '0', // 动画执行时间
|
|
85
|
+
animationPlayState: 'paused', // 动画的开始和结束执行
|
|
86
|
+
// nvue下,内容发生变化,导致滚动宽度也变化,需要标志为是否需要重新计算宽度
|
|
87
|
+
// 不能在内容变化时直接重新计算,因为nvue的animation模块上一次的滚动不是刚好结束,会有影响
|
|
88
|
+
nvueInit: true,
|
|
89
|
+
show: true
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
watch: {
|
|
93
|
+
text: {
|
|
94
|
+
immediate: true,
|
|
95
|
+
handler(newValue, oldValue) {
|
|
96
|
+
// #ifdef APP-NVUE
|
|
97
|
+
this.nvueInit = true
|
|
98
|
+
// #endif
|
|
99
|
+
// #ifndef APP-NVUE
|
|
100
|
+
this.vue()
|
|
101
|
+
// #endif
|
|
102
|
+
|
|
103
|
+
if(!this.$uv.test.string(newValue)) {
|
|
104
|
+
this.$uv.error('noticebar组件direction为row时,要求text参数为字符串形式')
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
fontSize() {
|
|
109
|
+
// #ifdef APP-NVUE
|
|
110
|
+
this.nvueInit = true
|
|
111
|
+
// #endif
|
|
112
|
+
// #ifndef APP-NVUE
|
|
113
|
+
this.vue()
|
|
114
|
+
// #endif
|
|
115
|
+
},
|
|
116
|
+
speed() {
|
|
117
|
+
// #ifdef APP-NVUE
|
|
118
|
+
this.nvueInit = true
|
|
119
|
+
// #endif
|
|
120
|
+
// #ifndef APP-NVUE
|
|
121
|
+
this.vue()
|
|
122
|
+
// #endif
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
computed: {
|
|
126
|
+
// 文字内容的样式
|
|
127
|
+
textStyle() {
|
|
128
|
+
let style = {}
|
|
129
|
+
style.color = this.color
|
|
130
|
+
style.fontSize = this.$uv.addUnit(this.fontSize)
|
|
131
|
+
return style
|
|
132
|
+
},
|
|
133
|
+
animationStyle() {
|
|
134
|
+
let style = {}
|
|
135
|
+
style.animationDuration = this.animationDuration
|
|
136
|
+
style.animationPlayState = this.animationPlayState
|
|
137
|
+
return style
|
|
138
|
+
},
|
|
139
|
+
// 内部对用户传入的数据进一步分割,放到多个text标签循环,否则如果用户传入的字符串很长(100个字符以上)
|
|
140
|
+
// 放在一个text标签中进行滚动,在低端安卓机上,动画可能会出现抖动现象,需要分割到多个text中可解决此问题
|
|
141
|
+
innerText() {
|
|
142
|
+
let result = [],
|
|
143
|
+
// 每组text标签的字符长度
|
|
144
|
+
len = 20
|
|
145
|
+
const textArr = this.text? this.text.split(''):[]
|
|
146
|
+
for (let i = 0; i < textArr.length; i += len) {
|
|
147
|
+
// 对拆分的后的text进行slice分割,得到的为数组再进行join拼接为字符串
|
|
148
|
+
result.push(textArr.slice(i, i + len).join(''))
|
|
149
|
+
}
|
|
150
|
+
return result
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
mounted() {
|
|
154
|
+
// #ifdef APP-PLUS
|
|
155
|
+
// 在APP上(含nvue),监听当前webview是否处于隐藏状态(进入下一页时即为hide状态)
|
|
156
|
+
// 如果webivew隐藏了,为了节省性能的损耗,应停止动画的执行,同时也是为了保持进入下一页返回后,滚动位置保持不变
|
|
157
|
+
var pages = getCurrentPages()
|
|
158
|
+
var page = pages[pages.length - 1]
|
|
159
|
+
var currentWebview = page.$getAppWebview()
|
|
160
|
+
currentWebview.addEventListener('hide', () => {
|
|
161
|
+
this.webviewHide = true
|
|
162
|
+
})
|
|
163
|
+
currentWebview.addEventListener('show', () => {
|
|
164
|
+
this.webviewHide = false
|
|
165
|
+
})
|
|
166
|
+
// #endif
|
|
167
|
+
|
|
168
|
+
this.init()
|
|
169
|
+
},
|
|
170
|
+
methods: {
|
|
171
|
+
init() {
|
|
172
|
+
// #ifdef APP-NVUE
|
|
173
|
+
this.nvue()
|
|
174
|
+
// #endif
|
|
175
|
+
|
|
176
|
+
// #ifndef APP-NVUE
|
|
177
|
+
this.vue()
|
|
178
|
+
// #endif
|
|
179
|
+
|
|
180
|
+
if(!this.$uv.test.string(this.text)) {
|
|
181
|
+
this.$uv.error('noticebar组件direction为row时,要求text参数为字符串形式')
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
// vue版处理
|
|
185
|
+
async vue() {
|
|
186
|
+
// #ifndef APP-NVUE
|
|
187
|
+
let boxWidth = 0,
|
|
188
|
+
textWidth = 0
|
|
189
|
+
// 进行一定的延时
|
|
190
|
+
await this.$uv.sleep()
|
|
191
|
+
// 查询盒子和文字的宽度
|
|
192
|
+
textWidth = (await this.$uvGetRect('.uv-notice__content__text')).width
|
|
193
|
+
boxWidth = (await this.$uvGetRect('.uv-notice__content')).width
|
|
194
|
+
// 根据t=s/v(时间=路程/速度),这里为何不需要加上#uv-notice-box的宽度,因为中设置了.uv-notice-content样式中设置了padding-left: 100%
|
|
195
|
+
// 恰巧计算出来的结果中已经包含了#uv-notice-box的宽度
|
|
196
|
+
this.animationDuration = `${textWidth / this.$uv.getPx(this.speed)}s`
|
|
197
|
+
// 这里必须这样开始动画,否则在APP上动画速度不会改变
|
|
198
|
+
this.animationPlayState = 'paused'
|
|
199
|
+
setTimeout(() => {
|
|
200
|
+
this.animationPlayState = 'running'
|
|
201
|
+
}, 10)
|
|
202
|
+
// #endif
|
|
203
|
+
},
|
|
204
|
+
// nvue版处理
|
|
205
|
+
async nvue() {
|
|
206
|
+
// #ifdef APP-NVUE
|
|
207
|
+
this.nvueInit = false
|
|
208
|
+
let boxWidth = 0,
|
|
209
|
+
textWidth = 0
|
|
210
|
+
// 进行一定的延时
|
|
211
|
+
await this.$uv.sleep()
|
|
212
|
+
// 查询盒子和文字的宽度
|
|
213
|
+
textWidth = (await this.getNvueRect('uv-notice__content__text')).width
|
|
214
|
+
boxWidth = (await this.getNvueRect('uv-notice__content')).width
|
|
215
|
+
// 将文字移动到盒子的右边沿,之所以需要这么做,是因为nvue不支持100%单位,否则可以通过css设置
|
|
216
|
+
animation.transition(this.$refs['uv-notice__content__text'], {
|
|
217
|
+
styles: {
|
|
218
|
+
transform: `translateX(${boxWidth}px)`
|
|
219
|
+
},
|
|
220
|
+
}, () => {
|
|
221
|
+
// 如果非禁止动画,则开始滚动
|
|
222
|
+
!this.stopAnimation && this.loopAnimation(textWidth, boxWidth)
|
|
223
|
+
});
|
|
224
|
+
// #endif
|
|
225
|
+
},
|
|
226
|
+
loopAnimation(textWidth, boxWidth) {
|
|
227
|
+
// #ifdef APP-NVUE
|
|
228
|
+
animation.transition(this.$refs['uv-notice__content__text'], {
|
|
229
|
+
styles: {
|
|
230
|
+
// 目标移动终点为-textWidth,也即当文字的最右边贴到盒子的左边框的位置
|
|
231
|
+
transform: `translateX(-${textWidth}px)`
|
|
232
|
+
},
|
|
233
|
+
// 滚动时间的计算为,时间 = 路程(boxWidth + textWidth) / 速度,最后转为毫秒
|
|
234
|
+
duration: (boxWidth + textWidth) / this.$uv.getPx(this.speed) * 1000,
|
|
235
|
+
delay: 10
|
|
236
|
+
}, () => {
|
|
237
|
+
animation.transition(this.$refs['uv-notice__content__text'], {
|
|
238
|
+
styles: {
|
|
239
|
+
// 重新将文字移动到盒子的右边沿
|
|
240
|
+
transform: `translateX(${this.stopAnimation ? 0 : boxWidth}px)`
|
|
241
|
+
},
|
|
242
|
+
}, () => {
|
|
243
|
+
// 如果非禁止动画,则继续下一轮滚动
|
|
244
|
+
if (!this.stopAnimation) {
|
|
245
|
+
// 判断是否需要初始化计算尺寸
|
|
246
|
+
if (this.nvueInit) {
|
|
247
|
+
this.nvue()
|
|
248
|
+
} else {
|
|
249
|
+
this.loopAnimation(textWidth, boxWidth)
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
})
|
|
254
|
+
// #endif
|
|
255
|
+
},
|
|
256
|
+
getNvueRect(el) {
|
|
257
|
+
// #ifdef APP-NVUE
|
|
258
|
+
// 返回一个promise
|
|
259
|
+
return new Promise(resolve => {
|
|
260
|
+
dom.getComponentRect(this.$refs[el], (res) => {
|
|
261
|
+
resolve(res.size)
|
|
262
|
+
})
|
|
263
|
+
})
|
|
264
|
+
// #endif
|
|
265
|
+
},
|
|
266
|
+
// 点击通告栏
|
|
267
|
+
clickHandler(index) {
|
|
268
|
+
this.$emit('click')
|
|
269
|
+
},
|
|
270
|
+
// 点击右侧按钮,需要判断点击的是关闭图标还是箭头图标
|
|
271
|
+
close() {
|
|
272
|
+
this.$emit('close')
|
|
273
|
+
}
|
|
274
|
+
},
|
|
275
|
+
// #ifdef APP-NVUE
|
|
276
|
+
// #ifdef VUE2
|
|
277
|
+
beforeDestroy() {
|
|
278
|
+
this.stopAnimation = true
|
|
279
|
+
},
|
|
280
|
+
// #endif
|
|
281
|
+
// #ifdef VUE3
|
|
282
|
+
unmounted() {
|
|
283
|
+
this.stopAnimation = true
|
|
284
|
+
}
|
|
285
|
+
// #endif
|
|
286
|
+
// #endif
|
|
287
|
+
};
|
|
288
|
+
</script>
|
|
289
|
+
|
|
290
|
+
<style lang="scss" scoped>
|
|
291
|
+
@import '../../libs/css/components.scss';
|
|
292
|
+
@import '../../libs/css/color.scss';
|
|
293
|
+
.uv-notice {
|
|
294
|
+
@include flex;
|
|
295
|
+
align-items: center;
|
|
296
|
+
justify-content: space-between;
|
|
297
|
+
|
|
298
|
+
&__left-icon {
|
|
299
|
+
align-items: center;
|
|
300
|
+
margin-right: 5px;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
&__right-icon {
|
|
304
|
+
margin-left: 5px;
|
|
305
|
+
align-items: center;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
&__content {
|
|
309
|
+
text-align: right;
|
|
310
|
+
flex: 1;
|
|
311
|
+
@include flex;
|
|
312
|
+
flex-wrap: nowrap;
|
|
313
|
+
overflow: hidden;
|
|
314
|
+
|
|
315
|
+
&__text {
|
|
316
|
+
font-size: 14px;
|
|
317
|
+
color: $uv-warning;
|
|
318
|
+
/* #ifndef APP-NVUE */
|
|
319
|
+
// 这一句很重要,为了能让滚动左右连接起来
|
|
320
|
+
padding-left: 100%;
|
|
321
|
+
word-break: keep-all;
|
|
322
|
+
white-space: nowrap;
|
|
323
|
+
animation: uv-loop-animation 10s linear infinite both;
|
|
324
|
+
/* #endif */
|
|
325
|
+
@include flex(row);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
}
|
|
330
|
+
/* #ifndef APP-NVUE */
|
|
331
|
+
@keyframes uv-loop-animation {
|
|
332
|
+
0% {
|
|
333
|
+
transform: translate3d(0, 0, 0);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
100% {
|
|
337
|
+
transform: translate3d(-100%, 0, 0);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
/* #endif */
|
|
341
|
+
</style>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="uv-safe-bottom"
|
|
4
|
+
:style="[style]"
|
|
5
|
+
:class="[!isNvue && 'uv-safe-area-inset-bottom']"
|
|
6
|
+
>
|
|
7
|
+
</view>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
import mpMixin from '../../libs/mixin/mpMixin.js'
|
|
12
|
+
import mixin from '../../libs/mixin/mixin.js'
|
|
13
|
+
/**
|
|
14
|
+
* SafeBottom 底部安全区
|
|
15
|
+
* @description 这个适配,主要是针对IPhone X等一些底部带指示条的机型,指示条的操作区域与页面底部存在重合,容易导致用户误操作,因此我们需要针对这些机型进行底部安全区适配。
|
|
16
|
+
* @tutorial https://www.uvui.cn/components/safeAreaInset.html
|
|
17
|
+
* @property {type} prop_name
|
|
18
|
+
* @property {Object} customStyle 定义需要用到的外部样式
|
|
19
|
+
*
|
|
20
|
+
* @event {Function()}
|
|
21
|
+
* @example <uv-status-bar></uv-status-bar>
|
|
22
|
+
*/
|
|
23
|
+
export default {
|
|
24
|
+
name: "uv-safe-bottom",
|
|
25
|
+
mixins: [mpMixin, mixin],
|
|
26
|
+
data() {
|
|
27
|
+
return {
|
|
28
|
+
safeAreaBottomHeight: 0,
|
|
29
|
+
isNvue: false,
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
computed: {
|
|
33
|
+
style() {
|
|
34
|
+
const style = {};
|
|
35
|
+
// #ifdef APP-NVUE || MP-TOUTIAO || MP-LARK
|
|
36
|
+
// nvue下,高度使用js计算填充
|
|
37
|
+
style.height = this.$uv.addUnit(this.$uv.sys()?.safeAreaInsets?.bottom, 'px');
|
|
38
|
+
// #endif
|
|
39
|
+
return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle));
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
mounted() {
|
|
43
|
+
// #ifdef APP-NVUE
|
|
44
|
+
// 标识为是否nvue
|
|
45
|
+
this.isNvue = true;
|
|
46
|
+
// #endif
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
</script>
|
|
50
|
+
|
|
51
|
+
<style lang="scss" scoped>
|
|
52
|
+
.uv-safe-bottom {
|
|
53
|
+
/* #ifndef APP-NVUE */
|
|
54
|
+
width: 100%;
|
|
55
|
+
/* #endif */
|
|
56
|
+
}
|
|
57
|
+
/* #ifndef APP-NVUE */
|
|
58
|
+
// 历遍生成4个方向的底部安全区
|
|
59
|
+
@each $d in top, right, bottom, left {
|
|
60
|
+
.uv-safe-area-inset-#{$d} {
|
|
61
|
+
padding-#{$d}: 0;
|
|
62
|
+
padding-#{$d}: constant(safe-area-inset-#{$d});
|
|
63
|
+
padding-#{$d}: env(safe-area-inset-#{$d});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/* #endif */
|
|
67
|
+
</style>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// 引入bindingx,此库类似于微信小程序wxs,目的是让js运行在视图层,减少视图层和逻辑层的通信折损
|
|
2
|
+
const BindingX = uni.requireNativePlugin('bindingx')
|
|
3
|
+
export default {
|
|
4
|
+
methods: {
|
|
5
|
+
// 此处不写注释,请自行体会
|
|
6
|
+
nvueScrollHandler(e) {
|
|
7
|
+
if (this.indicator) {
|
|
8
|
+
const anchor = this.$refs['uv-scroll-list__scroll-view'].ref
|
|
9
|
+
const element = this.$refs['uv-scroll-list__indicator__line__bar'].ref
|
|
10
|
+
const scrollLeft = e.contentOffset.x
|
|
11
|
+
const contentSize = e.contentSize.width
|
|
12
|
+
const { scrollWidth } = this
|
|
13
|
+
const barAllMoveWidth = this.indicatorWidth - this.indicatorBarWidth
|
|
14
|
+
// 在安卓和iOS上,需要除的倍数不一样,iOS需要除以2
|
|
15
|
+
const actionNum = this.$uv.os() === 'ios' ? 2 : 1
|
|
16
|
+
const expression = `(x / ${actionNum}) / ${contentSize - scrollWidth} * ${this.$uv.getPx(this.$uv.addUnit(barAllMoveWidth))}`
|
|
17
|
+
BindingX.bind({
|
|
18
|
+
anchor,
|
|
19
|
+
eventType: 'scroll',
|
|
20
|
+
props: [{
|
|
21
|
+
element,
|
|
22
|
+
property: 'transform.translateX',
|
|
23
|
+
expression
|
|
24
|
+
}]
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
// 指示器的整体宽度
|
|
4
|
+
indicatorWidth: {
|
|
5
|
+
type: [String, Number],
|
|
6
|
+
default: 50
|
|
7
|
+
},
|
|
8
|
+
// 滑块的宽度
|
|
9
|
+
indicatorBarWidth: {
|
|
10
|
+
type: [String, Number],
|
|
11
|
+
default: 20
|
|
12
|
+
},
|
|
13
|
+
// 是否显示面板指示器
|
|
14
|
+
indicator: {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
default: true
|
|
17
|
+
},
|
|
18
|
+
// 指示器非激活颜色
|
|
19
|
+
indicatorColor: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: '#f2f2f2'
|
|
22
|
+
},
|
|
23
|
+
// 指示器的激活颜色
|
|
24
|
+
indicatorActiveColor: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: '#3c9cff'
|
|
27
|
+
},
|
|
28
|
+
// 指示器样式,可通过bottom,left,right进行定位
|
|
29
|
+
indicatorStyle: {
|
|
30
|
+
type: [String, Object],
|
|
31
|
+
default: ''
|
|
32
|
+
},
|
|
33
|
+
...uni.$uv?.props?.scrollList
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
function scroll(event, ownerInstance) {
|
|
2
|
+
// detail中含有scroll-view的信息,比如scroll-view的实际宽度,当前时间点scroll-view的移动距离等
|
|
3
|
+
var detail = event.detail
|
|
4
|
+
var scrollWidth = detail.scrollWidth
|
|
5
|
+
var scrollLeft = detail.scrollLeft
|
|
6
|
+
// 获取当前组件的dataset,说白了就是祸国殃民的腾xun搞出来的垃ji
|
|
7
|
+
var dataset = event.currentTarget.dataset
|
|
8
|
+
// 此为scroll-view外部包裹元素的宽度
|
|
9
|
+
// 某些HX版本(3.1.18),发现view元素中大写的data-scrollWidth,在wxs中,变成了全部小写,所以这里需要特别处理
|
|
10
|
+
var scrollComponentWidth = dataset.scrollWidth || dataset.scrollwidth || 0
|
|
11
|
+
// 指示器和滑块的宽度
|
|
12
|
+
var indicatorWidth = dataset.indicatorWidth || dataset.indicatorwidth || 0
|
|
13
|
+
var barWidth = dataset.barWidth || dataset.barwidth || 0
|
|
14
|
+
// 此处的计算理由为:scroll-view的滚动距离与目标滚动距离(scroll-view的实际宽度减去包裹元素的宽度)之比,等于滑块当前移动距离与总需
|
|
15
|
+
// 滑动距离(指示器的总宽度减去滑块宽度)的比值
|
|
16
|
+
var x = scrollLeft / (scrollWidth - scrollComponentWidth) * (indicatorWidth - barWidth)
|
|
17
|
+
setBarStyle(ownerInstance, x, dataset.unit)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// 由于webview的无能,无法保证scroll-view在滑动过程中,一直触发scroll事件,会导致
|
|
21
|
+
// 无法监听到某些滚动值,当在首尾临界值无法监听到时,这是致命的,因为错失这些值会导致滑块无法回到起点和终点
|
|
22
|
+
// 所以这里需要对临界值做监听并处理
|
|
23
|
+
function scrolltolower(event, ownerInstance) {
|
|
24
|
+
ownerInstance.callMethod('scrollEvent', 'right')
|
|
25
|
+
// 获取当前组件的dataset
|
|
26
|
+
var dataset = event.currentTarget.dataset
|
|
27
|
+
// 指示器和滑块的宽度
|
|
28
|
+
var indicatorWidth = dataset.indicatorWidth || dataset.indicatorwidth || 0
|
|
29
|
+
var barWidth = dataset.barWidth || dataset.barwidth || 0
|
|
30
|
+
// scroll-view滚动到右边终点时,将滑块也设置为到右边的终点,它所需移动的距离为:指示器宽度 - 滑块宽度
|
|
31
|
+
setBarStyle(ownerInstance, indicatorWidth - barWidth, dataset.unit)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function scrolltoupper(event, ownerInstance) {
|
|
35
|
+
var dataset = event.currentTarget.dataset
|
|
36
|
+
ownerInstance.callMethod('scrollEvent', 'left')
|
|
37
|
+
// 滚动到左边时,将滑块设置为0的偏移距离,回到起点
|
|
38
|
+
setBarStyle(ownerInstance, 0, dataset.unit)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function setBarStyle(ownerInstance, x, unit) {
|
|
42
|
+
ownerInstance.selectComponent('.uv-scroll-list__indicator__line__bar') && ownerInstance.selectComponent('.uv-scroll-list__indicator__line__bar').setStyle({
|
|
43
|
+
transform: unit == 'rpx' ? 'translateX(' + x + 'rpx)' : 'translateX(' + x + 'px)'
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = {
|
|
48
|
+
scroll: scroll,
|
|
49
|
+
scrolltolower: scrolltolower,
|
|
50
|
+
scrolltoupper: scrolltoupper
|
|
51
|
+
}
|