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,223 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="u-text"
|
|
4
|
+
:class="[]"
|
|
5
|
+
v-if="show"
|
|
6
|
+
:style="{
|
|
7
|
+
margin: margin,
|
|
8
|
+
justifyContent: align === 'left' ? 'flex-start' : align === 'center' ? 'center' : 'flex-end'
|
|
9
|
+
}"
|
|
10
|
+
@tap="clickHandler"
|
|
11
|
+
>
|
|
12
|
+
<text
|
|
13
|
+
:class="['u-text__price', type && `u-text__value--${type}`]"
|
|
14
|
+
v-if="mode === 'price'"
|
|
15
|
+
:style="[valueStyle]"
|
|
16
|
+
>¥</text
|
|
17
|
+
>
|
|
18
|
+
<view class="u-text__prefix-icon" v-if="prefixIcon">
|
|
19
|
+
<u-icon
|
|
20
|
+
:name="prefixIcon"
|
|
21
|
+
:customStyle="$u.addStyle(iconStyle)"
|
|
22
|
+
></u-icon>
|
|
23
|
+
</view>
|
|
24
|
+
<u-link
|
|
25
|
+
v-if="mode === 'link'"
|
|
26
|
+
:text="value"
|
|
27
|
+
:href="href"
|
|
28
|
+
underLine
|
|
29
|
+
></u-link>
|
|
30
|
+
<template v-else-if="openType && isMp">
|
|
31
|
+
<button
|
|
32
|
+
class="u-reset-button u-text__value"
|
|
33
|
+
:style="[valueStyle]"
|
|
34
|
+
:data-index="index"
|
|
35
|
+
:openType="openType"
|
|
36
|
+
@getuserinfo="onGetUserInfo"
|
|
37
|
+
@contact="onContact"
|
|
38
|
+
@getphonenumber="onGetPhoneNumber"
|
|
39
|
+
@error="onError"
|
|
40
|
+
@launchapp="onLaunchApp"
|
|
41
|
+
@opensetting="onOpenSetting"
|
|
42
|
+
:lang="lang"
|
|
43
|
+
:session-from="sessionFrom"
|
|
44
|
+
:send-message-title="sendMessageTitle"
|
|
45
|
+
:send-message-path="sendMessagePath"
|
|
46
|
+
:send-message-img="sendMessageImg"
|
|
47
|
+
:show-message-card="showMessageCard"
|
|
48
|
+
:app-parameter="appParameter"
|
|
49
|
+
>
|
|
50
|
+
{{ value }}
|
|
51
|
+
</button>
|
|
52
|
+
</template>
|
|
53
|
+
<text
|
|
54
|
+
v-else
|
|
55
|
+
class="u-text__value"
|
|
56
|
+
:style="[valueStyle]"
|
|
57
|
+
:class="[
|
|
58
|
+
type && `u-text__value--${type}`,
|
|
59
|
+
lines && `u-line-${lines}`
|
|
60
|
+
]"
|
|
61
|
+
>{{ value }}</text
|
|
62
|
+
>
|
|
63
|
+
<view class="u-text__suffix-icon" v-if="suffixIcon">
|
|
64
|
+
<u-icon
|
|
65
|
+
:name="suffixIcon"
|
|
66
|
+
:customStyle="$u.addStyle(iconStyle)"
|
|
67
|
+
></u-icon>
|
|
68
|
+
</view>
|
|
69
|
+
</view>
|
|
70
|
+
</template>
|
|
71
|
+
|
|
72
|
+
<script>
|
|
73
|
+
import value from './value.js'
|
|
74
|
+
import button from '../../libs/mixin/button.js'
|
|
75
|
+
import openType from '../../libs/mixin/openType.js'
|
|
76
|
+
import props from './props.js'
|
|
77
|
+
/**
|
|
78
|
+
* Text 文本
|
|
79
|
+
* @description 此组件集成了文本类在项目中的常用功能,包括状态,拨打电话,格式化日期,*替换,超链接...等功能。 您大可不必在使用特殊文本时自己定义,text组件几乎涵盖您能使用的大部分场景。
|
|
80
|
+
* @tutorial https://www.uviewui.com/components/loading.html
|
|
81
|
+
* @property {String} type 主题颜色
|
|
82
|
+
* @property {Boolean} show 是否显示(默认 true )
|
|
83
|
+
* @property {String | Number} text 显示的值
|
|
84
|
+
* @property {String} prefixIcon 前置图标
|
|
85
|
+
* @property {String} suffixIcon 后置图标
|
|
86
|
+
* @property {String} mode 文本处理的匹配模式 text-普通文本,price-价格,phone-手机号,name-姓名,date-日期,link-超链接
|
|
87
|
+
* @property {String} href mode=link下,配置的链接
|
|
88
|
+
* @property {String | Function} format 格式化规则
|
|
89
|
+
* @property {Boolean} call mode=phone时,点击文本是否拨打电话(默认 false )
|
|
90
|
+
* @property {String} openType 小程序的打开方式
|
|
91
|
+
* @property {Boolean} bold 是否粗体,默认normal(默认 false )
|
|
92
|
+
* @property {Boolean} block 是否块状(默认 false )
|
|
93
|
+
* @property {String | Number} lines 文本显示的行数,如果设置,超出此行数,将会显示省略号
|
|
94
|
+
* @property {String} color 文本颜色(默认 '#303133' )
|
|
95
|
+
* @property {String | Number} size 字体大小(默认 15 )
|
|
96
|
+
* @property {Object | String} iconStyle 图标的样式 (默认 {fontSize: '15px'} )
|
|
97
|
+
* @property {String} decoration 文字装饰,下划线,中划线等,可选值 none|underline|line-through(默认 'none' )
|
|
98
|
+
* @property {Object | String | Number} margin 外边距,对象、字符串,数值形式均可(默认 0 )
|
|
99
|
+
* @property {String | Number} lineHeight 文本行高
|
|
100
|
+
* @property {String} align 文本对齐方式,可选值left|center|right(默认 'left' )
|
|
101
|
+
* @property {String} wordWrap 文字换行,可选值break-word|normal|anywhere(默认 'normal' )
|
|
102
|
+
* @event {Function} click 点击触发事件
|
|
103
|
+
* @example <u--text text="我用十年青春,赴你最后之约"></u--text>
|
|
104
|
+
*/
|
|
105
|
+
export default {
|
|
106
|
+
name: 'u--text',
|
|
107
|
+
// #ifdef MP
|
|
108
|
+
mixins: [uni.$u.mpMixin, uni.$u.mixin, value, button, openType, props],
|
|
109
|
+
// #endif
|
|
110
|
+
// #ifndef MP
|
|
111
|
+
mixins: [uni.$u.mpMixin, uni.$u.mixin, value, props],
|
|
112
|
+
// #endif
|
|
113
|
+
computed: {
|
|
114
|
+
valueStyle() {
|
|
115
|
+
const style = {
|
|
116
|
+
textDecoration: this.decoration,
|
|
117
|
+
fontWeight: this.bold ? 'bold' : 'normal',
|
|
118
|
+
wordWrap: this.wordWrap,
|
|
119
|
+
fontSize: uni.$u.addUnit(this.size)
|
|
120
|
+
}
|
|
121
|
+
!this.type && (style.color = this.color)
|
|
122
|
+
this.isNvue && this.lines && (style.lines = this.lines)
|
|
123
|
+
this.lineHeight &&
|
|
124
|
+
(style.lineHeight = uni.$u.addUnit(this.lineHeight))
|
|
125
|
+
!this.isNvue && this.block && (style.display = 'block')
|
|
126
|
+
return uni.$u.deepMerge(style, uni.$u.addStyle(this.customStyle))
|
|
127
|
+
},
|
|
128
|
+
isNvue() {
|
|
129
|
+
let nvue = false
|
|
130
|
+
// #ifdef APP-NVUE
|
|
131
|
+
nvue = true
|
|
132
|
+
// #endif
|
|
133
|
+
return nvue
|
|
134
|
+
},
|
|
135
|
+
isMp() {
|
|
136
|
+
let mp = false
|
|
137
|
+
// #ifdef MP
|
|
138
|
+
mp = true
|
|
139
|
+
// #endif
|
|
140
|
+
return mp
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
data() {
|
|
144
|
+
return {}
|
|
145
|
+
},
|
|
146
|
+
methods: {
|
|
147
|
+
clickHandler() {
|
|
148
|
+
// 如果为手机号模式,拨打电话
|
|
149
|
+
if (this.call && this.mode === 'phone') {
|
|
150
|
+
uni.makePhoneCall({
|
|
151
|
+
phoneNumber: this.text
|
|
152
|
+
})
|
|
153
|
+
}
|
|
154
|
+
this.$emit('click')
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
</script>
|
|
159
|
+
|
|
160
|
+
<style lang="scss" scoped>
|
|
161
|
+
@import '../../libs/css/components.scss';
|
|
162
|
+
|
|
163
|
+
.u-text {
|
|
164
|
+
@include flex(row);
|
|
165
|
+
align-items: center;
|
|
166
|
+
flex-wrap: nowrap;
|
|
167
|
+
flex: 1;
|
|
168
|
+
/* #ifndef APP-NVUE */
|
|
169
|
+
width: 100%;
|
|
170
|
+
/* #endif */
|
|
171
|
+
|
|
172
|
+
&__price {
|
|
173
|
+
font-size: 14px;
|
|
174
|
+
color: $u-content-color;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
&__value {
|
|
178
|
+
font-size: 14px;
|
|
179
|
+
@include flex;
|
|
180
|
+
color: $u-content-color;
|
|
181
|
+
flex-wrap: wrap;
|
|
182
|
+
// flex: 1;
|
|
183
|
+
text-overflow: ellipsis;
|
|
184
|
+
align-items: center;
|
|
185
|
+
|
|
186
|
+
&--primary {
|
|
187
|
+
color: $u-primary;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
&--warning {
|
|
191
|
+
color: $u-warning;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
&--success {
|
|
195
|
+
color: $u-success;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
&--info {
|
|
199
|
+
color: $u-info;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
&--error {
|
|
203
|
+
color: $u-error;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
&--main {
|
|
207
|
+
color: $u-main-color;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
&--content {
|
|
211
|
+
color: $u-content-color;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
&--tips {
|
|
215
|
+
color: $u-tips-color;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
&--light {
|
|
219
|
+
color: $u-light-color;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
</style>
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
computed: {
|
|
3
|
+
// 经处理后需要显示的值
|
|
4
|
+
value() {
|
|
5
|
+
const {
|
|
6
|
+
text,
|
|
7
|
+
mode,
|
|
8
|
+
format,
|
|
9
|
+
href
|
|
10
|
+
} = this
|
|
11
|
+
// 价格类型
|
|
12
|
+
if (mode === 'price') {
|
|
13
|
+
// 如果text不为金额进行提示
|
|
14
|
+
if (!/^\d+(\.\d+)?$/.test(text)) {
|
|
15
|
+
uni.$u.error('金额模式下,text参数需要为金额格式');
|
|
16
|
+
}
|
|
17
|
+
// 进行格式化,判断用户传入的format参数为正则,或者函数,如果没有传入format,则使用默认的金额格式化处理
|
|
18
|
+
if (uni.$u.test.func(format)) {
|
|
19
|
+
// 如果用户传入的是函数,使用函数格式化
|
|
20
|
+
return format(text)
|
|
21
|
+
}
|
|
22
|
+
// 如果format非正则,非函数,则使用默认的金额格式化方法进行操作
|
|
23
|
+
return uni.$u.priceFormat(text, 2)
|
|
24
|
+
} if (mode === 'date') {
|
|
25
|
+
// 判断是否合法的日期或者时间戳
|
|
26
|
+
!uni.$u.test.date(text) && uni.$u.error('日期模式下,text参数需要为日期或时间戳格式')
|
|
27
|
+
// 进行格式化,判断用户传入的format参数为正则,或者函数,如果没有传入format,则使用默认的格式化处理
|
|
28
|
+
if (uni.$u.test.func(format)) {
|
|
29
|
+
// 如果用户传入的是函数,使用函数格式化
|
|
30
|
+
return format(text)
|
|
31
|
+
} if (format) {
|
|
32
|
+
// 如果format非正则,非函数,则使用默认的时间格式化方法进行操作
|
|
33
|
+
return uni.$u.timeFormat(text, format)
|
|
34
|
+
}
|
|
35
|
+
// 如果没有设置format,则设置为默认的时间格式化形式
|
|
36
|
+
return uni.$u.timeFormat(text, 'yyyy-mm-dd')
|
|
37
|
+
} if (mode === 'phone') {
|
|
38
|
+
// 判断是否合法的手机号
|
|
39
|
+
// !uni.$u.test.mobile(text) && uni.$u.error('手机号模式下,text参数需要为手机号码格式')
|
|
40
|
+
if (uni.$u.test.func(format)) {
|
|
41
|
+
// 如果用户传入的是函数,使用函数格式化
|
|
42
|
+
return format(text)
|
|
43
|
+
} if (format === 'encrypt') {
|
|
44
|
+
// 如果format为encrypt,则将手机号进行星号加密处理
|
|
45
|
+
return `${text.substr(0, 3)}****${text.substr(7)}`
|
|
46
|
+
}
|
|
47
|
+
return text
|
|
48
|
+
} if (mode === 'name') {
|
|
49
|
+
// 判断是否合法的字符粗
|
|
50
|
+
!(typeof (text) === 'string') && uni.$u.error('姓名模式下,text参数需要为字符串格式')
|
|
51
|
+
if (uni.$u.test.func(format)) {
|
|
52
|
+
// 如果用户传入的是函数,使用函数格式化
|
|
53
|
+
return format(text)
|
|
54
|
+
} if (format === 'encrypt') {
|
|
55
|
+
// 如果format为encrypt,则将姓名进行星号加密处理
|
|
56
|
+
return this.formatName(text)
|
|
57
|
+
}
|
|
58
|
+
return text
|
|
59
|
+
} if (mode === 'link') {
|
|
60
|
+
// 判断是否合法的字符粗
|
|
61
|
+
!uni.$u.test.url(href) && uni.$u.error('超链接模式下,href参数需要为URL格式')
|
|
62
|
+
return text
|
|
63
|
+
}
|
|
64
|
+
return text
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
methods: {
|
|
68
|
+
// 默认的姓名脱敏规则
|
|
69
|
+
formatName(name) {
|
|
70
|
+
let value = ''
|
|
71
|
+
if (name.length === 2) {
|
|
72
|
+
value = name.substr(0, 1) + '*'
|
|
73
|
+
} else if (name.length > 2) {
|
|
74
|
+
let char = ''
|
|
75
|
+
for (let i = 0, len = name.length - 2; i < len; i++) {
|
|
76
|
+
char += '*'
|
|
77
|
+
}
|
|
78
|
+
value = name.substr(0, 1) + char + name.substr(-1, 1)
|
|
79
|
+
} else {
|
|
80
|
+
value = name
|
|
81
|
+
}
|
|
82
|
+
return value
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
// 输入框的内容
|
|
4
|
+
value: {
|
|
5
|
+
type: [String, Number],
|
|
6
|
+
default: uni.$u.props.textarea.value
|
|
7
|
+
},
|
|
8
|
+
// 输入框为空时占位符
|
|
9
|
+
placeholder: {
|
|
10
|
+
type: [String, Number],
|
|
11
|
+
default: uni.$u.props.textarea.placeholder
|
|
12
|
+
},
|
|
13
|
+
// 指定placeholder的样式类,注意页面或组件的style中写了scoped时,需要在类名前写/deep/
|
|
14
|
+
placeholderClass: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: uni.$u.props.input.placeholderClass
|
|
17
|
+
},
|
|
18
|
+
// 指定placeholder的样式
|
|
19
|
+
placeholderStyle: {
|
|
20
|
+
type: [String, Object],
|
|
21
|
+
default: uni.$u.props.input.placeholderStyle
|
|
22
|
+
},
|
|
23
|
+
// 输入框高度
|
|
24
|
+
height: {
|
|
25
|
+
type: [String, Number],
|
|
26
|
+
default: uni.$u.props.textarea.height
|
|
27
|
+
},
|
|
28
|
+
// 设置键盘右下角按钮的文字,仅微信小程序,App-vue和H5有效
|
|
29
|
+
confirmType: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: uni.$u.props.textarea.confirmType
|
|
32
|
+
},
|
|
33
|
+
// 是否禁用
|
|
34
|
+
disabled: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: uni.$u.props.textarea.disabled
|
|
37
|
+
},
|
|
38
|
+
// 是否显示统计字数
|
|
39
|
+
count: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: uni.$u.props.textarea.count
|
|
42
|
+
},
|
|
43
|
+
// 是否自动获取焦点,nvue不支持,H5取决于浏览器的实现
|
|
44
|
+
focus: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: uni.$u.props.textarea.focus
|
|
47
|
+
},
|
|
48
|
+
// 是否自动增加高度
|
|
49
|
+
autoHeight: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
default: uni.$u.props.textarea.autoHeight
|
|
52
|
+
},
|
|
53
|
+
// 如果textarea是在一个position:fixed的区域,需要显示指定属性fixed为true
|
|
54
|
+
fixed: {
|
|
55
|
+
type: Boolean,
|
|
56
|
+
default: uni.$u.props.textarea.fixed
|
|
57
|
+
},
|
|
58
|
+
// 指定光标与键盘的距离
|
|
59
|
+
cursorSpacing: {
|
|
60
|
+
type: Number,
|
|
61
|
+
default: uni.$u.props.textarea.cursorSpacing
|
|
62
|
+
},
|
|
63
|
+
// 指定focus时的光标位置
|
|
64
|
+
cursor: {
|
|
65
|
+
type: [String, Number],
|
|
66
|
+
default: uni.$u.props.textarea.cursor
|
|
67
|
+
},
|
|
68
|
+
// 是否显示键盘上方带有”完成“按钮那一栏,
|
|
69
|
+
showConfirmBar: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
default: uni.$u.props.textarea.showConfirmBar
|
|
72
|
+
},
|
|
73
|
+
// 光标起始位置,自动聚焦时有效,需与selection-end搭配使用
|
|
74
|
+
selectionStart: {
|
|
75
|
+
type: Number,
|
|
76
|
+
default: uni.$u.props.textarea.selectionStart
|
|
77
|
+
},
|
|
78
|
+
// 光标结束位置,自动聚焦时有效,需与selection-start搭配使用
|
|
79
|
+
selectionEnd: {
|
|
80
|
+
type: Number,
|
|
81
|
+
default: uni.$u.props.textarea.selectionEnd
|
|
82
|
+
},
|
|
83
|
+
// 键盘弹起时,是否自动上推页面
|
|
84
|
+
adjustPosition: {
|
|
85
|
+
type: Boolean,
|
|
86
|
+
default: uni.$u.props.textarea.adjustPosition
|
|
87
|
+
},
|
|
88
|
+
// 是否去掉 iOS 下的默认内边距,只微信小程序有效
|
|
89
|
+
disableDefaultPadding: {
|
|
90
|
+
type: Boolean,
|
|
91
|
+
default: uni.$u.props.textarea.disableDefaultPadding
|
|
92
|
+
},
|
|
93
|
+
// focus时,点击页面的时候不收起键盘,只微信小程序有效
|
|
94
|
+
holdKeyboard: {
|
|
95
|
+
type: Boolean,
|
|
96
|
+
default: uni.$u.props.textarea.holdKeyboard
|
|
97
|
+
},
|
|
98
|
+
// 最大输入长度,设置为 -1 的时候不限制最大长度
|
|
99
|
+
maxlength: {
|
|
100
|
+
type: [String, Number],
|
|
101
|
+
default: uni.$u.props.textarea.maxlength
|
|
102
|
+
},
|
|
103
|
+
// 边框类型,surround-四周边框,bottom-底部边框
|
|
104
|
+
border: {
|
|
105
|
+
type: String,
|
|
106
|
+
default: uni.$u.props.textarea.border
|
|
107
|
+
},
|
|
108
|
+
// 用于处理或者过滤输入框内容的方法
|
|
109
|
+
formatter: {
|
|
110
|
+
type: [Function, null],
|
|
111
|
+
default: uni.$u.props.textarea.formatter
|
|
112
|
+
},
|
|
113
|
+
// 是否忽略组件内对文本合成系统事件的处理
|
|
114
|
+
ignoreCompositionEvent: {
|
|
115
|
+
type: Boolean,
|
|
116
|
+
default: true
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="u-textarea" :class="textareaClass" :style="[textareaStyle]">
|
|
3
|
+
<textarea
|
|
4
|
+
class="u-textarea__field"
|
|
5
|
+
:value="innerValue"
|
|
6
|
+
:style="{ height: $u.addUnit(height) }"
|
|
7
|
+
:placeholder="placeholder"
|
|
8
|
+
:placeholder-style="$u.addStyle(placeholderStyle, 'string')"
|
|
9
|
+
:placeholder-class="placeholderClass"
|
|
10
|
+
:disabled="disabled"
|
|
11
|
+
:focus="focus"
|
|
12
|
+
:autoHeight="autoHeight"
|
|
13
|
+
:fixed="fixed"
|
|
14
|
+
:cursorSpacing="cursorSpacing"
|
|
15
|
+
:cursor="cursor"
|
|
16
|
+
:showConfirmBar="showConfirmBar"
|
|
17
|
+
:selectionStart="selectionStart"
|
|
18
|
+
:selectionEnd="selectionEnd"
|
|
19
|
+
:adjustPosition="adjustPosition"
|
|
20
|
+
:disableDefaultPadding="disableDefaultPadding"
|
|
21
|
+
:holdKeyboard="holdKeyboard"
|
|
22
|
+
:maxlength="maxlength"
|
|
23
|
+
:confirmType="confirmType"
|
|
24
|
+
:ignoreCompositionEvent="ignoreCompositionEvent"
|
|
25
|
+
@focus="onFocus"
|
|
26
|
+
@blur="onBlur"
|
|
27
|
+
@linechange="onLinechange"
|
|
28
|
+
@input="onInput"
|
|
29
|
+
@confirm="onConfirm"
|
|
30
|
+
@keyboardheightchange="onKeyboardheightchange"
|
|
31
|
+
></textarea>
|
|
32
|
+
<text
|
|
33
|
+
class="u-textarea__count"
|
|
34
|
+
:style="{
|
|
35
|
+
'background-color': disabled ? 'transparent' : '#fff',
|
|
36
|
+
}"
|
|
37
|
+
v-if="count"
|
|
38
|
+
>{{ innerValue.length }}/{{ maxlength }}</text
|
|
39
|
+
>
|
|
40
|
+
</view>
|
|
41
|
+
</template>
|
|
42
|
+
|
|
43
|
+
<script>
|
|
44
|
+
import props from "./props.js";
|
|
45
|
+
/**
|
|
46
|
+
* Textarea 文本域
|
|
47
|
+
* @description 文本域此组件满足了可能出现的表单信息补充,编辑等实际逻辑的功能,内置了字数校验等
|
|
48
|
+
* @tutorial https://www.uviewui.com/components/textarea.html
|
|
49
|
+
*
|
|
50
|
+
* @property {String | Number} value 输入框的内容
|
|
51
|
+
* @property {String | Number} placeholder 输入框为空时占位符
|
|
52
|
+
* @property {String} placeholderClass 指定placeholder的样式类,注意页面或组件的style中写了scoped时,需要在类名前写/deep/ ( 默认 'input-placeholder' )
|
|
53
|
+
* @property {String | Object} placeholderStyle 指定placeholder的样式,字符串/对象形式,如"color: red;"
|
|
54
|
+
* @property {String | Number} height 输入框高度(默认 70 )
|
|
55
|
+
* @property {String} confirmType 设置键盘右下角按钮的文字,仅微信小程序,App-vue和H5有效(默认 'done' )
|
|
56
|
+
* @property {Boolean} disabled 是否禁用(默认 false )
|
|
57
|
+
* @property {Boolean} count 是否显示统计字数(默认 false )
|
|
58
|
+
* @property {Boolean} focus 是否自动获取焦点,nvue不支持,H5取决于浏览器的实现(默认 false )
|
|
59
|
+
* @property {Boolean | Function} autoHeight 是否自动增加高度(默认 false )
|
|
60
|
+
* @property {Boolean} fixed 如果textarea是在一个position:fixed的区域,需要显示指定属性fixed为true(默认 false )
|
|
61
|
+
* @property {Number} cursorSpacing 指定光标与键盘的距离(默认 0 )
|
|
62
|
+
* @property {String | Number} cursor 指定focus时的光标位置
|
|
63
|
+
* @property {Function} formatter 内容式化函数
|
|
64
|
+
* @property {Boolean} showConfirmBar 是否显示键盘上方带有”完成“按钮那一栏,(默认 true )
|
|
65
|
+
* @property {Number} selectionStart 光标起始位置,自动聚焦时有效,需与selection-end搭配使用,(默认 -1 )
|
|
66
|
+
* @property {Number | Number} selectionEnd 光标结束位置,自动聚焦时有效,需与selection-start搭配使用(默认 -1 )
|
|
67
|
+
* @property {Boolean} adjustPosition 键盘弹起时,是否自动上推页面(默认 true )
|
|
68
|
+
* @property {Boolean | Number} disableDefaultPadding 是否去掉 iOS 下的默认内边距,只微信小程序有效(默认 false )
|
|
69
|
+
* @property {Boolean} holdKeyboard focus时,点击页面的时候不收起键盘,只微信小程序有效(默认 false )
|
|
70
|
+
* @property {String | Number} maxlength 最大输入长度,设置为 -1 的时候不限制最大长度(默认 140 )
|
|
71
|
+
* @property {String} border 边框类型,surround-四周边框,none-无边框,bottom-底部边框(默认 'surround' )
|
|
72
|
+
* @property {Boolean} ignoreCompositionEvent 是否忽略组件内对文本合成系统事件的处理
|
|
73
|
+
*
|
|
74
|
+
* @event {Function(e)} focus 输入框聚焦时触发,event.detail = { value, height },height 为键盘高度
|
|
75
|
+
* @event {Function(e)} blur 输入框失去焦点时触发,event.detail = {value, cursor}
|
|
76
|
+
* @event {Function(e)} linechange 输入框行数变化时调用,event.detail = {height: 0, heightRpx: 0, lineCount: 0}
|
|
77
|
+
* @event {Function(e)} input 当键盘输入时,触发 input 事件
|
|
78
|
+
* @event {Function(e)} confirm 点击完成时, 触发 confirm 事件
|
|
79
|
+
* @event {Function(e)} keyboardheightchange 键盘高度发生变化的时候触发此事件
|
|
80
|
+
* @example <u--textarea v-model="value1" placeholder="请输入内容" ></u--textarea>
|
|
81
|
+
*/
|
|
82
|
+
export default {
|
|
83
|
+
name: "u-textarea",
|
|
84
|
+
mixins: [uni.$u.mpMixin, uni.$u.mixin, props],
|
|
85
|
+
data() {
|
|
86
|
+
return {
|
|
87
|
+
// 输入框的值
|
|
88
|
+
innerValue: "",
|
|
89
|
+
// 是否处于获得焦点状态
|
|
90
|
+
focused: false,
|
|
91
|
+
// value是否第一次变化,在watch中,由于加入immediate属性,会在第一次触发,此时不应该认为value发生了变化
|
|
92
|
+
firstChange: true,
|
|
93
|
+
// value绑定值的变化是由内部还是外部引起的
|
|
94
|
+
changeFromInner: false,
|
|
95
|
+
// 过滤处理方法
|
|
96
|
+
innerFormatter: value => value
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
watch: {
|
|
100
|
+
value: {
|
|
101
|
+
immediate: true,
|
|
102
|
+
handler(newVal, oldVal) {
|
|
103
|
+
this.innerValue = newVal;
|
|
104
|
+
/* #ifdef H5 */
|
|
105
|
+
// 在H5中,外部value变化后,修改input中的值,不会触发@input事件,此时手动调用值变化方法
|
|
106
|
+
if (
|
|
107
|
+
this.firstChange === false &&
|
|
108
|
+
this.changeFromInner === false
|
|
109
|
+
) {
|
|
110
|
+
this.valueChange();
|
|
111
|
+
}
|
|
112
|
+
/* #endif */
|
|
113
|
+
this.firstChange = false;
|
|
114
|
+
// 重置changeFromInner的值为false,标识下一次引起默认为外部引起的
|
|
115
|
+
this.changeFromInner = false;
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
computed: {
|
|
120
|
+
// 组件的类名
|
|
121
|
+
textareaClass() {
|
|
122
|
+
let classes = [],
|
|
123
|
+
{ border, disabled, shape } = this;
|
|
124
|
+
border === "surround" &&
|
|
125
|
+
(classes = classes.concat(["u-border", "u-textarea--radius"]));
|
|
126
|
+
border === "bottom" &&
|
|
127
|
+
(classes = classes.concat([
|
|
128
|
+
"u-border-bottom",
|
|
129
|
+
"u-textarea--no-radius",
|
|
130
|
+
]));
|
|
131
|
+
disabled && classes.push("u-textarea--disabled");
|
|
132
|
+
return classes.join(" ");
|
|
133
|
+
},
|
|
134
|
+
// 组件的样式
|
|
135
|
+
textareaStyle() {
|
|
136
|
+
const style = {};
|
|
137
|
+
// #ifdef APP-NVUE
|
|
138
|
+
// 由于textarea在安卓nvue上的差异性,需要额外再调整其内边距
|
|
139
|
+
if (uni.$u.os() === "android") {
|
|
140
|
+
style.paddingTop = "6px";
|
|
141
|
+
style.paddingLeft = "9px";
|
|
142
|
+
style.paddingBottom = "3px";
|
|
143
|
+
style.paddingRight = "6px";
|
|
144
|
+
}
|
|
145
|
+
// #endif
|
|
146
|
+
return uni.$u.deepMerge(style, uni.$u.addStyle(this.customStyle));
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
methods: {
|
|
150
|
+
// 在微信小程序中,不支持将函数当做props参数,故只能通过ref形式调用
|
|
151
|
+
setFormatter(e) {
|
|
152
|
+
this.innerFormatter = e
|
|
153
|
+
},
|
|
154
|
+
onFocus(e) {
|
|
155
|
+
this.$emit("focus", e);
|
|
156
|
+
},
|
|
157
|
+
onBlur(e) {
|
|
158
|
+
this.$emit("blur", e);
|
|
159
|
+
// 尝试调用u-form的验证方法
|
|
160
|
+
uni.$u.formValidate(this, "blur");
|
|
161
|
+
},
|
|
162
|
+
onLinechange(e) {
|
|
163
|
+
this.$emit("linechange", e);
|
|
164
|
+
},
|
|
165
|
+
onInput(e) {
|
|
166
|
+
let { value = "" } = e.detail || {};
|
|
167
|
+
// 格式化过滤方法
|
|
168
|
+
const formatter = this.formatter || this.innerFormatter
|
|
169
|
+
const formatValue = formatter(value)
|
|
170
|
+
// 为了避免props的单向数据流特性,需要先将innerValue值设置为当前值,再在$nextTick中重新赋予设置后的值才有效
|
|
171
|
+
this.innerValue = value
|
|
172
|
+
this.$nextTick(() => {
|
|
173
|
+
this.innerValue = formatValue;
|
|
174
|
+
this.valueChange();
|
|
175
|
+
})
|
|
176
|
+
},
|
|
177
|
+
// 内容发生变化,进行处理
|
|
178
|
+
valueChange() {
|
|
179
|
+
const value = this.innerValue;
|
|
180
|
+
this.$nextTick(() => {
|
|
181
|
+
this.$emit("input", value);
|
|
182
|
+
// 标识value值的变化是由内部引起的
|
|
183
|
+
this.changeFromInner = true;
|
|
184
|
+
this.$emit("change", value);
|
|
185
|
+
// 尝试调用u-form的验证方法
|
|
186
|
+
uni.$u.formValidate(this, "change");
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
onConfirm(e) {
|
|
190
|
+
this.$emit("confirm", e);
|
|
191
|
+
},
|
|
192
|
+
onKeyboardheightchange(e) {
|
|
193
|
+
this.$emit("keyboardheightchange", e);
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
};
|
|
197
|
+
</script>
|
|
198
|
+
|
|
199
|
+
<style lang="scss" scoped>
|
|
200
|
+
@import "../../libs/css/components.scss";
|
|
201
|
+
|
|
202
|
+
.u-textarea {
|
|
203
|
+
border-radius: 4px;
|
|
204
|
+
background-color: #fff;
|
|
205
|
+
position: relative;
|
|
206
|
+
@include flex;
|
|
207
|
+
flex: 1;
|
|
208
|
+
padding: 9px;
|
|
209
|
+
|
|
210
|
+
&--radius {
|
|
211
|
+
border-radius: 4px;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
&--no-radius {
|
|
215
|
+
border-radius: 0;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
&--disabled {
|
|
219
|
+
background-color: #f5f7fa;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
&__field {
|
|
223
|
+
flex: 1;
|
|
224
|
+
font-size: 15px;
|
|
225
|
+
color: $u-content-color;
|
|
226
|
+
width: 100%;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
&__count {
|
|
230
|
+
position: absolute;
|
|
231
|
+
right: 5px;
|
|
232
|
+
bottom: 2px;
|
|
233
|
+
font-size: 12px;
|
|
234
|
+
color: $u-tips-color;
|
|
235
|
+
background-color: #ffffff;
|
|
236
|
+
padding: 1px 4px;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
</style>
|