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,29 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="u-table">
|
|
3
|
+
|
|
4
|
+
</view>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import props from './props.js';
|
|
9
|
+
/**
|
|
10
|
+
* Table 表格
|
|
11
|
+
* @description 表格组件一般用于展示大量结构化数据的场景 本组件标签类似HTML的table表格,由table、tr、th、td四个组件组成
|
|
12
|
+
* @tutorial https://www.uviewui.com/components/table.html
|
|
13
|
+
* @example <u-table><u-tr><u-th>学校</u-th </u-tr> <u-tr><u-td>浙江大学</u-td> </u-tr> <u-tr><u-td>清华大学</u-td> </u-tr></u-table>
|
|
14
|
+
*/
|
|
15
|
+
export default {
|
|
16
|
+
name: 'u-table',
|
|
17
|
+
mixins: [uni.$u.mpMixin, uni.$u.mixin,props],
|
|
18
|
+
data() {
|
|
19
|
+
return {
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<style lang="scss" scoped>
|
|
27
|
+
@import "../../libs/css/components.scss";
|
|
28
|
+
|
|
29
|
+
</style>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
// 滑块的移动过渡时间,单位ms
|
|
4
|
+
duration: {
|
|
5
|
+
type: Number,
|
|
6
|
+
default: uni.$u.props.tabs.duration
|
|
7
|
+
},
|
|
8
|
+
// tabs标签数组
|
|
9
|
+
list: {
|
|
10
|
+
type: Array,
|
|
11
|
+
default: uni.$u.props.tabs.list
|
|
12
|
+
},
|
|
13
|
+
// 滑块颜色
|
|
14
|
+
lineColor: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: uni.$u.props.tabs.lineColor
|
|
17
|
+
},
|
|
18
|
+
// 菜单选择中时的样式
|
|
19
|
+
activeStyle: {
|
|
20
|
+
type: [String, Object],
|
|
21
|
+
default: uni.$u.props.tabs.activeStyle
|
|
22
|
+
},
|
|
23
|
+
// 菜单非选中时的样式
|
|
24
|
+
inactiveStyle: {
|
|
25
|
+
type: [String, Object],
|
|
26
|
+
default: uni.$u.props.tabs.inactiveStyle
|
|
27
|
+
},
|
|
28
|
+
// 滑块长度
|
|
29
|
+
lineWidth: {
|
|
30
|
+
type: [String, Number],
|
|
31
|
+
default: uni.$u.props.tabs.lineWidth
|
|
32
|
+
},
|
|
33
|
+
// 滑块高度
|
|
34
|
+
lineHeight: {
|
|
35
|
+
type: [String, Number],
|
|
36
|
+
default: uni.$u.props.tabs.lineHeight
|
|
37
|
+
},
|
|
38
|
+
// 滑块背景显示大小,当滑块背景设置为图片时使用
|
|
39
|
+
lineBgSize: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: uni.$u.props.tabs.lineBgSize
|
|
42
|
+
},
|
|
43
|
+
// 菜单item的样式
|
|
44
|
+
itemStyle: {
|
|
45
|
+
type: [String, Object],
|
|
46
|
+
default: uni.$u.props.tabs.itemStyle
|
|
47
|
+
},
|
|
48
|
+
// 菜单是否可滚动
|
|
49
|
+
scrollable: {
|
|
50
|
+
type: Boolean,
|
|
51
|
+
default: uni.$u.props.tabs.scrollable
|
|
52
|
+
},
|
|
53
|
+
// 当前选中标签的索引
|
|
54
|
+
current: {
|
|
55
|
+
type: [Number, String],
|
|
56
|
+
default: uni.$u.props.tabs.current
|
|
57
|
+
},
|
|
58
|
+
// 默认读取的键名
|
|
59
|
+
keyName: {
|
|
60
|
+
type: String,
|
|
61
|
+
default: uni.$u.props.tabs.keyName
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="u-tabs">
|
|
3
|
+
<view class="u-tabs__wrapper">
|
|
4
|
+
<slot name="left" />
|
|
5
|
+
<view class="u-tabs__wrapper__scroll-view-wrapper">
|
|
6
|
+
<scroll-view
|
|
7
|
+
:scroll-x="scrollable"
|
|
8
|
+
:scroll-left="scrollLeft"
|
|
9
|
+
scroll-with-animation
|
|
10
|
+
class="u-tabs__wrapper__scroll-view"
|
|
11
|
+
:show-scrollbar="false"
|
|
12
|
+
ref="u-tabs__wrapper__scroll-view"
|
|
13
|
+
>
|
|
14
|
+
<view
|
|
15
|
+
class="u-tabs__wrapper__nav"
|
|
16
|
+
ref="u-tabs__wrapper__nav"
|
|
17
|
+
>
|
|
18
|
+
<view
|
|
19
|
+
class="u-tabs__wrapper__nav__item"
|
|
20
|
+
v-for="(item, index) in list"
|
|
21
|
+
:key="index"
|
|
22
|
+
@tap="clickHandler(item, index)"
|
|
23
|
+
@longpress="longPressHandler(item,index)"
|
|
24
|
+
:ref="`u-tabs__wrapper__nav__item-${index}`"
|
|
25
|
+
:style="[$u.addStyle(itemStyle), {flex: scrollable ? '' : 1}]"
|
|
26
|
+
:class="[`u-tabs__wrapper__nav__item-${index}`, item.disabled && 'u-tabs__wrapper__nav__item--disabled']"
|
|
27
|
+
>
|
|
28
|
+
<text
|
|
29
|
+
:class="[item.disabled && 'u-tabs__wrapper__nav__item__text--disabled']"
|
|
30
|
+
class="u-tabs__wrapper__nav__item__text"
|
|
31
|
+
:style="[textStyle(index)]"
|
|
32
|
+
>{{ item[keyName] }}</text>
|
|
33
|
+
<u-badge
|
|
34
|
+
:show="!!(item.badge && (item.badge.show || item.badge.isDot || item.badge.value))"
|
|
35
|
+
:isDot="item.badge && item.badge.isDot || propsBadge.isDot"
|
|
36
|
+
:value="item.badge && item.badge.value || propsBadge.value"
|
|
37
|
+
:max="item.badge && item.badge.max || propsBadge.max"
|
|
38
|
+
:type="item.badge && item.badge.type || propsBadge.type"
|
|
39
|
+
:showZero="item.badge && item.badge.showZero || propsBadge.showZero"
|
|
40
|
+
:bgColor="item.badge && item.badge.bgColor || propsBadge.bgColor"
|
|
41
|
+
:color="item.badge && item.badge.color || propsBadge.color"
|
|
42
|
+
:shape="item.badge && item.badge.shape || propsBadge.shape"
|
|
43
|
+
:numberType="item.badge && item.badge.numberType || propsBadge.numberType"
|
|
44
|
+
:inverted="item.badge && item.badge.inverted || propsBadge.inverted"
|
|
45
|
+
customStyle="margin-left: 4px;"
|
|
46
|
+
></u-badge>
|
|
47
|
+
</view>
|
|
48
|
+
<!-- #ifdef APP-NVUE -->
|
|
49
|
+
<view
|
|
50
|
+
class="u-tabs__wrapper__nav__line"
|
|
51
|
+
ref="u-tabs__wrapper__nav__line"
|
|
52
|
+
:style="[{
|
|
53
|
+
width: $u.addUnit(lineWidth),
|
|
54
|
+
height: $u.addUnit(lineHeight),
|
|
55
|
+
background: lineColor,
|
|
56
|
+
backgroundSize: lineBgSize,
|
|
57
|
+
}]"
|
|
58
|
+
>
|
|
59
|
+
<!-- #endif -->
|
|
60
|
+
<!-- #ifndef APP-NVUE -->
|
|
61
|
+
<view
|
|
62
|
+
class="u-tabs__wrapper__nav__line"
|
|
63
|
+
ref="u-tabs__wrapper__nav__line"
|
|
64
|
+
:style="[{
|
|
65
|
+
width: $u.addUnit(lineWidth),
|
|
66
|
+
transform: `translate(${lineOffsetLeft}px)`,
|
|
67
|
+
transitionDuration: `${firstTime ? 0 : duration}ms`,
|
|
68
|
+
height: $u.addUnit(lineHeight),
|
|
69
|
+
background: lineColor,
|
|
70
|
+
backgroundSize: lineBgSize,
|
|
71
|
+
}]"
|
|
72
|
+
>
|
|
73
|
+
<!-- #endif -->
|
|
74
|
+
</view>
|
|
75
|
+
</view>
|
|
76
|
+
</scroll-view>
|
|
77
|
+
</view>
|
|
78
|
+
<slot name="right" />
|
|
79
|
+
</view>
|
|
80
|
+
</view>
|
|
81
|
+
</template>
|
|
82
|
+
|
|
83
|
+
<script>
|
|
84
|
+
// #ifdef APP-NVUE
|
|
85
|
+
const animation = uni.requireNativePlugin('animation')
|
|
86
|
+
const dom = uni.requireNativePlugin('dom')
|
|
87
|
+
// #endif
|
|
88
|
+
import props from './props.js';
|
|
89
|
+
/**
|
|
90
|
+
* Tabs 标签
|
|
91
|
+
* @description tabs标签组件,在标签多的时候,可以配置为左右滑动,标签少的时候,可以禁止滑动。 该组件的一个特点是配置为滚动模式时,激活的tab会自动移动到组件的中间位置。
|
|
92
|
+
* @tutorial https://www.uviewui.com/components/tabs.html
|
|
93
|
+
* @property {String | Number} duration 滑块移动一次所需的时间,单位秒(默认 200 )
|
|
94
|
+
* @property {String | Number} swierWidth swiper的宽度(默认 '750rpx' )
|
|
95
|
+
* @property {String} keyName 从`list`元素对象中读取的键名(默认 'name' )
|
|
96
|
+
* @event {Function(index)} change 标签改变时触发 index: 点击了第几个tab,索引从0开始
|
|
97
|
+
* @event {Function(index)} click 点击标签时触发 index: 点击了第几个tab,索引从0开始
|
|
98
|
+
* @event {Function(index)} longPress 长按标签时触发 index: 点击了第几个tab,索引从0开始
|
|
99
|
+
* @example <u-tabs :list="list" :is-scroll="false" :current="current" @change="change" @longPress="longPress"></u-tabs>
|
|
100
|
+
*/
|
|
101
|
+
export default {
|
|
102
|
+
name: 'u-tabs',
|
|
103
|
+
mixins: [uni.$u.mpMixin, uni.$u.mixin, props],
|
|
104
|
+
data() {
|
|
105
|
+
return {
|
|
106
|
+
firstTime: true,
|
|
107
|
+
scrollLeft: 0,
|
|
108
|
+
scrollViewWidth: 0,
|
|
109
|
+
lineOffsetLeft: 0,
|
|
110
|
+
tabsRect: {
|
|
111
|
+
left: 0
|
|
112
|
+
},
|
|
113
|
+
innerCurrent: 0,
|
|
114
|
+
moving: false,
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
watch: {
|
|
118
|
+
current: {
|
|
119
|
+
immediate: true,
|
|
120
|
+
handler (newValue, oldValue) {
|
|
121
|
+
// 内外部值不相等时,才尝试移动滑块
|
|
122
|
+
if (newValue !== this.innerCurrent) {
|
|
123
|
+
this.innerCurrent = newValue
|
|
124
|
+
this.$nextTick(() => {
|
|
125
|
+
this.resize()
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
// list变化时,重新渲染list各项信息
|
|
131
|
+
list() {
|
|
132
|
+
this.$nextTick(() => {
|
|
133
|
+
this.resize()
|
|
134
|
+
})
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
computed: {
|
|
138
|
+
textStyle() {
|
|
139
|
+
return index => {
|
|
140
|
+
const style = {}
|
|
141
|
+
// 取当期是否激活的样式
|
|
142
|
+
const customeStyle = index === this.innerCurrent ? uni.$u.addStyle(this.activeStyle) : uni.$u
|
|
143
|
+
.addStyle(
|
|
144
|
+
this.inactiveStyle)
|
|
145
|
+
// 如果当前菜单被禁用,则加上对应颜色,需要在此做处理,是因为nvue下,无法在style样式中通过!import覆盖标签的内联样式
|
|
146
|
+
if (this.list[index].disabled) {
|
|
147
|
+
style.color = '#c8c9cc'
|
|
148
|
+
}
|
|
149
|
+
return uni.$u.deepMerge(customeStyle, style)
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
propsBadge() {
|
|
153
|
+
return uni.$u.props.badge
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
async mounted() {
|
|
157
|
+
this.init()
|
|
158
|
+
},
|
|
159
|
+
methods: {
|
|
160
|
+
setLineLeft() {
|
|
161
|
+
const tabItem = this.list[this.innerCurrent];
|
|
162
|
+
if (!tabItem) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
// 获取滑块该移动的位置
|
|
166
|
+
let lineOffsetLeft = this.list
|
|
167
|
+
.slice(0, this.innerCurrent)
|
|
168
|
+
.reduce((total, curr) => total + curr.rect.width, 0);
|
|
169
|
+
// 获取下划线的数值px表示法
|
|
170
|
+
const lineWidth = uni.$u.getPx(this.lineWidth);
|
|
171
|
+
this.lineOffsetLeft = lineOffsetLeft + (tabItem.rect.width - lineWidth) / 2
|
|
172
|
+
// #ifdef APP-NVUE
|
|
173
|
+
// 第一次移动滑块,无需过渡时间
|
|
174
|
+
this.animation(this.lineOffsetLeft, this.firstTime ? 0 : parseInt(this.duration))
|
|
175
|
+
// #endif
|
|
176
|
+
|
|
177
|
+
// 如果是第一次执行此方法,让滑块在初始化时,瞬间滑动到第一个tab item的中间
|
|
178
|
+
// 这里需要一个定时器,因为在非nvue下,是直接通过style绑定过渡时间,需要等其过渡完成后,再设置为false(非第一次移动滑块)
|
|
179
|
+
if (this.firstTime) {
|
|
180
|
+
setTimeout(() => {
|
|
181
|
+
this.firstTime = false
|
|
182
|
+
}, 10);
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
// nvue下设置滑块的位置
|
|
186
|
+
animation(x, duration = 0) {
|
|
187
|
+
// #ifdef APP-NVUE
|
|
188
|
+
const ref = this.$refs['u-tabs__wrapper__nav__line']
|
|
189
|
+
animation.transition(ref, {
|
|
190
|
+
styles: {
|
|
191
|
+
transform: `translateX(${x}px)`
|
|
192
|
+
},
|
|
193
|
+
duration
|
|
194
|
+
})
|
|
195
|
+
// #endif
|
|
196
|
+
},
|
|
197
|
+
// 点击某一个标签
|
|
198
|
+
clickHandler(item, index) {
|
|
199
|
+
// 因为标签可能为disabled状态,所以click是一定会发出的,但是change事件是需要可用的状态才发出
|
|
200
|
+
this.$emit('click', {
|
|
201
|
+
...item,
|
|
202
|
+
index
|
|
203
|
+
})
|
|
204
|
+
// 如果disabled状态,返回
|
|
205
|
+
if (item.disabled) return
|
|
206
|
+
this.innerCurrent = index
|
|
207
|
+
this.resize()
|
|
208
|
+
this.$emit('change', {
|
|
209
|
+
...item,
|
|
210
|
+
index
|
|
211
|
+
})
|
|
212
|
+
},
|
|
213
|
+
// 长按事件
|
|
214
|
+
longPressHandler(item, index) {
|
|
215
|
+
this.$emit('longPress', {
|
|
216
|
+
...item,
|
|
217
|
+
index
|
|
218
|
+
})
|
|
219
|
+
},
|
|
220
|
+
init() {
|
|
221
|
+
uni.$u.sleep().then(() => {
|
|
222
|
+
this.resize()
|
|
223
|
+
})
|
|
224
|
+
},
|
|
225
|
+
setScrollLeft() {
|
|
226
|
+
// 当前活动tab的布局信息,有tab菜单的width和left(为元素左边界到父元素左边界的距离)等信息
|
|
227
|
+
const tabRect = this.list[this.innerCurrent]
|
|
228
|
+
// 累加得到当前item到左边的距离
|
|
229
|
+
const offsetLeft = this.list
|
|
230
|
+
.slice(0, this.innerCurrent)
|
|
231
|
+
.reduce((total, curr) => {
|
|
232
|
+
return total + curr.rect.width
|
|
233
|
+
}, 0)
|
|
234
|
+
// 此处为屏幕宽度
|
|
235
|
+
const windowWidth = uni.$u.sys().windowWidth
|
|
236
|
+
// 将活动的tabs-item移动到屏幕正中间,实际上是对scroll-view的移动
|
|
237
|
+
let scrollLeft = offsetLeft - (this.tabsRect.width - tabRect.rect.width) / 2 - (windowWidth - this.tabsRect
|
|
238
|
+
.right) / 2 + this.tabsRect.left / 2
|
|
239
|
+
// 这里做一个限制,限制scrollLeft的最大值为整个scroll-view宽度减去tabs组件的宽度
|
|
240
|
+
scrollLeft = Math.min(scrollLeft, this.scrollViewWidth - this.tabsRect.width)
|
|
241
|
+
this.scrollLeft = Math.max(0, scrollLeft)
|
|
242
|
+
},
|
|
243
|
+
// 获取所有标签的尺寸
|
|
244
|
+
resize() {
|
|
245
|
+
// 如果不存在list,则不处理
|
|
246
|
+
if(this.list.length === 0) {
|
|
247
|
+
return
|
|
248
|
+
}
|
|
249
|
+
Promise.all([this.getTabsRect(), this.getAllItemRect()]).then(([tabsRect, itemRect = []]) => {
|
|
250
|
+
this.tabsRect = tabsRect
|
|
251
|
+
this.scrollViewWidth = 0
|
|
252
|
+
itemRect.map((item, index) => {
|
|
253
|
+
// 计算scroll-view的宽度,这里
|
|
254
|
+
this.scrollViewWidth += item.width
|
|
255
|
+
// 另外计算每一个item的中心点X轴坐标
|
|
256
|
+
this.list[index].rect = item
|
|
257
|
+
})
|
|
258
|
+
// 获取了tabs的尺寸之后,设置滑块的位置
|
|
259
|
+
this.setLineLeft()
|
|
260
|
+
this.setScrollLeft()
|
|
261
|
+
})
|
|
262
|
+
},
|
|
263
|
+
// 获取导航菜单的尺寸
|
|
264
|
+
getTabsRect() {
|
|
265
|
+
return new Promise(resolve => {
|
|
266
|
+
this.queryRect('u-tabs__wrapper__scroll-view').then(size => resolve(size))
|
|
267
|
+
})
|
|
268
|
+
},
|
|
269
|
+
// 获取所有标签的尺寸
|
|
270
|
+
getAllItemRect() {
|
|
271
|
+
return new Promise(resolve => {
|
|
272
|
+
const promiseAllArr = this.list.map((item, index) => this.queryRect(
|
|
273
|
+
`u-tabs__wrapper__nav__item-${index}`, true))
|
|
274
|
+
Promise.all(promiseAllArr).then(sizes => resolve(sizes))
|
|
275
|
+
})
|
|
276
|
+
},
|
|
277
|
+
// 获取各个标签的尺寸
|
|
278
|
+
queryRect(el, item) {
|
|
279
|
+
// #ifndef APP-NVUE
|
|
280
|
+
// $uGetRect为uView自带的节点查询简化方法,详见文档介绍:https://www.uviewui.com/js/getRect.html
|
|
281
|
+
// 组件内部一般用this.$uGetRect,对外的为uni.$u.getRect,二者功能一致,名称不同
|
|
282
|
+
return new Promise(resolve => {
|
|
283
|
+
this.$uGetRect(`.${el}`).then(size => {
|
|
284
|
+
resolve(size)
|
|
285
|
+
})
|
|
286
|
+
})
|
|
287
|
+
// #endif
|
|
288
|
+
|
|
289
|
+
// #ifdef APP-NVUE
|
|
290
|
+
// nvue下,使用dom模块查询元素高度
|
|
291
|
+
// 返回一个promise,让调用此方法的主体能使用then回调
|
|
292
|
+
return new Promise(resolve => {
|
|
293
|
+
dom.getComponentRect(item ? this.$refs[el][0] : this.$refs[el], res => {
|
|
294
|
+
resolve(res.size)
|
|
295
|
+
})
|
|
296
|
+
})
|
|
297
|
+
// #endif
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
}
|
|
301
|
+
</script>
|
|
302
|
+
|
|
303
|
+
<style lang="scss" scoped>
|
|
304
|
+
@import "../../libs/css/components.scss";
|
|
305
|
+
|
|
306
|
+
.u-tabs {
|
|
307
|
+
|
|
308
|
+
&__wrapper {
|
|
309
|
+
@include flex;
|
|
310
|
+
align-items: center;
|
|
311
|
+
|
|
312
|
+
&__scroll-view-wrapper {
|
|
313
|
+
flex: 1;
|
|
314
|
+
/* #ifndef APP-NVUE */
|
|
315
|
+
overflow: auto hidden;
|
|
316
|
+
/* #endif */
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
&__scroll-view {
|
|
320
|
+
@include flex;
|
|
321
|
+
flex: 1;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
&__nav {
|
|
325
|
+
@include flex;
|
|
326
|
+
position: relative;
|
|
327
|
+
|
|
328
|
+
&__item {
|
|
329
|
+
padding: 0 11px;
|
|
330
|
+
@include flex;
|
|
331
|
+
align-items: center;
|
|
332
|
+
justify-content: center;
|
|
333
|
+
|
|
334
|
+
&--disabled {
|
|
335
|
+
/* #ifndef APP-NVUE */
|
|
336
|
+
cursor: not-allowed;
|
|
337
|
+
/* #endif */
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
&__text {
|
|
341
|
+
font-size: 15px;
|
|
342
|
+
color: $u-content-color;
|
|
343
|
+
|
|
344
|
+
&--disabled {
|
|
345
|
+
color: $u-disabled-color !important;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
&__line {
|
|
351
|
+
height: 3px;
|
|
352
|
+
background: $u-primary;
|
|
353
|
+
width: 30px;
|
|
354
|
+
position: absolute;
|
|
355
|
+
bottom: 2px;
|
|
356
|
+
border-radius: 100px;
|
|
357
|
+
transition-property: transform;
|
|
358
|
+
transition-duration: 300ms;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
</style>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<swiper-item>
|
|
3
|
+
<slot />
|
|
4
|
+
</swiper-item>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import props from './props.js';
|
|
9
|
+
/**
|
|
10
|
+
* TabsItem tabs标签组件的自组件
|
|
11
|
+
* @description tabs标签组件,在标签多的时候,可以配置为左右滑动,标签少的时候,可以禁止滑动。 该组件的一个特点是配置为滚动模式时,激活的tab会自动移动到组件的中间位置。
|
|
12
|
+
* @tutorial https://www.uviewui.com/components/tabs.html
|
|
13
|
+
* @property {type} prop_name
|
|
14
|
+
* @event {Function()}
|
|
15
|
+
* @example
|
|
16
|
+
*/
|
|
17
|
+
export default {
|
|
18
|
+
name: 'u-tabs-item',
|
|
19
|
+
mixins: [uni.$u.mpMixin, uni.$u.mixin,props],
|
|
20
|
+
data() {
|
|
21
|
+
return {
|
|
22
|
+
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<style>
|
|
29
|
+
</style>
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
// 标签类型info、primary、success、warning、error
|
|
4
|
+
type: {
|
|
5
|
+
type: String,
|
|
6
|
+
default: uni.$u.props.tag.type
|
|
7
|
+
},
|
|
8
|
+
// 不可用
|
|
9
|
+
disabled: {
|
|
10
|
+
type: [Boolean, String],
|
|
11
|
+
default: uni.$u.props.tag.disabled
|
|
12
|
+
},
|
|
13
|
+
// 标签的大小,large,medium,mini
|
|
14
|
+
size: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: uni.$u.props.tag.size
|
|
17
|
+
},
|
|
18
|
+
// tag的形状,circle(两边半圆形), square(方形,带圆角)
|
|
19
|
+
shape: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: uni.$u.props.tag.shape
|
|
22
|
+
},
|
|
23
|
+
// 标签文字
|
|
24
|
+
text: {
|
|
25
|
+
type: [String, Number],
|
|
26
|
+
default: uni.$u.props.tag.text
|
|
27
|
+
},
|
|
28
|
+
// 背景颜色,默认为空字符串,即不处理
|
|
29
|
+
bgColor: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: uni.$u.props.tag.bgColor
|
|
32
|
+
},
|
|
33
|
+
// 标签字体颜色,默认为空字符串,即不处理
|
|
34
|
+
color: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: uni.$u.props.tag.color
|
|
37
|
+
},
|
|
38
|
+
// 标签的边框颜色
|
|
39
|
+
borderColor: {
|
|
40
|
+
type: String,
|
|
41
|
+
default: uni.$u.props.tag.borderColor
|
|
42
|
+
},
|
|
43
|
+
// 关闭按钮图标的颜色
|
|
44
|
+
closeColor: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: uni.$u.props.tag.closeColor
|
|
47
|
+
},
|
|
48
|
+
// 点击时返回的索引值,用于区分例遍的数组哪个元素被点击了
|
|
49
|
+
name: {
|
|
50
|
+
type: [String, Number],
|
|
51
|
+
default: uni.$u.props.tag.name
|
|
52
|
+
},
|
|
53
|
+
// // 模式选择,dark|light|plain
|
|
54
|
+
// mode: {
|
|
55
|
+
// type: String,
|
|
56
|
+
// default: 'light'
|
|
57
|
+
// },
|
|
58
|
+
// 镂空时是否填充背景色
|
|
59
|
+
plainFill: {
|
|
60
|
+
type: Boolean,
|
|
61
|
+
default: uni.$u.props.tag.plainFill
|
|
62
|
+
},
|
|
63
|
+
// 是否镂空
|
|
64
|
+
plain: {
|
|
65
|
+
type: Boolean,
|
|
66
|
+
default: uni.$u.props.tag.plain
|
|
67
|
+
},
|
|
68
|
+
// 是否可关闭
|
|
69
|
+
closable: {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
default: uni.$u.props.tag.closable
|
|
72
|
+
},
|
|
73
|
+
// 是否显示
|
|
74
|
+
show: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
default: uni.$u.props.tag.show
|
|
77
|
+
},
|
|
78
|
+
// 内置图标,或绝对路径的图片
|
|
79
|
+
icon: {
|
|
80
|
+
type: String,
|
|
81
|
+
default: uni.$u.props.tag.icon
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|