@10yun/cv-mobile-ui 0.5.29 → 0.5.30
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/package.json +1 -1
- package/plugins/luch-request/adapters/index.js +131 -0
- package/plugins/luch-request/core/InterceptorManager.js +50 -0
- package/plugins/luch-request/core/Request.js +199 -0
- package/plugins/luch-request/core/buildFullPath.js +20 -0
- package/plugins/luch-request/core/defaults.js +32 -0
- package/plugins/luch-request/core/dispatchRequest.js +5 -0
- package/plugins/luch-request/core/mergeConfig.js +125 -0
- package/plugins/luch-request/core/settle.js +16 -0
- package/plugins/luch-request/helpers/buildURL.js +71 -0
- package/plugins/luch-request/helpers/combineURLs.js +12 -0
- package/plugins/luch-request/helpers/isAbsoluteURL.js +14 -0
- package/plugins/luch-request/index.d.ts +197 -0
- package/plugins/luch-request/index.js +2 -0
- package/plugins/luch-request/readme.md +3 -0
- package/plugins/luch-request/utils/clone.js +264 -0
- package/plugins/luch-request/utils.js +131 -0
- package/plugins/request.js +2 -2
- package/ui-cv/components/cv-form-item/cv-form-item.vue +1 -1
- package/ui-fireui/fui-actionsheet/fui-actionsheet.vue +202 -0
- package/ui-fireui/fui-alert/fui-alert.vue +141 -0
- package/ui-fireui/fui-badge/fui-badge.vue +158 -0
- package/ui-fireui/fui-bottom-navigation/fui-bottom-navigation.vue +390 -0
- package/ui-fireui/fui-bottom-popup/fui-bottom-popup.vue +100 -0
- package/ui-fireui/fui-bubble-popup/fui-bubble-popup.vue +236 -0
- package/ui-fireui/fui-button/fui-button.vue +424 -0
- package/ui-fireui/fui-calendar/fui-calendar.js +915 -0
- package/ui-fireui/fui-calendar/fui-calendar.vue +868 -0
- package/ui-fireui/fui-card/fui-card.vue +231 -0
- package/ui-fireui/fui-cascade-selection/fui-cascade-selection.vue +538 -0
- package/ui-fireui/fui-circular-progress/fui-circular-progress.vue +261 -0
- package/ui-fireui/fui-collapse/fui-collapse.vue +179 -0
- package/ui-fireui/fui-countdown/fui-countdown.vue +301 -0
- package/ui-fireui/fui-datetime/fui-datetime.vue +570 -0
- package/ui-fireui/fui-divider/fui-divider.vue +118 -0
- package/ui-fireui/fui-drawer/fui-drawer.vue +103 -0
- package/ui-fireui/fui-dropdown-list/fui-dropdown-list.vue +70 -0
- package/ui-fireui/fui-fab/fui-fab.vue +284 -0
- package/ui-fireui/fui-footer/fui-footer.vue +131 -0
- package/ui-fireui/fui-grid/fui-grid.vue +42 -0
- package/ui-fireui/fui-grid-item/fui-grid-item.vue +142 -0
- package/ui-fireui/fui-icon/fui-icon.vue +820 -0
- package/ui-fireui/fui-image-cropper/fui-image-cropper.vue +1058 -0
- package/ui-fireui/fui-image-group/fui-image-group.vue +149 -0
- package/ui-fireui/fui-keyboard/fui-keyboard.vue +254 -0
- package/ui-fireui/fui-keyboard-input/fui-keyboard-input.vue +78 -0
- package/ui-fireui/fui-list-cell/fui-list-cell.vue +178 -0
- package/ui-fireui/fui-list-view/fui-list-view.vue +87 -0
- package/ui-fireui/fui-loading/fui-loading.vue +78 -0
- package/ui-fireui/fui-loadmore/fui-loadmore.vue +163 -0
- package/ui-fireui/fui-modal/fui-modal.vue +392 -0
- package/ui-fireui/fui-navigation-bar/fui-navigation-bar.vue +180 -0
- package/ui-fireui/fui-no-data/fui-no-data.vue +116 -0
- package/ui-fireui/fui-nomore/fui-nomore.vue +116 -0
- package/ui-fireui/fui-numberbox/fui-numberbox.vue +234 -0
- package/ui-fireui/fui-numberbox-border/fui-numberbox-border.vue +232 -0
- package/ui-fireui/fui-picture-cropper/fui-picture-cropper.vue +682 -0
- package/ui-fireui/fui-picture-cropper/fui-picture-cropper.wxs +560 -0
- package/ui-fireui/fui-rate/fui-rate.vue +167 -0
- package/ui-fireui/fui-round-progress/fui-round-progress.vue +306 -0
- package/ui-fireui/fui-scroll-top/fui-scroll-top.vue +189 -0
- package/ui-fireui/fui-sharemodel/fui-sharemodel.vue +181 -0
- package/ui-fireui/fui-skeleton/fui-skeleton.vue +248 -0
- package/ui-fireui/fui-steps/fui-steps.vue +214 -0
- package/ui-fireui/fui-sticky/fui-sticky.vue +155 -0
- package/ui-fireui/fui-sticky-wxs/fui-sticky-wxs.vue +133 -0
- package/ui-fireui/fui-sticky-wxs/fui-sticky.wxs +44 -0
- package/ui-fireui/fui-swipe-action/fui-swipe-action.vue +301 -0
- package/ui-fireui/fui-tabbar/fui-tabbar.vue +283 -0
- package/ui-fireui/fui-tabs/fui-tabs.vue +284 -0
- package/ui-fireui/fui-tabs2/fui-tabs2.vue +284 -0
- package/ui-fireui/fui-tag/fui-tag.vue +374 -0
- package/ui-fireui/fui-time-axis/fui-time-axis.vue +36 -0
- package/ui-fireui/fui-timeaxis-item/fui-timeaxis-item.vue +48 -0
- package/ui-fireui/fui-tips/fui-tips.vue +161 -0
- package/ui-fireui/fui-toast/fui-toast.vue +117 -0
- package/ui-fireui/fui-top-dropdown/fui-top-dropdown.vue +129 -0
- package/ui-fireui/fui-upload/fui-upload.vue +446 -0
- package/ui-fireui/fui-uploadsamll/fui-uploadsamll.vue +472 -0
- package/uview-plus/README.md +1 -1
- package/uview-plus/changelog-wu-tool.md +21 -0
- package/uview-plus/changelog-wu.md +91 -0
- package/uview-plus/components/u-action-sheet/_doc/changelog.md +12 -0
- package/uview-plus/components/u-action-sheet/_doc/package.json +92 -0
- package/uview-plus/components/u-action-sheet/_doc/readme.md +16 -0
- package/uview-plus/components/u-app-update/_doc/changelog.md +26 -0
- package/uview-plus/components/u-app-update/_doc/package.json +89 -0
- package/uview-plus/components/u-app-update/_doc/readme.md +16 -0
- package/uview-plus/components/u-app-update/config.js +120 -0
- package/uview-plus/components/u-app-update/img/act.png +0 -0
- package/uview-plus/components/u-app-update/img/appUploadAlertBoxBg.png +0 -0
- package/uview-plus/components/u-app-update/img/close.png +0 -0
- package/uview-plus/components/u-app-update/js-sdk/checkVersion.js +81 -0
- package/uview-plus/components/u-app-update/js-sdk/silentlyAppUpdate.js +41 -0
- package/uview-plus/components/u-app-update/pages/index.vue +8 -0
- package/uview-plus/components/u-app-update/u-app-update.vue +583 -0
- package/uview-plus/components/u-button-wu/_doc/changelog.md +6 -0
- package/uview-plus/components/u-button-wu/_doc/package.json +89 -0
- package/uview-plus/components/u-button-wu/_doc/readme.md +16 -0
- package/uview-plus/components/u-button-wu/u-button-wu.vue +522 -0
- package/uview-plus/components/u-button-wu/vue.scss +81 -0
- package/uview-plus/components/u-calendar-wu/_doc/changelog.md +145 -0
- package/uview-plus/components/u-calendar-wu/_doc/package.json +90 -0
- package/uview-plus/components/u-calendar-wu/_doc/readme.md +16 -0
- package/uview-plus/components/u-calendar-wu/calendar.js +664 -0
- package/uview-plus/components/u-calendar-wu/i18n/en.json +14 -0
- package/uview-plus/components/u-calendar-wu/i18n/index.js +8 -0
- package/uview-plus/components/u-calendar-wu/i18n/zh-Hans.json +14 -0
- package/uview-plus/components/u-calendar-wu/i18n/zh-Hant.json +14 -0
- package/uview-plus/components/u-calendar-wu/props.js +166 -0
- package/uview-plus/components/u-calendar-wu/style.css +196 -0
- package/uview-plus/components/u-calendar-wu/u-calendar-wu.vue +921 -0
- package/uview-plus/components/u-calendar-wu/util.js +552 -0
- package/uview-plus/components/u-calendar-wu/wu-calendar-block/props.js +73 -0
- package/uview-plus/components/u-calendar-wu/wu-calendar-block/wu-calendar-block.vue +122 -0
- package/uview-plus/components/u-calendar-wu/wu-calendar-item/props.js +55 -0
- package/uview-plus/components/u-calendar-wu/wu-calendar-item/wu-calendar-item.vue +293 -0
- package/uview-plus/components/u-cell/_doc/changelog.md +6 -0
- package/uview-plus/components/u-cell/_doc/package.json +89 -0
- package/uview-plus/components/u-cell/_doc/readme.md +25 -0
- package/uview-plus/components/u-checkbox/_doc/changelog.md +8 -0
- package/uview-plus/components/u-checkbox/_doc/package.json +88 -0
- package/uview-plus/components/u-checkbox/_doc/readme.md +25 -0
- package/uview-plus/components/u-code/_doc/changelog.md +6 -0
- package/uview-plus/components/u-code/_doc/package.json +86 -0
- package/uview-plus/components/u-code/_doc/readme.md +16 -0
- package/uview-plus/components/u-drag-sort/_doc/changelog.md +0 -0
- package/uview-plus/components/u-drag-sort/_doc/package.json +85 -0
- package/uview-plus/components/u-drag-sort/_doc/readme.md +16 -0
- package/uview-plus/components/u-drag-sort/u-drag-sort.vue +3 -0
- package/uview-plus/components/u-empty/u-empty.vue +27 -1
- package/uview-plus/components/u-gap/_doc/changelog.md +4 -0
- package/uview-plus/components/u-gap/_doc/package.json +86 -0
- package/uview-plus/components/u-gap/_doc/readme.md +22 -0
- package/uview-plus/components/u-icon/_doc/changelog.md +10 -0
- package/uview-plus/components/u-icon/_doc/package.json +85 -0
- package/uview-plus/components/u-icon/_doc/readme.md +10 -0
- package/uview-plus/components/u-icon/icon.js +23 -25
- package/uview-plus/components/u-icon/icons.js +213 -213
- package/uview-plus/components/u-icon/style.css +3 -3
- package/uview-plus/components/u-icon/u-icon2.vue +149 -0
- package/uview-plus/components/u-image-wu/_doc/changelog.md +21 -0
- package/uview-plus/components/u-image-wu/_doc/package.json +88 -0
- package/uview-plus/components/u-image-wu/_doc/readme.md +11 -0
- package/uview-plus/components/u-image-wu/props.js +94 -0
- package/uview-plus/components/u-image-wu/u-image-wu.vue +243 -0
- package/uview-plus/components/u-input/_doc/changelog.md +6 -0
- package/uview-plus/components/u-input/_doc/package.json +88 -0
- package/uview-plus/components/u-input/_doc/readme.md +16 -0
- package/uview-plus/components/u-line/_doc/changelog.md +8 -0
- package/uview-plus/components/u-line/_doc/package.json +86 -0
- package/uview-plus/components/u-line/_doc/readme.md +16 -0
- package/uview-plus/components/u-link/_doc/changelog.md +8 -0
- package/uview-plus/components/u-link/_doc/package.json +86 -0
- package/uview-plus/components/u-link/_doc/readme.md +20 -0
- package/uview-plus/components/u-loading-icon/_doc/changelog.md +12 -0
- package/uview-plus/components/u-loading-icon/_doc/package.json +86 -0
- package/uview-plus/components/u-loading-icon/_doc/readme.md +16 -0
- package/uview-plus/components/u-loading-icon/props.js +1 -1
- package/uview-plus/components/u-navbar/_doc/changelog.md +6 -0
- package/uview-plus/components/u-navbar/_doc/package.json +89 -0
- package/uview-plus/components/u-navbar/_doc/readme.md +16 -0
- package/uview-plus/components/u-navbar-wu/props.js +102 -0
- package/uview-plus/components/u-navbar-wu/u-navbar-wu.vue +196 -0
- package/uview-plus/components/u-number-box/_doc/changelog.md +19 -0
- package/uview-plus/components/u-number-box/_doc/package.json +88 -0
- package/uview-plus/components/u-number-box/_doc/readme.md +16 -0
- package/uview-plus/components/u-overlay/_doc/changelog.md +4 -0
- package/uview-plus/components/u-overlay/_doc/package.json +88 -0
- package/uview-plus/components/u-overlay/_doc/readme.md +16 -0
- package/uview-plus/components/u-popup/_doc/changelog.md +4 -0
- package/uview-plus/components/u-popup/_doc/package.json +92 -0
- package/uview-plus/components/u-popup/_doc/readme.md +16 -0
- package/uview-plus/components/u-popup-wu/keypress.js +45 -0
- package/uview-plus/components/u-popup-wu/u-popup-wu.vue +519 -0
- package/uview-plus/components/u-radio/_doc/changelog.md +6 -0
- package/uview-plus/components/u-radio/_doc/package.json +88 -0
- package/uview-plus/components/u-radio/_doc/readme.md +25 -0
- package/uview-plus/components/u-row/_doc/changelog.md +8 -0
- package/uview-plus/components/u-row/_doc/package.json +86 -0
- package/uview-plus/components/u-row/_doc/readme.md +16 -0
- package/uview-plus/components/u-safe-bottom/_doc/changelog.md +6 -0
- package/uview-plus/components/u-safe-bottom/_doc/package.json +86 -0
- package/uview-plus/components/u-safe-bottom/_doc/readme.md +16 -0
- package/uview-plus/components/u-sku-wu/_doc/changelog.md +27 -0
- package/uview-plus/components/u-sku-wu/_doc/package.json +93 -0
- package/uview-plus/components/u-sku-wu/_doc/readme.md +16 -0
- package/uview-plus/components/u-sku-wu/props.js +86 -0
- package/uview-plus/components/u-sku-wu/style.css +271 -0
- package/uview-plus/components/u-sku-wu/u-sku-wu.vue +864 -0
- package/uview-plus/components/u-status-bar/_doc/changelog.md +4 -0
- package/uview-plus/components/u-status-bar/_doc/package.json +86 -0
- package/uview-plus/components/u-status-bar/_doc/readme.md +16 -0
- package/uview-plus/components/u-text/_doc/changelog.md +10 -0
- package/uview-plus/components/u-text/_doc/package.json +89 -0
- package/uview-plus/components/u-text/_doc/readme.md +20 -0
- package/uview-plus/components/u-textarea/_doc/changelog.md +6 -0
- package/uview-plus/components/u-textarea/_doc/package.json +86 -0
- package/uview-plus/components/u-textarea/_doc/readme.md +25 -0
- package/uview-plus/components/u-transition/_doc/changelog.md +14 -0
- package/uview-plus/components/u-transition/_doc/package.json +86 -0
- package/uview-plus/components/u-transition/_doc/readme.md +16 -0
- package/uview-plus/components/u-transition-wu/createAnimation.js +148 -0
- package/uview-plus/components/u-transition-wu/props.js +32 -0
- package/uview-plus/components/u-transition-wu/u-transition.vue +300 -0
- package/uview-plus/components/u-verification-code/u-verification-code.vue +161 -0
- package/uview-plus/index.js +107 -94
- package/uview-plus/libs/config/config.js +46 -48
- package/uview-plus/libs/css/color.scss +32 -311
- package/uview-plus/libs/css/components-wu.scss +30 -0
- package/uview-plus/libs/css/vue.scss +10 -10
- package/uview-plus/libs/function/calc.js +61 -55
- package/uview-plus/libs/function/cc.js +66 -0
- package/uview-plus/libs/function/color/color-convert/CHANGELOG.md +54 -0
- package/uview-plus/libs/function/color/color-convert/LICENSE +21 -0
- package/uview-plus/libs/function/color/color-convert/README.md +68 -0
- package/uview-plus/libs/function/color/color-convert/conversions.js +839 -0
- package/uview-plus/libs/function/color/color-convert/index.js +81 -0
- package/uview-plus/libs/function/color/color-convert/package.json +48 -0
- package/uview-plus/libs/function/color/color-convert/route.js +97 -0
- package/uview-plus/libs/function/color/color-name/LICENSE +8 -0
- package/uview-plus/libs/function/color/color-name/README.md +11 -0
- package/uview-plus/libs/function/color/color-name/index.js +152 -0
- package/uview-plus/libs/function/color/color-name/package.json +28 -0
- package/uview-plus/libs/function/color/color-string/LICENSE +21 -0
- package/uview-plus/libs/function/color/color-string/README.md +62 -0
- package/uview-plus/libs/function/color/color-string/index.js +244 -0
- package/uview-plus/libs/function/color/color-string/package.json +39 -0
- package/uview-plus/libs/function/color/color.js +496 -0
- package/uview-plus/libs/function/color/index.js +158 -0
- package/uview-plus/libs/function/color/is-arrayish/LICENSE +21 -0
- package/uview-plus/libs/function/color/is-arrayish/README.md +16 -0
- package/uview-plus/libs/function/color/is-arrayish/index.js +9 -0
- package/uview-plus/libs/function/color/is-arrayish/package.json +45 -0
- package/uview-plus/libs/function/color/is-arrayish/yarn-error.log +1443 -0
- package/uview-plus/libs/function/color/simple-swizzle/LICENSE +21 -0
- package/uview-plus/libs/function/color/simple-swizzle/README.md +39 -0
- package/uview-plus/libs/function/color/simple-swizzle/index.js +29 -0
- package/uview-plus/libs/function/color/simple-swizzle/package.json +36 -0
- package/uview-plus/libs/function/colorGradient.js +108 -106
- package/uview-plus/libs/function/debounce.js +17 -17
- package/uview-plus/libs/function/digit.js +1 -3
- package/uview-plus/libs/function/http.js +3 -3
- package/uview-plus/libs/function/index-wu.js +231 -0
- package/uview-plus/libs/function/index.js +579 -566
- package/uview-plus/libs/function/platform.js +18 -18
- package/uview-plus/libs/function/test.js +135 -137
- package/uview-plus/libs/function/throttle.js +17 -17
- package/uview-plus/libs/luch-request/core/Request.js +199 -199
- package/uview-plus/libs/mixin/mpMixin.js +1 -0
- package/uview-plus/libs/mixin/openType.js +33 -0
- package/uview-plus/libs/util/async-validator.js +1343 -1343
- package/uview-plus/libs/util/dayjs.js +404 -0
- package/uview-plus/libs/util/route.js +101 -105
- package/uview-plus/package-wu-tool.json +84 -0
- package/uview-plus/package-wu.json +112 -0
- package/uview-plus/package.json +106 -95
- package/uview-plus/readme-wu.md +148 -0
- package/uview-ui/index.js +51 -52
- package/plugins/uni-upgrade.js +0 -294
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- #ifndef APP-NVUE -->
|
|
3
|
+
<view v-show="isShow" ref="ani" :animation="animationData" :class="customClass" :style="transformStyles" @click="onClick">
|
|
4
|
+
<slot></slot>
|
|
5
|
+
</view>
|
|
6
|
+
<!-- #endif -->
|
|
7
|
+
<!-- #ifdef APP-NVUE -->
|
|
8
|
+
<view v-if="isShow" ref="ani" :animation="animationData" :class="customClass" :style="transformStyles" @click="onClick">
|
|
9
|
+
<slot></slot>
|
|
10
|
+
</view>
|
|
11
|
+
<!-- #endif -->
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
import { createAnimation } from './createAnimation';
|
|
16
|
+
import { mpMixin } from '../../libs/mixin/mpMixin';
|
|
17
|
+
import { mixin } from '../../libs/mixin/mixin';
|
|
18
|
+
/**
|
|
19
|
+
* transition 过渡动画
|
|
20
|
+
* @description 过渡动画组件
|
|
21
|
+
* @tutorial https://ijry.github.io/uview-plus/components/transition.html
|
|
22
|
+
* @property {Boolean} show = [false|true] 控制组件显示或隐藏
|
|
23
|
+
* @property {Array|String} mode = [fade|slide-top|slide-right|slide-bottom|slide-left|zoom-in|zoom-out] 过渡动画类型
|
|
24
|
+
* @value fade 渐隐渐出过渡
|
|
25
|
+
* @value slide-top 由上至下过渡
|
|
26
|
+
* @value slide-right 由右至左过渡
|
|
27
|
+
* @value slide-bottom 由下至上过渡
|
|
28
|
+
* @value slide-left 由左至右过渡
|
|
29
|
+
* @value zoom-in 由小到大过渡
|
|
30
|
+
* @value zoom-out 由大到小过渡
|
|
31
|
+
* @property {Number} duration 过渡动画持续时间,单位ms(默认300)
|
|
32
|
+
* @property {String} timingFunction 使用的动画过渡函数 (默认 'ease-out' )
|
|
33
|
+
* @property {Object} customStyle 自定义样式
|
|
34
|
+
* @property {String} customClass 自定义类名
|
|
35
|
+
* @event {Function} click 点击组件触发
|
|
36
|
+
* @event {Function} change 过渡动画结束时触发
|
|
37
|
+
*/
|
|
38
|
+
export default {
|
|
39
|
+
name: 'u-transition',
|
|
40
|
+
mixins: [mpMixin, mixin],
|
|
41
|
+
emits: ['click', 'change'],
|
|
42
|
+
props: {
|
|
43
|
+
// 是否展示组件
|
|
44
|
+
show: {
|
|
45
|
+
type: Boolean,
|
|
46
|
+
default: false
|
|
47
|
+
},
|
|
48
|
+
// 使用的动画模式
|
|
49
|
+
mode: {
|
|
50
|
+
type: [Array, String, null],
|
|
51
|
+
default() {
|
|
52
|
+
return 'fade';
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
// 动画的执行时间,单位ms
|
|
56
|
+
duration: {
|
|
57
|
+
type: [String, Number],
|
|
58
|
+
default: 300
|
|
59
|
+
},
|
|
60
|
+
// 使用的动画过渡函数
|
|
61
|
+
timingFunction: {
|
|
62
|
+
type: String,
|
|
63
|
+
default: 'ease-out'
|
|
64
|
+
},
|
|
65
|
+
customClass: {
|
|
66
|
+
type: String,
|
|
67
|
+
default: ''
|
|
68
|
+
},
|
|
69
|
+
// nvue模式下 是否直接显示,在u-list等cell下面使用就需要设置
|
|
70
|
+
cellChild: {
|
|
71
|
+
type: Boolean,
|
|
72
|
+
default: false
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
data() {
|
|
76
|
+
return {
|
|
77
|
+
isShow: false,
|
|
78
|
+
transform: '',
|
|
79
|
+
opacity: 1,
|
|
80
|
+
animationData: {},
|
|
81
|
+
durationTime: 300,
|
|
82
|
+
config: {}
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
watch: {
|
|
86
|
+
show: {
|
|
87
|
+
handler(newVal) {
|
|
88
|
+
if (newVal) {
|
|
89
|
+
this.open();
|
|
90
|
+
} else {
|
|
91
|
+
// 避免上来就执行 close,导致动画错乱
|
|
92
|
+
if (this.isShow) {
|
|
93
|
+
this.close();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
immediate: true
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
computed: {
|
|
101
|
+
// 生成样式数据
|
|
102
|
+
stylesObject() {
|
|
103
|
+
let styles = {
|
|
104
|
+
...this.customStyle,
|
|
105
|
+
'transition-duration': this.duration / 1000 + 's'
|
|
106
|
+
};
|
|
107
|
+
let transform = '';
|
|
108
|
+
for (let i in styles) {
|
|
109
|
+
let line = this.toLine(i);
|
|
110
|
+
transform += line + ':' + styles[i] + ';';
|
|
111
|
+
}
|
|
112
|
+
return transform;
|
|
113
|
+
},
|
|
114
|
+
// 初始化动画条件
|
|
115
|
+
transformStyles() {
|
|
116
|
+
return 'transform:' + this.transform + ';' + 'opacity:' + this.opacity + ';' + this.stylesObject;
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
created() {
|
|
120
|
+
// 动画默认配置
|
|
121
|
+
this.config = {
|
|
122
|
+
duration: this.duration,
|
|
123
|
+
timingFunction: 'ease',
|
|
124
|
+
transformOrigin: '50% 50%',
|
|
125
|
+
delay: 0
|
|
126
|
+
};
|
|
127
|
+
this.durationTime = this.duration;
|
|
128
|
+
},
|
|
129
|
+
methods: {
|
|
130
|
+
/**
|
|
131
|
+
* ref 触发 初始化动画
|
|
132
|
+
*/
|
|
133
|
+
init(obj = {}) {
|
|
134
|
+
if (obj.duration) {
|
|
135
|
+
this.durationTime = obj.duration;
|
|
136
|
+
}
|
|
137
|
+
this.animation = createAnimation(Object.assign(this.config, obj), this);
|
|
138
|
+
},
|
|
139
|
+
/**
|
|
140
|
+
* 点击组件触发回调
|
|
141
|
+
*/
|
|
142
|
+
onClick() {
|
|
143
|
+
this.$emit('click', {
|
|
144
|
+
detail: this.isShow
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
/**
|
|
148
|
+
* ref 触发 动画分组
|
|
149
|
+
* @param {Object} obj
|
|
150
|
+
*/
|
|
151
|
+
step(obj, config = {}) {
|
|
152
|
+
if (!this.animation) return;
|
|
153
|
+
for (let i in obj) {
|
|
154
|
+
try {
|
|
155
|
+
if (typeof obj[i] === 'object') {
|
|
156
|
+
this.animation[i](...obj[i]);
|
|
157
|
+
} else {
|
|
158
|
+
this.animation[i](obj[i]);
|
|
159
|
+
}
|
|
160
|
+
} catch (e) {
|
|
161
|
+
console.error(`方法 ${i} 不存在`);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
this.animation.step(config);
|
|
165
|
+
return this;
|
|
166
|
+
},
|
|
167
|
+
/**
|
|
168
|
+
* ref 触发 执行动画
|
|
169
|
+
*/
|
|
170
|
+
run(fn) {
|
|
171
|
+
if (!this.animation) return;
|
|
172
|
+
this.animation.run(fn);
|
|
173
|
+
},
|
|
174
|
+
// 开始过度动画
|
|
175
|
+
open() {
|
|
176
|
+
clearTimeout(this.timer);
|
|
177
|
+
this.transform = '';
|
|
178
|
+
this.isShow = true;
|
|
179
|
+
let { opacity, transform } = this.styleInit(false);
|
|
180
|
+
if (typeof opacity !== 'undefined') {
|
|
181
|
+
this.opacity = opacity;
|
|
182
|
+
}
|
|
183
|
+
this.transform = transform;
|
|
184
|
+
// 确保动态样式已经生效后,执行动画,如果不加 nextTick ,会导致 wx 动画执行异常
|
|
185
|
+
this.$nextTick(() => {
|
|
186
|
+
// TODO 定时器保证动画完全执行,目前有些问题,后面会取消定时器
|
|
187
|
+
this.timer = setTimeout(() => {
|
|
188
|
+
this.animation = createAnimation(this.config, this);
|
|
189
|
+
this.tranfromInit(false).step();
|
|
190
|
+
this.animation.run();
|
|
191
|
+
this.$emit('change', {
|
|
192
|
+
detail: this.isShow
|
|
193
|
+
});
|
|
194
|
+
}, 20);
|
|
195
|
+
});
|
|
196
|
+
},
|
|
197
|
+
// 关闭过度动画
|
|
198
|
+
close(type) {
|
|
199
|
+
if (!this.animation) return;
|
|
200
|
+
this.tranfromInit(true)
|
|
201
|
+
.step()
|
|
202
|
+
.run(() => {
|
|
203
|
+
this.isShow = false;
|
|
204
|
+
this.animationData = null;
|
|
205
|
+
this.animation = null;
|
|
206
|
+
let { opacity, transform } = this.styleInit(false);
|
|
207
|
+
this.opacity = opacity || 1;
|
|
208
|
+
this.transform = transform;
|
|
209
|
+
this.$emit('change', {
|
|
210
|
+
detail: this.isShow
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
},
|
|
214
|
+
// 处理动画开始前的默认样式
|
|
215
|
+
styleInit(type) {
|
|
216
|
+
let styles = {
|
|
217
|
+
transform: ''
|
|
218
|
+
};
|
|
219
|
+
let buildStyle = (type, mode) => {
|
|
220
|
+
if (mode === 'fade') {
|
|
221
|
+
styles.opacity = this.animationType(type)[mode];
|
|
222
|
+
} else {
|
|
223
|
+
styles.transform += this.animationType(type)[mode] + ' ';
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
if (typeof this.mode === 'string') {
|
|
227
|
+
buildStyle(type, this.mode);
|
|
228
|
+
} else {
|
|
229
|
+
this.mode.forEach((mode) => {
|
|
230
|
+
buildStyle(type, mode);
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return styles;
|
|
234
|
+
},
|
|
235
|
+
// 处理内置组合动画
|
|
236
|
+
tranfromInit(type) {
|
|
237
|
+
let buildTranfrom = (type, mode) => {
|
|
238
|
+
let aniNum = null;
|
|
239
|
+
if (mode === 'fade') {
|
|
240
|
+
aniNum = type ? 0 : 1;
|
|
241
|
+
} else {
|
|
242
|
+
aniNum = type ? '-100%' : '0';
|
|
243
|
+
if (mode === 'zoom-in') {
|
|
244
|
+
aniNum = type ? 0.8 : 1;
|
|
245
|
+
}
|
|
246
|
+
if (mode === 'zoom-out') {
|
|
247
|
+
aniNum = type ? 1.2 : 1;
|
|
248
|
+
}
|
|
249
|
+
if (mode === 'slide-right') {
|
|
250
|
+
aniNum = type ? '100%' : '0';
|
|
251
|
+
}
|
|
252
|
+
if (mode === 'slide-bottom') {
|
|
253
|
+
aniNum = type ? '100%' : '0';
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
this.animation[this.animationMode()[mode]](aniNum);
|
|
258
|
+
};
|
|
259
|
+
if (typeof this.mode === 'string') {
|
|
260
|
+
buildTranfrom(type, this.mode);
|
|
261
|
+
} else {
|
|
262
|
+
this.mode.forEach((mode) => {
|
|
263
|
+
buildTranfrom(type, mode);
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
return this.animation;
|
|
268
|
+
},
|
|
269
|
+
animationType(type) {
|
|
270
|
+
return {
|
|
271
|
+
fade: type ? 1 : 0,
|
|
272
|
+
'slide-top': `translateY(${type ? '0' : '-100%'})`,
|
|
273
|
+
'slide-right': `translateX(${type ? '0' : '100%'})`,
|
|
274
|
+
'slide-bottom': `translateY(${type ? '0' : '100%'})`,
|
|
275
|
+
'slide-left': `translateX(${type ? '0' : '-100%'})`,
|
|
276
|
+
'zoom-in': `scaleX(${type ? 1 : 0.8}) scaleY(${type ? 1 : 0.8})`,
|
|
277
|
+
'zoom-out': `scaleX(${type ? 1 : 1.2}) scaleY(${type ? 1 : 1.2})`
|
|
278
|
+
};
|
|
279
|
+
},
|
|
280
|
+
// 内置动画类型与实际动画对应字典
|
|
281
|
+
animationMode() {
|
|
282
|
+
return {
|
|
283
|
+
fade: 'opacity',
|
|
284
|
+
'slide-top': 'translateY',
|
|
285
|
+
'slide-right': 'translateX',
|
|
286
|
+
'slide-bottom': 'translateY',
|
|
287
|
+
'slide-left': 'translateX',
|
|
288
|
+
'zoom-in': 'scale',
|
|
289
|
+
'zoom-out': 'scale'
|
|
290
|
+
};
|
|
291
|
+
},
|
|
292
|
+
// 驼峰转中横线
|
|
293
|
+
toLine(name) {
|
|
294
|
+
return name.replace(/([A-Z])/g, '-$1').toLowerCase();
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
</script>
|
|
299
|
+
|
|
300
|
+
<style></style>
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="u-code-wrap">
|
|
3
|
+
<!-- 此组件功能由js完成,无需写html逻辑 -->
|
|
4
|
+
</view>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
/**
|
|
9
|
+
* verificationCode 验证码输入框
|
|
10
|
+
* @description 考虑到用户实际发送验证码的场景,可能是一个按钮,也可能是一段文字,提示语各有不同,所以本组件 不提供界面显示,只提供提示语,由用户将提示语嵌入到具体的场景
|
|
11
|
+
* @tutorial https://www.uviewui.com/components/verificationCode.html
|
|
12
|
+
* @property {Number String} seconds 倒计时所需的秒数(默认60)
|
|
13
|
+
* @property {String} start-text 开始前的提示语,见官网说明(默认获取验证码)
|
|
14
|
+
* @property {String} change-text 倒计时期间的提示语,必须带有字母"x",见官网说明(默认X秒重新获取)
|
|
15
|
+
* @property {String} end-text 倒计结束的提示语,见官网说明(默认重新获取)
|
|
16
|
+
* @property {Boolean} keep-running 是否在H5刷新或各端返回再进入时继续倒计时(默认false)
|
|
17
|
+
* @event {Function} change 倒计时期间,每秒触发一次
|
|
18
|
+
* @event {Function} start 开始倒计时触发
|
|
19
|
+
* @event {Function} end 结束倒计时触发
|
|
20
|
+
* @example <up-verification-code :seconds="seconds" @end="end" @start="start" ref="uCode"
|
|
21
|
+
*/
|
|
22
|
+
export default {
|
|
23
|
+
name: 'up-verification-code',
|
|
24
|
+
props: {
|
|
25
|
+
// 倒计时总秒数
|
|
26
|
+
seconds: {
|
|
27
|
+
type: [String, Number],
|
|
28
|
+
default: 60
|
|
29
|
+
},
|
|
30
|
+
// 尚未开始时提示
|
|
31
|
+
startText: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: '获取验证码'
|
|
34
|
+
},
|
|
35
|
+
// 正在倒计时中的提示
|
|
36
|
+
changeText: {
|
|
37
|
+
type: String,
|
|
38
|
+
default: 'X秒重新获取'
|
|
39
|
+
},
|
|
40
|
+
// 倒计时结束时的提示
|
|
41
|
+
endText: {
|
|
42
|
+
type: String,
|
|
43
|
+
default: '重新获取'
|
|
44
|
+
},
|
|
45
|
+
// 是否在H5刷新或各端返回再进入时继续倒计时
|
|
46
|
+
keepRunning: {
|
|
47
|
+
type: Boolean,
|
|
48
|
+
default: false
|
|
49
|
+
},
|
|
50
|
+
// 为了区分多个页面,或者一个页面多个倒计时组件本地存储的继续倒计时变了
|
|
51
|
+
uniqueKey: {
|
|
52
|
+
type: String,
|
|
53
|
+
default: ''
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
data() {
|
|
57
|
+
return {
|
|
58
|
+
secNum: this.seconds,
|
|
59
|
+
timer: null,
|
|
60
|
+
canGetCode: true // 是否可以执行验证码操作
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
mounted() {
|
|
64
|
+
this.checkKeepRunning();
|
|
65
|
+
},
|
|
66
|
+
watch: {
|
|
67
|
+
seconds: {
|
|
68
|
+
immediate: true,
|
|
69
|
+
handler(n) {
|
|
70
|
+
this.secNum = n;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
methods: {
|
|
75
|
+
checkKeepRunning() {
|
|
76
|
+
// 获取上一次退出页面(H5还包括刷新)时的时间戳,如果没有上次的保存,此值可能为空
|
|
77
|
+
let lastTimestamp = Number(uni.getStorageSync(this.uniqueKey + '_$uCountDownTimestamp'));
|
|
78
|
+
if (!lastTimestamp) return this.changeEvent(this.startText);
|
|
79
|
+
// 当前秒的时间戳
|
|
80
|
+
let nowTimestamp = Math.floor(+new Date() / 1000);
|
|
81
|
+
// 判断当前的时间戳,是否小于上一次的本该按设定结束,却提前结束的时间戳
|
|
82
|
+
if (this.keepRunning && lastTimestamp && lastTimestamp > nowTimestamp) {
|
|
83
|
+
// 剩余尚未执行完的倒计秒数
|
|
84
|
+
this.secNum = lastTimestamp - nowTimestamp;
|
|
85
|
+
// 清除本地保存的变量
|
|
86
|
+
uni.removeStorageSync(this.uniqueKey + '_$uCountDownTimestamp');
|
|
87
|
+
// 开始倒计时
|
|
88
|
+
this.start();
|
|
89
|
+
} else {
|
|
90
|
+
// 如果不存在需要继续上一次的倒计时,执行正常的逻辑
|
|
91
|
+
this.changeEvent(this.startText);
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
// 开始倒计时
|
|
95
|
+
start() {
|
|
96
|
+
// 防止快速点击获取验证码的按钮而导致内部产生多个定时器导致混乱
|
|
97
|
+
if (this.timer) {
|
|
98
|
+
clearInterval(this.timer);
|
|
99
|
+
this.timer = null;
|
|
100
|
+
}
|
|
101
|
+
this.$emit('start');
|
|
102
|
+
this.canGetCode = false;
|
|
103
|
+
// 这里放这句,是为了一开始时就提示,否则要等setInterval的1秒后才会有提示
|
|
104
|
+
this.changeEvent(this.changeText.replace(/x|X/, this.secNum));
|
|
105
|
+
this.setTimeToStorage();
|
|
106
|
+
this.timer = setInterval(() => {
|
|
107
|
+
if (--this.secNum) {
|
|
108
|
+
// 用当前倒计时的秒数替换提示字符串中的"x"字母
|
|
109
|
+
this.changeEvent(this.changeText.replace(/x|X/, this.secNum));
|
|
110
|
+
} else {
|
|
111
|
+
clearInterval(this.timer);
|
|
112
|
+
this.timer = null;
|
|
113
|
+
this.changeEvent(this.endText);
|
|
114
|
+
this.secNum = this.seconds;
|
|
115
|
+
this.$emit('end');
|
|
116
|
+
this.canGetCode = true;
|
|
117
|
+
}
|
|
118
|
+
}, 1000);
|
|
119
|
+
},
|
|
120
|
+
// 重置,可以让用户再次获取验证码
|
|
121
|
+
reset() {
|
|
122
|
+
this.canGetCode = true;
|
|
123
|
+
clearInterval(this.timer);
|
|
124
|
+
this.secNum = this.seconds;
|
|
125
|
+
this.changeEvent(this.endText);
|
|
126
|
+
},
|
|
127
|
+
changeEvent(text) {
|
|
128
|
+
this.$emit('change', text);
|
|
129
|
+
},
|
|
130
|
+
// 保存时间戳,为了防止倒计时尚未结束,H5刷新或者各端的右上角返回上一页再进来
|
|
131
|
+
setTimeToStorage() {
|
|
132
|
+
if (!this.keepRunning || !this.timer) return;
|
|
133
|
+
// 记录当前的时间戳,为了下次进入页面,如果还在倒计时内的话,继续倒计时
|
|
134
|
+
// 倒计时尚未结束,结果大于0;倒计时已经开始,就会小于初始值,如果等于初始值,说明没有开始倒计时,无需处理
|
|
135
|
+
if (this.secNum > 0 && this.secNum <= this.seconds) {
|
|
136
|
+
// 获取当前时间戳(+ new Date()为特殊写法),除以1000变成秒,再去除小数部分
|
|
137
|
+
let nowTimestamp = Math.floor(+new Date() / 1000);
|
|
138
|
+
// 将本该结束时候的时间戳保存起来 => 当前时间戳 + 剩余的秒数
|
|
139
|
+
uni.setStorage({
|
|
140
|
+
key: this.uniqueKey + '_$uCountDownTimestamp',
|
|
141
|
+
data: nowTimestamp + Number(this.secNum)
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
// 组件销毁的时候,清除定时器,否则定时器会继续存在,系统不会自动清除
|
|
147
|
+
beforeDestroy() {
|
|
148
|
+
this.setTimeToStorage();
|
|
149
|
+
clearTimeout(this.timer);
|
|
150
|
+
this.timer = null;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
</script>
|
|
154
|
+
<style scoped>
|
|
155
|
+
.u-code-wrap {
|
|
156
|
+
width: 0;
|
|
157
|
+
height: 0;
|
|
158
|
+
position: fixed;
|
|
159
|
+
z-index: -1;
|
|
160
|
+
}
|
|
161
|
+
</style>
|