PasswordInputer.vue
2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<template>
<v-card flat id="PasswordInputer">
<div class="PasswordInputerTitle">请输入交易密码</div>
<div class="PasswordInputBlock">
<div class="passwordDisplayer" v-for="(len, index) in 6" :key="index"><span :class="password.length >= len ? '' : 'white'">*</span></div>
</div>
<!-- <div class="submitButton" @click="submit">确 定</div> -->
<PasswordBeyboard :showClose="false" :showTitle="false" @input="passwordInput" @delete="deleteInput"/>
</v-card>
</template>
<script>
import PasswordBeyboard from '@/components/PasswordBeyboard'
export default {
data: () => ({
password: '',
}),
components: {
PasswordBeyboard
},
props: {
display: {
type: Boolean,
default: false
}
},
watch: {
display: function (val, oldVal) {
if (val) {
// this.reset()
// this.$refs['0'].focus()
}
},
},
methods: {
reset() {
this.password = ''
},
passwordInput(e) {
if (this.password.length < 6) {
this.password += e
}
if (this.password.length === 6) {
this.submit()
}
},
deleteInput(e) {
this.password = this.password.slice(0, this.password.length - 1)
},
submit() {
if (this.password.length !== 6) return
this.$emit('passwordSubmit', this.password)
}
}
}
</script>
<style lang="scss" scoped>
#PasswordInputer {
background-color: $background-black;
color: $light-gold;
.PasswordInputerTitle {
height: 3rem;
line-height: 3rem;
text-align: center;
position: relative;
font-size: 1.5rem;
}
.PasswordInputBlock {
height: 3.5rem;
margin: 0 0 2rem 0;
text-align: center;
vertical-align: bottom;
.passwordDisplayer {
width: 3.5rem;
height: 3.5rem;
color: #000;
background-color: #fff;
border: 1px solid $gold;
border-left: none;
text-align: center;
font-size: 2.5rem;
display: inline-block;
.white {
color: #fff;
}
&:nth-child(1) {
border-left: 1px solid $gold;
border-radius: 5px 0 0 5px;
}
&:nth-child(6) {
border-radius: 0 5px 5px 0;
}
}
}
.submitButton {
height: 3.5rem;
font-size: 1.2rem;
line-height: 3.5rem;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
margin-top: 3rem;
}
}
</style>