hy-app 0.5.14 → 0.5.16
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/components/hy-address-picker/hy-address-picker.vue +0 -1
- package/components/hy-button/hy-button.vue +7 -1
- package/components/hy-button/index.scss +22 -21
- package/components/hy-code-input/hy-code-input.vue +231 -231
- package/components/hy-code-input/props.ts +90 -88
- package/components/hy-config-provider/index.scss +1 -1
- package/components/hy-datetime-picker/hy-datetime-picker.vue +519 -521
- package/components/hy-icon/index.scss +1 -2
- package/components/hy-index-bar/hy-index-bar.vue +0 -12
- package/components/hy-index-bar/index.scss +1 -1
- package/components/hy-notify/hy-notify.vue +174 -174
- package/components/hy-picker/hy-picker.vue +0 -1
- package/components/hy-picker/index.scss +1 -1
- package/components/hy-skeleton/hy-skeleton.vue +142 -0
- package/components/hy-skeleton/index.scss +90 -0
- package/components/hy-skeleton/props.ts +46 -0
- package/components/hy-skeleton/typing.d.ts +31 -0
- package/components/hy-steps/hy-steps.vue +267 -267
- package/components/hy-steps/index.scss +7 -2
- package/components/hy-steps/typing.d.ts +25 -21
- package/components/hy-tabs/index.scss +1 -0
- package/components/hy-tag/hy-tag.vue +174 -174
- package/components/hy-tag/index.scss +3 -6
- package/components/hy-tag/props.ts +89 -89
- package/components/hy-text/hy-text.vue +1 -1
- package/components/hy-textarea/hy-textarea.vue +1 -1
- package/components/hy-textarea/index.scss +1 -4
- package/global.d.ts +2 -0
- package/index.scss +1 -1
- package/libs/css/iconfont.css +117 -119
- package/libs/css/theme.scss +1 -0
- package/libs/css/vars.scss +2 -0
- package/libs/utils/utils.ts +0 -1
- package/package.json +62 -3
- package/web-types.json +1 -1
|
@@ -25,7 +25,13 @@
|
|
|
25
25
|
:hover-class="!disabled && !loading ? 'hy-button--active' : ''"
|
|
26
26
|
:style="[baseColor, customStyle]"
|
|
27
27
|
@click="clickHandler"
|
|
28
|
-
:class="[
|
|
28
|
+
:class="[
|
|
29
|
+
'hy-button',
|
|
30
|
+
border && 'hy-button__no-border',
|
|
31
|
+
!disabled && 'hy-button__no-disabled',
|
|
32
|
+
bemClass,
|
|
33
|
+
customClass
|
|
34
|
+
]"
|
|
29
35
|
>
|
|
30
36
|
<template v-if="loading">
|
|
31
37
|
<HyLoading :mode="loadingMode" :size="loadingSize" :color="loadingColor"></HyLoading>
|
|
@@ -17,27 +17,28 @@
|
|
|
17
17
|
/* 防止文字内容被压缩换行 */
|
|
18
18
|
flex-shrink: 0;
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
20
|
+
@include e(no-disabled) {
|
|
21
|
+
/* 亮光效果 */
|
|
22
|
+
&::before {
|
|
23
|
+
content: '';
|
|
24
|
+
position: absolute;
|
|
25
|
+
top: 0;
|
|
26
|
+
left: -100%;
|
|
27
|
+
width: 100%;
|
|
28
|
+
height: 100%;
|
|
29
|
+
background: linear-gradient(
|
|
30
|
+
90deg,
|
|
31
|
+
transparent,
|
|
32
|
+
rgba(255, 255, 255, 0.4),
|
|
33
|
+
transparent
|
|
34
|
+
);
|
|
35
|
+
transition: left 0.7s;
|
|
36
|
+
z-index: 1;
|
|
37
|
+
}
|
|
38
|
+
&:active::before {
|
|
39
|
+
left: 100%;
|
|
40
|
+
transition: left 0.2s;
|
|
41
|
+
}
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
|
|
@@ -1,231 +1,231 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="hy-code-input">
|
|
3
|
-
<view
|
|
4
|
-
:class="itemClass(index)"
|
|
5
|
-
:style="[itemStyle(index)]"
|
|
6
|
-
v-for="(item, index) in codeLength"
|
|
7
|
-
:key="index"
|
|
8
|
-
>
|
|
9
|
-
<view
|
|
10
|
-
class="hy-code-input--item__dot"
|
|
11
|
-
v-if="dot && current > index"
|
|
12
|
-
:style="{ color: color }"
|
|
13
|
-
></view>
|
|
14
|
-
<text
|
|
15
|
-
v-else
|
|
16
|
-
class="hy-code-input--item__text"
|
|
17
|
-
:style="{
|
|
18
|
-
fontSize: addUnit(fontSize),
|
|
19
|
-
fontWeight: bold ? 'bold' : 'normal',
|
|
20
|
-
color: color
|
|
21
|
-
}"
|
|
22
|
-
>
|
|
23
|
-
{{ codeArray[index] }}
|
|
24
|
-
</text>
|
|
25
|
-
</view>
|
|
26
|
-
<input
|
|
27
|
-
:disabled="disabledKeyboard"
|
|
28
|
-
type="number"
|
|
29
|
-
:focus="focus"
|
|
30
|
-
:value="inputValue"
|
|
31
|
-
:maxlength="maxlength"
|
|
32
|
-
:adjustPosition="adjustPosition"
|
|
33
|
-
class="hy-code-input__input"
|
|
34
|
-
@input="inputHandler"
|
|
35
|
-
:style="{
|
|
36
|
-
height: boxSize
|
|
37
|
-
}"
|
|
38
|
-
@focus="isFocus = true"
|
|
39
|
-
@blur="isFocus = false"
|
|
40
|
-
/>
|
|
41
|
-
</view>
|
|
42
|
-
</template>
|
|
43
|
-
|
|
44
|
-
<script lang="ts">
|
|
45
|
-
export default {
|
|
46
|
-
name: 'hy-code-input',
|
|
47
|
-
options: {
|
|
48
|
-
addGlobalClass: true,
|
|
49
|
-
virtualHost: true,
|
|
50
|
-
styleIsolation: 'shared'
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
</script>
|
|
54
|
-
|
|
55
|
-
<script setup lang="ts">
|
|
56
|
-
import { computed, nextTick, onUnmounted, ref, watch } from 'vue'
|
|
57
|
-
import type { CSSProperties } from 'vue'
|
|
58
|
-
import type { ICodeInputEmits } from './typing'
|
|
59
|
-
import { addUnit, getPx } from '../../libs'
|
|
60
|
-
import type { InputOnInputEvent } from '@uni-helper/uni-types'
|
|
61
|
-
import codeInputProps from './props'
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* 一般用于验证用户短信验证码的场景,也可以结合华玥的键盘组件使用
|
|
65
|
-
* @displayName hy-code-input
|
|
66
|
-
*/
|
|
67
|
-
defineOptions({})
|
|
68
|
-
|
|
69
|
-
const props = defineProps(codeInputProps)
|
|
70
|
-
const emit = defineEmits<ICodeInputEmits>()
|
|
71
|
-
|
|
72
|
-
const current = ref(0)
|
|
73
|
-
const inputValue = ref('')
|
|
74
|
-
const isFocus = ref(props.focus)
|
|
75
|
-
let timer: ReturnType<typeof setInterval>
|
|
76
|
-
const opacity = ref(1)
|
|
77
|
-
const borderWidth = computed(() => (props.hairline ? '0.5px' : '2px'))
|
|
78
|
-
const lineHeight = computed(() => (props.hairline ? '2px' : '4px'))
|
|
79
|
-
const boxSize = addUnit(props.size)
|
|
80
|
-
|
|
81
|
-
watch(
|
|
82
|
-
() => props.modelValue,
|
|
83
|
-
(newValue: string | number) => {
|
|
84
|
-
inputValue.value = String(newValue).substring(0, props.maxlength)
|
|
85
|
-
current.value = newValue.toString().length
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
{ immediate: true }
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
watch(
|
|
92
|
-
() => isFocus.value,
|
|
93
|
-
(newValue) => {
|
|
94
|
-
// #ifdef APP-NVUE
|
|
95
|
-
if (newValue) {
|
|
96
|
-
timer = setInterval(() => {
|
|
97
|
-
opacity.value = Math.abs(opacity.value - 1)
|
|
98
|
-
}, 600)
|
|
99
|
-
} else {
|
|
100
|
-
clearInterval(timer)
|
|
101
|
-
}
|
|
102
|
-
// #endif
|
|
103
|
-
}
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
onUnmounted(() => {
|
|
107
|
-
// #ifdef APP-NVUE
|
|
108
|
-
clearInterval(timer)
|
|
109
|
-
// #endif
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
// 根据长度,循环输入框的个数,因为头条小程序数值不能用于v-for
|
|
113
|
-
const codeLength = computed(() => {
|
|
114
|
-
return new Array(Number(props.maxlength))
|
|
115
|
-
})
|
|
116
|
-
// 循环item的样式
|
|
117
|
-
const itemStyle = computed(() => {
|
|
118
|
-
return (index: number) => {
|
|
119
|
-
const style: CSSProperties = {
|
|
120
|
-
width: boxSize,
|
|
121
|
-
height: boxSize
|
|
122
|
-
}
|
|
123
|
-
if (props.borderColor) {
|
|
124
|
-
style['--hy-border-color'] = props.borderColor
|
|
125
|
-
}
|
|
126
|
-
// 盒子模式下,需要额外进行处理
|
|
127
|
-
if (props.mode === 'box' && props.border) {
|
|
128
|
-
// 设置盒子的边框,如果是细边框,则设置为1px宽度
|
|
129
|
-
style.borderWidth = borderWidth.value
|
|
130
|
-
style.borderStyle = 'solid'
|
|
131
|
-
style.borderColor = props.borderColor
|
|
132
|
-
// 如果盒子间距为0的话
|
|
133
|
-
if (getPx(props.space) === 0) {
|
|
134
|
-
// 给第一和最后一个盒子设置圆角
|
|
135
|
-
if (index === 0) {
|
|
136
|
-
style.borderTopLeftRadius = '6px'
|
|
137
|
-
style.borderBottomLeftRadius = '6px'
|
|
138
|
-
}
|
|
139
|
-
if (index === codeLength.value.length - 1) {
|
|
140
|
-
style.borderTopRightRadius = '6px'
|
|
141
|
-
style.borderBottomRightRadius = '6px'
|
|
142
|
-
}
|
|
143
|
-
// 最后一个盒子的右边框需要保留
|
|
144
|
-
if (index !== codeLength.value.length - 1) {
|
|
145
|
-
style.borderRight = 'none'
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
if (index !== codeLength.value.length - 1) {
|
|
150
|
-
// 设置验证码字符之间的距离,通过margin-right设置,最后一个字符,无需右边框
|
|
151
|
-
style.marginRight = addUnit(props.space)
|
|
152
|
-
} else {
|
|
153
|
-
// 最后一个盒子的有边框需要保留
|
|
154
|
-
style.marginRight = 0
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return style
|
|
158
|
-
}
|
|
159
|
-
})
|
|
160
|
-
|
|
161
|
-
const itemClass = computed(() => {
|
|
162
|
-
return (index: number) => {
|
|
163
|
-
return [
|
|
164
|
-
'hy-code-input--item',
|
|
165
|
-
props.border ? `hy-code-input--item__${props.mode}` : 'hy-code-input--item__no',
|
|
166
|
-
current.value > index &&
|
|
167
|
-
getPx(props.space) != 0 &&
|
|
168
|
-
props.border &&
|
|
169
|
-
`hy-code-input--item__${props.mode}__border`,
|
|
170
|
-
isFocus.value &&
|
|
171
|
-
current.value === index &&
|
|
172
|
-
getPx(props.space) != 0 &&
|
|
173
|
-
(props.border
|
|
174
|
-
? `hy-code-input--item__${props.mode}__active`
|
|
175
|
-
: 'hy-code-input--item__no--active')
|
|
176
|
-
]
|
|
177
|
-
}
|
|
178
|
-
})
|
|
179
|
-
|
|
180
|
-
/**
|
|
181
|
-
* @description 将输入的值,转为数组,给item历遍时,根据当前的索引显示数组的元素
|
|
182
|
-
*/
|
|
183
|
-
const codeArray = computed(() => {
|
|
184
|
-
return String(inputValue.value).split('')
|
|
185
|
-
})
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* @description 监听输入框的值发生变化
|
|
189
|
-
* */
|
|
190
|
-
const inputHandler = (e: InputOnInputEvent) => {
|
|
191
|
-
const value = e.detail.value
|
|
192
|
-
inputValue.value = value
|
|
193
|
-
// 是否允许输入“.”符号
|
|
194
|
-
if (props.disabledDot) {
|
|
195
|
-
nextTick(() => {
|
|
196
|
-
inputValue.value = value.replace('.', '')
|
|
197
|
-
})
|
|
198
|
-
}
|
|
199
|
-
// 未达到maxlength之前,发送change事件,达到后发送finish事件
|
|
200
|
-
emit('change', value)
|
|
201
|
-
// 修改通过v-model双向绑定的值
|
|
202
|
-
emit('update:modelValue', value)
|
|
203
|
-
// 达到用户指定输入长度时,发出完成事件
|
|
204
|
-
if (String(value).length >= Number(props.maxlength)) {
|
|
205
|
-
emit('finish', value)
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
</script>
|
|
209
|
-
|
|
210
|
-
<style scoped lang="scss">
|
|
211
|
-
@import './index.scss';
|
|
212
|
-
@import '../../libs/css/mixin';
|
|
213
|
-
@import '../../libs/css/theme';
|
|
214
|
-
@include b(code-input) {
|
|
215
|
-
@include m(item) {
|
|
216
|
-
&__box {
|
|
217
|
-
&__active {
|
|
218
|
-
width: v-bind(boxSize);
|
|
219
|
-
height: v-bind(boxSize);
|
|
220
|
-
border-width: v-bind(borderWidth);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
&__line {
|
|
224
|
-
&::after {
|
|
225
|
-
height: v-bind(lineHeight);
|
|
226
|
-
background-color: $hy-border-color;
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="['hy-code-input', customClass]">
|
|
3
|
+
<view
|
|
4
|
+
:class="itemClass(index)"
|
|
5
|
+
:style="[itemStyle(index)]"
|
|
6
|
+
v-for="(item, index) in codeLength"
|
|
7
|
+
:key="index"
|
|
8
|
+
>
|
|
9
|
+
<view
|
|
10
|
+
class="hy-code-input--item__dot"
|
|
11
|
+
v-if="dot && current > index"
|
|
12
|
+
:style="{ color: color }"
|
|
13
|
+
></view>
|
|
14
|
+
<text
|
|
15
|
+
v-else
|
|
16
|
+
class="hy-code-input--item__text"
|
|
17
|
+
:style="{
|
|
18
|
+
fontSize: addUnit(fontSize),
|
|
19
|
+
fontWeight: bold ? 'bold' : 'normal',
|
|
20
|
+
color: color
|
|
21
|
+
}"
|
|
22
|
+
>
|
|
23
|
+
{{ codeArray[index] }}
|
|
24
|
+
</text>
|
|
25
|
+
</view>
|
|
26
|
+
<input
|
|
27
|
+
:disabled="disabledKeyboard"
|
|
28
|
+
type="number"
|
|
29
|
+
:focus="focus"
|
|
30
|
+
:value="inputValue"
|
|
31
|
+
:maxlength="maxlength"
|
|
32
|
+
:adjustPosition="adjustPosition"
|
|
33
|
+
class="hy-code-input__input"
|
|
34
|
+
@input="inputHandler"
|
|
35
|
+
:style="{
|
|
36
|
+
height: boxSize
|
|
37
|
+
}"
|
|
38
|
+
@focus="isFocus = true"
|
|
39
|
+
@blur="isFocus = false"
|
|
40
|
+
/>
|
|
41
|
+
</view>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script lang="ts">
|
|
45
|
+
export default {
|
|
46
|
+
name: 'hy-code-input',
|
|
47
|
+
options: {
|
|
48
|
+
addGlobalClass: true,
|
|
49
|
+
virtualHost: true,
|
|
50
|
+
styleIsolation: 'shared'
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<script setup lang="ts">
|
|
56
|
+
import { computed, nextTick, onUnmounted, ref, watch } from 'vue'
|
|
57
|
+
import type { CSSProperties } from 'vue'
|
|
58
|
+
import type { ICodeInputEmits } from './typing'
|
|
59
|
+
import { addUnit, getPx } from '../../libs'
|
|
60
|
+
import type { InputOnInputEvent } from '@uni-helper/uni-types'
|
|
61
|
+
import codeInputProps from './props'
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 一般用于验证用户短信验证码的场景,也可以结合华玥的键盘组件使用
|
|
65
|
+
* @displayName hy-code-input
|
|
66
|
+
*/
|
|
67
|
+
defineOptions({})
|
|
68
|
+
|
|
69
|
+
const props = defineProps(codeInputProps)
|
|
70
|
+
const emit = defineEmits<ICodeInputEmits>()
|
|
71
|
+
|
|
72
|
+
const current = ref(0)
|
|
73
|
+
const inputValue = ref('')
|
|
74
|
+
const isFocus = ref(props.focus)
|
|
75
|
+
let timer: ReturnType<typeof setInterval>
|
|
76
|
+
const opacity = ref(1)
|
|
77
|
+
const borderWidth = computed(() => (props.hairline ? '0.5px' : '2px'))
|
|
78
|
+
const lineHeight = computed(() => (props.hairline ? '2px' : '4px'))
|
|
79
|
+
const boxSize = addUnit(props.size)
|
|
80
|
+
|
|
81
|
+
watch(
|
|
82
|
+
() => props.modelValue,
|
|
83
|
+
(newValue: string | number) => {
|
|
84
|
+
inputValue.value = String(newValue).substring(0, props.maxlength)
|
|
85
|
+
current.value = newValue.toString().length
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
{ immediate: true }
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
watch(
|
|
92
|
+
() => isFocus.value,
|
|
93
|
+
(newValue) => {
|
|
94
|
+
// #ifdef APP-NVUE
|
|
95
|
+
if (newValue) {
|
|
96
|
+
timer = setInterval(() => {
|
|
97
|
+
opacity.value = Math.abs(opacity.value - 1)
|
|
98
|
+
}, 600)
|
|
99
|
+
} else {
|
|
100
|
+
clearInterval(timer)
|
|
101
|
+
}
|
|
102
|
+
// #endif
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
onUnmounted(() => {
|
|
107
|
+
// #ifdef APP-NVUE
|
|
108
|
+
clearInterval(timer)
|
|
109
|
+
// #endif
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
// 根据长度,循环输入框的个数,因为头条小程序数值不能用于v-for
|
|
113
|
+
const codeLength = computed(() => {
|
|
114
|
+
return new Array(Number(props.maxlength))
|
|
115
|
+
})
|
|
116
|
+
// 循环item的样式
|
|
117
|
+
const itemStyle = computed(() => {
|
|
118
|
+
return (index: number) => {
|
|
119
|
+
const style: CSSProperties = {
|
|
120
|
+
width: boxSize,
|
|
121
|
+
height: boxSize
|
|
122
|
+
}
|
|
123
|
+
if (props.borderColor) {
|
|
124
|
+
style['--hy-border-color'] = props.borderColor
|
|
125
|
+
}
|
|
126
|
+
// 盒子模式下,需要额外进行处理
|
|
127
|
+
if (props.mode === 'box' && props.border) {
|
|
128
|
+
// 设置盒子的边框,如果是细边框,则设置为1px宽度
|
|
129
|
+
style.borderWidth = borderWidth.value
|
|
130
|
+
style.borderStyle = 'solid'
|
|
131
|
+
style.borderColor = props.borderColor
|
|
132
|
+
// 如果盒子间距为0的话
|
|
133
|
+
if (getPx(props.space) === 0) {
|
|
134
|
+
// 给第一和最后一个盒子设置圆角
|
|
135
|
+
if (index === 0) {
|
|
136
|
+
style.borderTopLeftRadius = '6px'
|
|
137
|
+
style.borderBottomLeftRadius = '6px'
|
|
138
|
+
}
|
|
139
|
+
if (index === codeLength.value.length - 1) {
|
|
140
|
+
style.borderTopRightRadius = '6px'
|
|
141
|
+
style.borderBottomRightRadius = '6px'
|
|
142
|
+
}
|
|
143
|
+
// 最后一个盒子的右边框需要保留
|
|
144
|
+
if (index !== codeLength.value.length - 1) {
|
|
145
|
+
style.borderRight = 'none'
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (index !== codeLength.value.length - 1) {
|
|
150
|
+
// 设置验证码字符之间的距离,通过margin-right设置,最后一个字符,无需右边框
|
|
151
|
+
style.marginRight = addUnit(props.space)
|
|
152
|
+
} else {
|
|
153
|
+
// 最后一个盒子的有边框需要保留
|
|
154
|
+
style.marginRight = 0
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return style
|
|
158
|
+
}
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
const itemClass = computed(() => {
|
|
162
|
+
return (index: number) => {
|
|
163
|
+
return [
|
|
164
|
+
'hy-code-input--item',
|
|
165
|
+
props.border ? `hy-code-input--item__${props.mode}` : 'hy-code-input--item__no',
|
|
166
|
+
current.value > index &&
|
|
167
|
+
getPx(props.space) != 0 &&
|
|
168
|
+
props.border &&
|
|
169
|
+
`hy-code-input--item__${props.mode}__border`,
|
|
170
|
+
isFocus.value &&
|
|
171
|
+
current.value === index &&
|
|
172
|
+
getPx(props.space) != 0 &&
|
|
173
|
+
(props.border
|
|
174
|
+
? `hy-code-input--item__${props.mode}__active`
|
|
175
|
+
: 'hy-code-input--item__no--active')
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
})
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* @description 将输入的值,转为数组,给item历遍时,根据当前的索引显示数组的元素
|
|
182
|
+
*/
|
|
183
|
+
const codeArray = computed(() => {
|
|
184
|
+
return String(inputValue.value).split('')
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* @description 监听输入框的值发生变化
|
|
189
|
+
* */
|
|
190
|
+
const inputHandler = (e: InputOnInputEvent) => {
|
|
191
|
+
const value = e.detail.value
|
|
192
|
+
inputValue.value = value
|
|
193
|
+
// 是否允许输入“.”符号
|
|
194
|
+
if (props.disabledDot) {
|
|
195
|
+
nextTick(() => {
|
|
196
|
+
inputValue.value = value.replace('.', '')
|
|
197
|
+
})
|
|
198
|
+
}
|
|
199
|
+
// 未达到maxlength之前,发送change事件,达到后发送finish事件
|
|
200
|
+
emit('change', value)
|
|
201
|
+
// 修改通过v-model双向绑定的值
|
|
202
|
+
emit('update:modelValue', value)
|
|
203
|
+
// 达到用户指定输入长度时,发出完成事件
|
|
204
|
+
if (String(value).length >= Number(props.maxlength)) {
|
|
205
|
+
emit('finish', value)
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
</script>
|
|
209
|
+
|
|
210
|
+
<style scoped lang="scss">
|
|
211
|
+
@import './index.scss';
|
|
212
|
+
@import '../../libs/css/mixin';
|
|
213
|
+
@import '../../libs/css/theme';
|
|
214
|
+
@include b(code-input) {
|
|
215
|
+
@include m(item) {
|
|
216
|
+
&__box {
|
|
217
|
+
&__active {
|
|
218
|
+
width: v-bind(boxSize);
|
|
219
|
+
height: v-bind(boxSize);
|
|
220
|
+
border-width: v-bind(borderWidth);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
&__line {
|
|
224
|
+
&::after {
|
|
225
|
+
height: v-bind(lineHeight);
|
|
226
|
+
background-color: $hy-border-color;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
</style>
|