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,45 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
// #ifdef APP-PLUS-NVUE
|
|
4
|
+
bgColor: String,
|
|
5
|
+
// #endif
|
|
6
|
+
content: String,
|
|
7
|
+
copyLink: {
|
|
8
|
+
type: Boolean,
|
|
9
|
+
default: uni.$u.props.parse.copyLink
|
|
10
|
+
},
|
|
11
|
+
domain: String,
|
|
12
|
+
errorImg: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: uni.$u.props.parse.errorImg
|
|
15
|
+
},
|
|
16
|
+
lazyLoad: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
default: uni.$u.props.parse.lazyLoad
|
|
19
|
+
},
|
|
20
|
+
loadingImg: {
|
|
21
|
+
type: String,
|
|
22
|
+
default: uni.$u.props.parse.loadingImg
|
|
23
|
+
},
|
|
24
|
+
pauseVideo: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: uni.$u.props.parse.pauseVideo
|
|
27
|
+
},
|
|
28
|
+
previewImg: {
|
|
29
|
+
type: Boolean,
|
|
30
|
+
default: uni.$u.props.parse.previewImg
|
|
31
|
+
},
|
|
32
|
+
scrollTable: Boolean,
|
|
33
|
+
selectable: Boolean,
|
|
34
|
+
setTitle: {
|
|
35
|
+
type: Boolean,
|
|
36
|
+
default: uni.$u.props.parse.setTitle
|
|
37
|
+
},
|
|
38
|
+
showImgMenu: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: uni.$u.props.parse.showImgMenu
|
|
41
|
+
},
|
|
42
|
+
tagStyle: Object,
|
|
43
|
+
useAnchor: null
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view id="_root" :class="(selectable?'_select ':'')+'_root'">
|
|
3
|
+
<slot v-if="!nodes[0]" />
|
|
4
|
+
<!-- #ifndef APP-PLUS-NVUE -->
|
|
5
|
+
<node v-else :childs="nodes" :opts="[lazyLoad,loadingImg,errorImg,showImgMenu]" />
|
|
6
|
+
<!-- #endif -->
|
|
7
|
+
<!-- #ifdef APP-PLUS-NVUE -->
|
|
8
|
+
<web-view ref="web" src="/static/app-plus/mp-html/local.html" :style="'margin-top:-2px;height:' + height + 'px'" @onPostMessage="_onMessage" />
|
|
9
|
+
<!-- #endif -->
|
|
10
|
+
</view>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script>
|
|
14
|
+
import props from './props.js';
|
|
15
|
+
/**
|
|
16
|
+
* mp-html v2.0.4
|
|
17
|
+
* @description 富文本组件
|
|
18
|
+
* @tutorial https://github.com/jin-yufeng/mp-html
|
|
19
|
+
* @property {String} bgColor 背景颜色,只适用与APP-PLUS-NVUE
|
|
20
|
+
* @property {String} content 用于渲染的富文本字符串(默认 true )
|
|
21
|
+
* @property {Boolean} copyLink 是否允许外部链接被点击时自动复制
|
|
22
|
+
* @property {String} domain 主域名,用于拼接链接
|
|
23
|
+
* @property {String} errorImg 图片出错时的占位图链接
|
|
24
|
+
* @property {Boolean} lazyLoad 是否开启图片懒加载(默认 true )
|
|
25
|
+
* @property {string} loadingImg 图片加载过程中的占位图链接
|
|
26
|
+
* @property {Boolean} pauseVideo 是否在播放一个视频时自动暂停其它视频(默认 true )
|
|
27
|
+
* @property {Boolean} previewImg 是否允许图片被点击时自动预览(默认 true )
|
|
28
|
+
* @property {Boolean} scrollTable 是否给每个表格添加一个滚动层使其能单独横向滚动
|
|
29
|
+
* @property {Boolean} selectable 是否开启长按复制
|
|
30
|
+
* @property {Boolean} setTitle 是否将 title 标签的内容设置到页面标题(默认 true )
|
|
31
|
+
* @property {Boolean} showImgMenu 是否允许图片被长按时显示菜单(默认 true )
|
|
32
|
+
* @property {Object} tagStyle 标签的默认样式
|
|
33
|
+
* @property {Boolean | Number} useAnchor 是否使用锚点链接
|
|
34
|
+
*
|
|
35
|
+
* @event {Function} load dom 结构加载完毕时触发
|
|
36
|
+
* @event {Function} ready 所有图片加载完毕时触发
|
|
37
|
+
* @event {Function} imgTap 图片被点击时触发
|
|
38
|
+
* @event {Function} linkTap 链接被点击时触发
|
|
39
|
+
* @event {Function} error 媒体加载出错时触发
|
|
40
|
+
*/
|
|
41
|
+
const plugins=[]
|
|
42
|
+
const parser = require('./parser')
|
|
43
|
+
// #ifndef APP-PLUS-NVUE
|
|
44
|
+
import node from './node/node'
|
|
45
|
+
// #endif
|
|
46
|
+
// #ifdef APP-PLUS-NVUE
|
|
47
|
+
const dom = weex.requireModule('dom')
|
|
48
|
+
// #endif
|
|
49
|
+
export default {
|
|
50
|
+
name: 'mp-html',
|
|
51
|
+
data() {
|
|
52
|
+
return {
|
|
53
|
+
nodes: [],
|
|
54
|
+
// #ifdef APP-PLUS-NVUE
|
|
55
|
+
height: 0
|
|
56
|
+
// #endif
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
mixins:[props],
|
|
60
|
+
// #ifndef APP-PLUS-NVUE
|
|
61
|
+
components: {
|
|
62
|
+
node
|
|
63
|
+
},
|
|
64
|
+
// #endif
|
|
65
|
+
watch: {
|
|
66
|
+
content(content) {
|
|
67
|
+
this.setContent(content)
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
created() {
|
|
71
|
+
this.plugins = []
|
|
72
|
+
for (let i = plugins.length; i--;)
|
|
73
|
+
this.plugins.push(new plugins[i](this))
|
|
74
|
+
},
|
|
75
|
+
mounted() {
|
|
76
|
+
if (this.content && !this.nodes.length)
|
|
77
|
+
this.setContent(this.content)
|
|
78
|
+
},
|
|
79
|
+
beforeDestroy() {
|
|
80
|
+
this._hook('onDetached')
|
|
81
|
+
clearInterval(this._timer)
|
|
82
|
+
},
|
|
83
|
+
methods: {
|
|
84
|
+
/**
|
|
85
|
+
* @description 将锚点跳转的范围限定在一个 scroll-view 内
|
|
86
|
+
* @param {Object} page scroll-view 所在页面的示例
|
|
87
|
+
* @param {String} selector scroll-view 的选择器
|
|
88
|
+
* @param {String} scrollTop scroll-view scroll-top 属性绑定的变量名
|
|
89
|
+
*/
|
|
90
|
+
in(page, selector, scrollTop) {
|
|
91
|
+
// #ifndef APP-PLUS-NVUE
|
|
92
|
+
if (page && selector && scrollTop)
|
|
93
|
+
this._in = {
|
|
94
|
+
page,
|
|
95
|
+
selector,
|
|
96
|
+
scrollTop
|
|
97
|
+
}
|
|
98
|
+
// #endif
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @description 锚点跳转
|
|
103
|
+
* @param {String} id 要跳转的锚点 id
|
|
104
|
+
* @param {Number} offset 跳转位置的偏移量
|
|
105
|
+
* @returns {Promise}
|
|
106
|
+
*/
|
|
107
|
+
navigateTo(id, offset) {
|
|
108
|
+
return new Promise((resolve, reject) => {
|
|
109
|
+
if (!this.useAnchor)
|
|
110
|
+
return reject('Anchor is disabled')
|
|
111
|
+
offset = offset || parseInt(this.useAnchor) || 0
|
|
112
|
+
// #ifdef APP-PLUS-NVUE
|
|
113
|
+
if (!id) {
|
|
114
|
+
dom.scrollToElement(this.$refs.web, {
|
|
115
|
+
offset
|
|
116
|
+
})
|
|
117
|
+
resolve()
|
|
118
|
+
} else {
|
|
119
|
+
this._navigateTo = {
|
|
120
|
+
resolve,
|
|
121
|
+
reject,
|
|
122
|
+
offset
|
|
123
|
+
}
|
|
124
|
+
this.$refs.web.evalJs('uni.postMessage({data:{action:"getOffset",offset:(document.getElementById(' + id + ')||{}).offsetTop}})')
|
|
125
|
+
}
|
|
126
|
+
// #endif
|
|
127
|
+
// #ifndef APP-PLUS-NVUE
|
|
128
|
+
let deep = ' '
|
|
129
|
+
// #ifdef MP-WEIXIN || MP-QQ || MP-TOUTIAO
|
|
130
|
+
deep = '>>>'
|
|
131
|
+
// #endif
|
|
132
|
+
const selector = uni.createSelectorQuery()
|
|
133
|
+
// #ifndef MP-ALIPAY
|
|
134
|
+
.in(this._in ? this._in.page : this)
|
|
135
|
+
// #endif
|
|
136
|
+
.select((this._in ? this._in.selector : '._root') + (id ? `${deep}#${id}` : '')).boundingClientRect()
|
|
137
|
+
if (this._in)
|
|
138
|
+
selector.select(this._in.selector).scrollOffset()
|
|
139
|
+
.select(this._in.selector).boundingClientRect() // 获取 scroll-view 的位置和滚动距离
|
|
140
|
+
else
|
|
141
|
+
selector.selectViewport().scrollOffset() // 获取窗口的滚动距离
|
|
142
|
+
selector.exec(res => {
|
|
143
|
+
if (!res[0])
|
|
144
|
+
return reject('Label not found')
|
|
145
|
+
const scrollTop = res[1].scrollTop + res[0].top - (res[2] ? res[2].top : 0) + offset
|
|
146
|
+
if (this._in)
|
|
147
|
+
// scroll-view 跳转
|
|
148
|
+
this._in.page[this._in.scrollTop] = scrollTop
|
|
149
|
+
else
|
|
150
|
+
// 页面跳转
|
|
151
|
+
uni.pageScrollTo({
|
|
152
|
+
scrollTop,
|
|
153
|
+
duration: 300
|
|
154
|
+
})
|
|
155
|
+
resolve()
|
|
156
|
+
})
|
|
157
|
+
// #endif
|
|
158
|
+
})
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @description 获取文本内容
|
|
163
|
+
* @return {String}
|
|
164
|
+
*/
|
|
165
|
+
getText() {
|
|
166
|
+
let text = '';
|
|
167
|
+
(function traversal(nodes) {
|
|
168
|
+
for (let i = 0; i < nodes.length; i++) {
|
|
169
|
+
const node = nodes[i]
|
|
170
|
+
if (node.type == 'text')
|
|
171
|
+
text += node.text.replace(/&/g, '&')
|
|
172
|
+
else if (node.name == 'br')
|
|
173
|
+
text += '\n'
|
|
174
|
+
else {
|
|
175
|
+
// 块级标签前后加换行
|
|
176
|
+
const isBlock = node.name == 'p' || node.name == 'div' || node.name == 'tr' || node.name == 'li' || (node.name[0] == 'h' && node.name[1] > '0' && node.name[1] < '7')
|
|
177
|
+
if (isBlock && text && text[text.length - 1] != '\n')
|
|
178
|
+
text += '\n'
|
|
179
|
+
// 递归获取子节点的文本
|
|
180
|
+
if (node.children)
|
|
181
|
+
traversal(node.children)
|
|
182
|
+
if (isBlock && text[text.length - 1] != '\n')
|
|
183
|
+
text += '\n'
|
|
184
|
+
else if (node.name == 'td' || node.name == 'th')
|
|
185
|
+
text += '\t'
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
})(this.nodes)
|
|
189
|
+
return text
|
|
190
|
+
},
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* @description 获取内容大小和位置
|
|
194
|
+
* @return {Promise}
|
|
195
|
+
*/
|
|
196
|
+
getRect() {
|
|
197
|
+
return new Promise((resolve, reject) => {
|
|
198
|
+
uni.createSelectorQuery()
|
|
199
|
+
// #ifndef MP-ALIPAY
|
|
200
|
+
.in(this)
|
|
201
|
+
// #endif
|
|
202
|
+
.select('#_root').boundingClientRect().exec(res => res[0] ? resolve(res[0]) : reject('Root label not found'))
|
|
203
|
+
})
|
|
204
|
+
},
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* @description 设置内容
|
|
208
|
+
* @param {String} content html 内容
|
|
209
|
+
* @param {Boolean} append 是否在尾部追加
|
|
210
|
+
*/
|
|
211
|
+
setContent(content, append) {
|
|
212
|
+
if (!append || !this.imgList)
|
|
213
|
+
this.imgList = []
|
|
214
|
+
const nodes = new parser(this).parse(content)
|
|
215
|
+
// #ifdef APP-PLUS-NVUE
|
|
216
|
+
if (this._ready)
|
|
217
|
+
this._set(nodes, append)
|
|
218
|
+
// #endif
|
|
219
|
+
this.$set(this, 'nodes', append ? (this.nodes || []).concat(nodes) : nodes)
|
|
220
|
+
|
|
221
|
+
// #ifndef APP-PLUS-NVUE
|
|
222
|
+
this._videos = []
|
|
223
|
+
this.$nextTick(() => {
|
|
224
|
+
this._hook('onLoad')
|
|
225
|
+
this.$emit('load')
|
|
226
|
+
})
|
|
227
|
+
|
|
228
|
+
// 等待图片加载完毕
|
|
229
|
+
let height
|
|
230
|
+
clearInterval(this._timer)
|
|
231
|
+
this._timer = setInterval(() => {
|
|
232
|
+
this.getRect().then(rect => {
|
|
233
|
+
// 350ms 总高度无变化就触发 ready 事件
|
|
234
|
+
if (rect.height == height) {
|
|
235
|
+
this.$emit('ready', rect)
|
|
236
|
+
clearInterval(this._timer)
|
|
237
|
+
}
|
|
238
|
+
height = rect.height
|
|
239
|
+
}).catch(() => { })
|
|
240
|
+
}, 350)
|
|
241
|
+
// #endif
|
|
242
|
+
},
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* @description 调用插件钩子函数
|
|
246
|
+
*/
|
|
247
|
+
_hook(name) {
|
|
248
|
+
for (let i = plugins.length; i--;)
|
|
249
|
+
if (this.plugins[i][name])
|
|
250
|
+
this.plugins[i][name]()
|
|
251
|
+
},
|
|
252
|
+
|
|
253
|
+
// #ifdef APP-PLUS-NVUE
|
|
254
|
+
/**
|
|
255
|
+
* @description 设置内容
|
|
256
|
+
*/
|
|
257
|
+
_set(nodes, append) {
|
|
258
|
+
this.$refs.web.evalJs('setContent(' + JSON.stringify(nodes) + ',' + JSON.stringify([this.bgColor, this.errorImg, this.loadingImg, this.pauseVideo, this.scrollTable, this.selectable]) + ',' + append + ')')
|
|
259
|
+
},
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* @description 接收到 web-view 消息
|
|
263
|
+
*/
|
|
264
|
+
_onMessage(e) {
|
|
265
|
+
const message = e.detail.data[0]
|
|
266
|
+
switch (message.action) {
|
|
267
|
+
// web-view 初始化完毕
|
|
268
|
+
case 'onJSBridgeReady':
|
|
269
|
+
this._ready = true
|
|
270
|
+
if (this.nodes)
|
|
271
|
+
this._set(this.nodes)
|
|
272
|
+
break
|
|
273
|
+
// 内容 dom 加载完毕
|
|
274
|
+
case 'onLoad':
|
|
275
|
+
this.height = message.height
|
|
276
|
+
this._hook('onLoad')
|
|
277
|
+
this.$emit('load')
|
|
278
|
+
break
|
|
279
|
+
// 所有图片加载完毕
|
|
280
|
+
case 'onReady':
|
|
281
|
+
this.getRect().then(res => {
|
|
282
|
+
this.$emit('ready', res)
|
|
283
|
+
}).catch(() => { })
|
|
284
|
+
break
|
|
285
|
+
// 总高度发生变化
|
|
286
|
+
case 'onHeightChange':
|
|
287
|
+
this.height = message.height
|
|
288
|
+
break
|
|
289
|
+
// 图片点击
|
|
290
|
+
case 'onImgTap':
|
|
291
|
+
this.$emit('imgTap', message.attrs)
|
|
292
|
+
if (this.previewImg)
|
|
293
|
+
uni.previewImage({
|
|
294
|
+
current: parseInt(message.attrs.i),
|
|
295
|
+
urls: this.imgList
|
|
296
|
+
})
|
|
297
|
+
break
|
|
298
|
+
// 链接点击
|
|
299
|
+
case 'onLinkTap':
|
|
300
|
+
const href = message.attrs.href
|
|
301
|
+
this.$emit('linkTap', message.attrs)
|
|
302
|
+
if (href) {
|
|
303
|
+
// 锚点跳转
|
|
304
|
+
if (href[0] == '#') {
|
|
305
|
+
if (this.useAnchor)
|
|
306
|
+
dom.scrollToElement(this.$refs.web, {
|
|
307
|
+
offset: message.offset
|
|
308
|
+
})
|
|
309
|
+
}
|
|
310
|
+
// 打开外链
|
|
311
|
+
else if (href.includes('://')) {
|
|
312
|
+
if (this.copyLink)
|
|
313
|
+
plus.runtime.openWeb(href)
|
|
314
|
+
}
|
|
315
|
+
else
|
|
316
|
+
uni.navigateTo({
|
|
317
|
+
url: href,
|
|
318
|
+
fail() {
|
|
319
|
+
wx.switchTab({
|
|
320
|
+
url: href
|
|
321
|
+
})
|
|
322
|
+
}
|
|
323
|
+
})
|
|
324
|
+
}
|
|
325
|
+
break
|
|
326
|
+
// 获取到锚点的偏移量
|
|
327
|
+
case 'getOffset':
|
|
328
|
+
if (typeof message.offset == 'number') {
|
|
329
|
+
dom.scrollToElement(this.$refs.web, {
|
|
330
|
+
offset: message.offset + this._navigateTo.offset
|
|
331
|
+
})
|
|
332
|
+
this._navigateTo.resolve()
|
|
333
|
+
} else
|
|
334
|
+
this._navigateTo.reject('Label not found')
|
|
335
|
+
break
|
|
336
|
+
// 点击
|
|
337
|
+
case 'onClick':
|
|
338
|
+
this.$emit('tap')
|
|
339
|
+
break
|
|
340
|
+
// 出错
|
|
341
|
+
case 'onError':
|
|
342
|
+
this.$emit('error', {
|
|
343
|
+
source: message.source,
|
|
344
|
+
attrs: message.attrs
|
|
345
|
+
})
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
// #endif
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
</script>
|
|
352
|
+
|
|
353
|
+
<style>
|
|
354
|
+
/* #ifndef APP-PLUS-NVUE */
|
|
355
|
+
/* 根节点样式 */
|
|
356
|
+
._root {
|
|
357
|
+
overflow: auto;
|
|
358
|
+
-webkit-overflow-scrolling: touch;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/* 长按复制 */
|
|
362
|
+
._select {
|
|
363
|
+
user-select: text;
|
|
364
|
+
}
|
|
365
|
+
/* #endif */
|
|
366
|
+
</style>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
// 是否展示picker弹窗
|
|
4
|
+
show: {
|
|
5
|
+
type: Boolean,
|
|
6
|
+
default: uni.$u.props.picker.show
|
|
7
|
+
},
|
|
8
|
+
// 是否展示顶部的操作栏
|
|
9
|
+
showToolbar: {
|
|
10
|
+
type: Boolean,
|
|
11
|
+
default: uni.$u.props.picker.showToolbar
|
|
12
|
+
},
|
|
13
|
+
// 顶部标题
|
|
14
|
+
title: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: uni.$u.props.picker.title
|
|
17
|
+
},
|
|
18
|
+
// 对象数组,设置每一列的数据
|
|
19
|
+
columns: {
|
|
20
|
+
type: Array,
|
|
21
|
+
default: uni.$u.props.picker.columns
|
|
22
|
+
},
|
|
23
|
+
// 是否显示加载中状态
|
|
24
|
+
loading: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: uni.$u.props.picker.loading
|
|
27
|
+
},
|
|
28
|
+
// 各列中,单个选项的高度
|
|
29
|
+
itemHeight: {
|
|
30
|
+
type: [String, Number],
|
|
31
|
+
default: uni.$u.props.picker.itemHeight
|
|
32
|
+
},
|
|
33
|
+
// 取消按钮的文字
|
|
34
|
+
cancelText: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: uni.$u.props.picker.cancelText
|
|
37
|
+
},
|
|
38
|
+
// 确认按钮的文字
|
|
39
|
+
confirmText: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: uni.$u.props.picker.confirmText
|
|
42
|
+
},
|
|
43
|
+
// 取消按钮的颜色
|
|
44
|
+
cancelColor: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: uni.$u.props.picker.cancelColor
|
|
47
|
+
},
|
|
48
|
+
// 确认按钮的颜色
|
|
49
|
+
confirmColor: {
|
|
50
|
+
type: String,
|
|
51
|
+
default: uni.$u.props.picker.confirmColor
|
|
52
|
+
},
|
|
53
|
+
// 每列中可见选项的数量
|
|
54
|
+
visibleItemCount: {
|
|
55
|
+
type: [String, Number],
|
|
56
|
+
default: uni.$u.props.picker.visibleItemCount
|
|
57
|
+
},
|
|
58
|
+
// 选项对象中,需要展示的属性键名
|
|
59
|
+
keyName: {
|
|
60
|
+
type: String,
|
|
61
|
+
default: uni.$u.props.picker.keyName
|
|
62
|
+
},
|
|
63
|
+
// 是否允许点击遮罩关闭选择器
|
|
64
|
+
closeOnClickOverlay: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
default: uni.$u.props.picker.closeOnClickOverlay
|
|
67
|
+
},
|
|
68
|
+
// 各列的默认索引
|
|
69
|
+
defaultIndex: {
|
|
70
|
+
type: Array,
|
|
71
|
+
default: uni.$u.props.picker.defaultIndex
|
|
72
|
+
},
|
|
73
|
+
// 是否在手指松开时立即触发 change 事件。若不开启则会在滚动动画结束后触发 change 事件,只在微信2.21.1及以上有效
|
|
74
|
+
immediateChange: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
default: uni.$u.props.picker.immediateChange
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|