v-uni-app-ui 1.0.0 → 1.0.2
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/config.js +123 -0
- package/components/layout/v-card/v-card.vue +108 -0
- package/components/layout/v-grid/v-grid.vue +162 -0
- package/components/layout/v-icon-grid/v-icon-grid.vue +195 -0
- package/components/layout/v-infinite-scroll/v-infinite-scroll.vue +172 -0
- package/components/layout/v-list/v-list.vue +43 -0
- package/components/layout/v-row/v-row.vue +142 -0
- package/components/layout/v-waterfall/v-waterfall.vue +79 -0
- package/components/model/compound/v-checkbox-group/v-checkbox-group.vue +96 -0
- package/components/model/compound/v-console/v-console.js +20 -0
- package/components/model/compound/v-console/v-console.vue +299 -0
- package/components/model/compound/v-date-time/v-date-time.vue +261 -0
- package/components/model/compound/v-dialog/v-dialog.vue +178 -0
- package/components/model/compound/v-drum-select-picker/v-drum-select-picker.vue +83 -0
- package/components/model/compound/v-form/v-form.vue +226 -0
- package/components/model/compound/v-form-item/v-form-item.vue +255 -0
- package/components/model/compound/v-image/v-image.vue +357 -0
- package/components/model/compound/v-input-desensitize/v-input-desensitize.vue +101 -0
- package/components/model/compound/v-page/v-page.vue +11 -0
- package/components/model/compound/v-pages/v-pages.vue +141 -0
- package/components/model/compound/v-picker-list/v-picker-list.vue +109 -0
- package/components/model/compound/v-popup/v-popup.vue +151 -0
- package/components/model/compound/v-radio-group/v-radio-group.vue +86 -0
- package/components/model/compound/v-select-picker/v-select-picker.vue +202 -0
- package/components/model/compound/v-series-picker-list/v-series-picker-list.vue +221 -0
- package/components/model/compound/v-series-select-picker/v-series-select-picker.vue +203 -0
- package/components/model/compound/v-switch/v-switch.vue +136 -0
- package/components/model/compound/v-tabs-page/v-tabs-page.vue +138 -0
- package/components/model/native/v-badge/v-badge.vue +143 -0
- package/components/model/native/v-button/v-button.vue +273 -0
- package/components/model/native/v-carousel/v-carousel.vue +138 -0
- package/components/model/native/v-checkbox/v-checkbox.vue +215 -0
- package/components/model/native/v-collapse/v-collapse.vue +190 -0
- package/components/model/native/v-header-navigation-bar/v-header-navigation-bar.vue +92 -0
- package/components/model/native/v-input/v-input.vue +352 -0
- package/components/model/native/v-input-code/v-input-code.vue +146 -0
- package/components/model/native/v-loading/v-loading.vue +206 -0
- package/components/model/native/v-menu/v-menu.vue +222 -0
- package/components/model/native/v-menu-slide/v-menu-slide.vue +364 -0
- package/components/model/native/v-min-loading/v-min-loading.vue +80 -0
- package/components/model/native/v-null/v-null.vue +97 -0
- package/components/model/native/v-overlay/v-overlay.vue +96 -0
- package/components/model/native/v-pull-up-refresh/v-pull-up-refresh.vue +157 -0
- package/components/model/native/v-radio/v-radio.vue +138 -0
- package/components/model/native/v-scroll-list/v-scroll-list.vue +169 -0
- package/components/model/native/v-steps/v-steps.vue +253 -0
- package/components/model/native/v-table/v-table.vue +203 -0
- package/components/model/native/v-tabs/v-tabs.vue +235 -0
- package/components/model/native/v-tag/v-tag.vue +206 -0
- package/components/model/native/v-text/v-text.vue +187 -0
- package/components/model/native/v-text-button/v-text-button.vue +139 -0
- package/components/model/native/v-textarea/v-textarea.vue +178 -0
- package/components/model/native/v-title/v-title.vue +91 -0
- package/components/model/native/v-toast/info.png +0 -0
- package/components/model/native/v-toast/success.png +0 -0
- package/components/model/native/v-toast/v-toast.vue +198 -0
- package/components/model/native/v-toast/warn.png +0 -0
- package/components/model/native/v-upload-file-button/v-upload-file-button.vue +296 -0
- package/components/model/native/v-video/v-video.vue +175 -0
- package/components/model/native/v-window/v-window.vue +158 -0
- package/package.json +18 -94
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="['input-combination', `input-combination--${size}`]">
|
|
3
|
+
<view :class="['combination', 'left-combination']" v-if="combinationConfig.isShow && combinationConfig.position === 'left' || combinationConfig.position === 'ends'">
|
|
4
|
+
<slot name="left">
|
|
5
|
+
<button>{{ combinationConfig.buttonText }}</button>
|
|
6
|
+
</slot>
|
|
7
|
+
</view>
|
|
8
|
+
<view :class="['input-container', `input-container--${combinationConfig.position}`]">
|
|
9
|
+
<input
|
|
10
|
+
:value="inputValue"
|
|
11
|
+
:class="[
|
|
12
|
+
'v-input',
|
|
13
|
+
{ 'v-input--disabled': disabled },
|
|
14
|
+
{ 'input-focused': focused },
|
|
15
|
+
`v-input--border--${borderModel}`,
|
|
16
|
+
`v-input--right--combination--${combinationConfig.position}`
|
|
17
|
+
]"
|
|
18
|
+
:placeholder="currentPlaceholder"
|
|
19
|
+
:maxlength="maxlength || undefined"
|
|
20
|
+
:disabled="disabled"
|
|
21
|
+
:type="type"
|
|
22
|
+
:focus="autoFocus"
|
|
23
|
+
@input="handleInput"
|
|
24
|
+
@focus="handleFocus"
|
|
25
|
+
@blur="handleBlur"
|
|
26
|
+
@confirm="handleConfirm"
|
|
27
|
+
/>
|
|
28
|
+
<view v-if="showCounter && maxlength" class="input-counter">{{ currentLength }}/{{ maxlength }}</view>
|
|
29
|
+
</view>
|
|
30
|
+
<view :class="['combination', 'right-combination']" v-if="combinationConfig.isShow && combinationConfig.position === 'right' || combinationConfig.position === 'ends'">
|
|
31
|
+
<slot name="right">
|
|
32
|
+
<button>{{ combinationConfig.buttonText }}</button>
|
|
33
|
+
</slot>
|
|
34
|
+
</view>
|
|
35
|
+
</view>
|
|
36
|
+
</template>
|
|
37
|
+
|
|
38
|
+
<script setup lang="ts">
|
|
39
|
+
import { ref, watch, onMounted, onUnmounted, inject } from 'vue';
|
|
40
|
+
|
|
41
|
+
interface CombinationConfig {
|
|
42
|
+
isShow: Boolean;
|
|
43
|
+
position: String;
|
|
44
|
+
buttonText: String;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* v-input 输入框
|
|
49
|
+
* value 双向绑定值
|
|
50
|
+
* size 文本框大小 默认值:medium 可选值small小、medium中、large大
|
|
51
|
+
* placeholder 提示语 字符串、数组
|
|
52
|
+
* placeholderTimeNumber 更换提示词耗时 默认:8秒
|
|
53
|
+
* maxlength 最大输入值 默认:null 不限制
|
|
54
|
+
* disabled 是否禁用 默认:false 可选值:true禁用 false不禁用
|
|
55
|
+
* type 文本框类型 默认:text 可选值:text、password、number
|
|
56
|
+
* showCounter 是否显示统计文字 默认:false 可选值:true显示统计文字 false不显示统计文字
|
|
57
|
+
* borderModel 边框模式 默认:all 可选值:all普通边框 nont无边框模式 bottom底部边框模式 top上边框模式 left左边框模式 right右边框模式 ends左右两端边框模式 up-down上下边框模式
|
|
58
|
+
* combinationConfig 组合组件
|
|
59
|
+
* isShow:是否显示插槽 默认值:false 可选值:true显示 false不显示
|
|
60
|
+
* position:组合组件显示位置 默认值:default 可选值:right右边 left左边 ends两端
|
|
61
|
+
* 插槽right、left
|
|
62
|
+
* 相关事件:focus、blur、confirm
|
|
63
|
+
*/
|
|
64
|
+
const props = defineProps({
|
|
65
|
+
value: {
|
|
66
|
+
type: String,
|
|
67
|
+
default: '',
|
|
68
|
+
required: true
|
|
69
|
+
},
|
|
70
|
+
size: {
|
|
71
|
+
type: String,
|
|
72
|
+
default: 'medium',
|
|
73
|
+
validator: (value: string) => ['small', 'medium', 'large'].includes(value)
|
|
74
|
+
},
|
|
75
|
+
placeholder: {
|
|
76
|
+
type: [String, Array],
|
|
77
|
+
default: ''
|
|
78
|
+
},
|
|
79
|
+
placeholderTimeNumber: {
|
|
80
|
+
type: Number,
|
|
81
|
+
default: 8000
|
|
82
|
+
},
|
|
83
|
+
maxlength: {
|
|
84
|
+
type: Number,
|
|
85
|
+
default: null
|
|
86
|
+
},
|
|
87
|
+
disabled: {
|
|
88
|
+
type: Boolean,
|
|
89
|
+
default: false
|
|
90
|
+
},
|
|
91
|
+
type: {
|
|
92
|
+
type: String,
|
|
93
|
+
default: 'text',
|
|
94
|
+
validator: (value: string) => ['text', 'password', 'number'].includes(value)
|
|
95
|
+
},
|
|
96
|
+
showCounter: {
|
|
97
|
+
type: Boolean,
|
|
98
|
+
default: false
|
|
99
|
+
},
|
|
100
|
+
borderModel: {
|
|
101
|
+
type: String,
|
|
102
|
+
default: 'all'
|
|
103
|
+
},
|
|
104
|
+
combinationConfig: {
|
|
105
|
+
type: Object as () => CombinationConfig,
|
|
106
|
+
default: {
|
|
107
|
+
isShow: false,
|
|
108
|
+
position: 'default',
|
|
109
|
+
buttonText: ''
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
inputTextPosition: {
|
|
113
|
+
type: String,
|
|
114
|
+
default: 'left'
|
|
115
|
+
},
|
|
116
|
+
autoFocus: {
|
|
117
|
+
type: Boolean,
|
|
118
|
+
default: false
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const emit = defineEmits(['update:value', 'input', 'focus', 'blur', 'confirm']);
|
|
123
|
+
|
|
124
|
+
const config = inject<any>('config');
|
|
125
|
+
const inputValue = ref(props.value);
|
|
126
|
+
const focused = ref(false);
|
|
127
|
+
const currentLength = ref(props.value.length);
|
|
128
|
+
const currentPlaceholder = ref('');
|
|
129
|
+
const placeholderIndex = ref(0);
|
|
130
|
+
let placeholderInterval: NodeJS.Timeout | null = null;
|
|
131
|
+
|
|
132
|
+
watch(
|
|
133
|
+
() => props.value,
|
|
134
|
+
(newVal) => {
|
|
135
|
+
inputValue.value = newVal;
|
|
136
|
+
currentLength.value = newVal.length;
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
watch(
|
|
141
|
+
() => props.placeholder,
|
|
142
|
+
(newVal) => {
|
|
143
|
+
if (Array.isArray(newVal) && newVal.length > 0) {
|
|
144
|
+
currentPlaceholder.value = newVal[0];
|
|
145
|
+
placeholderIndex.value = 0;
|
|
146
|
+
} else if (typeof newVal === 'string') {
|
|
147
|
+
currentPlaceholder.value = newVal;
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
{ immediate: true }
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
onMounted(() => {
|
|
154
|
+
if (Array.isArray(props.placeholder) && props.placeholder.length > 1) {
|
|
155
|
+
startPlaceholderRotation();
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
onUnmounted(() => {
|
|
160
|
+
if (placeholderInterval) {
|
|
161
|
+
clearInterval(placeholderInterval);
|
|
162
|
+
placeholderInterval = null;
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
const startPlaceholderRotation = () => {
|
|
167
|
+
placeholderInterval = setInterval(() => {
|
|
168
|
+
placeholderIndex.value = (placeholderIndex.value + 1) % props.placeholder.length;
|
|
169
|
+
currentPlaceholder.value = props.placeholder[placeholderIndex.value];
|
|
170
|
+
}, props.placeholderTimeNumber);
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
const handleInput = (e: any) => {
|
|
174
|
+
const value = e.detail.value;
|
|
175
|
+
inputValue.value = value;
|
|
176
|
+
currentLength.value = value.length;
|
|
177
|
+
emit('update:value', value);
|
|
178
|
+
emit('input', value);
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const handleFocus = (e: any) => {
|
|
182
|
+
focused.value = true;
|
|
183
|
+
emit('focus', e);
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const handleBlur = (e: any) => {
|
|
187
|
+
focused.value = false;
|
|
188
|
+
emit('blur', e);
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
//回车搜索
|
|
192
|
+
const handleConfirm = (e: any) => {
|
|
193
|
+
if (e.detail.value.trim() === '' && Array.isArray(props.placeholder) && currentPlaceholder.value) {
|
|
194
|
+
emit('confirm', currentPlaceholder.value, e);
|
|
195
|
+
} else {
|
|
196
|
+
emit('confirm', e.detail.value, e);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
</script>
|
|
200
|
+
|
|
201
|
+
<style lang="scss" scoped>
|
|
202
|
+
.input-combination {
|
|
203
|
+
display: flex;
|
|
204
|
+
|
|
205
|
+
&--small {
|
|
206
|
+
height: 50rpx;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
&--medium {
|
|
210
|
+
height: 60rpx;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
&--large {
|
|
214
|
+
height: 70rpx;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.input-container {
|
|
218
|
+
width: 100%;
|
|
219
|
+
height: 100%;
|
|
220
|
+
position: relative;
|
|
221
|
+
|
|
222
|
+
&--default {
|
|
223
|
+
width: 100%;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
&--right,
|
|
227
|
+
&--left {
|
|
228
|
+
width: 75%;
|
|
229
|
+
}
|
|
230
|
+
&--ends {
|
|
231
|
+
width: 50%;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.v-input {
|
|
235
|
+
width: 100%;
|
|
236
|
+
height: 100%;
|
|
237
|
+
min-height: 45rpx;
|
|
238
|
+
box-sizing: border-box;
|
|
239
|
+
background-color: #fff;
|
|
240
|
+
font-size: v-bind("config.fontSize.mediumText");
|
|
241
|
+
line-height: 1.5;
|
|
242
|
+
transition: border-color 0.3s;
|
|
243
|
+
text-align: v-bind('props.inputTextPosition');
|
|
244
|
+
|
|
245
|
+
::v-deep .uni-input-wrapper {
|
|
246
|
+
width: 92% !important;
|
|
247
|
+
margin-left: 3%;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
&--border--all {
|
|
251
|
+
border: 1px solid v-bind('config.border.color');
|
|
252
|
+
border-radius: 6rpx;
|
|
253
|
+
|
|
254
|
+
&.input-focused {
|
|
255
|
+
border-color: v-bind('config.border.default');
|
|
256
|
+
box-shadow: v-bind("config.VInput.boxShadow");
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
&--border--none {
|
|
261
|
+
border: none;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
&--border--bottom {
|
|
265
|
+
border-bottom: 1rpx solid v-bind('config.border.color');
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
&--border--top {
|
|
269
|
+
border-top: 1rpx solid v-bind('config.border.color');
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
&--border--left {
|
|
273
|
+
border-left: 1rpx solid v-bind('config.border.color');
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
&--border--right {
|
|
277
|
+
border-right: 1rpx solid v-bind('config.border.color');
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
&--border--ends {
|
|
281
|
+
border-left: 1rpx solid v-bind('config.border.color');
|
|
282
|
+
border-right: 1rpx solid v-bind('config.border.color');
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
&--border--up-down {
|
|
286
|
+
border-top: 1rpx solid v-bind('config.border.color');
|
|
287
|
+
border-bottom: 1rpx solid v-bind('config.border.color');
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
&--right--combination--right {
|
|
291
|
+
border-right: none;
|
|
292
|
+
border-top-right-radius: 0;
|
|
293
|
+
border-bottom-right-radius: 0;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
&--right--combination--left {
|
|
297
|
+
border-left: none;
|
|
298
|
+
border-top-left-radius: 0;
|
|
299
|
+
border-bottom-left-radius: 0;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
&--right--combination--ends {
|
|
303
|
+
border-right: none;
|
|
304
|
+
border-top-right-radius: 0;
|
|
305
|
+
border-bottom-right-radius: 0;
|
|
306
|
+
|
|
307
|
+
border-left: none;
|
|
308
|
+
border-top-left-radius: 0;
|
|
309
|
+
border-bottom-left-radius: 0;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
&--disabled {
|
|
313
|
+
opacity: v-bind('config.opacity.disabled');
|
|
314
|
+
background-color: v-bind('config.backgroundColor.disabled');
|
|
315
|
+
color: v-bind('config.fontColor.text');
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
.input-counter {
|
|
319
|
+
position: absolute;
|
|
320
|
+
bottom: 8rpx;
|
|
321
|
+
right: 8rpx;
|
|
322
|
+
font-size: v-bind("config.fontSize.smallText");
|
|
323
|
+
color: v-bind('config.fontColor.text');
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.combination {
|
|
328
|
+
width: 25%;
|
|
329
|
+
height: 100%;
|
|
330
|
+
button {
|
|
331
|
+
width: 100%;
|
|
332
|
+
height: 100%;
|
|
333
|
+
display: flex;
|
|
334
|
+
align-items: center;
|
|
335
|
+
justify-content: center;
|
|
336
|
+
background-color: v-bind('config.backgroundColor.default');
|
|
337
|
+
color: v-bind('config.fontColor.reversal');
|
|
338
|
+
font-size: v-bind("config.fontSize.mediumText");
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
.left-combination button {
|
|
343
|
+
border-bottom-right-radius: 0;
|
|
344
|
+
border-top-right-radius: 0;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.right-combination button {
|
|
348
|
+
border-bottom-left-radius: 0;
|
|
349
|
+
border-top-left-radius: 0;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
</style>
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="v-input-code">
|
|
3
|
+
<div class="input-box" :style="{ width: `${inputWidth * length + (length - 1) * 20}px`, height: `${inputHeight}px` }">
|
|
4
|
+
<input
|
|
5
|
+
v-for="(item, index) in length"
|
|
6
|
+
:key="index"
|
|
7
|
+
type="text"
|
|
8
|
+
:class="['input-item', { 'input-focus': focusIndex === index }]"
|
|
9
|
+
:maxlength="1"
|
|
10
|
+
:placeholder="placeholder"
|
|
11
|
+
@input="onInput(index, $event)"
|
|
12
|
+
@focus="onFocus(index)"
|
|
13
|
+
@blur="onBlur(index)"
|
|
14
|
+
@keydown="onkeydown(index, $event)"
|
|
15
|
+
:focus="inputFocus[index]"
|
|
16
|
+
:blur="inputBlur[index]"
|
|
17
|
+
/>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script lang="ts" setup>
|
|
23
|
+
import { ref, watch, onMounted, inject } from 'vue';
|
|
24
|
+
|
|
25
|
+
const props = defineProps({
|
|
26
|
+
value: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: ''
|
|
29
|
+
},
|
|
30
|
+
length: {
|
|
31
|
+
type: Number,
|
|
32
|
+
default: 4
|
|
33
|
+
},
|
|
34
|
+
inputWidth: {
|
|
35
|
+
type: Number,
|
|
36
|
+
default: 30
|
|
37
|
+
},
|
|
38
|
+
inputHeight: {
|
|
39
|
+
type: Number,
|
|
40
|
+
default: 50
|
|
41
|
+
},
|
|
42
|
+
focus: {
|
|
43
|
+
type: Boolean,
|
|
44
|
+
default: false
|
|
45
|
+
},
|
|
46
|
+
placeholder: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: ''
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const emit = defineEmits(['update:value', 'complete']);
|
|
53
|
+
|
|
54
|
+
const config = inject<any>('config');
|
|
55
|
+
const focusIndex = ref<number | null>(null);
|
|
56
|
+
const inputFocus = ref([]);
|
|
57
|
+
const inputBlur = ref([]);
|
|
58
|
+
|
|
59
|
+
onMounted(() => {
|
|
60
|
+
inputFocus.value.length = props.length;
|
|
61
|
+
inputBlur.value.length = props.length;
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const onInput = (index: number, event: any) => {
|
|
65
|
+
const value = event.detail.value;
|
|
66
|
+
if (value) {
|
|
67
|
+
if (index < props.length - 1) {
|
|
68
|
+
console.log(index + 1);
|
|
69
|
+
inputFocus.value[index + 1] = true;
|
|
70
|
+
}
|
|
71
|
+
updateModelValue(value, index);
|
|
72
|
+
} else {
|
|
73
|
+
updateModelValue('', index);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
const onkeydown = (index: number, event: any) => {
|
|
77
|
+
if (event.code === 'Backspace') {
|
|
78
|
+
inputFocus.value[index] = false;
|
|
79
|
+
// inputFocus.value[index - 2] = false;
|
|
80
|
+
// inputFocus.value[index - 2] = true;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const onFocus = (index: number) => {
|
|
85
|
+
focusIndex.value = index;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const onBlur = (index: number) => {
|
|
89
|
+
if (focusIndex.value === index) {
|
|
90
|
+
focusIndex.value = null;
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const updateModelValue = (value: string, index: number) => {
|
|
95
|
+
const newValue = props.value.split('');
|
|
96
|
+
newValue[index] = value;
|
|
97
|
+
const joinedValue = newValue.join('');
|
|
98
|
+
emit('update:value', joinedValue);
|
|
99
|
+
if (joinedValue.length === props.length) {
|
|
100
|
+
emit('complete');
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
watch(
|
|
105
|
+
() => props.focus,
|
|
106
|
+
(newValue) => {
|
|
107
|
+
if (newValue) {
|
|
108
|
+
inputFocus.value[0].focus();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
);
|
|
112
|
+
</script>
|
|
113
|
+
|
|
114
|
+
<style lang="scss" scoped>
|
|
115
|
+
.v-input-code {
|
|
116
|
+
display: flex;
|
|
117
|
+
justify-content: center;
|
|
118
|
+
align-items: center;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.input-box {
|
|
122
|
+
display: flex;
|
|
123
|
+
justify-content: center;
|
|
124
|
+
align-items: center;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.input-item {
|
|
128
|
+
width: v-bind("inputWidth + 'rpx'");
|
|
129
|
+
height: v-bind("inputHeight + 'rpx'");
|
|
130
|
+
margin: 0 15rpx;
|
|
131
|
+
padding: 0 15rpx;
|
|
132
|
+
text-align: center;
|
|
133
|
+
font-size: 16px;
|
|
134
|
+
border-bottom: 4rpx solid v-bind("config.border.color");
|
|
135
|
+
outline: none;
|
|
136
|
+
transition: all 0.3s ease;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.input-item:focus {
|
|
140
|
+
border-bottom: 4rpx solid v-bind("config.border.default");
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.input-focus {
|
|
144
|
+
border-bottom: 4rpx solid v-bind("config.border.default");
|
|
145
|
+
}
|
|
146
|
+
</style>
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view v-if="currentShow" :class="['v-loading', { 'v-loading--full-screen': fullScreen }]" :style="loadingStyle">
|
|
3
|
+
<slot name="spinner">
|
|
4
|
+
<view class="v-loading-spinner">
|
|
5
|
+
<view class="spinner-outer"></view>
|
|
6
|
+
<view class="spinner-inner"></view>
|
|
7
|
+
</view>
|
|
8
|
+
</slot>
|
|
9
|
+
<text v-if="text" class="v-loading-text">{{ text }}</text>
|
|
10
|
+
</view>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup lang="ts">
|
|
14
|
+
import { computed, ref, watch,onMounted,inject } from 'vue';
|
|
15
|
+
|
|
16
|
+
const props = defineProps({
|
|
17
|
+
fullScreen: {
|
|
18
|
+
type: Boolean,
|
|
19
|
+
default: false
|
|
20
|
+
},
|
|
21
|
+
text: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: '',
|
|
24
|
+
required: true
|
|
25
|
+
},
|
|
26
|
+
size: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: 'medium',
|
|
29
|
+
validator: (value: any) => {
|
|
30
|
+
return ['small', 'medium', 'large'].includes(value);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
color: {
|
|
34
|
+
type: String,
|
|
35
|
+
default: '#287afa'
|
|
36
|
+
},
|
|
37
|
+
textColor: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: '#666'
|
|
40
|
+
},
|
|
41
|
+
duration: {
|
|
42
|
+
type: Number,
|
|
43
|
+
default: 0
|
|
44
|
+
},
|
|
45
|
+
show: {
|
|
46
|
+
type: Boolean,
|
|
47
|
+
default: false
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
const emit = defineEmits(['update:show']);
|
|
52
|
+
|
|
53
|
+
const config = inject<any>('config');
|
|
54
|
+
const currentShow = ref(props.show);
|
|
55
|
+
let timer: NodeJS.Timeout | null = null;
|
|
56
|
+
|
|
57
|
+
watch(
|
|
58
|
+
() => props.show,
|
|
59
|
+
(newValue) => {
|
|
60
|
+
currentShow.value = newValue;
|
|
61
|
+
if (newValue) {
|
|
62
|
+
if (timer) {
|
|
63
|
+
clearTimeout(timer);
|
|
64
|
+
}
|
|
65
|
+
if (props.duration > 0) {
|
|
66
|
+
timer = setTimeout(() => {
|
|
67
|
+
currentShow.value = false;
|
|
68
|
+
emit('update:show', false);
|
|
69
|
+
}, props.duration);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
watch(
|
|
76
|
+
() => props.duration,
|
|
77
|
+
(newValue) => {
|
|
78
|
+
if (currentShow.value && newValue > 0) {
|
|
79
|
+
if (timer) {
|
|
80
|
+
clearTimeout(timer);
|
|
81
|
+
}
|
|
82
|
+
timer = setTimeout(() => {
|
|
83
|
+
currentShow.value = false;
|
|
84
|
+
emit('update:show', false);
|
|
85
|
+
}, newValue);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
onMounted(()=>{
|
|
91
|
+
if (currentShow.value && props.duration > 0) {
|
|
92
|
+
if (timer) {
|
|
93
|
+
clearTimeout(timer);
|
|
94
|
+
}
|
|
95
|
+
timer = setTimeout(() => {
|
|
96
|
+
currentShow.value = false;
|
|
97
|
+
emit('update:show', false);
|
|
98
|
+
}, props.duration);
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
const loadingStyle = computed(() => {
|
|
103
|
+
return {
|
|
104
|
+
'--loading-color': props.color,
|
|
105
|
+
'--text-color': props.textColor
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
</script>
|
|
109
|
+
|
|
110
|
+
<style lang="scss" scoped>
|
|
111
|
+
.v-loading {
|
|
112
|
+
min-height: 150rpx;
|
|
113
|
+
position: relative;
|
|
114
|
+
display: flex;
|
|
115
|
+
flex-direction: column;
|
|
116
|
+
align-items: center;
|
|
117
|
+
justify-content: center;
|
|
118
|
+
padding: 16rpx;
|
|
119
|
+
z-index: 1000;
|
|
120
|
+
|
|
121
|
+
&--full-screen {
|
|
122
|
+
position: fixed;
|
|
123
|
+
top: 0;
|
|
124
|
+
left: 0;
|
|
125
|
+
right: 0;
|
|
126
|
+
bottom: 0;
|
|
127
|
+
background-color: rgba(255, 255, 255, 0.8);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.v-loading-spinner {
|
|
131
|
+
width: 80rpx;
|
|
132
|
+
height: 80rpx;
|
|
133
|
+
position: relative;
|
|
134
|
+
margin-bottom: 12rpx;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.spinner-outer {
|
|
138
|
+
position: absolute;
|
|
139
|
+
top: 0;
|
|
140
|
+
left: 0;
|
|
141
|
+
right: 0;
|
|
142
|
+
bottom: 0;
|
|
143
|
+
border: 6rpx solid var(--loading-color);
|
|
144
|
+
border-radius: 50%;
|
|
145
|
+
border-top-color: transparent;
|
|
146
|
+
animation: spin 1s linear infinite;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.spinner-inner {
|
|
150
|
+
position: absolute;
|
|
151
|
+
top: 20%;
|
|
152
|
+
left: 20%;
|
|
153
|
+
transform: translate(-50%, -50%);
|
|
154
|
+
width: 60%;
|
|
155
|
+
height: 60%;
|
|
156
|
+
border: 6rpx solid var(--loading-color);
|
|
157
|
+
border-radius: 50%;
|
|
158
|
+
border-top-color: transparent;
|
|
159
|
+
animation: spin 0.6s linear infinite reverse;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.v-loading-text {
|
|
163
|
+
color: var(--text-color);
|
|
164
|
+
font-size: v-bind("config.fontSize.mediumText");
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
@keyframes spin {
|
|
168
|
+
0% {
|
|
169
|
+
transform: rotate(0deg);
|
|
170
|
+
}
|
|
171
|
+
100% {
|
|
172
|
+
transform: rotate(360deg);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
&--small .v-loading-spinner {
|
|
177
|
+
width: 60rpx;
|
|
178
|
+
height: 60rpx;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
&--small .spinner-outer {
|
|
182
|
+
border-width: 4rpx;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
&--small .spinner-inner {
|
|
186
|
+
width: 70%;
|
|
187
|
+
height: 70%;
|
|
188
|
+
border-width: 4rpx;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
&--large .v-loading-spinner {
|
|
192
|
+
width: 100rpx;
|
|
193
|
+
height: 100rpx;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
&--large .spinner-outer {
|
|
197
|
+
border-width: 8rpx;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
&--large .spinner-inner {
|
|
201
|
+
width: 50%;
|
|
202
|
+
height: 50%;
|
|
203
|
+
border-width: 8rpx;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
</style>
|