123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- <template>
- <view class="keyborder-panel">
- <view class="key-group" v-for="(item,index) in keyGroup" :key="item.id">
- <template v-for="(child,cindex) in item.children" :key="child.id">
- <view @click="tapKey(child.value)" hover-class="key-active"
- :class="{'key-group-item':item.children.length >1}">
- <text>{{child.value}}</text>
- </view>
- </template>
- </view>
- <view class="key-group">
- <view @click="tapKey('0')" hover-class="key-active" class="key-group-item">
- <text>0</text>
- </view>
- <view @click="onComplete" hover-class="key-active" class="key-group-item keyboard">
- <text class="keyboard key-complete" />
- </view>
- <view @click="tapKey('delete')" hover-class="key-active" class="key-group-item keyboard">
- <text class="keyboard key-back" />
- </view>
- </view>
- </view>
- </template>
- <script>
- import "./style.css";
- export default {
- name: "number-keybord",
- props: {
- refKey: {
- type: String
- }
- },
- emits: {
- "typeCharacter": null,
- "typeComplete": null
- },
- data() {
- return {
- keyGroup: []
- };
- },
- created() {
- const keyGroup = [{
- id: 0,
- children: [{
- id: 0,
- value: "1"
- }, {
- id: 1,
- value: "2"
- }, {
- id: 2,
- value: "3"
- }]
- },
- {
- id: 1,
- children: [{
- id: 0,
- value: "4"
- }, {
- id: 1,
- value: "5"
- }, {
- id: 2,
- value: "6"
- }]
- },
- {
- id: 2,
- children: [{
- id: 0,
- value: "7"
- }, {
- id: 1,
- value: "8"
- }, {
- id: 2,
- value: "9"
- }]
- }
- ];
- this.keyGroup = keyGroup;
- },
- methods: {
- tapKey(character) {
- //console.log(this);
- this.$emit("typeCharacter", character);
- },
- onComplete() {
- this.$emit("typeComplete");
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .keyborder-panel {
- border-radius: 16px 16px 0 0;
- }
- .key-group {
- display: flex;
- justify-content: space-around;
- align-items: center;
- .key-group-item {
- padding-top: 25rpx;
- padding-bottom: 25rpx;
- background-color: #FFFFFF;
- width: 33%;
- text-align: center;
- }
- .key-group-item:nth-child(2n) {
- border-left: 1px dashed #C0C0C0;
- border-right: 1px dashed #C0C0C0;
- }
- .key-active {
- background-color: #d4e9ff;
- }
- }
- .key-group:nth-child(n+2) {
- border-top: 1px dashed #C0C0C0;
- }
- </style>
|