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
| <template>
| <view class="xm-keyboard-v2">
| <xm-popup :show="isShow" @close="toCancel" background="#d4d5d9" :showContent="showContent" :anim="anim">
| <view style="background-color: #FFF;">
| <view class="xm-flex xm-title" v-if="title">
| {{ title }}
| </view>
| <view style="padding: 10px;">
| <xm-keyboard-input ref="keyboardInput" @change="inputChange" :cursor="cursor"
| :show-pointer="type == 'plate'" :max="max"></xm-keyboard-input>
| </view>
| </view>
| <xm-keyboard-box ref="keyboardBox" :show-change-btn="type == 'plate'" :show-cancel-btn="!showContent"
| :vibration="vibration" @add="inputAdd" @del="inputDel" @clear="inputClear" @cancel="toCancel"
| @confirm="toConfirm"></xm-keyboard-box>
| </xm-popup>
| </view>
| </template>
|
| <script>
| export default {
| name: 'xm-keyboard-v2',
| emits: ['confirm', 'cancel'],
| props: {
| title: {
| type: String,
| default: ''
| },
| cursor: {
| type: Boolean,
| default: false
| },
| vibration: {
| type: Boolean,
| default: false
| },
| type: {
| type: String,
| default: 'plate'
| },
| max: {
| type: Number,
| default: 8,
| },
| showContent: {
| type: Boolean,
| default: false
| },
| // 是否加入动画效果
| anim: {
| type: Boolean,
| default: true
| }
| },
| data() {
| return {
| isShow: false,
| value: '',
| }
| },
| methods: {
| toShow(value) {
| this.value = value || '';
| this.isShow = true;
| this.$refs.keyboardInput.changeValue(this.value);
| },
| toConfirm() {
| this.isShow = false;
| let value = this.$refs.keyboardInput.values.join('')
| this.$emit('confirm', value);
| },
| toCancel() {
| this.isShow = false;
| this.$emit('cancel');
| },
| inputChange(index) {
| if (this.type == 'plate') {
| this.$refs.keyboardBox.changeMode(index == 0 ? 0 : 1);
| } else {
| this.$refs.keyboardBox.changeMode(1);
| }
| },
| inputAdd(v) {
| this.$refs.keyboardInput.toAdd(v);
| },
| inputDel() {
| this.$refs.keyboardInput.toDel();
| },
| inputClear() {
| this.$refs.keyboardInput.toClear();
| }
| },
| }
| </script>
|
| <style lang="scss" scoped>
| .xm-keyboard-v2 {
| .xm-flex {
| display: flex;
| align-items: center;
| justify-content: center;
| }
|
| .xm-title {
| padding: 20px 0 10px 0;
| font-weight: bold;
| }
| }
| </style>
|
|