@gmcb/uv-ui 0.2.26
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/CHANGELOG.md +295 -0
- package/LICENSE +21 -0
- package/README.md +164 -0
- package/components/uv-action-sheet/props.js +50 -0
- package/components/uv-action-sheet/uv-action-sheet.vue +280 -0
- package/components/uv-album/uv-album.vue +312 -0
- package/components/uv-alert/props.js +45 -0
- package/components/uv-alert/uv-alert.vue +246 -0
- package/components/uv-avatar/props.js +85 -0
- package/components/uv-avatar/uv-avatar.vue +182 -0
- package/components/uv-avatar-group/props.js +53 -0
- package/components/uv-avatar-group/uv-avatar-group.vue +106 -0
- package/components/uv-back-top/props.js +58 -0
- package/components/uv-back-top/uv-back-top.vue +116 -0
- package/components/uv-badge/props.js +73 -0
- package/components/uv-badge/uv-badge.vue +176 -0
- package/components/uv-button/nvue.scss +46 -0
- package/components/uv-button/props.js +163 -0
- package/components/uv-button/uv-button.vue +529 -0
- package/components/uv-button/vue.scss +93 -0
- package/components/uv-calendar/calendar.js +546 -0
- package/components/uv-calendar/header.vue +104 -0
- package/components/uv-calendar/month.vue +616 -0
- package/components/uv-calendar/props.js +145 -0
- package/components/uv-calendar/uv-calendar.vue +390 -0
- package/components/uv-calendars/calendar-body.vue +376 -0
- package/components/uv-calendars/calendar-item.vue +248 -0
- package/components/uv-calendars/calendar.js +546 -0
- package/components/uv-calendars/i18n/en.json +12 -0
- package/components/uv-calendars/i18n/index.js +8 -0
- package/components/uv-calendars/i18n/zh-Hans.json +12 -0
- package/components/uv-calendars/i18n/zh-Hant.json +12 -0
- package/components/uv-calendars/util.js +435 -0
- package/components/uv-calendars/uv-calendars.vue +452 -0
- package/components/uv-cell/props.js +116 -0
- package/components/uv-cell/uv-cell.vue +209 -0
- package/components/uv-cell-group/props.js +15 -0
- package/components/uv-cell-group/uv-cell-group.vue +63 -0
- package/components/uv-checkbox/props.js +70 -0
- package/components/uv-checkbox/uv-checkbox.vue +371 -0
- package/components/uv-checkbox-group/props.js +84 -0
- package/components/uv-checkbox-group/uv-checkbox-group.vue +119 -0
- package/components/uv-code/props.js +35 -0
- package/components/uv-code/uv-code.vue +136 -0
- package/components/uv-code-input/props.js +83 -0
- package/components/uv-code-input/uv-code-input.vue +272 -0
- package/components/uv-col/props.js +30 -0
- package/components/uv-col/uv-col.vue +165 -0
- package/components/uv-collapse/props.js +20 -0
- package/components/uv-collapse/uv-collapse.vue +86 -0
- package/components/uv-collapse-item/props.js +60 -0
- package/components/uv-collapse-item/uv-collapse-item.vue +228 -0
- package/components/uv-column-notice/props.js +61 -0
- package/components/uv-column-notice/uv-column-notice.vue +176 -0
- package/components/uv-count-down/props.js +25 -0
- package/components/uv-count-down/utils.js +62 -0
- package/components/uv-count-down/uv-count-down.vue +169 -0
- package/components/uv-count-to/props.js +60 -0
- package/components/uv-count-to/uv-count-to.vue +187 -0
- package/components/uv-datetime-picker/props.js +130 -0
- package/components/uv-datetime-picker/uv-datetime-picker.vue +355 -0
- package/components/uv-divider/props.js +45 -0
- package/components/uv-divider/uv-divider.vue +113 -0
- package/components/uv-drop-down/uv-drop-down.vue +135 -0
- package/components/uv-drop-down-item/uv-drop-down-item.vue +169 -0
- package/components/uv-drop-down-popup/uv-drop-down-popup.vue +242 -0
- package/components/uv-empty/props.js +60 -0
- package/components/uv-empty/uv-empty.vue +126 -0
- package/components/uv-form/props.js +46 -0
- package/components/uv-form/uv-form.vue +209 -0
- package/components/uv-form/valid.js +1343 -0
- package/components/uv-form-item/props.js +49 -0
- package/components/uv-form-item/uv-form-item.vue +226 -0
- package/components/uv-gap/props.js +25 -0
- package/components/uv-gap/uv-gap.vue +36 -0
- package/components/uv-grid/props.js +20 -0
- package/components/uv-grid/uv-grid.vue +100 -0
- package/components/uv-grid-item/props.js +15 -0
- package/components/uv-grid-item/uv-grid-item.vue +223 -0
- package/components/uv-icon/icons.js +160 -0
- package/components/uv-icon/props.js +90 -0
- package/components/uv-icon/uv-icon.vue +226 -0
- package/components/uv-icon/uvicons.ttf +0 -0
- package/components/uv-image/props.js +100 -0
- package/components/uv-image/uv-image.vue +296 -0
- package/components/uv-index-anchor/props.js +30 -0
- package/components/uv-index-anchor/uv-index-anchor.vue +98 -0
- package/components/uv-index-item/uv-index-item.vue +87 -0
- package/components/uv-index-list/props.js +30 -0
- package/components/uv-index-list/uv-index-list.vue +461 -0
- package/components/uv-input/props.js +175 -0
- package/components/uv-input/uv-input.vue +348 -0
- package/components/uv-keyboard/props.js +95 -0
- package/components/uv-keyboard/uv-keyboard.vue +180 -0
- package/components/uv-keyboard-car/props.js +24 -0
- package/components/uv-keyboard-car/uv-keyboard-car.vue +347 -0
- package/components/uv-keyboard-number/props.js +19 -0
- package/components/uv-keyboard-number/uv-keyboard-number.vue +201 -0
- package/components/uv-line/props.js +34 -0
- package/components/uv-line/uv-line.vue +60 -0
- package/components/uv-line-progress/props.js +29 -0
- package/components/uv-line-progress/uv-line-progress.vue +146 -0
- package/components/uv-link/props.js +40 -0
- package/components/uv-link/uv-link.vue +83 -0
- package/components/uv-list/uv-list.vue +147 -0
- package/components/uv-list-item/uv-list-item.vue +535 -0
- package/components/uv-load-more/props.js +95 -0
- package/components/uv-load-more/uv-load-more.vue +152 -0
- package/components/uv-loading-icon/props.js +67 -0
- package/components/uv-loading-icon/uv-loading-icon.vue +347 -0
- package/components/uv-loading-page/props.js +55 -0
- package/components/uv-loading-page/uv-loading-page.vue +96 -0
- package/components/uv-modal/props.js +90 -0
- package/components/uv-modal/uv-modal.vue +245 -0
- package/components/uv-navbar/props.js +89 -0
- package/components/uv-navbar/uv-navbar.vue +245 -0
- package/components/uv-no-network/props.js +20 -0
- package/components/uv-no-network/uv-no-network.vue +222 -0
- package/components/uv-notice-bar/props.js +76 -0
- package/components/uv-notice-bar/uv-notice-bar.vue +110 -0
- package/components/uv-notify/props.js +45 -0
- package/components/uv-notify/uv-notify.vue +220 -0
- package/components/uv-number-box/props.js +118 -0
- package/components/uv-number-box/uv-number-box.vue +397 -0
- package/components/uv-overlay/props.js +25 -0
- package/components/uv-overlay/uv-overlay.vue +85 -0
- package/components/uv-parse/node/node.vue +576 -0
- package/components/uv-parse/parser.js +1335 -0
- package/components/uv-parse/uv-parse.vue +498 -0
- package/components/uv-pick-color/colors.js +217 -0
- package/components/uv-pick-color/props.js +47 -0
- package/components/uv-pick-color/uv-pick-color.vue +551 -0
- package/components/uv-picker/props.js +95 -0
- package/components/uv-picker/uv-picker.vue +329 -0
- package/components/uv-popup/keypress.js +45 -0
- package/components/uv-popup/uv-popup.vue +537 -0
- package/components/uv-preview-video/uv-preview-video.vue +52 -0
- package/components/uv-qrcode/cache.js +1 -0
- package/components/uv-qrcode/gcanvas/bridge/bridge-weex.js +241 -0
- package/components/uv-qrcode/gcanvas/context-2d/FillStyleLinearGradient.js +18 -0
- package/components/uv-qrcode/gcanvas/context-2d/FillStylePattern.js +8 -0
- package/components/uv-qrcode/gcanvas/context-2d/FillStyleRadialGradient.js +17 -0
- package/components/uv-qrcode/gcanvas/context-2d/RenderingContext.js +666 -0
- package/components/uv-qrcode/gcanvas/context-webgl/ActiveInfo.js +11 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Buffer.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Framebuffer.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/GLenum.js +298 -0
- package/components/uv-qrcode/gcanvas/context-webgl/GLmethod.js +142 -0
- package/components/uv-qrcode/gcanvas/context-webgl/GLtype.js +23 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Program.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Renderbuffer.js +21 -0
- package/components/uv-qrcode/gcanvas/context-webgl/RenderingContext.js +1191 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Shader.js +22 -0
- package/components/uv-qrcode/gcanvas/context-webgl/ShaderPrecisionFormat.js +11 -0
- package/components/uv-qrcode/gcanvas/context-webgl/Texture.js +22 -0
- package/components/uv-qrcode/gcanvas/context-webgl/UniformLocation.js +22 -0
- package/components/uv-qrcode/gcanvas/context-webgl/classUtils.js +3 -0
- package/components/uv-qrcode/gcanvas/env/canvas.js +74 -0
- package/components/uv-qrcode/gcanvas/env/image.js +96 -0
- package/components/uv-qrcode/gcanvas/env/tool.js +24 -0
- package/components/uv-qrcode/gcanvas/index.js +39 -0
- package/components/uv-qrcode/props.js +85 -0
- package/components/uv-qrcode/qrcode.js +34 -0
- package/components/uv-qrcode/queue.js +41 -0
- package/components/uv-qrcode/uv-qrcode.vue +1038 -0
- package/components/uv-radio/props.js +65 -0
- package/components/uv-radio/uv-radio.vue +349 -0
- package/components/uv-radio-group/props.js +89 -0
- package/components/uv-radio-group/uv-radio-group.vue +115 -0
- package/components/uv-rate/props.js +73 -0
- package/components/uv-rate/uv-rate.vue +274 -0
- package/components/uv-read-more/props.js +62 -0
- package/components/uv-read-more/uv-read-more.vue +162 -0
- package/components/uv-row/props.js +20 -0
- package/components/uv-row/uv-row.vue +95 -0
- package/components/uv-row-notice/props.js +40 -0
- package/components/uv-row-notice/uv-row-notice.vue +341 -0
- package/components/uv-safe-bottom/uv-safe-bottom.vue +67 -0
- package/components/uv-scroll-list/nvue.js +29 -0
- package/components/uv-scroll-list/props.js +35 -0
- package/components/uv-scroll-list/scrollWxs.wxs +51 -0
- package/components/uv-scroll-list/uv-scroll-list.vue +218 -0
- package/components/uv-search/props.js +127 -0
- package/components/uv-search/uv-search.vue +311 -0
- package/components/uv-skeleton/props.js +65 -0
- package/components/uv-skeleton/uv-skeleton.vue +250 -0
- package/components/uv-skeletons/uv-skeletons.vue +247 -0
- package/components/uv-slider/props.js +58 -0
- package/components/uv-slider/uv-slider.vue +58 -0
- package/components/uv-status-bar/props.js +8 -0
- package/components/uv-status-bar/uv-status-bar.vue +54 -0
- package/components/uv-steps/props.js +40 -0
- package/components/uv-steps/uv-steps.vue +83 -0
- package/components/uv-steps-item/props.js +25 -0
- package/components/uv-steps-item/uv-steps-item.vue +347 -0
- package/components/uv-sticky/props.js +41 -0
- package/components/uv-sticky/uv-sticky.vue +223 -0
- package/components/uv-subsection/props.js +54 -0
- package/components/uv-subsection/uv-subsection.vue +269 -0
- package/components/uv-swipe-action/props.js +10 -0
- package/components/uv-swipe-action/uv-swipe-action.vue +65 -0
- package/components/uv-swipe-action-item/index - backup.wxs +256 -0
- package/components/uv-swipe-action-item/index.wxs +225 -0
- package/components/uv-swipe-action-item/nvue - backup.js +264 -0
- package/components/uv-swipe-action-item/nvue.js +182 -0
- package/components/uv-swipe-action-item/props.js +40 -0
- package/components/uv-swipe-action-item/uv-swipe-action-item.vue +200 -0
- package/components/uv-swipe-action-item/wxs.js +15 -0
- package/components/uv-swiper/props.js +136 -0
- package/components/uv-swiper/uv-swiper.vue +263 -0
- package/components/uv-swiper-indicator/props.js +30 -0
- package/components/uv-swiper-indicator/uv-swiper-indicator.vue +112 -0
- package/components/uv-switch/props.js +58 -0
- package/components/uv-switch/uv-switch.vue +182 -0
- package/components/uv-tabbar/props.js +50 -0
- package/components/uv-tabbar/uv-tabbar.vue +146 -0
- package/components/uv-tabbar-item/props.js +40 -0
- package/components/uv-tabbar-item/uv-tabbar-item.vue +146 -0
- package/components/uv-tabs/props.js +71 -0
- package/components/uv-tabs/uv-tabs.vue +391 -0
- package/components/uv-tags/props.js +104 -0
- package/components/uv-tags/uv-tags.vue +379 -0
- package/components/uv-text/props.js +113 -0
- package/components/uv-text/uv-text.vue +218 -0
- package/components/uv-text/value.js +87 -0
- package/components/uv-textarea/props.js +138 -0
- package/components/uv-textarea/uv-textarea.vue +238 -0
- package/components/uv-toast/uv-toast.vue +292 -0
- package/components/uv-toolbar/props.js +40 -0
- package/components/uv-toolbar/uv-toolbar.vue +109 -0
- package/components/uv-tooltip/props.js +60 -0
- package/components/uv-tooltip/uv-tooltip.vue +372 -0
- package/components/uv-transition/createAnimation.js +131 -0
- package/components/uv-transition/props.js +31 -0
- package/components/uv-transition/uv-transition.vue +320 -0
- package/components/uv-upload/mixin.js +22 -0
- package/components/uv-upload/props.js +130 -0
- package/components/uv-upload/utils.js +151 -0
- package/components/uv-upload/uv-upload.vue +488 -0
- package/components/uv-vtabs/props.js +79 -0
- package/components/uv-vtabs/uv-vtabs.vue +438 -0
- package/components/uv-vtabs-item/uv-vtabs-item.vue +68 -0
- package/components/uv-waterfall/props.js +69 -0
- package/components/uv-waterfall/uv-waterfall.vue +265 -0
- package/index.js +82 -0
- package/index.scss +7 -0
- package/libs/config/config.js +34 -0
- package/libs/css/color.scss +32 -0
- package/libs/css/common.scss +100 -0
- package/libs/css/components.scss +23 -0
- package/libs/css/variable.scss +111 -0
- package/libs/css/vue.scss +40 -0
- package/libs/function/colorGradient.js +134 -0
- package/libs/function/compress.js +27 -0
- package/libs/function/debounce.js +29 -0
- package/libs/function/digit.js +167 -0
- package/libs/function/index.js +734 -0
- package/libs/function/platform.js +75 -0
- package/libs/function/test.js +287 -0
- package/libs/function/throttle.js +30 -0
- package/libs/luch-request/adapters/index.js +132 -0
- package/libs/luch-request/core/InterceptorManager.js +51 -0
- package/libs/luch-request/core/Request.js +201 -0
- package/libs/luch-request/core/buildFullPath.js +20 -0
- package/libs/luch-request/core/defaults.js +33 -0
- package/libs/luch-request/core/dispatchRequest.js +6 -0
- package/libs/luch-request/core/mergeConfig.js +126 -0
- package/libs/luch-request/core/settle.js +16 -0
- package/libs/luch-request/helpers/buildURL.js +64 -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 +197 -0
- package/libs/luch-request/index.js +2 -0
- package/libs/luch-request/utils/clone.js +264 -0
- package/libs/luch-request/utils.js +135 -0
- package/libs/mixin/button.js +13 -0
- package/libs/mixin/mixin.js +172 -0
- package/libs/mixin/mpMixin.js +8 -0
- package/libs/mixin/mpShare.js +13 -0
- package/libs/mixin/openType.js +47 -0
- package/libs/mixin/touch.js +59 -0
- package/libs/util/dayjs.js +216 -0
- package/libs/util/route.js +126 -0
- package/package.json +28 -0
- package/theme.scss +43 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="uv-code">
|
|
3
|
+
<!-- 此组件功能由js完成,无需写html逻辑 -->
|
|
4
|
+
</view>
|
|
5
|
+
</template>
|
|
6
|
+
<script>
|
|
7
|
+
import mpMixin from '../../libs/mixin/mpMixin.js'
|
|
8
|
+
import mixin from '../../libs/mixin/mixin.js'
|
|
9
|
+
import props from './props.js';
|
|
10
|
+
/**
|
|
11
|
+
* Code 验证码倒计时
|
|
12
|
+
* @description 考虑到用户实际发送验证码的场景,可能是一个按钮,也可能是一段文字,提示语各有不同,所以本组件不提供界面显示,只提供倒计时文本,由用户将文本嵌入到具体的场景
|
|
13
|
+
* @tutorial https://www.uvui.cn/components/code.html
|
|
14
|
+
* @property {String | Number} seconds 倒计时所需的秒数(默认 60 )
|
|
15
|
+
* @property {String} startText 开始前的提示语,见官网说明(默认 '获取验证码' )
|
|
16
|
+
* @property {String} changeText 倒计时期间的提示语,必须带有字母"x",见官网说明(默认 'X秒重新获取' )
|
|
17
|
+
* @property {String} endText 倒计结束的提示语,见官网说明(默认 '重新获取' )
|
|
18
|
+
* @property {Boolean} keepRunning 是否在H5刷新或各端返回再进入时继续倒计时( 默认false )
|
|
19
|
+
* @property {String} uniqueKey 为了区分多个页面,或者一个页面多个倒计时组件本地存储的继续倒计时变了
|
|
20
|
+
*
|
|
21
|
+
* @event {Function} change 倒计时期间,每秒触发一次
|
|
22
|
+
* @event {Function} start 开始倒计时触发
|
|
23
|
+
* @event {Function} end 结束倒计时触发
|
|
24
|
+
* @example <uv-code ref="uCode" @change="codeChange" seconds="20"></uv-code>
|
|
25
|
+
*/
|
|
26
|
+
export default {
|
|
27
|
+
name: "uv-code",
|
|
28
|
+
mixins: [mpMixin, mixin, props],
|
|
29
|
+
data() {
|
|
30
|
+
return {
|
|
31
|
+
secNum: this.seconds,
|
|
32
|
+
timer: null,
|
|
33
|
+
canGetCode: true, // 是否可以执行验证码操作
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
mounted() {
|
|
37
|
+
this.checkKeepRunning()
|
|
38
|
+
},
|
|
39
|
+
watch: {
|
|
40
|
+
seconds: {
|
|
41
|
+
immediate: true,
|
|
42
|
+
handler(n) {
|
|
43
|
+
this.secNum = n
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
methods: {
|
|
48
|
+
checkKeepRunning() {
|
|
49
|
+
// 获取上一次退出页面(H5还包括刷新)时的时间戳,如果没有上次的保存,此值可能为空
|
|
50
|
+
let lastTimestamp = Number(uni.getStorageSync(this.uniqueKey + '_$uCountDownTimestamp'))
|
|
51
|
+
if (!lastTimestamp) return this.changeEvent(this.startText)
|
|
52
|
+
// 当前秒的时间戳
|
|
53
|
+
let nowTimestamp = Math.floor((+new Date()) / 1000)
|
|
54
|
+
// 判断当前的时间戳,是否小于上一次的本该按设定结束,却提前结束的时间戳
|
|
55
|
+
if (this.keepRunning && lastTimestamp && lastTimestamp > nowTimestamp) {
|
|
56
|
+
// 剩余尚未执行完的倒计秒数
|
|
57
|
+
this.secNum = lastTimestamp - nowTimestamp
|
|
58
|
+
// 清除本地保存的变量
|
|
59
|
+
uni.removeStorageSync(this.uniqueKey + '_$uCountDownTimestamp')
|
|
60
|
+
// 开始倒计时
|
|
61
|
+
this.start()
|
|
62
|
+
} else {
|
|
63
|
+
// 如果不存在需要继续上一次的倒计时,执行正常的逻辑
|
|
64
|
+
this.changeEvent(this.startText)
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
// 开始倒计时
|
|
68
|
+
start() {
|
|
69
|
+
// 防止快速点击获取验证码的按钮而导致内部产生多个定时器导致混乱
|
|
70
|
+
if (this.timer) {
|
|
71
|
+
clearInterval(this.timer)
|
|
72
|
+
this.timer = null
|
|
73
|
+
}
|
|
74
|
+
this.$emit('start')
|
|
75
|
+
this.canGetCode = false
|
|
76
|
+
// 这里放这句,是为了一开始时就提示,否则要等setInterval的1秒后才会有提示
|
|
77
|
+
this.changeEvent(this.changeText.replace(/x|X/, this.secNum))
|
|
78
|
+
this.timer = setInterval(() => {
|
|
79
|
+
if (--this.secNum) {
|
|
80
|
+
// 用当前倒计时的秒数替换提示字符串中的"x"字母
|
|
81
|
+
this.changeEvent(this.changeText.replace(/x|X/, this.secNum))
|
|
82
|
+
} else {
|
|
83
|
+
clearInterval(this.timer)
|
|
84
|
+
this.timer = null
|
|
85
|
+
this.changeEvent(this.endText)
|
|
86
|
+
this.secNum = this.seconds
|
|
87
|
+
this.$emit('end')
|
|
88
|
+
this.canGetCode = true
|
|
89
|
+
}
|
|
90
|
+
}, 1000)
|
|
91
|
+
this.setTimeToStorage()
|
|
92
|
+
},
|
|
93
|
+
// 重置,可以让用户再次获取验证码
|
|
94
|
+
reset() {
|
|
95
|
+
this.canGetCode = true
|
|
96
|
+
clearInterval(this.timer)
|
|
97
|
+
this.secNum = this.seconds
|
|
98
|
+
this.changeEvent(this.endText)
|
|
99
|
+
},
|
|
100
|
+
changeEvent(text) {
|
|
101
|
+
this.$emit('change', text)
|
|
102
|
+
},
|
|
103
|
+
// 保存时间戳,为了防止倒计时尚未结束,H5刷新或者各端的右上角返回上一页再进来
|
|
104
|
+
setTimeToStorage() {
|
|
105
|
+
if (!this.keepRunning || !this.timer) return
|
|
106
|
+
// 记录当前的时间戳,为了下次进入页面,如果还在倒计时内的话,继续倒计时
|
|
107
|
+
// 倒计时尚未结束,结果大于0;倒计时已经开始,就会小于初始值,如果等于初始值,说明没有开始倒计时,无需处理
|
|
108
|
+
if (this.secNum > 0 && this.secNum <= this.seconds) {
|
|
109
|
+
// 获取当前时间戳(+ new Date()为特殊写法),除以1000变成秒,再去除小数部分
|
|
110
|
+
let nowTimestamp = Math.floor((+new Date()) / 1000)
|
|
111
|
+
// 将本该结束时候的时间戳保存起来 => 当前时间戳 + 剩余的秒数
|
|
112
|
+
uni.setStorage({
|
|
113
|
+
key: this.uniqueKey + '_$uCountDownTimestamp',
|
|
114
|
+
data: nowTimestamp + Number(this.secNum)
|
|
115
|
+
})
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
// #ifdef VUE2
|
|
120
|
+
// 组件销毁的时候,清除定时器,否则定时器会继续存在,系统不会自动清除
|
|
121
|
+
beforeDestroy() {
|
|
122
|
+
this.setTimeToStorage()
|
|
123
|
+
clearTimeout(this.timer)
|
|
124
|
+
this.timer = null
|
|
125
|
+
},
|
|
126
|
+
// #endif
|
|
127
|
+
// #ifdef VUE3
|
|
128
|
+
// 组件销毁,兼容vue3
|
|
129
|
+
unmounted() {
|
|
130
|
+
this.setTimeToStorage()
|
|
131
|
+
clearTimeout(this.timer)
|
|
132
|
+
this.timer = null
|
|
133
|
+
}
|
|
134
|
+
// #endif
|
|
135
|
+
}
|
|
136
|
+
</script>
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
value: {
|
|
4
|
+
type: [String, Number],
|
|
5
|
+
default: ''
|
|
6
|
+
},
|
|
7
|
+
modelValue: {
|
|
8
|
+
type: [String, Number],
|
|
9
|
+
default: ''
|
|
10
|
+
},
|
|
11
|
+
// 键盘弹起时,是否自动上推页面
|
|
12
|
+
adjustPosition: {
|
|
13
|
+
type: Boolean,
|
|
14
|
+
default: true
|
|
15
|
+
},
|
|
16
|
+
// 最大输入长度
|
|
17
|
+
maxlength: {
|
|
18
|
+
type: [String, Number],
|
|
19
|
+
default: 6
|
|
20
|
+
},
|
|
21
|
+
// 是否用圆点填充
|
|
22
|
+
dot: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
default: false
|
|
25
|
+
},
|
|
26
|
+
// 显示模式,box-盒子模式,line-底部横线模式
|
|
27
|
+
mode: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: 'box'
|
|
30
|
+
},
|
|
31
|
+
// 是否细边框
|
|
32
|
+
hairline: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: false
|
|
35
|
+
},
|
|
36
|
+
// 字符间的距离
|
|
37
|
+
space: {
|
|
38
|
+
type: [String, Number],
|
|
39
|
+
default: 10
|
|
40
|
+
},
|
|
41
|
+
// 是否自动获取焦点
|
|
42
|
+
focus: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: false
|
|
45
|
+
},
|
|
46
|
+
// 字体是否加粗
|
|
47
|
+
bold: {
|
|
48
|
+
type: Boolean,
|
|
49
|
+
default: false
|
|
50
|
+
},
|
|
51
|
+
// 字体颜色
|
|
52
|
+
color: {
|
|
53
|
+
type: String,
|
|
54
|
+
default: '#606266'
|
|
55
|
+
},
|
|
56
|
+
// 字体大小
|
|
57
|
+
fontSize: {
|
|
58
|
+
type: [String, Number],
|
|
59
|
+
default: 18
|
|
60
|
+
},
|
|
61
|
+
// 输入框的大小,宽等于高
|
|
62
|
+
size: {
|
|
63
|
+
type: [String, Number],
|
|
64
|
+
default: 35
|
|
65
|
+
},
|
|
66
|
+
// 是否隐藏原生键盘,如果想用自定义键盘的话,需设置此参数为true
|
|
67
|
+
disabledKeyboard: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
default: false
|
|
70
|
+
},
|
|
71
|
+
// 边框和线条颜色
|
|
72
|
+
borderColor: {
|
|
73
|
+
type: String,
|
|
74
|
+
default: '#c9cacc'
|
|
75
|
+
},
|
|
76
|
+
// 是否禁止输入"."符号
|
|
77
|
+
disabledDot: {
|
|
78
|
+
type: Boolean,
|
|
79
|
+
default: true
|
|
80
|
+
},
|
|
81
|
+
...uni.$uv?.props?.codeInput
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="uv-code-input">
|
|
3
|
+
<view
|
|
4
|
+
class="uv-code-input__item"
|
|
5
|
+
:style="[itemStyle(index)]"
|
|
6
|
+
v-for="(item, index) in codeLength"
|
|
7
|
+
:key="index"
|
|
8
|
+
>
|
|
9
|
+
<view
|
|
10
|
+
class="uv-code-input__item__dot"
|
|
11
|
+
v-if="dot && codeArray.length > index"
|
|
12
|
+
></view>
|
|
13
|
+
<text
|
|
14
|
+
v-else
|
|
15
|
+
:style="{
|
|
16
|
+
fontSize: $uv.addUnit(fontSize),
|
|
17
|
+
fontWeight: bold ? 'bold' : 'normal',
|
|
18
|
+
color: color
|
|
19
|
+
}"
|
|
20
|
+
>{{codeArray[index]}}</text>
|
|
21
|
+
<view
|
|
22
|
+
class="uv-code-input__item__line"
|
|
23
|
+
v-if="mode === 'line'"
|
|
24
|
+
:style="[lineStyle]"
|
|
25
|
+
></view>
|
|
26
|
+
<!-- #ifndef APP-PLUS -->
|
|
27
|
+
<view v-if="isFocus && codeArray.length === index" :style="{backgroundColor: color}" class="uv-code-input__item__cursor"></view>
|
|
28
|
+
<!-- #endif -->
|
|
29
|
+
</view>
|
|
30
|
+
<input
|
|
31
|
+
:disabled="disabledKeyboard"
|
|
32
|
+
type="number"
|
|
33
|
+
:focus="focus"
|
|
34
|
+
:value="inputValue"
|
|
35
|
+
:maxlength="maxlength"
|
|
36
|
+
:adjustPosition="adjustPosition"
|
|
37
|
+
class="uv-code-input__input"
|
|
38
|
+
@input="inputHandler"
|
|
39
|
+
:style="{
|
|
40
|
+
height: $uv.addUnit(size)
|
|
41
|
+
}"
|
|
42
|
+
@focus="isFocus = true"
|
|
43
|
+
@blur="isFocus = false"
|
|
44
|
+
/>
|
|
45
|
+
</view>
|
|
46
|
+
</template>
|
|
47
|
+
|
|
48
|
+
<script>
|
|
49
|
+
import mpMixin from '../../libs/mixin/mpMixin.js'
|
|
50
|
+
import mixin from '../../libs/mixin/mixin.js'
|
|
51
|
+
import props from './props.js';
|
|
52
|
+
/**
|
|
53
|
+
* CodeInput 验证码输入
|
|
54
|
+
* @description 该组件一般用于验证用户短信验证码的场景,也可以结合uvui的键盘组件使用
|
|
55
|
+
* @tutorial https://www.uvui.cn/components/codeInput.html
|
|
56
|
+
* @property {String | Number} value / v-model 预置值
|
|
57
|
+
* @property {String | Number} maxlength 最大输入长度 (默认 6 )
|
|
58
|
+
* @property {Boolean} dot 是否用圆点填充 (默认 false )
|
|
59
|
+
* @property {String} mode 显示模式,box-盒子模式,line-底部横线模式 (默认 'box' )
|
|
60
|
+
* @property {Boolean} hairline 是否细边框 (默认 false )
|
|
61
|
+
* @property {String | Number} space 字符间的距离 (默认 10 )
|
|
62
|
+
* @property {Boolean} focus 是否自动获取焦点 (默认 false )
|
|
63
|
+
* @property {Boolean} bold 字体和输入横线是否加粗 (默认 false )
|
|
64
|
+
* @property {String} color 字体颜色 (默认 '#606266' )
|
|
65
|
+
* @property {String | Number} fontSize 字体大小,单位px (默认 18 )
|
|
66
|
+
* @property {String | Number} size 输入框的大小,宽等于高 (默认 35 )
|
|
67
|
+
* @property {Boolean} disabledKeyboard 是否隐藏原生键盘,如果想用自定义键盘的话,需设置此参数为true (默认 false )
|
|
68
|
+
* @property {String} borderColor 边框和线条颜色 (默认 '#c9cacc' )
|
|
69
|
+
* @property {Boolean} disabledDot 是否禁止输入"."符号 (默认 true )
|
|
70
|
+
*
|
|
71
|
+
* @event {Function} change 输入内容发生改变时触发,具体见上方说明 value:当前输入的值
|
|
72
|
+
* @event {Function} finish 输入字符个数达maxlength值时触发,见上方说明 value:当前输入的值
|
|
73
|
+
* @example <uv-code-input v-model="value4" :focus="true"></uv-code-input>
|
|
74
|
+
*/
|
|
75
|
+
export default {
|
|
76
|
+
name: 'uv-code-input',
|
|
77
|
+
mixins: [mpMixin, mixin, props],
|
|
78
|
+
data() {
|
|
79
|
+
return {
|
|
80
|
+
inputValue: '',
|
|
81
|
+
isFocus: this.focus
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
created() {
|
|
85
|
+
const value = String(this.value) || String(this.modelValue);
|
|
86
|
+
this.inputValue = String(value).substring(0, this.maxlength);
|
|
87
|
+
},
|
|
88
|
+
watch: {
|
|
89
|
+
value(newVal) {
|
|
90
|
+
// 转为字符串,超出部分截掉
|
|
91
|
+
this.inputValue = String(newVal).substring(0, this.maxlength);
|
|
92
|
+
if (this.disabledKeyboard) {
|
|
93
|
+
this.customInput();
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
modelValue(newVal) {
|
|
97
|
+
// 转为字符串,超出部分截掉
|
|
98
|
+
this.inputValue = String(newVal).substring(0, this.maxlength);
|
|
99
|
+
if (this.disabledKeyboard) {
|
|
100
|
+
this.customInput();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
computed: {
|
|
105
|
+
// 根据长度,循环输入框的个数,因为头条小程序数值不能用于v-for
|
|
106
|
+
codeLength() {
|
|
107
|
+
return new Array(Number(this.maxlength))
|
|
108
|
+
},
|
|
109
|
+
// 循环item的样式
|
|
110
|
+
itemStyle() {
|
|
111
|
+
return index => {
|
|
112
|
+
const addUnit = this.$uv.addUnit
|
|
113
|
+
const style = {
|
|
114
|
+
width: addUnit(this.size),
|
|
115
|
+
height: addUnit(this.size)
|
|
116
|
+
}
|
|
117
|
+
// 盒子模式下,需要额外进行处理
|
|
118
|
+
if (this.mode === 'box') {
|
|
119
|
+
// 设置盒子的边框,如果是细边框,则设置为0.5px宽度
|
|
120
|
+
style.border = `${this.hairline ? 0.5 : 1}px solid ${this.borderColor}`
|
|
121
|
+
// 如果盒子间距为0的话
|
|
122
|
+
if (this.$uv.getPx(this.space) === 0) {
|
|
123
|
+
// 给第一和最后一个盒子设置圆角
|
|
124
|
+
if (index === 0) {
|
|
125
|
+
style.borderTopLeftRadius = '3px'
|
|
126
|
+
style.borderBottomLeftRadius = '3px'
|
|
127
|
+
}
|
|
128
|
+
if (index === this.codeLength.length - 1) {
|
|
129
|
+
style.borderTopRightRadius = '3px'
|
|
130
|
+
style.borderBottomRightRadius = '3px'
|
|
131
|
+
}
|
|
132
|
+
// 最后一个盒子的右边框需要保留
|
|
133
|
+
if (index !== this.codeLength.length - 1) {
|
|
134
|
+
style.borderRight = 'none'
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (index !== this.codeLength.length - 1) {
|
|
139
|
+
// 设置验证码字符之间的距离,通过margin-right设置,最后一个字符,无需右边框
|
|
140
|
+
style.marginRight = addUnit(this.space)
|
|
141
|
+
} else {
|
|
142
|
+
// 最后一个盒子的有边框需要保留
|
|
143
|
+
style.marginRight = 0
|
|
144
|
+
}
|
|
145
|
+
return style
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
// 将输入的值,转为数组,给item历遍时,根据当前的索引显示数组的元素
|
|
149
|
+
codeArray() {
|
|
150
|
+
return String(this.inputValue).split('')
|
|
151
|
+
},
|
|
152
|
+
// 下划线模式下,横线的样式
|
|
153
|
+
lineStyle() {
|
|
154
|
+
const style = {}
|
|
155
|
+
style.height = this.hairline ? '1px' : '4px'
|
|
156
|
+
style.width = this.$uv.addUnit(this.size)
|
|
157
|
+
// 线条模式下,背景色即为边框颜色
|
|
158
|
+
style.backgroundColor = this.borderColor
|
|
159
|
+
return style
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
methods: {
|
|
163
|
+
// 监听输入框的值发生变化
|
|
164
|
+
inputHandler(e) {
|
|
165
|
+
const value = e.detail.value
|
|
166
|
+
this.inputValue = value
|
|
167
|
+
// 是否允许输入“.”符号
|
|
168
|
+
if (this.disabledDot) {
|
|
169
|
+
this.$nextTick(() => {
|
|
170
|
+
this.inputValue = value.replace('.', '')
|
|
171
|
+
})
|
|
172
|
+
}
|
|
173
|
+
// 未达到maxlength之前,发送change事件,达到后发送finish事件
|
|
174
|
+
this.$emit('change', value)
|
|
175
|
+
// 修改通过v-model双向绑定的值
|
|
176
|
+
this.$emit('input', value)
|
|
177
|
+
this.$emit('update:modelValue', value)
|
|
178
|
+
// 达到用户指定输入长度时,发出完成事件
|
|
179
|
+
if (String(value).length >= Number(this.maxlength)) {
|
|
180
|
+
this.$emit('finish', value)
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
// 自定义键盘输入值监听
|
|
184
|
+
customInput() {
|
|
185
|
+
const value = this.inputValue;
|
|
186
|
+
// 是否允许输入“.”符号
|
|
187
|
+
if (this.disabledDot) {
|
|
188
|
+
this.$nextTick(() => {
|
|
189
|
+
this.inputValue = value.replace('.', '')
|
|
190
|
+
})
|
|
191
|
+
}
|
|
192
|
+
// 未达到maxlength之前,发送change事件,达到后发送finish事件
|
|
193
|
+
this.$emit('change', value)
|
|
194
|
+
// 达到用户指定输入长度时,发出完成事件
|
|
195
|
+
if (String(value).length >= Number(this.maxlength)) {
|
|
196
|
+
this.$emit('finish', value)
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
</script>
|
|
202
|
+
<style lang="scss" scoped>
|
|
203
|
+
@import '../../libs/css/components.scss';
|
|
204
|
+
@import '../../libs/css/color.scss';
|
|
205
|
+
$uv-code-input-cursor-width: 1px;
|
|
206
|
+
$uv-code-input-cursor-height: 40%;
|
|
207
|
+
$uv-code-input-cursor-animation-duration: 1s;
|
|
208
|
+
$uv-code-input-cursor-animation-name: uv-cursor-flicker;
|
|
209
|
+
.uv-code-input {
|
|
210
|
+
@include flex;
|
|
211
|
+
position: relative;
|
|
212
|
+
overflow: hidden;
|
|
213
|
+
&__item {
|
|
214
|
+
@include flex;
|
|
215
|
+
justify-content: center;
|
|
216
|
+
align-items: center;
|
|
217
|
+
position: relative;
|
|
218
|
+
&__text {
|
|
219
|
+
font-size: 15px;
|
|
220
|
+
color: $uv-content-color;
|
|
221
|
+
}
|
|
222
|
+
&__dot {
|
|
223
|
+
width: 7px;
|
|
224
|
+
height: 7px;
|
|
225
|
+
border-radius: 100px;
|
|
226
|
+
background-color: $uv-content-color;
|
|
227
|
+
}
|
|
228
|
+
&__line {
|
|
229
|
+
position: absolute;
|
|
230
|
+
bottom: 0;
|
|
231
|
+
height: 4px;
|
|
232
|
+
border-radius: 100px;
|
|
233
|
+
width: 40px;
|
|
234
|
+
background-color: $uv-content-color;
|
|
235
|
+
}
|
|
236
|
+
/* #ifndef APP-PLUS */
|
|
237
|
+
&__cursor {
|
|
238
|
+
position: absolute;
|
|
239
|
+
top: 50%;
|
|
240
|
+
left: 50%;
|
|
241
|
+
transform: translate(-50%, -50%);
|
|
242
|
+
width: $uv-code-input-cursor-width;
|
|
243
|
+
height: $uv-code-input-cursor-height;
|
|
244
|
+
animation: $uv-code-input-cursor-animation-duration uv-cursor-flicker infinite;
|
|
245
|
+
}
|
|
246
|
+
/* #endif */
|
|
247
|
+
}
|
|
248
|
+
&__input {
|
|
249
|
+
// 之所以需要input输入框,是因为有它才能唤起键盘
|
|
250
|
+
// 这里将它设置为两倍的屏幕宽度,再将左边的一半移出屏幕,为了不让用户看到输入的内容
|
|
251
|
+
position: absolute;
|
|
252
|
+
left: -750rpx;
|
|
253
|
+
width: 1500rpx;
|
|
254
|
+
top: 0;
|
|
255
|
+
background-color: transparent;
|
|
256
|
+
text-align: left;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/* #ifndef APP-PLUS */
|
|
260
|
+
@keyframes uv-cursor-flicker {
|
|
261
|
+
0% {
|
|
262
|
+
opacity: 0;
|
|
263
|
+
}
|
|
264
|
+
50% {
|
|
265
|
+
opacity: 1;
|
|
266
|
+
}
|
|
267
|
+
100% {
|
|
268
|
+
opacity: 0;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
/* #endif */
|
|
272
|
+
</style>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
// 占父容器宽度的多少等分,总分为12份
|
|
4
|
+
span: {
|
|
5
|
+
type: [String, Number],
|
|
6
|
+
default: 12
|
|
7
|
+
},
|
|
8
|
+
// 指定栅格左侧的间隔数(总12栏)
|
|
9
|
+
offset: {
|
|
10
|
+
type: [String, Number],
|
|
11
|
+
default: 0
|
|
12
|
+
},
|
|
13
|
+
// 水平排列方式,可选值为`start`(或`flex-start`)、`end`(或`flex-end`)、`center`、`around`(或`space-around`)、`between`(或`space-between`)
|
|
14
|
+
justify: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: 'start'
|
|
17
|
+
},
|
|
18
|
+
// 垂直对齐方式,可选值为top、center、bottom、stretch
|
|
19
|
+
align: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: 'stretch'
|
|
22
|
+
},
|
|
23
|
+
// 文字对齐方式
|
|
24
|
+
textAlign: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: 'left'
|
|
27
|
+
},
|
|
28
|
+
...uni.$uv?.props?.col
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="uv-col"
|
|
4
|
+
ref="uv-col"
|
|
5
|
+
:class="[
|
|
6
|
+
'uv-col-' + span
|
|
7
|
+
]"
|
|
8
|
+
:style="[colStyle]"
|
|
9
|
+
@tap="clickHandler"
|
|
10
|
+
>
|
|
11
|
+
<slot></slot>
|
|
12
|
+
</view>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script>
|
|
16
|
+
import mpMixin from '../../libs/mixin/mpMixin.js'
|
|
17
|
+
import mixin from '../../libs/mixin/mixin.js'
|
|
18
|
+
import props from './props.js';
|
|
19
|
+
/**
|
|
20
|
+
* CodeInput 栅格系统的列
|
|
21
|
+
* @description 该组件一般用于Layout 布局 通过基础的 12 分栏,迅速简便地创建布局
|
|
22
|
+
* @tutorial https://www.uvui.cn/components/Layout.html
|
|
23
|
+
* @property {String | Number} span 栅格占据的列数,总12等份 (默认 12 )
|
|
24
|
+
* @property {String | Number} offset 分栏左边偏移,计算方式与span相同 (默认 0 )
|
|
25
|
+
* @property {String} justify 水平排列方式,可选值为`start`(或`flex-start`)、`end`(或`flex-end`)、`center`、`around`(或`space-around`)、`between`(或`space-between`) (默认 'start' )
|
|
26
|
+
* @property {String} align 垂直对齐方式,可选值为top、center、bottom、stretch (默认 'stretch' )
|
|
27
|
+
* @property {String} textAlign 文字水平对齐方式 (默认 'left' )
|
|
28
|
+
* @property {Object} customStyle 定义需要用到的外部样式
|
|
29
|
+
* @event {Function} click col被点击,会阻止事件冒泡到row
|
|
30
|
+
* @example <uv-col span="3" offset="3" > <view class="demo-layout bg-purple"></view> </uv-col>
|
|
31
|
+
*/
|
|
32
|
+
export default {
|
|
33
|
+
name: 'uv-col',
|
|
34
|
+
emits: ['click'],
|
|
35
|
+
mixins: [mpMixin, mixin, props],
|
|
36
|
+
data() {
|
|
37
|
+
return {
|
|
38
|
+
width: 0,
|
|
39
|
+
parentData: {
|
|
40
|
+
gutter: 0
|
|
41
|
+
},
|
|
42
|
+
gridNum: 12
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
computed: {
|
|
46
|
+
uJustify() {
|
|
47
|
+
if (this.justify == 'end' || this.justify == 'start') return 'flex-' + this.justify
|
|
48
|
+
else if (this.justify == 'around' || this.justify == 'between') return 'space-' + this.justify
|
|
49
|
+
else return this.justify
|
|
50
|
+
},
|
|
51
|
+
uAlignItem() {
|
|
52
|
+
if (this.align == 'top') return 'flex-start'
|
|
53
|
+
if (this.align == 'bottom') return 'flex-end'
|
|
54
|
+
else return this.align
|
|
55
|
+
},
|
|
56
|
+
colStyle() {
|
|
57
|
+
const style = {
|
|
58
|
+
// 这里写成"padding: 0 10px"的形式是因为nvue的需要
|
|
59
|
+
paddingLeft: this.$uv.addUnit(this.$uv.getPx(this.parentData.gutter)/2),
|
|
60
|
+
paddingRight: this.$uv.addUnit(this.$uv.getPx(this.parentData.gutter)/2),
|
|
61
|
+
alignItems: this.uAlignItem,
|
|
62
|
+
justifyContent: this.uJustify,
|
|
63
|
+
textAlign: this.textAlign,
|
|
64
|
+
// #ifndef APP-NVUE
|
|
65
|
+
// 在非nvue上,使用百分比形式
|
|
66
|
+
flex: `0 0 ${100 / this.gridNum * this.span}%`,
|
|
67
|
+
marginLeft: 100 / 12 * this.offset + '%',
|
|
68
|
+
// #endif
|
|
69
|
+
// #ifdef APP-NVUE
|
|
70
|
+
// 在nvue上,由于无法使用百分比单位,这里需要获取父组件的宽度,再计算得出该有对应的百分比尺寸
|
|
71
|
+
width: this.$uv.addUnit(Math.floor(this.width / this.gridNum * Number(this.span))),
|
|
72
|
+
marginLeft: this.$uv.addUnit(Math.floor(this.width / this.gridNum * Number(this.offset))),
|
|
73
|
+
// #endif
|
|
74
|
+
}
|
|
75
|
+
return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle))
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
mounted() {
|
|
79
|
+
this.init()
|
|
80
|
+
},
|
|
81
|
+
methods: {
|
|
82
|
+
async init() {
|
|
83
|
+
// 支付宝小程序不支持provide/inject,所以使用这个方法获取整个父组件,在created定义,避免循环引用
|
|
84
|
+
this.updateParentData()
|
|
85
|
+
this.width = await this.parent.getComponentWidth()
|
|
86
|
+
},
|
|
87
|
+
updateParentData() {
|
|
88
|
+
this.getParentData('uv-row')
|
|
89
|
+
},
|
|
90
|
+
clickHandler(e) {
|
|
91
|
+
this.$emit('click');
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
</script>
|
|
96
|
+
|
|
97
|
+
<style lang="scss" scoped>
|
|
98
|
+
@import '../../libs/css/components.scss';
|
|
99
|
+
|
|
100
|
+
.uv-col {
|
|
101
|
+
padding: 0;
|
|
102
|
+
/* #ifndef APP-NVUE */
|
|
103
|
+
box-sizing:border-box;
|
|
104
|
+
/* #endif */
|
|
105
|
+
/* #ifdef MP */
|
|
106
|
+
display: block;
|
|
107
|
+
/* #endif */
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// nvue下百分比无效
|
|
111
|
+
/* #ifndef APP-NVUE */
|
|
112
|
+
.uv-col-0 {
|
|
113
|
+
width: 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.uv-col-1 {
|
|
117
|
+
width: calc(100%/12);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.uv-col-2 {
|
|
121
|
+
width: calc(100%/12 * 2);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.uv-col-3 {
|
|
125
|
+
width: calc(100%/12 * 3);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.uv-col-4 {
|
|
129
|
+
width: calc(100%/12 * 4);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.uv-col-5 {
|
|
133
|
+
width: calc(100%/12 * 5);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.uv-col-6 {
|
|
137
|
+
width: calc(100%/12 * 6);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.uv-col-7 {
|
|
141
|
+
width: calc(100%/12 * 7);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.uv-col-8 {
|
|
145
|
+
width: calc(100%/12 * 8);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.uv-col-9 {
|
|
149
|
+
width: calc(100%/12 * 9);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.uv-col-10 {
|
|
153
|
+
width: calc(100%/12 * 10);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.uv-col-11 {
|
|
157
|
+
width: calc(100%/12 * 11);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.uv-col-12 {
|
|
161
|
+
width: calc(100%/12 * 12);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/* #endif */
|
|
165
|
+
</style>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
props: {
|
|
3
|
+
// 当前展开面板的name,非手风琴模式:[<string | number>],手风琴模式:string | number
|
|
4
|
+
value: {
|
|
5
|
+
type: [String, Number, Array, null],
|
|
6
|
+
default: null
|
|
7
|
+
},
|
|
8
|
+
// 是否手风琴模式
|
|
9
|
+
accordion: {
|
|
10
|
+
type: Boolean,
|
|
11
|
+
default: false
|
|
12
|
+
},
|
|
13
|
+
// 是否显示外边框
|
|
14
|
+
border: {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
default: true
|
|
17
|
+
},
|
|
18
|
+
...uni.$uv?.props?.collapse
|
|
19
|
+
}
|
|
20
|
+
}
|