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,306 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="u-rate"
|
|
4
|
+
:id="elId"
|
|
5
|
+
ref="u-rate"
|
|
6
|
+
:style="[$u.addStyle(customStyle)]"
|
|
7
|
+
>
|
|
8
|
+
<view
|
|
9
|
+
class="u-rate__content"
|
|
10
|
+
@touchmove.stop="touchMove"
|
|
11
|
+
@touchend.stop="touchEnd"
|
|
12
|
+
>
|
|
13
|
+
<view
|
|
14
|
+
class="u-rate__content__item"
|
|
15
|
+
v-for="(item, index) in Number(count)"
|
|
16
|
+
:key="index"
|
|
17
|
+
:class="[elClass]"
|
|
18
|
+
>
|
|
19
|
+
<view
|
|
20
|
+
class="u-rate__content__item__icon-wrap"
|
|
21
|
+
ref="u-rate__content__item__icon-wrap"
|
|
22
|
+
@tap.stop="clickHandler($event, index + 1)"
|
|
23
|
+
>
|
|
24
|
+
<u-icon
|
|
25
|
+
:name="
|
|
26
|
+
Math.floor(activeIndex) > index
|
|
27
|
+
? activeIcon
|
|
28
|
+
: inactiveIcon
|
|
29
|
+
"
|
|
30
|
+
:color="
|
|
31
|
+
disabled
|
|
32
|
+
? '#c8c9cc'
|
|
33
|
+
: Math.floor(activeIndex) > index
|
|
34
|
+
? activeColor
|
|
35
|
+
: inactiveColor
|
|
36
|
+
"
|
|
37
|
+
:custom-style="{
|
|
38
|
+
'padding-left': $u.addUnit(gutter / 2),
|
|
39
|
+
'padding-right': $u.addUnit(gutter / 2)
|
|
40
|
+
}"
|
|
41
|
+
:size="size"
|
|
42
|
+
></u-icon>
|
|
43
|
+
</view>
|
|
44
|
+
<view
|
|
45
|
+
v-if="allowHalf"
|
|
46
|
+
@tap.stop="clickHandler($event, index + 1)"
|
|
47
|
+
class="u-rate__content__item__icon-wrap u-rate__content__item__icon-wrap--half"
|
|
48
|
+
:style="[{
|
|
49
|
+
width: $u.addUnit(rateWidth / 2),
|
|
50
|
+
}]"
|
|
51
|
+
ref="u-rate__content__item__icon-wrap"
|
|
52
|
+
>
|
|
53
|
+
<u-icon
|
|
54
|
+
:name="
|
|
55
|
+
Math.ceil(activeIndex) > index
|
|
56
|
+
? activeIcon
|
|
57
|
+
: inactiveIcon
|
|
58
|
+
"
|
|
59
|
+
:color="
|
|
60
|
+
disabled
|
|
61
|
+
? '#c8c9cc'
|
|
62
|
+
: Math.ceil(activeIndex) > index
|
|
63
|
+
? activeColor
|
|
64
|
+
: inactiveColor
|
|
65
|
+
"
|
|
66
|
+
:custom-style="{
|
|
67
|
+
'padding-left': $u.addUnit(gutter / 2),
|
|
68
|
+
'padding-right': $u.addUnit(gutter / 2)
|
|
69
|
+
}"
|
|
70
|
+
:size="size"
|
|
71
|
+
></u-icon>
|
|
72
|
+
</view>
|
|
73
|
+
</view>
|
|
74
|
+
</view>
|
|
75
|
+
</view>
|
|
76
|
+
</template>
|
|
77
|
+
|
|
78
|
+
<script>
|
|
79
|
+
import props from './props.js';
|
|
80
|
+
|
|
81
|
+
// #ifdef APP-NVUE
|
|
82
|
+
const dom = weex.requireModule("dom");
|
|
83
|
+
// #endif
|
|
84
|
+
/**
|
|
85
|
+
* rate 评分
|
|
86
|
+
* @description 该组件一般用于满意度调查,星型评分的场景
|
|
87
|
+
* @tutorial https://www.uviewui.com/components/rate.html
|
|
88
|
+
* @property {String | Number} value 用于v-model双向绑定选中的星星数量 (默认 1 )
|
|
89
|
+
* @property {String | Number} count 最多可选的星星数量 (默认 5 )
|
|
90
|
+
* @property {Boolean} disabled 是否禁止用户操作 (默认 false )
|
|
91
|
+
* @property {Boolean} readonly 是否只读 (默认 false )
|
|
92
|
+
* @property {String | Number} size 星星的大小,单位px (默认 18 )
|
|
93
|
+
* @property {String} inactiveColor 未选中星星的颜色 (默认 '#b2b2b2' )
|
|
94
|
+
* @property {String} activeColor 选中的星星颜色 (默认 '#FA3534' )
|
|
95
|
+
* @property {String | Number} gutter 星星之间的距离 (默认 4 )
|
|
96
|
+
* @property {String | Number} minCount 最少选中星星的个数 (默认 1 )
|
|
97
|
+
* @property {Boolean} allowHalf 是否允许半星选择 (默认 false )
|
|
98
|
+
* @property {String} activeIcon 选中时的图标名,只能为uView的内置图标 (默认 'star-fill' )
|
|
99
|
+
* @property {String} inactiveIcon 未选中时的图标名,只能为uView的内置图标 (默认 'star' )
|
|
100
|
+
* @property {Boolean} touchable 是否可以通过滑动手势选择评分 (默认 'true' )
|
|
101
|
+
* @property {Object} customStyle 组件的样式,对象形式
|
|
102
|
+
* @event {Function} change 选中的星星发生变化时触发
|
|
103
|
+
* @example <u-rate :count="count" :value="2"></u-rate>
|
|
104
|
+
*/
|
|
105
|
+
export default {
|
|
106
|
+
name: "u-rate",
|
|
107
|
+
mixins: [uni.$u.mpMixin, uni.$u.mixin,props],
|
|
108
|
+
data() {
|
|
109
|
+
return {
|
|
110
|
+
// 生成一个唯一id,否则一个页面多个评分组件,会造成冲突
|
|
111
|
+
elId: uni.$u.guid(),
|
|
112
|
+
elClass: uni.$u.guid(),
|
|
113
|
+
rateBoxLeft: 0, // 评分盒子左边到屏幕左边的距离,用于滑动选择时计算距离
|
|
114
|
+
activeIndex: this.value,
|
|
115
|
+
rateWidth: 0, // 每个星星的宽度
|
|
116
|
+
// 标识是否正在滑动,由于iOS事件上touch比click先触发,导致快速滑动结束后,接着触发click,导致事件混乱而出错
|
|
117
|
+
moving: false,
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
watch: {
|
|
121
|
+
value(val) {
|
|
122
|
+
this.activeIndex = val;
|
|
123
|
+
},
|
|
124
|
+
activeIndex: 'emitEvent'
|
|
125
|
+
},
|
|
126
|
+
methods: {
|
|
127
|
+
init() {
|
|
128
|
+
uni.$u.sleep().then(() => {
|
|
129
|
+
this.getRateItemRect();
|
|
130
|
+
this.getRateIconWrapRect();
|
|
131
|
+
})
|
|
132
|
+
},
|
|
133
|
+
// 获取评分组件盒子的布局信息
|
|
134
|
+
async getRateItemRect() {
|
|
135
|
+
await uni.$u.sleep();
|
|
136
|
+
// uView封装的获取节点的方法,详见文档
|
|
137
|
+
// #ifndef APP-NVUE
|
|
138
|
+
this.$uGetRect("#" + this.elId).then((res) => {
|
|
139
|
+
this.rateBoxLeft = res.left;
|
|
140
|
+
});
|
|
141
|
+
// #endif
|
|
142
|
+
// #ifdef APP-NVUE
|
|
143
|
+
dom.getComponentRect(this.$refs["u-rate"], (res) => {
|
|
144
|
+
this.rateBoxLeft = res.size.left;
|
|
145
|
+
});
|
|
146
|
+
// #endif
|
|
147
|
+
},
|
|
148
|
+
// 获取单个星星的尺寸
|
|
149
|
+
getRateIconWrapRect() {
|
|
150
|
+
// uView封装的获取节点的方法,详见文档
|
|
151
|
+
// #ifndef APP-NVUE
|
|
152
|
+
this.$uGetRect("." + this.elClass).then((res) => {
|
|
153
|
+
this.rateWidth = res.width;
|
|
154
|
+
});
|
|
155
|
+
// #endif
|
|
156
|
+
// #ifdef APP-NVUE
|
|
157
|
+
dom.getComponentRect(
|
|
158
|
+
this.$refs["u-rate__content__item__icon-wrap"][0],
|
|
159
|
+
(res) => {
|
|
160
|
+
this.rateWidth = res.size.width;
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
// #endif
|
|
164
|
+
},
|
|
165
|
+
// 手指滑动
|
|
166
|
+
touchMove(e) {
|
|
167
|
+
// 如果禁止通过手动滑动选择,返回
|
|
168
|
+
if (!this.touchable) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
this.preventEvent(e);
|
|
172
|
+
const x = e.changedTouches[0].pageX;
|
|
173
|
+
this.getActiveIndex(x);
|
|
174
|
+
},
|
|
175
|
+
// 停止滑动
|
|
176
|
+
touchEnd(e) {
|
|
177
|
+
// 如果禁止通过手动滑动选择,返回
|
|
178
|
+
if (!this.touchable) {
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
this.preventEvent(e);
|
|
182
|
+
const x = e.changedTouches[0].pageX;
|
|
183
|
+
this.getActiveIndex(x);
|
|
184
|
+
},
|
|
185
|
+
// 通过点击,直接选中
|
|
186
|
+
clickHandler(e, index) {
|
|
187
|
+
// ios上,moving状态取消事件触发
|
|
188
|
+
if (uni.$u.os() === "ios" && this.moving) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
this.preventEvent(e);
|
|
192
|
+
let x = 0;
|
|
193
|
+
// 点击时,在nvue上,无法获得点击的坐标,所以无法实现点击半星选择
|
|
194
|
+
// #ifndef APP-NVUE
|
|
195
|
+
x = e.changedTouches[0].pageX;
|
|
196
|
+
// #endif
|
|
197
|
+
// #ifdef APP-NVUE
|
|
198
|
+
// nvue下,无法通过点击获得坐标信息,这里通过元素的位置尺寸值模拟坐标
|
|
199
|
+
x = index * this.rateWidth + this.rateBoxLeft;
|
|
200
|
+
// #endif
|
|
201
|
+
this.getActiveIndex(x,true);
|
|
202
|
+
},
|
|
203
|
+
// 发出事件
|
|
204
|
+
emitEvent() {
|
|
205
|
+
// 发出change事件
|
|
206
|
+
this.$emit("change", this.activeIndex);
|
|
207
|
+
// 同时修改双向绑定的value的值
|
|
208
|
+
this.$emit("input", this.activeIndex);
|
|
209
|
+
},
|
|
210
|
+
// 获取当前激活的评分图标
|
|
211
|
+
getActiveIndex(x,isClick = false) {
|
|
212
|
+
if (this.disabled || this.readonly) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
// 判断当前操作的点的x坐标值,是否在允许的边界范围内
|
|
216
|
+
const allRateWidth = this.rateWidth * this.count + this.rateBoxLeft;
|
|
217
|
+
// 如果小于第一个图标的左边界,设置为最小值,如果大于所有图标的宽度,则设置为最大值
|
|
218
|
+
x = uni.$u.range(this.rateBoxLeft, allRateWidth, x) - this.rateBoxLeft
|
|
219
|
+
// 滑动点相对于评分盒子左边的距离
|
|
220
|
+
const distance = x;
|
|
221
|
+
// 滑动的距离,相当于多少颗星星
|
|
222
|
+
let index;
|
|
223
|
+
// 判断是否允许半星
|
|
224
|
+
if (this.allowHalf) {
|
|
225
|
+
index = Math.floor(distance / this.rateWidth);
|
|
226
|
+
// 取余,判断小数的区间范围
|
|
227
|
+
const decimal = distance % this.rateWidth;
|
|
228
|
+
if (decimal <= this.rateWidth / 2 && decimal > 0) {
|
|
229
|
+
index += 0.5;
|
|
230
|
+
} else if (decimal > this.rateWidth / 2) {
|
|
231
|
+
index++;
|
|
232
|
+
}
|
|
233
|
+
} else {
|
|
234
|
+
index = Math.floor(distance / this.rateWidth);
|
|
235
|
+
// 取余,判断小数的区间范围
|
|
236
|
+
const decimal = distance % this.rateWidth;
|
|
237
|
+
// 非半星时,只有超过了图标的一半距离,才认为是选择了这颗星
|
|
238
|
+
if (isClick){
|
|
239
|
+
if (decimal > 0) index++;
|
|
240
|
+
} else {
|
|
241
|
+
if (decimal > this.rateWidth / 2) index++;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
}
|
|
245
|
+
this.activeIndex = Math.min(index, this.count);
|
|
246
|
+
// 对最少颗星星的限制
|
|
247
|
+
if (this.activeIndex < this.minCount) {
|
|
248
|
+
this.activeIndex = this.minCount;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// 设置延时为了让click事件在touchmove之前触发
|
|
252
|
+
setTimeout(() => {
|
|
253
|
+
this.moving = true;
|
|
254
|
+
}, 10);
|
|
255
|
+
// 一定时间后,取消标识为移动中状态,是为了让click事件无效
|
|
256
|
+
setTimeout(() => {
|
|
257
|
+
this.moving = false;
|
|
258
|
+
}, 10);
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
mounted() {
|
|
262
|
+
this.init();
|
|
263
|
+
},
|
|
264
|
+
};
|
|
265
|
+
</script>
|
|
266
|
+
|
|
267
|
+
<style lang="scss" scoped>
|
|
268
|
+
@import "../../libs/css/components.scss";
|
|
269
|
+
$u-rate-margin: 0 !default;
|
|
270
|
+
$u-rate-padding: 0 !default;
|
|
271
|
+
$u-rate-item-icon-wrap-half-top: 0 !default;
|
|
272
|
+
$u-rate-item-icon-wrap-half-left: 0 !default;
|
|
273
|
+
|
|
274
|
+
.u-rate {
|
|
275
|
+
@include flex;
|
|
276
|
+
align-items: center;
|
|
277
|
+
margin: $u-rate-margin;
|
|
278
|
+
padding: $u-rate-padding;
|
|
279
|
+
/* #ifndef APP-NVUE */
|
|
280
|
+
touch-action: none;
|
|
281
|
+
/* #endif */
|
|
282
|
+
|
|
283
|
+
&__content {
|
|
284
|
+
@include flex;
|
|
285
|
+
|
|
286
|
+
&__item {
|
|
287
|
+
position: relative;
|
|
288
|
+
|
|
289
|
+
&__icon-wrap {
|
|
290
|
+
&--half {
|
|
291
|
+
position: absolute;
|
|
292
|
+
overflow: hidden;
|
|
293
|
+
top: $u-rate-item-icon-wrap-half-top;
|
|
294
|
+
left: $u-rate-item-icon-wrap-half-left;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.u-icon {
|
|
302
|
+
/* #ifndef APP-NVUE */
|
|
303
|
+
box-sizing: border-box;
|
|
304
|
+
/* #endif */
|
|
305
|
+
}
|
|
306
|
+
</style>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
// 默认的显示占位高度
|
|
4
|
+
showHeight: {
|
|
5
|
+
type: [String, Number],
|
|
6
|
+
default: uni.$u.props.readMore.showHeight
|
|
7
|
+
},
|
|
8
|
+
// 展开后是否显示"收起"按钮
|
|
9
|
+
toggle: {
|
|
10
|
+
type: Boolean,
|
|
11
|
+
default: uni.$u.props.readMore.toggle
|
|
12
|
+
},
|
|
13
|
+
// 关闭时的提示文字
|
|
14
|
+
closeText: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: uni.$u.props.readMore.closeText
|
|
17
|
+
},
|
|
18
|
+
// 展开时的提示文字
|
|
19
|
+
openText: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: uni.$u.props.readMore.openText
|
|
22
|
+
},
|
|
23
|
+
// 提示的文字颜色
|
|
24
|
+
color: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: uni.$u.props.readMore.color
|
|
27
|
+
},
|
|
28
|
+
// 提示文字的大小
|
|
29
|
+
fontSize: {
|
|
30
|
+
type: [String, Number],
|
|
31
|
+
default: uni.$u.props.readMore.fontSize
|
|
32
|
+
},
|
|
33
|
+
// 是否显示阴影
|
|
34
|
+
// 此参数不能写在props/readMore.js中进行默认配置,因为使用了条件编译,在外部js中
|
|
35
|
+
// uni无法准确识别当前是否处于nvue还是非nvue下
|
|
36
|
+
shadowStyle: {
|
|
37
|
+
type: Object,
|
|
38
|
+
default: () => ({
|
|
39
|
+
// #ifndef APP-NVUE
|
|
40
|
+
backgroundImage: 'linear-gradient(-180deg, rgba(255, 255, 255, 0) 0%, #fff 80%)',
|
|
41
|
+
// #endif
|
|
42
|
+
// #ifdef APP-NVUE
|
|
43
|
+
// nvue上不支持设置复杂的backgroundImage属性
|
|
44
|
+
backgroundImage: 'linear-gradient(to top, #fff, rgba(255, 255, 255, 0.5))',
|
|
45
|
+
// #endif
|
|
46
|
+
paddingTop: '100px',
|
|
47
|
+
marginTop: '-100px'
|
|
48
|
+
})
|
|
49
|
+
},
|
|
50
|
+
// 段落首行缩进的字符个数
|
|
51
|
+
textIndent: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: uni.$u.props.readMore.textIndent
|
|
54
|
+
},
|
|
55
|
+
// open和close事件时,将此参数返回在回调参数中
|
|
56
|
+
name: {
|
|
57
|
+
type: [String, Number],
|
|
58
|
+
default: uni.$u.props.readMore.name
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="u-read-more">
|
|
3
|
+
<view
|
|
4
|
+
class="u-read-more__content"
|
|
5
|
+
:style="{
|
|
6
|
+
height: isLongContent && status === 'close' ? $u.addUnit(showHeight) : $u.addUnit(contentHeight),
|
|
7
|
+
textIndent: textIndent
|
|
8
|
+
}"
|
|
9
|
+
>
|
|
10
|
+
<view
|
|
11
|
+
class="u-read-more__content__inner"
|
|
12
|
+
ref="u-read-more__content__inner"
|
|
13
|
+
:class="[elId]"
|
|
14
|
+
>
|
|
15
|
+
<slot></slot>
|
|
16
|
+
</view>
|
|
17
|
+
</view>
|
|
18
|
+
<view
|
|
19
|
+
class="u-read-more__toggle"
|
|
20
|
+
:style="[innerShadowStyle]"
|
|
21
|
+
v-if="isLongContent"
|
|
22
|
+
>
|
|
23
|
+
<slot name="toggle">
|
|
24
|
+
<view
|
|
25
|
+
class="u-read-more__toggle__text"
|
|
26
|
+
@tap="toggleReadMore"
|
|
27
|
+
>
|
|
28
|
+
<u--text
|
|
29
|
+
:text="status === 'close' ? closeText : openText"
|
|
30
|
+
:color="color"
|
|
31
|
+
:size="fontSize"
|
|
32
|
+
:lineHeight="fontSize"
|
|
33
|
+
margin="0 5px 0 0"
|
|
34
|
+
></u--text>
|
|
35
|
+
<view class="u-read-more__toggle__icon">
|
|
36
|
+
<u-icon
|
|
37
|
+
:color="color"
|
|
38
|
+
:size="fontSize + 2"
|
|
39
|
+
:name="status === 'close' ? 'arrow-down' : 'arrow-up'"
|
|
40
|
+
></u-icon>
|
|
41
|
+
</view>
|
|
42
|
+
</view>
|
|
43
|
+
</slot>
|
|
44
|
+
</view>
|
|
45
|
+
</view>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<script>
|
|
49
|
+
// #ifdef APP-NVUE
|
|
50
|
+
const dom = uni.requireNativePlugin('dom')
|
|
51
|
+
// #endif
|
|
52
|
+
import props from './props.js';
|
|
53
|
+
/**
|
|
54
|
+
* readMore 阅读更多
|
|
55
|
+
* @description 该组件一般用于内容较长,预先收起一部分,点击展开全部内容的场景。
|
|
56
|
+
* @tutorial https://www.uviewui.com/components/readMore.html
|
|
57
|
+
* @property {String | Number} showHeight 内容超出此高度才会显示展开全文按钮,单位px(默认 400 )
|
|
58
|
+
* @property {Boolean} toggle 展开后是否显示收起按钮(默认 false )
|
|
59
|
+
* @property {String} closeText 关闭时的提示文字(默认 '展开阅读全文' )
|
|
60
|
+
* @property {String} openText 展开时的提示文字(默认 '收起' )
|
|
61
|
+
* @property {String} color 提示文字的颜色(默认 '#2979ff' )
|
|
62
|
+
* @property {String | Number} fontSize 提示文字的大小,单位px (默认 14 )
|
|
63
|
+
* @property {Object} shadowStyle 显示阴影的样式
|
|
64
|
+
* @property {String} textIndent 段落首行缩进的字符个数 (默认 '2em' )
|
|
65
|
+
* @property {String | Number} name 用于在 open 和 close 事件中当作回调参数返回
|
|
66
|
+
* @event {Function} open 内容被展开时触发
|
|
67
|
+
* @event {Function} close 内容被收起时触发
|
|
68
|
+
* @example <u-read-more><rich-text :nodes="content"></rich-text></u-read-more>
|
|
69
|
+
*/
|
|
70
|
+
export default {
|
|
71
|
+
name: 'u-read-more',
|
|
72
|
+
mixins: [uni.$u.mpMixin, uni.$u.mixin, props],
|
|
73
|
+
data() {
|
|
74
|
+
return {
|
|
75
|
+
isLongContent: false, // 是否需要隐藏一部分内容
|
|
76
|
+
status: 'close', // 当前隐藏与显示的状态,close-收起状态,open-展开状态
|
|
77
|
+
elId: uni.$u.guid(), // 生成唯一class
|
|
78
|
+
contentHeight: 100, // 内容高度
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
computed: {
|
|
82
|
+
// 展开后无需阴影,收起时才需要阴影样式
|
|
83
|
+
innerShadowStyle() {
|
|
84
|
+
if (this.status === 'open') return {}
|
|
85
|
+
else return this.shadowStyle
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
mounted() {
|
|
89
|
+
this.init()
|
|
90
|
+
},
|
|
91
|
+
methods: {
|
|
92
|
+
async init() {
|
|
93
|
+
this.getContentHeight().then(height => {
|
|
94
|
+
this.contentHeight = height
|
|
95
|
+
// 判断高度,如果真实内容高度大于占位高度,则显示收起与展开的控制按钮
|
|
96
|
+
if (height > uni.$u.getPx(this.showHeight)) {
|
|
97
|
+
this.isLongContent = true
|
|
98
|
+
this.status = 'close'
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
},
|
|
102
|
+
// 获取内容的高度
|
|
103
|
+
async getContentHeight() {
|
|
104
|
+
// 延时一定时间再获取节点
|
|
105
|
+
await uni.$u.sleep(30)
|
|
106
|
+
return new Promise(resolve => {
|
|
107
|
+
// #ifndef APP-NVUE
|
|
108
|
+
this.$uGetRect('.' + this.elId).then(res => {
|
|
109
|
+
resolve(res.height)
|
|
110
|
+
})
|
|
111
|
+
// #endif
|
|
112
|
+
|
|
113
|
+
// #ifdef APP-NVUE
|
|
114
|
+
const ref = this.$refs['u-read-more__content__inner']
|
|
115
|
+
dom.getComponentRect(ref, (res) => {
|
|
116
|
+
resolve(res.size.height)
|
|
117
|
+
})
|
|
118
|
+
// #endif
|
|
119
|
+
})
|
|
120
|
+
},
|
|
121
|
+
// 展开或者收起
|
|
122
|
+
toggleReadMore() {
|
|
123
|
+
this.status = this.status === 'close' ? 'open' : 'close'
|
|
124
|
+
// 如果toggle为false,隐藏"收起"部分的内容
|
|
125
|
+
if (this.toggle == false) this.isLongContent = false
|
|
126
|
+
// 发出打开或者收齐的事件
|
|
127
|
+
this.$emit(this.status, this.name)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
</script>
|
|
132
|
+
|
|
133
|
+
<style lang="scss" scoped>
|
|
134
|
+
@import "../../libs/css/components.scss";
|
|
135
|
+
|
|
136
|
+
.u-read-more {
|
|
137
|
+
|
|
138
|
+
&__content {
|
|
139
|
+
overflow: hidden;
|
|
140
|
+
color: $u-content-color;
|
|
141
|
+
font-size: 15px;
|
|
142
|
+
text-align: left;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
&__toggle {
|
|
146
|
+
@include flex;
|
|
147
|
+
justify-content: center;
|
|
148
|
+
|
|
149
|
+
&__text {
|
|
150
|
+
@include flex;
|
|
151
|
+
align-items: center;
|
|
152
|
+
justify-content: center;
|
|
153
|
+
margin-top: 5px;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
</style>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
// 给col添加间距,左右边距各占一半
|
|
4
|
+
gutter: {
|
|
5
|
+
type: [String, Number],
|
|
6
|
+
default: uni.$u.props.row.gutter
|
|
7
|
+
},
|
|
8
|
+
// 水平排列方式,可选值为`start`(或`flex-start`)、`end`(或`flex-end`)、`center`、`around`(或`space-around`)、`between`(或`space-between`)
|
|
9
|
+
justify: {
|
|
10
|
+
type: String,
|
|
11
|
+
default: uni.$u.props.row.justify
|
|
12
|
+
},
|
|
13
|
+
// 垂直对齐方式,可选值为top、center、bottom
|
|
14
|
+
align: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: uni.$u.props.row.align
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="u-row"
|
|
4
|
+
ref="u-row"
|
|
5
|
+
:style="[rowStyle]"
|
|
6
|
+
@tap="clickHandler"
|
|
7
|
+
>
|
|
8
|
+
<slot />
|
|
9
|
+
</view>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script>
|
|
13
|
+
// #ifdef APP-NVUE
|
|
14
|
+
const dom = uni.requireNativePlugin('dom')
|
|
15
|
+
// #endif
|
|
16
|
+
import props from './props.js';
|
|
17
|
+
/**
|
|
18
|
+
* Row 栅格系统中的行
|
|
19
|
+
* @description 通过基础的 12 分栏,迅速简便地创建布局
|
|
20
|
+
* @tutorial https://www.uviewui.com/components/layout.html
|
|
21
|
+
* @property {String | Number} gutter 栅格间隔,左右各为此值的一半,单位px (默认 0 )
|
|
22
|
+
* @property {String} justify 水平排列方式(微信小程序暂不支持) 可选值为`start`(或`flex-start`)、`end`(或`flex-end`)、`center`、`around`(或`space-around`)、`between`(或`space-between`) (默认 'start' )
|
|
23
|
+
* @property {String} align 垂直排列方式 (默认 'center' )
|
|
24
|
+
* @property {Object} customStyle 定义需要用到的外部样式
|
|
25
|
+
*
|
|
26
|
+
* @event {Function} click row被点击
|
|
27
|
+
* @example <u-row justify="space-between" customStyle="margin-bottom: 10px"></u-row>
|
|
28
|
+
*/
|
|
29
|
+
export default {
|
|
30
|
+
name: "u-row",
|
|
31
|
+
mixins: [uni.$u.mpMixin, uni.$u.mixin, props],
|
|
32
|
+
data() {
|
|
33
|
+
return {
|
|
34
|
+
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
computed: {
|
|
38
|
+
uJustify() {
|
|
39
|
+
if (this.justify == 'end' || this.justify == 'start') return 'flex-' + this.justify
|
|
40
|
+
else if (this.justify == 'around' || this.justify == 'between') return 'space-' + this.justify
|
|
41
|
+
else return this.justify
|
|
42
|
+
},
|
|
43
|
+
uAlignItem() {
|
|
44
|
+
if (this.align == 'top') return 'flex-start'
|
|
45
|
+
if (this.align == 'bottom') return 'flex-end'
|
|
46
|
+
else return this.align
|
|
47
|
+
},
|
|
48
|
+
rowStyle() {
|
|
49
|
+
const style = {
|
|
50
|
+
alignItems: this.uAlignItem,
|
|
51
|
+
justifyContent: this.uJustify
|
|
52
|
+
}
|
|
53
|
+
// 通过给u-row左右两边的负外边距,消除u-col在有gutter时,第一个和最后一个元素的左内边距和右内边距造成的影响
|
|
54
|
+
if(this.gutter) {
|
|
55
|
+
style.marginLeft = uni.$u.addUnit(-Number(this.gutter)/2)
|
|
56
|
+
style.marginRight = uni.$u.addUnit(-Number(this.gutter)/2)
|
|
57
|
+
}
|
|
58
|
+
return uni.$u.deepMerge(style, uni.$u.addStyle(this.customStyle))
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
methods: {
|
|
62
|
+
clickHandler(e) {
|
|
63
|
+
this.$emit('click')
|
|
64
|
+
},
|
|
65
|
+
async getComponentWidth() {
|
|
66
|
+
// 延时一定时间,以确保节点渲染完成
|
|
67
|
+
await uni.$u.sleep()
|
|
68
|
+
return new Promise(resolve => {
|
|
69
|
+
// uView封装的获取节点的方法,详见文档
|
|
70
|
+
// #ifndef APP-NVUE
|
|
71
|
+
this.$uGetRect('.u-row').then(res => {
|
|
72
|
+
resolve(res.width)
|
|
73
|
+
})
|
|
74
|
+
// #endif
|
|
75
|
+
// #ifdef APP-NVUE
|
|
76
|
+
// nvue的dom模块用于获取节点
|
|
77
|
+
dom.getComponentRect(this.$refs['u-row'], (res) => {
|
|
78
|
+
resolve(res.size.width)
|
|
79
|
+
})
|
|
80
|
+
// #endif
|
|
81
|
+
})
|
|
82
|
+
},
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
</script>
|
|
86
|
+
|
|
87
|
+
<style lang="scss" scoped>
|
|
88
|
+
@import "../../libs/css/components.scss";
|
|
89
|
+
|
|
90
|
+
.u-row {
|
|
91
|
+
@include flex;
|
|
92
|
+
}
|
|
93
|
+
</style>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
// 显示的内容,字符串
|
|
4
|
+
text: {
|
|
5
|
+
type: String,
|
|
6
|
+
default: uni.$u.props.rowNotice.text
|
|
7
|
+
},
|
|
8
|
+
// 是否显示左侧的音量图标
|
|
9
|
+
icon: {
|
|
10
|
+
type: String,
|
|
11
|
+
default: uni.$u.props.rowNotice.icon
|
|
12
|
+
},
|
|
13
|
+
// 通告模式,link-显示右箭头,closable-显示右侧关闭图标
|
|
14
|
+
mode: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: uni.$u.props.rowNotice.mode
|
|
17
|
+
},
|
|
18
|
+
// 文字颜色,各图标也会使用文字颜色
|
|
19
|
+
color: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: uni.$u.props.rowNotice.color
|
|
22
|
+
},
|
|
23
|
+
// 背景颜色
|
|
24
|
+
bgColor: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: uni.$u.props.rowNotice.bgColor
|
|
27
|
+
},
|
|
28
|
+
// 字体大小,单位px
|
|
29
|
+
fontSize: {
|
|
30
|
+
type: [String, Number],
|
|
31
|
+
default: uni.$u.props.rowNotice.fontSize
|
|
32
|
+
},
|
|
33
|
+
// 水平滚动时的滚动速度,即每秒滚动多少px(rpx),这有利于控制文字无论多少时,都能有一个恒定的速度
|
|
34
|
+
speed: {
|
|
35
|
+
type: [String, Number],
|
|
36
|
+
default: uni.$u.props.rowNotice.speed
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|