uview-ui-wjf 1.0.0
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/LICENSE +21 -0
- package/README.md +71 -0
- package/changelog.md +388 -0
- package/components/u--form/u--form.vue +92 -0
- package/components/u--image/u--image.vue +73 -0
- package/components/u--input/u--input.vue +115 -0
- package/components/u--text/u--text.vue +72 -0
- package/components/u--textarea/u--textarea.vue +85 -0
- package/components/u-action-sheet/props.js +54 -0
- package/components/u-action-sheet/u-action-sheet.vue +278 -0
- package/components/u-album/props.js +59 -0
- package/components/u-album/u-album.vue +259 -0
- package/components/u-alert/props.js +44 -0
- package/components/u-alert/u-alert.vue +243 -0
- package/components/u-avatar/props.js +78 -0
- package/components/u-avatar/u-avatar.vue +173 -0
- package/components/u-avatar-group/props.js +52 -0
- package/components/u-avatar-group/u-avatar-group.vue +103 -0
- package/components/u-back-top/props.js +54 -0
- package/components/u-back-top/u-back-top.vue +129 -0
- package/components/u-badge/props.js +72 -0
- package/components/u-badge/u-badge.vue +171 -0
- package/components/u-button/nvue.scss +46 -0
- package/components/u-button/props.js +161 -0
- package/components/u-button/u-button.vue +495 -0
- package/components/u-button/vue.scss +80 -0
- package/components/u-calendar/header.vue +99 -0
- package/components/u-calendar/month.vue +579 -0
- package/components/u-calendar/props.js +144 -0
- package/components/u-calendar/u-calendar.vue +384 -0
- package/components/u-calendar/util.js +85 -0
- package/components/u-car-keyboard/props.js +14 -0
- package/components/u-car-keyboard/u-car-keyboard.vue +311 -0
- package/components/u-cell/props.js +110 -0
- package/components/u-cell/u-cell.vue +229 -0
- package/components/u-cell-group/props.js +14 -0
- package/components/u-cell-group/u-cell-group.vue +61 -0
- package/components/u-checkbox/props.js +69 -0
- package/components/u-checkbox/u-checkbox.vue +344 -0
- package/components/u-checkbox-group/props.js +82 -0
- package/components/u-checkbox-group/u-checkbox-group.vue +103 -0
- package/components/u-circle-progress/props.js +8 -0
- package/components/u-circle-progress/u-circle-progress.vue +198 -0
- package/components/u-code/props.js +34 -0
- package/components/u-code/u-code.vue +129 -0
- package/components/u-code-input/props.js +79 -0
- package/components/u-code-input/u-code-input.vue +252 -0
- package/components/u-col/props.js +29 -0
- package/components/u-col/u-col.vue +162 -0
- package/components/u-collapse/props.js +19 -0
- package/components/u-collapse/u-collapse.vue +90 -0
- package/components/u-collapse-item/props.js +59 -0
- package/components/u-collapse-item/u-collapse-item.vue +225 -0
- package/components/u-column-notice/props.js +55 -0
- package/components/u-column-notice/u-column-notice.vue +160 -0
- package/components/u-count-down/props.js +24 -0
- package/components/u-count-down/u-count-down.vue +163 -0
- package/components/u-count-down/utils.js +62 -0
- package/components/u-count-to/props.js +59 -0
- package/components/u-count-to/u-count-to.vue +184 -0
- package/components/u-datetime-picker/props.js +120 -0
- package/components/u-datetime-picker/u-datetime-picker.vue +361 -0
- package/components/u-divider/props.js +44 -0
- package/components/u-divider/u-divider.vue +116 -0
- package/components/u-dropdown/props.js +65 -0
- package/components/u-dropdown/u-dropdown.vue +127 -0
- package/components/u-dropdown-item/props.js +36 -0
- package/components/u-dropdown-item/u-dropdown-item.vue +127 -0
- package/components/u-empty/props.js +59 -0
- package/components/u-empty/u-empty.vue +128 -0
- package/components/u-form/props.js +45 -0
- package/components/u-form/u-form.vue +214 -0
- package/components/u-form-item/props.js +48 -0
- package/components/u-form-item/u-form-item.vue +235 -0
- package/components/u-gap/props.js +24 -0
- package/components/u-gap/u-gap.vue +38 -0
- package/components/u-grid/props.js +19 -0
- package/components/u-grid/u-grid.vue +97 -0
- package/components/u-grid-item/props.js +14 -0
- package/components/u-grid-item/u-grid-item.vue +209 -0
- package/components/u-icon/icons.js +214 -0
- package/components/u-icon/props.js +89 -0
- package/components/u-icon/u-icon.vue +237 -0
- package/components/u-image/props.js +84 -0
- package/components/u-image/u-image.vue +232 -0
- package/components/u-index-anchor/props.js +29 -0
- package/components/u-index-anchor/u-index-anchor.vue +91 -0
- package/components/u-index-item/props.js +5 -0
- package/components/u-index-item/u-index-item.vue +87 -0
- package/components/u-index-list/props.js +29 -0
- package/components/u-index-list/u-index-list.vue +440 -0
- package/components/u-input/props.js +187 -0
- package/components/u-input/u-input.vue +369 -0
- package/components/u-keyboard/props.js +84 -0
- package/components/u-keyboard/u-keyboard.vue +164 -0
- package/components/u-line/props.js +33 -0
- package/components/u-line/u-line.vue +62 -0
- package/components/u-line-progress/props.js +28 -0
- package/components/u-line-progress/u-line-progress.vue +144 -0
- package/components/u-link/props.js +39 -0
- package/components/u-link/u-link.vue +83 -0
- package/components/u-list/props.js +76 -0
- package/components/u-list/u-list.vue +157 -0
- package/components/u-list-item/props.js +9 -0
- package/components/u-list-item/u-list-item.vue +116 -0
- package/components/u-loading-icon/props.js +59 -0
- package/components/u-loading-icon/u-loading-icon.vue +343 -0
- package/components/u-loading-page/props.js +49 -0
- package/components/u-loading-page/u-loading-page.vue +115 -0
- package/components/u-loadmore/props.js +94 -0
- package/components/u-loadmore/u-loadmore.vue +150 -0
- package/components/u-modal/props.js +89 -0
- package/components/u-modal/u-modal.vue +228 -0
- package/components/u-navbar/props.js +84 -0
- package/components/u-navbar/u-navbar.vue +186 -0
- package/components/u-no-network/props.js +19 -0
- package/components/u-no-network/u-no-network.vue +220 -0
- package/components/u-notice-bar/props.js +70 -0
- package/components/u-notice-bar/u-notice-bar.vue +101 -0
- package/components/u-notify/props.js +49 -0
- package/components/u-notify/u-notify.vue +211 -0
- package/components/u-number-box/props.js +109 -0
- package/components/u-number-box/u-number-box.vue +416 -0
- package/components/u-number-keyboard/props.js +19 -0
- package/components/u-number-keyboard/u-number-keyboard.vue +196 -0
- package/components/u-overlay/props.js +24 -0
- package/components/u-overlay/u-overlay.vue +68 -0
- package/components/u-parse/node/node.vue +499 -0
- package/components/u-parse/parser.js +1075 -0
- package/components/u-parse/props.js +45 -0
- package/components/u-parse/u-parse.vue +366 -0
- package/components/u-picker/props.js +79 -0
- package/components/u-picker/u-picker.vue +286 -0
- package/components/u-picker-column/props.js +5 -0
- package/components/u-picker-column/u-picker-column.vue +27 -0
- package/components/u-popup/props.js +79 -0
- package/components/u-popup/u-popup.vue +304 -0
- package/components/u-radio/props.js +64 -0
- package/components/u-radio/u-radio.vue +339 -0
- package/components/u-radio-group/props.js +85 -0
- package/components/u-radio-group/u-radio-group.vue +108 -0
- package/components/u-rate/props.js +69 -0
- package/components/u-rate/u-rate.vue +306 -0
- package/components/u-read-more/props.js +61 -0
- package/components/u-read-more/u-read-more.vue +157 -0
- package/components/u-row/props.js +19 -0
- package/components/u-row/u-row.vue +93 -0
- package/components/u-row-notice/props.js +39 -0
- package/components/u-row-notice/u-row-notice.vue +330 -0
- package/components/u-safe-bottom/props.js +5 -0
- package/components/u-safe-bottom/u-safe-bottom.vue +56 -0
- package/components/u-scroll-list/nvue.js +28 -0
- package/components/u-scroll-list/other.js +0 -0
- package/components/u-scroll-list/props.js +34 -0
- package/components/u-scroll-list/scrollWxs.wxs +50 -0
- package/components/u-scroll-list/u-scroll-list.vue +224 -0
- package/components/u-search/props.js +118 -0
- package/components/u-search/u-search.vue +303 -0
- package/components/u-skeleton/props.js +59 -0
- package/components/u-skeleton/u-skeleton.vue +244 -0
- package/components/u-slider/mpother.js +113 -0
- package/components/u-slider/mpwxs.js +42 -0
- package/components/u-slider/mpwxs.wxs +121 -0
- package/components/u-slider/nvue - /345/211/257/346/234/254.js" +180 -0
- package/components/u-slider/nvue.js +193 -0
- package/components/u-slider/props.js +54 -0
- package/components/u-slider/u-slider.vue +55 -0
- package/components/u-status-bar/props.js +8 -0
- package/components/u-status-bar/u-status-bar.vue +46 -0
- package/components/u-steps/props.js +39 -0
- package/components/u-steps/u-steps.vue +80 -0
- package/components/u-steps-item/props.js +24 -0
- package/components/u-steps-item/u-steps-item.vue +316 -0
- package/components/u-sticky/props.js +40 -0
- package/components/u-sticky/u-sticky.vue +212 -0
- package/components/u-subsection/props.js +49 -0
- package/components/u-subsection/u-subsection.vue +299 -0
- package/components/u-swipe-action/props.js +9 -0
- package/components/u-swipe-action/u-swipe-action.vue +67 -0
- package/components/u-swipe-action-item/index - backup.wxs +256 -0
- package/components/u-swipe-action-item/index.wxs +225 -0
- package/components/u-swipe-action-item/nvue - backup.js +270 -0
- package/components/u-swipe-action-item/nvue.js +174 -0
- package/components/u-swipe-action-item/props.js +41 -0
- package/components/u-swipe-action-item/u-swipe-action-item.vue +190 -0
- package/components/u-swipe-action-item/wxs.js +15 -0
- package/components/u-swiper/props.js +125 -0
- package/components/u-swiper/u-swiper.vue +255 -0
- package/components/u-swiper-indicator/props.js +29 -0
- package/components/u-swiper-indicator/u-swiper-indicator.vue +110 -0
- package/components/u-switch/props.js +54 -0
- package/components/u-switch/u-switch.vue +177 -0
- package/components/u-tabbar/props.js +44 -0
- package/components/u-tabbar/u-tabbar.vue +141 -0
- package/components/u-tabbar-item/props.js +35 -0
- package/components/u-tabbar-item/u-tabbar-item.vue +142 -0
- package/components/u-table/props.js +5 -0
- package/components/u-table/u-table.vue +29 -0
- package/components/u-tabs/props.js +64 -0
- package/components/u-tabs/u-tabs.vue +363 -0
- package/components/u-tabs-item/props.js +5 -0
- package/components/u-tabs-item/u-tabs-item.vue +29 -0
- package/components/u-tag/props.js +84 -0
- package/components/u-tag/u-tag.vue +358 -0
- package/components/u-td/props.js +5 -0
- package/components/u-td/u-td.vue +31 -0
- package/components/u-text/props.js +110 -0
- package/components/u-text/u-text.vue +223 -0
- package/components/u-text/value.js +85 -0
- package/components/u-textarea/props.js +119 -0
- package/components/u-textarea/u-textarea.vue +239 -0
- package/components/u-toast/u-toast.vue +291 -0
- package/components/u-toolbar/props.js +34 -0
- package/components/u-toolbar/u-toolbar.vue +102 -0
- package/components/u-tooltip/clipboard.min.js +58 -0
- package/components/u-tooltip/props.js +59 -0
- package/components/u-tooltip/u-tooltip.vue +366 -0
- package/components/u-tr/props.js +5 -0
- package/components/u-tr/u-tr.vue +31 -0
- package/components/u-transition/nvue.ani-map.js +68 -0
- package/components/u-transition/props.js +24 -0
- package/components/u-transition/transition.js +157 -0
- package/components/u-transition/u-transition.vue +92 -0
- package/components/u-transition/vue.ani-style.scss +113 -0
- package/components/u-upload/mixin.js +21 -0
- package/components/u-upload/props.js +124 -0
- package/components/u-upload/u-upload.vue +566 -0
- package/components/u-upload/utils.js +151 -0
- package/components/uview-ui/uview-ui.vue +15 -0
- package/index.js +79 -0
- package/index.scss +23 -0
- package/libs/config/color.js +17 -0
- package/libs/config/config.js +34 -0
- package/libs/config/props/actionSheet.js +25 -0
- package/libs/config/props/album.js +25 -0
- package/libs/config/props/alert.js +22 -0
- package/libs/config/props/avatar.js +28 -0
- package/libs/config/props/avatarGroup.js +23 -0
- package/libs/config/props/backtop.js +27 -0
- package/libs/config/props/badge.js +27 -0
- package/libs/config/props/button.js +42 -0
- package/libs/config/props/calendar.js +42 -0
- package/libs/config/props/carKeyboard.js +15 -0
- package/libs/config/props/cell.js +35 -0
- package/libs/config/props/cellGroup.js +17 -0
- package/libs/config/props/checkbox.js +27 -0
- package/libs/config/props/checkboxGroup.js +29 -0
- package/libs/config/props/circleProgress.js +15 -0
- package/libs/config/props/code.js +21 -0
- package/libs/config/props/codeInput.js +29 -0
- package/libs/config/props/col.js +19 -0
- package/libs/config/props/collapse.js +17 -0
- package/libs/config/props/collapseItem.js +25 -0
- package/libs/config/props/columnNotice.js +24 -0
- package/libs/config/props/countDown.js +18 -0
- package/libs/config/props/countTo.js +25 -0
- package/libs/config/props/datetimePicker.js +37 -0
- package/libs/config/props/divider.js +23 -0
- package/libs/config/props/empty.js +26 -0
- package/libs/config/props/form.js +22 -0
- package/libs/config/props/formItem.js +23 -0
- package/libs/config/props/gap.js +19 -0
- package/libs/config/props/grid.js +17 -0
- package/libs/config/props/gridItem.js +16 -0
- package/libs/config/props/icon.js +36 -0
- package/libs/config/props/image.js +30 -0
- package/libs/config/props/indexAnchor.js +19 -0
- package/libs/config/props/indexList.js +19 -0
- package/libs/config/props/input.js +48 -0
- package/libs/config/props/keyboard.js +30 -0
- package/libs/config/props/line.js +20 -0
- package/libs/config/props/lineProgress.js +19 -0
- package/libs/config/props/link.js +26 -0
- package/libs/config/props/list.js +28 -0
- package/libs/config/props/listItem.js +15 -0
- package/libs/config/props/loadingIcon.js +30 -0
- package/libs/config/props/loadingPage.js +23 -0
- package/libs/config/props/loadmore.js +32 -0
- package/libs/config/props/modal.js +31 -0
- package/libs/config/props/navbar.js +32 -0
- package/libs/config/props/noNetwork.js +18 -0
- package/libs/config/props/noticeBar.js +27 -0
- package/libs/config/props/notify.js +22 -0
- package/libs/config/props/numberBox.js +35 -0
- package/libs/config/props/numberKeyboard.js +17 -0
- package/libs/config/props/overlay.js +18 -0
- package/libs/config/props/parse.js +22 -0
- package/libs/config/props/picker.js +29 -0
- package/libs/config/props/popup.js +29 -0
- package/libs/config/props/radio.js +27 -0
- package/libs/config/props/radioGroup.js +30 -0
- package/libs/config/props/rate.js +26 -0
- package/libs/config/props/readMore.js +22 -0
- package/libs/config/props/row.js +17 -0
- package/libs/config/props/rowNotice.js +21 -0
- package/libs/config/props/scrollList.js +20 -0
- package/libs/config/props/search.js +37 -0
- package/libs/config/props/section.js +24 -0
- package/libs/config/props/skeleton.js +25 -0
- package/libs/config/props/slider.js +25 -0
- package/libs/config/props/statusBar.js +15 -0
- package/libs/config/props/steps.js +21 -0
- package/libs/config/props/stepsItem.js +18 -0
- package/libs/config/props/sticky.js +20 -0
- package/libs/config/props/subsection.js +23 -0
- package/libs/config/props/swipeAction.js +15 -0
- package/libs/config/props/swipeActionItem.js +21 -0
- package/libs/config/props/swiper.js +39 -0
- package/libs/config/props/swipterIndicator.js +19 -0
- package/libs/config/props/switch.js +24 -0
- package/libs/config/props/tabbar.js +22 -0
- package/libs/config/props/tabbarItem.js +20 -0
- package/libs/config/props/tabs.js +32 -0
- package/libs/config/props/tag.js +29 -0
- package/libs/config/props/text.js +38 -0
- package/libs/config/props/textarea.js +36 -0
- package/libs/config/props/toast.js +30 -0
- package/libs/config/props/toolbar.js +21 -0
- package/libs/config/props/tooltip.js +25 -0
- package/libs/config/props/transition.js +18 -0
- package/libs/config/props/upload.js +36 -0
- package/libs/config/props.js +190 -0
- package/libs/config/zIndex.js +20 -0
- package/libs/css/color.scss +155 -0
- package/libs/css/common.scss +97 -0
- package/libs/css/components.scss +15 -0
- package/libs/css/flex.scss +257 -0
- package/libs/css/h5.scss +0 -0
- package/libs/css/mixin.scss +8 -0
- package/libs/css/mp.scss +0 -0
- package/libs/css/nvue.scss +0 -0
- package/libs/css/vue.scss +27 -0
- package/libs/function/colorGradient.js +134 -0
- package/libs/function/debounce.js +29 -0
- package/libs/function/digit.js +167 -0
- package/libs/function/index.js +731 -0
- package/libs/function/platform.js +75 -0
- package/libs/function/test.js +288 -0
- package/libs/function/throttle.js +30 -0
- package/libs/luch-request/adapters/index.js +97 -0
- package/libs/luch-request/core/InterceptorManager.js +50 -0
- package/libs/luch-request/core/Request.js +198 -0
- package/libs/luch-request/core/buildFullPath.js +20 -0
- package/libs/luch-request/core/defaults.js +29 -0
- package/libs/luch-request/core/dispatchRequest.js +3 -0
- package/libs/luch-request/core/mergeConfig.js +103 -0
- package/libs/luch-request/core/settle.js +16 -0
- package/libs/luch-request/helpers/buildURL.js +69 -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 +116 -0
- package/libs/luch-request/index.js +3 -0
- package/libs/luch-request/utils/clone.js +264 -0
- package/libs/luch-request/utils.js +131 -0
- package/libs/mixin/button.js +13 -0
- package/libs/mixin/mixin.js +160 -0
- package/libs/mixin/mpMixin.js +8 -0
- package/libs/mixin/mpShare.js +13 -0
- package/libs/mixin/openType.js +25 -0
- package/libs/mixin/style.js +228 -0
- package/libs/mixin/touch.js +59 -0
- package/libs/util/async-validator.js +1343 -0
- package/libs/util/calendar.js +546 -0
- package/libs/util/dayjs.js +308 -0
- package/libs/util/emitter.js +51 -0
- package/libs/util/route.js +124 -0
- package/package.json +83 -0
- package/theme.scss +44 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="u-avatar"
|
|
4
|
+
:class="[`u-avatar--${shape}`]"
|
|
5
|
+
:style="[{
|
|
6
|
+
backgroundColor: (text || icon) ? (randomBgColor ? colors[colorIndex !== '' ? colorIndex : $u.random(0, 19)] : bgColor) : 'transparent',
|
|
7
|
+
width: $u.addUnit(size),
|
|
8
|
+
height: $u.addUnit(size),
|
|
9
|
+
}, $u.addStyle(customStyle)]"
|
|
10
|
+
@tap="clickHandler"
|
|
11
|
+
>
|
|
12
|
+
<slot>
|
|
13
|
+
<!-- #ifdef MP-WEIXIN || MP-QQ || MP-BAIDU -->
|
|
14
|
+
<open-data
|
|
15
|
+
v-if="mpAvatar && allowMp"
|
|
16
|
+
type="userAvatarUrl"
|
|
17
|
+
:style="[{
|
|
18
|
+
width: $u.addUnit(size),
|
|
19
|
+
height: $u.addUnit(size)
|
|
20
|
+
}]"
|
|
21
|
+
/>
|
|
22
|
+
<!-- #endif -->
|
|
23
|
+
<!-- #ifndef MP-WEIXIN && MP-QQ && MP-BAIDU -->
|
|
24
|
+
<template v-if="mpAvatar && allowMp"></template>
|
|
25
|
+
<!-- #endif -->
|
|
26
|
+
<u-icon
|
|
27
|
+
v-else-if="icon"
|
|
28
|
+
:name="icon"
|
|
29
|
+
:size="fontSize"
|
|
30
|
+
:color="color"
|
|
31
|
+
></u-icon>
|
|
32
|
+
<u--text
|
|
33
|
+
v-else-if="text"
|
|
34
|
+
:text="text"
|
|
35
|
+
:size="fontSize"
|
|
36
|
+
:color="color"
|
|
37
|
+
align="center"
|
|
38
|
+
customStyle="justify-content: center"
|
|
39
|
+
></u--text>
|
|
40
|
+
<image
|
|
41
|
+
class="u-avatar__image"
|
|
42
|
+
v-else
|
|
43
|
+
:class="[`u-avatar__image--${shape}`]"
|
|
44
|
+
:src="avatarUrl || defaultUrl"
|
|
45
|
+
:mode="mode"
|
|
46
|
+
@error="errorHandler"
|
|
47
|
+
:style="[{
|
|
48
|
+
width: $u.addUnit(size),
|
|
49
|
+
height: $u.addUnit(size)
|
|
50
|
+
}]"
|
|
51
|
+
></image>
|
|
52
|
+
</slot>
|
|
53
|
+
</view>
|
|
54
|
+
</template>
|
|
55
|
+
|
|
56
|
+
<script>
|
|
57
|
+
import props from './props.js';
|
|
58
|
+
const base64Avatar =
|
|
59
|
+
"data:image/jpg;base64,/9j/4QAYRXhpZgAASUkqAAgAAAAAAAAAAAAAAP/sABFEdWNreQABAAQAAAA8AAD/4QMraHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/PiA8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA1LjMtYzAxMSA2Ni4xNDU2NjEsIDIwMTIvMDIvMDYtMTQ6NTY6MjcgICAgICAgICI+IDxyZGY6UkRGIHhtbG5zOnJkZj0iaHR0cDovL3d3dy53My5vcmcvMTk5OS8wMi8yMi1yZGYtc3ludGF4LW5zIyI+IDxyZGY6RGVzY3JpcHRpb24gcmRmOmFib3V0PSIiIHhtbG5zOnhtcD0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLyIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bXA6Q3JlYXRvclRvb2w9IkFkb2JlIFBob3Rvc2hvcCBDUzYgKFdpbmRvd3MpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjREMEQwRkY0RjgwNDExRUE5OTY2RDgxODY3NkJFODMxIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjREMEQwRkY1RjgwNDExRUE5OTY2RDgxODY3NkJFODMxIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6NEQwRDBGRjJGODA0MTFFQTk5NjZEODE4Njc2QkU4MzEiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6NEQwRDBGRjNGODA0MTFFQTk5NjZEODE4Njc2QkU4MzEiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz7/7gAOQWRvYmUAZMAAAAAB/9sAhAAGBAQEBQQGBQUGCQYFBgkLCAYG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";
|
|
60
|
+
/**
|
|
61
|
+
* Avatar 头像
|
|
62
|
+
* @description 本组件一般用于展示头像的地方,如个人中心,或者评论列表页的用户头像展示等场所。
|
|
63
|
+
* @tutorial https://www.uviewui.com/components/avatar.html
|
|
64
|
+
*
|
|
65
|
+
* @property {String} src 头像路径,如加载失败,将会显示默认头像(不能为相对路径)
|
|
66
|
+
* @property {String} shape 头像形状 ( circle (默认) | square)
|
|
67
|
+
* @property {String | Number} size 头像尺寸,可以为指定字符串(large, default, mini),或者数值 (默认 40 )
|
|
68
|
+
* @property {String} mode 头像图片的裁剪类型,与uni的image组件的mode参数一致,如效果达不到需求,可尝试传widthFix值 (默认 'scaleToFill' )
|
|
69
|
+
* @property {String} text 用文字替代图片,级别优先于src
|
|
70
|
+
* @property {String} bgColor 背景颜色,一般显示文字时用 (默认 '#c0c4cc' )
|
|
71
|
+
* @property {String} color 文字颜色 (默认 '#ffffff' )
|
|
72
|
+
* @property {String | Number} fontSize 文字大小 (默认 18 )
|
|
73
|
+
* @property {String} icon 显示的图标
|
|
74
|
+
* @property {Boolean} mpAvatar 显示小程序头像,只对百度,微信,QQ小程序有效 (默认 false )
|
|
75
|
+
* @property {Boolean} randomBgColor 是否使用随机背景色 (默认 false )
|
|
76
|
+
* @property {String} defaultUrl 加载失败的默认头像(组件有内置默认图片)
|
|
77
|
+
* @property {String | Number} colorIndex 如果配置了randomBgColor为true,且配置了此值,则从默认的背景色数组中取出对应索引的颜色值,取值0-19之间
|
|
78
|
+
* @property {String} name 组件标识符 (默认 'level' )
|
|
79
|
+
* @property {Object} customStyle 定义需要用到的外部样式
|
|
80
|
+
*
|
|
81
|
+
* @event {Function} click 点击组件时触发 index: 用户传递的标识符
|
|
82
|
+
* @example <u-avatar :src="src" mode="square"></u-avatar>
|
|
83
|
+
*/
|
|
84
|
+
export default {
|
|
85
|
+
name: 'u-avatar',
|
|
86
|
+
mixins: [uni.$u.mpMixin, uni.$u.mixin, props],
|
|
87
|
+
data() {
|
|
88
|
+
return {
|
|
89
|
+
// 如果配置randomBgColor参数为true,在图标或者文字的模式下,会随机从中取出一个颜色值当做背景色
|
|
90
|
+
colors: ['#ffb34b', '#f2bba9', '#f7a196', '#f18080', '#88a867', '#bfbf39', '#89c152', '#94d554', '#f19ec2',
|
|
91
|
+
'#afaae4', '#e1b0df', '#c38cc1', '#72dcdc', '#9acdcb', '#77b1cc', '#448aca', '#86cefa', '#98d1ee',
|
|
92
|
+
'#73d1f1',
|
|
93
|
+
'#80a7dc'
|
|
94
|
+
],
|
|
95
|
+
avatarUrl: this.src,
|
|
96
|
+
allowMp: false
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
watch: {
|
|
100
|
+
// 监听头像src的变化,赋值给内部的avatarUrl变量,因为图片加载失败时,需要修改图片的src为默认值
|
|
101
|
+
// 而组件内部不能直接修改props的值,所以需要一个中间变量
|
|
102
|
+
src: {
|
|
103
|
+
immediate: true,
|
|
104
|
+
handler(newVal) {
|
|
105
|
+
this.avatarUrl = newVal
|
|
106
|
+
// 如果没有传src,则主动触发error事件,用于显示默认的头像,否则src为''空字符等的时候,会无内容展示
|
|
107
|
+
if(!newVal) {
|
|
108
|
+
this.errorHandler()
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
computed: {
|
|
114
|
+
imageStyle() {
|
|
115
|
+
const style = {}
|
|
116
|
+
return style
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
created() {
|
|
120
|
+
this.init()
|
|
121
|
+
},
|
|
122
|
+
methods: {
|
|
123
|
+
init() {
|
|
124
|
+
// 目前只有这几个小程序平台具有open-data标签
|
|
125
|
+
// 其他平台可以通过uni.getUserInfo类似接口获取信息,但是需要弹窗授权(首次),不合符组件逻辑
|
|
126
|
+
// 故目前自动获取小程序头像只支持这几个平台
|
|
127
|
+
// #ifdef MP-WEIXIN || MP-QQ || MP-BAIDU
|
|
128
|
+
this.allowMp = true
|
|
129
|
+
// #endif
|
|
130
|
+
},
|
|
131
|
+
// 判断传入的name属性,是否图片路径,只要带有"/"均认为是图片形式
|
|
132
|
+
isImg() {
|
|
133
|
+
return this.src.indexOf('/') !== -1
|
|
134
|
+
},
|
|
135
|
+
// 图片加载时失败时触发
|
|
136
|
+
errorHandler() {
|
|
137
|
+
this.avatarUrl = this.defaultUrl || base64Avatar
|
|
138
|
+
},
|
|
139
|
+
clickHandler() {
|
|
140
|
+
this.$emit('click', this.name)
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
</script>
|
|
145
|
+
|
|
146
|
+
<style lang="scss" scoped>
|
|
147
|
+
@import "../../libs/css/components.scss";
|
|
148
|
+
|
|
149
|
+
.u-avatar {
|
|
150
|
+
@include flex;
|
|
151
|
+
align-items: center;
|
|
152
|
+
justify-content: center;
|
|
153
|
+
|
|
154
|
+
&--circle {
|
|
155
|
+
border-radius: 100px;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
&--square {
|
|
159
|
+
border-radius: 4px;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
&__image {
|
|
163
|
+
&--circle {
|
|
164
|
+
border-radius: 100px;
|
|
165
|
+
overflow: hidden;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
&--square {
|
|
169
|
+
border-radius: 4px;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
</style>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
// 头像图片组
|
|
4
|
+
urls: {
|
|
5
|
+
type: Array,
|
|
6
|
+
default: uni.$u.props.avatarGroup.urls
|
|
7
|
+
},
|
|
8
|
+
// 最多展示的头像数量
|
|
9
|
+
maxCount: {
|
|
10
|
+
type: [String, Number],
|
|
11
|
+
default: uni.$u.props.avatarGroup.maxCount
|
|
12
|
+
},
|
|
13
|
+
// 头像形状
|
|
14
|
+
shape: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: uni.$u.props.avatarGroup.shape
|
|
17
|
+
},
|
|
18
|
+
// 图片裁剪模式
|
|
19
|
+
mode: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: uni.$u.props.avatarGroup.mode
|
|
22
|
+
},
|
|
23
|
+
// 超出maxCount时是否显示查看更多的提示
|
|
24
|
+
showMore: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: uni.$u.props.avatarGroup.showMore
|
|
27
|
+
},
|
|
28
|
+
// 头像大小
|
|
29
|
+
size: {
|
|
30
|
+
type: [String, Number],
|
|
31
|
+
default: uni.$u.props.avatarGroup.size
|
|
32
|
+
},
|
|
33
|
+
// 指定从数组的对象元素中读取哪个属性作为图片地址
|
|
34
|
+
keyName: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: uni.$u.props.avatarGroup.keyName
|
|
37
|
+
},
|
|
38
|
+
// 头像之间的遮挡比例
|
|
39
|
+
gap: {
|
|
40
|
+
type: [String, Number],
|
|
41
|
+
validator(value) {
|
|
42
|
+
return value >= 0 && value <= 1
|
|
43
|
+
},
|
|
44
|
+
default: uni.$u.props.avatarGroup.gap
|
|
45
|
+
},
|
|
46
|
+
// 需额外显示的值
|
|
47
|
+
extraValue: {
|
|
48
|
+
type: [Number, String],
|
|
49
|
+
default: uni.$u.props.avatarGroup.extraValue
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="u-avatar-group">
|
|
3
|
+
<view
|
|
4
|
+
class="u-avatar-group__item"
|
|
5
|
+
v-for="(item, index) in showUrl"
|
|
6
|
+
:key="index"
|
|
7
|
+
:style="{
|
|
8
|
+
marginLeft: index === 0 ? 0 : $u.addUnit(-size * gap)
|
|
9
|
+
}"
|
|
10
|
+
>
|
|
11
|
+
<u-avatar
|
|
12
|
+
:size="size"
|
|
13
|
+
:shape="shape"
|
|
14
|
+
:mode="mode"
|
|
15
|
+
:src="$u.test.object(item) ? keyName && item[keyName] || item.url : item"
|
|
16
|
+
></u-avatar>
|
|
17
|
+
<view
|
|
18
|
+
class="u-avatar-group__item__show-more"
|
|
19
|
+
v-if="showMore && index === showUrl.length - 1 && (urls.length > maxCount || extraValue > 0)"
|
|
20
|
+
@tap="clickHandler"
|
|
21
|
+
>
|
|
22
|
+
<u--text
|
|
23
|
+
color="#ffffff"
|
|
24
|
+
:size="size * 0.4"
|
|
25
|
+
:text="`+${extraValue || urls.length - showUrl.length}`"
|
|
26
|
+
align="center"
|
|
27
|
+
customStyle="justify-content: center"
|
|
28
|
+
></u--text>
|
|
29
|
+
</view>
|
|
30
|
+
</view>
|
|
31
|
+
</view>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<script>
|
|
35
|
+
import props from './props.js';
|
|
36
|
+
/**
|
|
37
|
+
* AvatarGroup 头像组
|
|
38
|
+
* @description 本组件一般用于展示头像的地方,如个人中心,或者评论列表页的用户头像展示等场所。
|
|
39
|
+
* @tutorial https://www.uviewui.com/components/avatar.html
|
|
40
|
+
*
|
|
41
|
+
* @property {Array} urls 头像图片组 (默认 [] )
|
|
42
|
+
* @property {String | Number} maxCount 最多展示的头像数量 ( 默认 5 )
|
|
43
|
+
* @property {String} shape 头像形状( 'circle' (默认) | 'square' )
|
|
44
|
+
* @property {String} mode 图片裁剪模式(默认 'scaleToFill' )
|
|
45
|
+
* @property {Boolean} showMore 超出maxCount时是否显示查看更多的提示 (默认 true )
|
|
46
|
+
* @property {String | Number} size 头像大小 (默认 40 )
|
|
47
|
+
* @property {String} keyName 指定从数组的对象元素中读取哪个属性作为图片地址
|
|
48
|
+
* @property {String | Number} gap 头像之间的遮挡比例(0.4代表遮挡40%) (默认 0.5 )
|
|
49
|
+
* @property {String | Number} extraValue 需额外显示的值
|
|
50
|
+
* @event {Function} showMore 头像组更多点击
|
|
51
|
+
* @example <u-avatar-group:urls="urls" size="35" gap="0.4" ></u-avatar-group:urls=>
|
|
52
|
+
*/
|
|
53
|
+
export default {
|
|
54
|
+
name: 'u-avatar-group',
|
|
55
|
+
mixins: [uni.$u.mpMixin, uni.$u.mixin, props],
|
|
56
|
+
data() {
|
|
57
|
+
return {
|
|
58
|
+
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
computed: {
|
|
62
|
+
showUrl() {
|
|
63
|
+
return this.urls.slice(0, this.maxCount)
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
methods: {
|
|
67
|
+
clickHandler() {
|
|
68
|
+
this.$emit('showMore')
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
}
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<style lang="scss" scoped>
|
|
75
|
+
@import "../../libs/css/components.scss";
|
|
76
|
+
|
|
77
|
+
.u-avatar-group {
|
|
78
|
+
@include flex;
|
|
79
|
+
|
|
80
|
+
&__item {
|
|
81
|
+
margin-left: -10px;
|
|
82
|
+
position: relative;
|
|
83
|
+
|
|
84
|
+
&--no-indent {
|
|
85
|
+
// 如果你想质疑作者不会使用:first-child,说明你太年轻,因为nvue不支持
|
|
86
|
+
margin-left: 0;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&__show-more {
|
|
90
|
+
position: absolute;
|
|
91
|
+
top: 0;
|
|
92
|
+
bottom: 0;
|
|
93
|
+
left: 0;
|
|
94
|
+
right: 0;
|
|
95
|
+
background-color: rgba(0, 0, 0, 0.3);
|
|
96
|
+
@include flex;
|
|
97
|
+
align-items: center;
|
|
98
|
+
justify-content: center;
|
|
99
|
+
border-radius: 100px;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
</style>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
// 返回顶部的形状,circle-圆形,square-方形
|
|
4
|
+
mode: {
|
|
5
|
+
type: String,
|
|
6
|
+
default: uni.$u.props.backtop.mode
|
|
7
|
+
},
|
|
8
|
+
// 自定义图标
|
|
9
|
+
icon: {
|
|
10
|
+
type: String,
|
|
11
|
+
default: uni.$u.props.backtop.icon
|
|
12
|
+
},
|
|
13
|
+
// 提示文字
|
|
14
|
+
text: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: uni.$u.props.backtop.text
|
|
17
|
+
},
|
|
18
|
+
// 返回顶部滚动时间
|
|
19
|
+
duration: {
|
|
20
|
+
type: [String, Number],
|
|
21
|
+
default: uni.$u.props.backtop.duration
|
|
22
|
+
},
|
|
23
|
+
// 滚动距离
|
|
24
|
+
scrollTop: {
|
|
25
|
+
type: [String, Number],
|
|
26
|
+
default: uni.$u.props.backtop.scrollTop
|
|
27
|
+
},
|
|
28
|
+
// 距离顶部多少距离显示,单位px
|
|
29
|
+
top: {
|
|
30
|
+
type: [String, Number],
|
|
31
|
+
default: uni.$u.props.backtop.top
|
|
32
|
+
},
|
|
33
|
+
// 返回顶部按钮到底部的距离,单位px
|
|
34
|
+
bottom: {
|
|
35
|
+
type: [String, Number],
|
|
36
|
+
default: uni.$u.props.backtop.bottom
|
|
37
|
+
},
|
|
38
|
+
// 返回顶部按钮到右边的距离,单位px
|
|
39
|
+
right: {
|
|
40
|
+
type: [String, Number],
|
|
41
|
+
default: uni.$u.props.backtop.right
|
|
42
|
+
},
|
|
43
|
+
// 层级
|
|
44
|
+
zIndex: {
|
|
45
|
+
type: [String, Number],
|
|
46
|
+
default: uni.$u.props.backtop.zIndex
|
|
47
|
+
},
|
|
48
|
+
// 图标的样式,对象形式
|
|
49
|
+
iconStyle: {
|
|
50
|
+
type: Object,
|
|
51
|
+
default: uni.$u.props.backtop.iconStyle
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<u-transition
|
|
3
|
+
mode="fade"
|
|
4
|
+
:customStyle="backTopStyle"
|
|
5
|
+
:show="show"
|
|
6
|
+
>
|
|
7
|
+
<view
|
|
8
|
+
class="u-back-top"
|
|
9
|
+
:style="[contentStyle]"
|
|
10
|
+
v-if="!$slots.default && !$slots.$default"
|
|
11
|
+
@click="backToTop"
|
|
12
|
+
>
|
|
13
|
+
<u-icon
|
|
14
|
+
:name="icon"
|
|
15
|
+
:custom-style="iconStyle"
|
|
16
|
+
></u-icon>
|
|
17
|
+
<text
|
|
18
|
+
v-if="text"
|
|
19
|
+
class="u-back-top__text"
|
|
20
|
+
>{{text}}</text>
|
|
21
|
+
</view>
|
|
22
|
+
<slot v-else />
|
|
23
|
+
</u-transition>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script>
|
|
27
|
+
import props from './props.js';
|
|
28
|
+
// #ifdef APP-NVUE
|
|
29
|
+
const dom = weex.requireModule('dom')
|
|
30
|
+
// #endif
|
|
31
|
+
/**
|
|
32
|
+
* backTop 返回顶部
|
|
33
|
+
* @description 本组件一个用于长页面,滑动一定距离后,出现返回顶部按钮,方便快速返回顶部的场景。
|
|
34
|
+
* @tutorial https://uviewui.com/components/backTop.html
|
|
35
|
+
*
|
|
36
|
+
* @property {String} mode 返回顶部的形状,circle-圆形,square-方形 (默认 'circle' )
|
|
37
|
+
* @property {String} icon 自定义图标 (默认 'arrow-upward' ) 见官方文档示例
|
|
38
|
+
* @property {String} text 提示文字
|
|
39
|
+
* @property {String | Number} duration 返回顶部滚动时间 (默认 100)
|
|
40
|
+
* @property {String | Number} scrollTop 滚动距离 (默认 0 )
|
|
41
|
+
* @property {String | Number} top 距离顶部多少距离显示,单位px (默认 400 )
|
|
42
|
+
* @property {String | Number} bottom 返回顶部按钮到底部的距离,单位px (默认 100 )
|
|
43
|
+
* @property {String | Number} right 返回顶部按钮到右边的距离,单位px (默认 20 )
|
|
44
|
+
* @property {String | Number} zIndex 层级 (默认 9 )
|
|
45
|
+
* @property {Object<Object>} iconStyle 图标的样式,对象形式 (默认 {color: '#909399',fontSize: '19px'})
|
|
46
|
+
* @property {Object} customStyle 定义需要用到的外部样式
|
|
47
|
+
*
|
|
48
|
+
* @example <u-back-top :scrollTop="scrollTop"></u-back-top>
|
|
49
|
+
*/
|
|
50
|
+
export default {
|
|
51
|
+
name: 'u-back-top',
|
|
52
|
+
mixins: [uni.$u.mpMixin, uni.$u.mixin,props],
|
|
53
|
+
computed: {
|
|
54
|
+
backTopStyle() {
|
|
55
|
+
// 动画组件样式
|
|
56
|
+
const style = {
|
|
57
|
+
bottom: uni.$u.addUnit(this.bottom),
|
|
58
|
+
right: uni.$u.addUnit(this.right),
|
|
59
|
+
width: '40px',
|
|
60
|
+
height: '40px',
|
|
61
|
+
position: 'fixed',
|
|
62
|
+
zIndex: 10,
|
|
63
|
+
}
|
|
64
|
+
return style
|
|
65
|
+
},
|
|
66
|
+
show() {
|
|
67
|
+
return uni.$u.getPx(this.scrollTop) > uni.$u.getPx(this.top)
|
|
68
|
+
},
|
|
69
|
+
contentStyle() {
|
|
70
|
+
const style = {}
|
|
71
|
+
let radius = 0
|
|
72
|
+
// 是否圆形
|
|
73
|
+
if(this.mode === 'circle') {
|
|
74
|
+
radius = '100px'
|
|
75
|
+
} else {
|
|
76
|
+
radius = '4px'
|
|
77
|
+
}
|
|
78
|
+
// 为了兼容安卓nvue,只能这么分开写
|
|
79
|
+
style.borderTopLeftRadius = radius
|
|
80
|
+
style.borderTopRightRadius = radius
|
|
81
|
+
style.borderBottomLeftRadius = radius
|
|
82
|
+
style.borderBottomRightRadius = radius
|
|
83
|
+
return uni.$u.deepMerge(style, uni.$u.addStyle(this.customStyle))
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
methods: {
|
|
87
|
+
backToTop() {
|
|
88
|
+
// #ifdef APP-NVUE
|
|
89
|
+
if (!this.$parent.$refs['u-back-top']) {
|
|
90
|
+
uni.$u.error(`nvue页面需要给页面最外层元素设置"ref='u-back-top'`)
|
|
91
|
+
}
|
|
92
|
+
dom.scrollToElement(this.$parent.$refs['u-back-top'], {
|
|
93
|
+
offset: 0
|
|
94
|
+
})
|
|
95
|
+
// #endif
|
|
96
|
+
|
|
97
|
+
// #ifndef APP-NVUE
|
|
98
|
+
uni.pageScrollTo({
|
|
99
|
+
scrollTop: 0,
|
|
100
|
+
duration: this.duration
|
|
101
|
+
});
|
|
102
|
+
// #endif
|
|
103
|
+
this.$emit('click')
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
</script>
|
|
108
|
+
|
|
109
|
+
<style lang="scss" scoped>
|
|
110
|
+
@import '../../libs/css/components.scss';
|
|
111
|
+
$u-back-top-flex:1 !default;
|
|
112
|
+
$u-back-top-height:100% !default;
|
|
113
|
+
$u-back-top-background-color:#E1E1E1 !default;
|
|
114
|
+
$u-back-top-tips-font-size:12px !default;
|
|
115
|
+
.u-back-top {
|
|
116
|
+
@include flex;
|
|
117
|
+
flex-direction: column;
|
|
118
|
+
align-items: center;
|
|
119
|
+
flex:$u-back-top-flex;
|
|
120
|
+
height: $u-back-top-height;
|
|
121
|
+
justify-content: center;
|
|
122
|
+
background-color: $u-back-top-background-color;
|
|
123
|
+
|
|
124
|
+
&__tips {
|
|
125
|
+
font-size:$u-back-top-tips-font-size;
|
|
126
|
+
transform: scale(0.8);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
</style>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
// 是否显示圆点
|
|
4
|
+
isDot: {
|
|
5
|
+
type: Boolean,
|
|
6
|
+
default: uni.$u.props.badge.isDot
|
|
7
|
+
},
|
|
8
|
+
// 显示的内容
|
|
9
|
+
value: {
|
|
10
|
+
type: [Number, String],
|
|
11
|
+
default: uni.$u.props.badge.value
|
|
12
|
+
},
|
|
13
|
+
// 是否显示
|
|
14
|
+
show: {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
default: uni.$u.props.badge.show
|
|
17
|
+
},
|
|
18
|
+
// 最大值,超过最大值会显示 '{max}+'
|
|
19
|
+
max: {
|
|
20
|
+
type: [Number, String],
|
|
21
|
+
default: uni.$u.props.badge.max
|
|
22
|
+
},
|
|
23
|
+
// 主题类型,error|warning|success|primary
|
|
24
|
+
type: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: uni.$u.props.badge.type
|
|
27
|
+
},
|
|
28
|
+
// 当数值为 0 时,是否展示 Badge
|
|
29
|
+
showZero: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: uni.$u.props.badge.showZero
|
|
32
|
+
},
|
|
33
|
+
// 背景颜色,优先级比type高,如设置,type参数会失效
|
|
34
|
+
bgColor: {
|
|
35
|
+
type: [String, null],
|
|
36
|
+
default: uni.$u.props.badge.bgColor
|
|
37
|
+
},
|
|
38
|
+
// 字体颜色
|
|
39
|
+
color: {
|
|
40
|
+
type: [String, null],
|
|
41
|
+
default: uni.$u.props.badge.color
|
|
42
|
+
},
|
|
43
|
+
// 徽标形状,circle-四角均为圆角,horn-左下角为直角
|
|
44
|
+
shape: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: uni.$u.props.badge.shape
|
|
47
|
+
},
|
|
48
|
+
// 设置数字的显示方式,overflow|ellipsis|limit
|
|
49
|
+
// overflow会根据max字段判断,超出显示`${max}+`
|
|
50
|
+
// ellipsis会根据max判断,超出显示`${max}...`
|
|
51
|
+
// limit会依据1000作为判断条件,超出1000,显示`${value/1000}K`,比如2.2k、3.34w,最多保留2位小数
|
|
52
|
+
numberType: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: uni.$u.props.badge.numberType
|
|
55
|
+
},
|
|
56
|
+
// 设置badge的位置偏移,格式为 [x, y],也即设置的为top和right的值,absolute为true时有效
|
|
57
|
+
offset: {
|
|
58
|
+
type: Array,
|
|
59
|
+
default: uni.$u.props.badge.offset
|
|
60
|
+
},
|
|
61
|
+
// 是否反转背景和字体颜色
|
|
62
|
+
inverted: {
|
|
63
|
+
type: Boolean,
|
|
64
|
+
default: uni.$u.props.badge.inverted
|
|
65
|
+
},
|
|
66
|
+
// 是否绝对定位
|
|
67
|
+
absolute: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
default: uni.$u.props.badge.absolute
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|