@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,296 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :style="viewStyle">
|
|
3
|
+
<uv-transition
|
|
4
|
+
:show="show"
|
|
5
|
+
mode="fade"
|
|
6
|
+
:duration="fade ? duration : 0"
|
|
7
|
+
:cell-child="cellChild"
|
|
8
|
+
:custom-style="wrapStyle"
|
|
9
|
+
>
|
|
10
|
+
<view
|
|
11
|
+
class="uv-image"
|
|
12
|
+
:class="[`uv-image--${elIndex}`]"
|
|
13
|
+
@tap="onClick"
|
|
14
|
+
:style="[wrapStyle, backgroundStyle]"
|
|
15
|
+
>
|
|
16
|
+
<image
|
|
17
|
+
v-if="!isError && observeShow"
|
|
18
|
+
:src="imageUrl"
|
|
19
|
+
:mode="mode"
|
|
20
|
+
@error="onErrorHandler"
|
|
21
|
+
@load="onLoadHandler"
|
|
22
|
+
:show-menu-by-longpress="showMenuByLongpress"
|
|
23
|
+
:lazy-load="lazyLoad"
|
|
24
|
+
class="uv-image__image"
|
|
25
|
+
:style="[imageStyle]"
|
|
26
|
+
:webp="webp"
|
|
27
|
+
></image>
|
|
28
|
+
<view
|
|
29
|
+
v-if="showLoading && loading"
|
|
30
|
+
class="uv-image__loading"
|
|
31
|
+
:style="{
|
|
32
|
+
borderRadius: shape == 'circle' ? '50%' : $uv.addUnit(radius),
|
|
33
|
+
backgroundColor: bgColor,
|
|
34
|
+
width: $uv.addUnit(width),
|
|
35
|
+
height: $uv.addUnit(height)
|
|
36
|
+
}"
|
|
37
|
+
>
|
|
38
|
+
<slot name="loading">
|
|
39
|
+
<uv-icon
|
|
40
|
+
:name="loadingIcon"
|
|
41
|
+
:width="width"
|
|
42
|
+
:height="height"
|
|
43
|
+
></uv-icon>
|
|
44
|
+
</slot>
|
|
45
|
+
</view>
|
|
46
|
+
<view
|
|
47
|
+
v-if="showError && isError && !loading"
|
|
48
|
+
class="uv-image__error"
|
|
49
|
+
:style="{
|
|
50
|
+
borderRadius: shape == 'circle' ? '50%' : $uv.addUnit(radius),
|
|
51
|
+
width: $uv.addUnit(width),
|
|
52
|
+
height: $uv.addUnit(height)
|
|
53
|
+
}"
|
|
54
|
+
>
|
|
55
|
+
<slot name="error">
|
|
56
|
+
<uv-icon
|
|
57
|
+
:name="errorIcon"
|
|
58
|
+
:width="width"
|
|
59
|
+
:height="height"
|
|
60
|
+
></uv-icon>
|
|
61
|
+
</slot>
|
|
62
|
+
</view>
|
|
63
|
+
</view>
|
|
64
|
+
</uv-transition>
|
|
65
|
+
</view>
|
|
66
|
+
</template>
|
|
67
|
+
|
|
68
|
+
<script>
|
|
69
|
+
import mpMixin from '../../libs/mixin/mpMixin.js'
|
|
70
|
+
import mixin from '../../libs/mixin/mixin.js'
|
|
71
|
+
import props from './props.js';
|
|
72
|
+
/**
|
|
73
|
+
* Image 图片
|
|
74
|
+
* @description 此组件为uni-app的image组件的加强版,在继承了原有功能外,还支持淡入动画、加载中、加载失败提示、圆角值和形状等。
|
|
75
|
+
* @tutorial https://www.uvui.cn/components/image.html
|
|
76
|
+
* @property {String} src 图片地址
|
|
77
|
+
* @property {String} mode 裁剪模式,见官网说明 (默认 'aspectFill' )
|
|
78
|
+
* @property {String | Number} width 宽度,单位任意,如果为数值,则为px单位 (默认 '300' )
|
|
79
|
+
* @property {String | Number} height 高度,单位任意,如果为数值,则为px单位 (默认 '225' )
|
|
80
|
+
* @property {String} shape 图片形状,circle-圆形,square-方形 (默认 'square' )
|
|
81
|
+
* @property {String | Number} radius 圆角值,单位任意,如果为数值,则为px单位 (默认 0 )
|
|
82
|
+
* @property {Boolean} lazyLoad 是否懒加载,仅微信小程序、App、百度小程序、字节跳动小程序有效 (默认 true )
|
|
83
|
+
* @property {Boolean} showMenuByLongpress 是否开启长按图片显示识别小程序码菜单,仅微信小程序有效 (默认 true )
|
|
84
|
+
* @property {String} loadingIcon 加载中的图标,或者小图片 (默认 'photo' )
|
|
85
|
+
* @property {String} errorIcon 加载失败的图标,或者小图片 (默认 'error-circle' )
|
|
86
|
+
* @property {Boolean} showLoading 是否显示加载中的图标或者自定义的slot (默认 true )
|
|
87
|
+
* @property {Boolean} showError 是否显示加载错误的图标或者自定义的slot (默认 true )
|
|
88
|
+
* @property {Boolean} fade 是否需要淡入效果 (默认 true )
|
|
89
|
+
* @property {Boolean} webp 只支持网络资源,只对微信小程序有效 (默认 false )
|
|
90
|
+
* @property {String | Number} duration 搭配fade参数的过渡时间,单位ms (默认 500 )
|
|
91
|
+
* @property {String} bgColor 背景颜色,用于深色页面加载图片时,为了和背景色融合 (默认 '#f3f4f6' )
|
|
92
|
+
* @property {Object} customStyle 定义需要用到的外部样式
|
|
93
|
+
* @property {Boolean} compress 是否压缩图片,默认true
|
|
94
|
+
* @event {Function} click 点击图片时触发
|
|
95
|
+
* @event {Function} error 图片加载失败时触发
|
|
96
|
+
* @event {Function} load 图片加载成功时触发
|
|
97
|
+
* @example <uv-image width="100%" height="300px" :src="src"></uv-image>
|
|
98
|
+
*/
|
|
99
|
+
export default {
|
|
100
|
+
name: 'uv-image',
|
|
101
|
+
emits: ['click','load','error'],
|
|
102
|
+
mixins: [mpMixin, mixin, props],
|
|
103
|
+
data() {
|
|
104
|
+
return {
|
|
105
|
+
// 图片是否加载错误,如果是,则显示错误占位图
|
|
106
|
+
isError: false,
|
|
107
|
+
// 初始化组件时,默认为加载中状态
|
|
108
|
+
loading: true,
|
|
109
|
+
// 图片加载完成时,去掉背景颜色,因为如果是png图片,就会显示灰色的背景
|
|
110
|
+
backgroundStyle: {},
|
|
111
|
+
// 用于fade模式的控制组件显示与否
|
|
112
|
+
show: false,
|
|
113
|
+
// 是否开启图片出现在可视范围进行加载(另一种懒加载)
|
|
114
|
+
observeShow: !this.observeLazyLoad,
|
|
115
|
+
elIndex: '',
|
|
116
|
+
// 因为props的值无法修改,故需要一个中间值
|
|
117
|
+
imgWidth: this.width,
|
|
118
|
+
// 因为props的值无法修改,故需要一个中间值
|
|
119
|
+
imgHeight: this.height,
|
|
120
|
+
thresholdValue: 50
|
|
121
|
+
};
|
|
122
|
+
},
|
|
123
|
+
watch: {
|
|
124
|
+
src: {
|
|
125
|
+
immediate: true,
|
|
126
|
+
handler(n) {
|
|
127
|
+
if (!n) {
|
|
128
|
+
// 如果传入null或者'',或者false,或者undefined,标记为错误状态
|
|
129
|
+
this.isError = true
|
|
130
|
+
} else {
|
|
131
|
+
this.isError = false;
|
|
132
|
+
this.loading = true;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
width(newVal){
|
|
137
|
+
// 这样做的目的是避免在更新时候,某些平台动画会恢复关闭状态
|
|
138
|
+
this.show = false;
|
|
139
|
+
this.$uv.sleep(2).then(res=>{
|
|
140
|
+
this.show = true;
|
|
141
|
+
});
|
|
142
|
+
this.imgWidth = newVal;
|
|
143
|
+
},
|
|
144
|
+
height(newVal){
|
|
145
|
+
// 这样做的目的是避免在更新时候,某些平台动画会恢复关闭状态
|
|
146
|
+
this.show = false;
|
|
147
|
+
this.$uv.sleep(2).then(res=>{
|
|
148
|
+
this.show = true;
|
|
149
|
+
});
|
|
150
|
+
this.imgHeight = newVal;
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
computed: {
|
|
154
|
+
wrapStyle() {
|
|
155
|
+
const style = {};
|
|
156
|
+
// 通过调用addUnit()方法,如果有单位,如百分比,px单位等,直接返回,如果是纯粹的数值,则加上rpx单位
|
|
157
|
+
if(this.mode !== 'heightFix') {
|
|
158
|
+
style.width = this.$uv.addUnit(this.imgWidth);
|
|
159
|
+
}
|
|
160
|
+
if(this.mode !== 'widthFix') {
|
|
161
|
+
style.height = this.$uv.addUnit(this.imgHeight);
|
|
162
|
+
}
|
|
163
|
+
// 如果是显示圆形,设置一个很多的半径值即可
|
|
164
|
+
style.borderRadius = this.shape == 'circle' ? '10000px' : this.$uv.addUnit(this.radius)
|
|
165
|
+
// 如果设置圆角,必须要有hidden,否则可能圆角无效
|
|
166
|
+
style.overflow = 'hidden';
|
|
167
|
+
return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle));
|
|
168
|
+
},
|
|
169
|
+
viewStyle({ wrapStyle }) {
|
|
170
|
+
const { width, height } = wrapStyle;
|
|
171
|
+
return {
|
|
172
|
+
width,
|
|
173
|
+
height,
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
imageStyle({ imgWidth, imgHeight }) {
|
|
177
|
+
return {
|
|
178
|
+
width: this.$uv.addUnit(imgWidth),
|
|
179
|
+
height: this.$uv.addUnit(imgHeight),
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
imageUrl({ src, imageStyle, compress }) {
|
|
183
|
+
return compress && uni.$uv.compress ? uni.$uv.compress.image(src, imageStyle) : src;
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
created() {
|
|
187
|
+
this.elIndex = this.$uv.guid();
|
|
188
|
+
this.observer = {}
|
|
189
|
+
this.observerName = 'lazyLoadContentObserver'
|
|
190
|
+
},
|
|
191
|
+
mounted() {
|
|
192
|
+
this.show = true;
|
|
193
|
+
this.$nextTick(()=>{
|
|
194
|
+
if(this.observeLazyLoad) this.observerFn();
|
|
195
|
+
})
|
|
196
|
+
},
|
|
197
|
+
methods: {
|
|
198
|
+
// 点击图片
|
|
199
|
+
onClick() {
|
|
200
|
+
this.$emit('click')
|
|
201
|
+
},
|
|
202
|
+
// 图片加载失败
|
|
203
|
+
onErrorHandler(err) {
|
|
204
|
+
this.loading = false
|
|
205
|
+
this.isError = true
|
|
206
|
+
this.$emit('error', err)
|
|
207
|
+
},
|
|
208
|
+
// 图片加载完成,标记loading结束
|
|
209
|
+
onLoadHandler(event) {
|
|
210
|
+
if(this.mode == 'widthFix') this.imgHeight = 'auto'
|
|
211
|
+
if(this.mode == 'heightFix') this.imgWidth = 'auto'
|
|
212
|
+
this.loading = false
|
|
213
|
+
this.isError = false
|
|
214
|
+
this.$emit('load', event)
|
|
215
|
+
this.removeBgColor()
|
|
216
|
+
},
|
|
217
|
+
// 移除图片的背景色
|
|
218
|
+
removeBgColor() {
|
|
219
|
+
// 淡入动画过渡完成后,将背景设置为透明色,否则png图片会看到灰色的背景
|
|
220
|
+
this.backgroundStyle = {
|
|
221
|
+
backgroundColor: 'transparent'
|
|
222
|
+
};
|
|
223
|
+
},
|
|
224
|
+
// 观察图片是否在可见视口
|
|
225
|
+
observerFn(){
|
|
226
|
+
// 在需要用到懒加载的页面,在触发底部的时候触发tOnLazyLoadReachBottom事件,保证所有图片进行加载
|
|
227
|
+
this.$nextTick(() => {
|
|
228
|
+
uni.$once('onLazyLoadReachBottom', () => {
|
|
229
|
+
if (!this.observeShow) this.observeShow = true
|
|
230
|
+
})
|
|
231
|
+
})
|
|
232
|
+
setTimeout(() => {
|
|
233
|
+
// #ifndef APP-NVUE
|
|
234
|
+
this.disconnectObserver(this.observerName)
|
|
235
|
+
const contentObserver = uni.createIntersectionObserver(this)
|
|
236
|
+
contentObserver.relativeToViewport({
|
|
237
|
+
bottom: this.thresholdValue
|
|
238
|
+
}).observe(`.uv-image--${this.elIndex}`, (res) => {
|
|
239
|
+
if (res.intersectionRatio > 0) {
|
|
240
|
+
// 懒加载状态改变
|
|
241
|
+
this.observeShow = true
|
|
242
|
+
// 如果图片已经加载,去掉监听,减少性能消耗
|
|
243
|
+
this.disconnectObserver(this.observerName)
|
|
244
|
+
}
|
|
245
|
+
})
|
|
246
|
+
this[this.observerName] = contentObserver
|
|
247
|
+
// #endif
|
|
248
|
+
// #ifdef APP-NVUE
|
|
249
|
+
this.observeShow = true;
|
|
250
|
+
// #endif
|
|
251
|
+
}, 50)
|
|
252
|
+
},
|
|
253
|
+
disconnectObserver(observerName) {
|
|
254
|
+
const observer = this[observerName]
|
|
255
|
+
observer && observer.disconnect()
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
</script>
|
|
260
|
+
|
|
261
|
+
<style lang="scss" scoped>
|
|
262
|
+
@import '../../libs/css/components.scss';
|
|
263
|
+
@import '../../libs/css/color.scss';
|
|
264
|
+
$uv-image-error-top:0px !default;
|
|
265
|
+
$uv-image-error-left:0px !default;
|
|
266
|
+
$uv-image-error-width:100% !default;
|
|
267
|
+
$uv-image-error-hight:100% !default;
|
|
268
|
+
$uv-image-error-background-color:$uv-bg-color !default;
|
|
269
|
+
$uv-image-error-color:$uv-tips-color !default;
|
|
270
|
+
$uv-image-error-font-size: 46rpx !default;
|
|
271
|
+
|
|
272
|
+
.uv-image {
|
|
273
|
+
position: relative;
|
|
274
|
+
transition: opacity 0.5s ease-in-out;
|
|
275
|
+
|
|
276
|
+
&__image {
|
|
277
|
+
width: 100%;
|
|
278
|
+
height: 100%;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
&__loading,
|
|
282
|
+
&__error {
|
|
283
|
+
position: absolute;
|
|
284
|
+
top: $uv-image-error-top;
|
|
285
|
+
left: $uv-image-error-left;
|
|
286
|
+
width: $uv-image-error-width;
|
|
287
|
+
height: $uv-image-error-hight;
|
|
288
|
+
@include flex;
|
|
289
|
+
align-items: center;
|
|
290
|
+
justify-content: center;
|
|
291
|
+
background-color: $uv-image-error-background-color;
|
|
292
|
+
color: $uv-image-error-color;
|
|
293
|
+
font-size: $uv-image-error-font-size;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
</style>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
// 列表锚点文本内容
|
|
4
|
+
text: {
|
|
5
|
+
type: [String, Number],
|
|
6
|
+
default: ''
|
|
7
|
+
},
|
|
8
|
+
// 列表锚点文字颜色
|
|
9
|
+
color: {
|
|
10
|
+
type: String,
|
|
11
|
+
default: '#606266'
|
|
12
|
+
},
|
|
13
|
+
// 列表锚点文字大小,单位默认px
|
|
14
|
+
size: {
|
|
15
|
+
type: [String, Number],
|
|
16
|
+
default: 14
|
|
17
|
+
},
|
|
18
|
+
// 列表锚点背景颜色
|
|
19
|
+
bgColor: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: '#dedede'
|
|
22
|
+
},
|
|
23
|
+
// 列表锚点高度,单位默认px
|
|
24
|
+
height: {
|
|
25
|
+
type: [String, Number],
|
|
26
|
+
default: 32
|
|
27
|
+
},
|
|
28
|
+
...uni.$uv?.props?.indexAnchor
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- #ifdef APP-NVUE -->
|
|
3
|
+
<header>
|
|
4
|
+
<!-- #endif -->
|
|
5
|
+
<view
|
|
6
|
+
:class="['uv-index-anchor',{'uv-index-anchor-sticky': parentData.sticky}]"
|
|
7
|
+
:ref="`uv-index-anchor-${text}`"
|
|
8
|
+
:style="{
|
|
9
|
+
height: $uv.addUnit(height),
|
|
10
|
+
backgroundColor: bgColor
|
|
11
|
+
}"
|
|
12
|
+
>
|
|
13
|
+
<text
|
|
14
|
+
class="uv-index-anchor__text"
|
|
15
|
+
:style="{
|
|
16
|
+
fontSize: $uv.addUnit(size),
|
|
17
|
+
color: color
|
|
18
|
+
}"
|
|
19
|
+
>{{ text }}</text>
|
|
20
|
+
</view>
|
|
21
|
+
<!-- #ifdef APP-NVUE -->
|
|
22
|
+
</header>
|
|
23
|
+
<!-- #endif -->
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script>
|
|
27
|
+
import mpMixin from '../../libs/mixin/mpMixin.js'
|
|
28
|
+
import mixin from '../../libs/mixin/mixin.js'
|
|
29
|
+
import props from './props.js';
|
|
30
|
+
// #ifdef APP-NVUE
|
|
31
|
+
const dom = uni.requireNativePlugin('dom')
|
|
32
|
+
// #endif
|
|
33
|
+
/**
|
|
34
|
+
* IndexAnchor 列表锚点
|
|
35
|
+
* @description
|
|
36
|
+
* @tutorial https://www.uvui.cn/components/indexList.html
|
|
37
|
+
* @property {String | Number} text 列表锚点文本内容
|
|
38
|
+
* @property {String} color 列表锚点文字颜色 ( 默认 '#606266' )
|
|
39
|
+
* @property {String | Number} size 列表锚点文字大小,单位默认px ( 默认 14 )
|
|
40
|
+
* @property {String} bgColor 列表锚点背景颜色 ( 默认 '#dedede' )
|
|
41
|
+
* @property {String | Number} height 列表锚点高度,单位默认px ( 默认 32 )
|
|
42
|
+
* @example <uv-index-anchor :text="indexList[index]"></uv-index-anchor>
|
|
43
|
+
*/
|
|
44
|
+
export default {
|
|
45
|
+
name: 'uv-index-anchor',
|
|
46
|
+
mixins: [mpMixin, mixin, props],
|
|
47
|
+
data() {
|
|
48
|
+
return {
|
|
49
|
+
parentData: {
|
|
50
|
+
sticky: true
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
created() {
|
|
55
|
+
this.init()
|
|
56
|
+
},
|
|
57
|
+
methods: {
|
|
58
|
+
init() {
|
|
59
|
+
// 此处会活动父组件实例,并赋值给实例的parent属性
|
|
60
|
+
const indexList = this.$uv.$parent.call(this, 'uv-index-list')
|
|
61
|
+
if (!indexList) {
|
|
62
|
+
return this.$uv.error('uv-index-anchor必须要搭配uv-index-list组件使用')
|
|
63
|
+
}
|
|
64
|
+
this.parentData.sticky = indexList.sticky;
|
|
65
|
+
// 将当前实例放入到uv-index-list中
|
|
66
|
+
indexList.anchors.push(this)
|
|
67
|
+
const indexListItem = this.$uv.$parent.call(this, 'uv-index-item')
|
|
68
|
+
// #ifndef APP-NVUE
|
|
69
|
+
// 只有在非nvue下,uv-index-anchor才是嵌套在uv-index-item中的
|
|
70
|
+
if (!indexListItem) {
|
|
71
|
+
return this.$uv.error('uv-index-anchor必须要搭配uv-index-item组件使用')
|
|
72
|
+
}
|
|
73
|
+
// 设置uv-index-item的id为anchor的text标识符,因为非nvue下滚动列表需要依赖scroll-view滚动到元素的特性
|
|
74
|
+
indexListItem.id = this.text.charCodeAt(0)
|
|
75
|
+
// #endif
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
}
|
|
79
|
+
</script>
|
|
80
|
+
|
|
81
|
+
<style lang="scss" scoped>
|
|
82
|
+
@import '../../libs/css/components.scss';
|
|
83
|
+
|
|
84
|
+
.uv-index-anchor {
|
|
85
|
+
@include flex;
|
|
86
|
+
align-items: center;
|
|
87
|
+
padding-left: 15px;
|
|
88
|
+
z-index: 1;
|
|
89
|
+
&-sticky {
|
|
90
|
+
position: sticky;
|
|
91
|
+
top: 0;
|
|
92
|
+
}
|
|
93
|
+
&__text {
|
|
94
|
+
@include flex;
|
|
95
|
+
align-items: center;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
</style>
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- #ifdef APP-NVUE -->
|
|
3
|
+
<cell ref="uv-index-item">
|
|
4
|
+
<!-- #endif -->
|
|
5
|
+
<view
|
|
6
|
+
class="uv-index-item"
|
|
7
|
+
:id="`uv-index-item-${id}`"
|
|
8
|
+
:class="[`uv-index-item-${id}`]"
|
|
9
|
+
>
|
|
10
|
+
<slot />
|
|
11
|
+
</view>
|
|
12
|
+
<!-- #ifdef APP-NVUE -->
|
|
13
|
+
</cell>
|
|
14
|
+
<!-- #endif -->
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script>
|
|
18
|
+
import mpMixin from '../../libs/mixin/mpMixin.js'
|
|
19
|
+
import mixin from '../../libs/mixin/mixin.js'
|
|
20
|
+
// #ifdef APP-NVUE
|
|
21
|
+
// 由于weex为阿里的KPI业绩考核的产物,所以不支持百分比单位,这里需要通过dom查询组件的宽度
|
|
22
|
+
const dom = uni.requireNativePlugin('dom')
|
|
23
|
+
// #endif
|
|
24
|
+
/**
|
|
25
|
+
* IndexItem
|
|
26
|
+
* @description
|
|
27
|
+
* @tutorial https://www.uvui.cn/components/indexList.html
|
|
28
|
+
* @property {String}
|
|
29
|
+
* @event {Function}
|
|
30
|
+
* @example
|
|
31
|
+
*/
|
|
32
|
+
export default {
|
|
33
|
+
name: 'uv-index-item',
|
|
34
|
+
mixins: [mpMixin, mixin],
|
|
35
|
+
data() {
|
|
36
|
+
return {
|
|
37
|
+
// 本组件到滚动条顶部的距离
|
|
38
|
+
top: 0,
|
|
39
|
+
height: 0,
|
|
40
|
+
id: ''
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
created() {
|
|
44
|
+
// 子组件uv-index-anchor的实例
|
|
45
|
+
this.anchor = {}
|
|
46
|
+
},
|
|
47
|
+
mounted() {
|
|
48
|
+
this.init()
|
|
49
|
+
},
|
|
50
|
+
methods: {
|
|
51
|
+
init() {
|
|
52
|
+
// 此处会活动父组件实例,并赋值给实例的parent属性
|
|
53
|
+
this.getParentData('uv-index-list')
|
|
54
|
+
if (!this.parent) {
|
|
55
|
+
return this.$uv.error('uv-index-item必须要搭配uv-index-list组件使用')
|
|
56
|
+
}
|
|
57
|
+
this.$uv.sleep().then(() =>{
|
|
58
|
+
this.getIndexItemRect().then(size => {
|
|
59
|
+
// 由于对象的引用特性,此处会同时生效到父组件的children数组的本实例的top属性中,供父组件判断读取
|
|
60
|
+
this.top = Math.ceil(size.top)
|
|
61
|
+
this.height = Math.ceil(size.height)
|
|
62
|
+
})
|
|
63
|
+
})
|
|
64
|
+
},
|
|
65
|
+
getIndexItemRect() {
|
|
66
|
+
return new Promise(resolve => {
|
|
67
|
+
// #ifndef APP-NVUE
|
|
68
|
+
this.$uvGetRect('.uv-index-item').then(size => {
|
|
69
|
+
resolve(size)
|
|
70
|
+
})
|
|
71
|
+
// #endif
|
|
72
|
+
|
|
73
|
+
// #ifdef APP-NVUE
|
|
74
|
+
const ref = this.$refs['uv-index-item']
|
|
75
|
+
dom.getComponentRect(ref, res => {
|
|
76
|
+
resolve(res.size)
|
|
77
|
+
})
|
|
78
|
+
// #endif
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
}
|
|
83
|
+
</script>
|
|
84
|
+
|
|
85
|
+
<style lang="scss" scoped>
|
|
86
|
+
@import '../../libs/css/components.scss';
|
|
87
|
+
</style>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
// 右边锚点非激活的颜色
|
|
4
|
+
inactiveColor: {
|
|
5
|
+
type: String,
|
|
6
|
+
default: '#606266'
|
|
7
|
+
},
|
|
8
|
+
// 右边锚点激活的颜色
|
|
9
|
+
activeColor: {
|
|
10
|
+
type: String,
|
|
11
|
+
default: '#5677fc'
|
|
12
|
+
},
|
|
13
|
+
// 索引字符列表,数组形式
|
|
14
|
+
indexList: {
|
|
15
|
+
type: Array,
|
|
16
|
+
default: () => []
|
|
17
|
+
},
|
|
18
|
+
// 是否开启锚点自动吸顶
|
|
19
|
+
sticky: {
|
|
20
|
+
type: Boolean,
|
|
21
|
+
default: true
|
|
22
|
+
},
|
|
23
|
+
// 自定义导航栏的高度
|
|
24
|
+
customNavHeight: {
|
|
25
|
+
type: [String, Number],
|
|
26
|
+
default: 0
|
|
27
|
+
},
|
|
28
|
+
...uni.$uv?.props?.indexList
|
|
29
|
+
}
|
|
30
|
+
}
|