<template>
<view class="id-card-keyboard_container">
<view class="id-card-keyboard_box">
<view class="id-card-keyboard_box-header">
<text class="id-card-keyboard_box-header-label">{idCard}</text>
<text class="id-card-keyboard_box-header-button" @click="finish">完成</text>
</view>
<safe-area>
<view class="id-card-keyboard_box-item-container">
<view class="id-card-keyboard_box-item" v-for="item in numbers">
<view class="id-card-keyboard_box-item-label" v-if="item.type=='number'" data-key={item.key} @click="getNumber">
<text style="font-size:28px;">{item.key}</text>
</view>
<view class="id-card-keyboard_box-item-label" v-else-if="item.type=='ico'" @click="delNumber">
<image class="id-card-keyboard_box-item-ico" src={item.key} mode="widthFix"></image>
</view>
</view>
</view>
</safe-area>
</view>
</view>
</template>
<script>
import checkIdcard from './id-card-check.js'
export default {
name: 'id-card-keyboard',
data() {
return{
numbers:[{type:'number',key:'1'},{type:'number',key:'2'},{type:'number',key:'3'},{type:'number',key:'4'},{type:'number',key:'5'},{type:'number',key:'6'},{type:'number',key:'7'}
,{type:'number',key:'8'},{type:'number',key:'9'},{type:'number',key:'X'},{type:'number',key:'0'},{type:'ico',key:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAAAtCAYAAAA5reyyAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QAAAAAAAD5Q7t/AAAACXBIWXMAAC4jAAAuIwF4pT92AAAC/UlEQVRo3u2aO2gUURSGv1k1PlFXUHwUQZEYlUACPiM2KbQSKxEkBEtbHyDxAWqjoK2gqIjYWJpC0gQLQUWjoBJUtBOMiWJMwJiYiGtxdtlzx1lndr07w4X7wcBm59xzcv655752wOPxeDwej8dJggxjtwGHgHagsQ7+fwHvgJvA1QzzrAv7gUKK12NgQdZJ22J3yuKVruf1SCbtEu4Cbqm/nyEl9hKYBGZYivMbyCMP66j6/gxwNuWcrXEMs0fcSynuKRXzY9Yi1EoHpnivUoydRyaUAvApayFqYQtSUiXxPgPLUoyfA0aKsYeyFqNaOjHFewisSNCuHRm7ZiaM0wQcB1ZH3JsNfMXBHniAv5cSSQgo95gBYH6M/XJggso9bI7y54yAzZjijZB8xg+AMZKNlw3Aa2U7HGHjnIAbgO8qqTFgY5U+9mI+gNsRNguBF5jirYuwc0rAFsozXqkEV9boaxvmg3iAjGcArcCguvcIWFLBj1MCvlVJvQHm/qe/9cC48nkf2E55zCsAH2J8OCPgVsyyW2PJbwuVt2fjwNqY9s4IeBpzuWKTDmSM0+L1A6sStK2rgDmLvvLq86Dl/7MfGVs1ozi8NYuik3Lv+GbR7yxErKgSfkL8AYQzJbwolNxFCz4D4KnyOQQcDsXpjfHhjIAAR7AnYiNSuiVf75FZGWSXM63u3fiHH6cEBBFNi3i3Bh9NmLuRAWBeyKYNmMKcuKLK2TkBAS5hininyvYDqu0UsuuIohX4qWz7ImycFBDkwFSL2F1F21KbaWBzjG34rDGMswICXA4ldyVhuz2I4M0J7XcBJ4GdEfecFhDgPKaIPSnHD4AvOHqgWiI8Jl5LMXYD8oOV0wKCrNe0iCdSitulYjpZwppwOfcCO5BeEiDLEBtXDlgMHMRc6ly3nVAWr3acQw4eNMPFRG3tzQuIgPpthB/I4cNoBjlb5wLpvpUwAWyqRyK23gSolj7kxGYpUgUB0gNtXpPFGD3APuS3E4/H4/F4PB6Pxwp/AGH7f53PGS6/AAAAAElFTkSuQmCC'}],
numberIndex:0,
resultNumber:[],
idCard:''
}
},
methods: {
getNumber(e){
// console.log(JSON.stringify(e));
if(this.data.numberIndex<18){
this.data.resultNumber[this.data.numberIndex] = e.currentTarget.dataset.key;//兼容IOS和安卓
this.data.numberIndex += 1;
this.data.idCard = this.data.resultNumber.join('');
}
},
delNumber(e){
this.data.numberIndex -= 1;
if(this.data.numberIndex>=0){
this.data.resultNumber.splice(this.data.numberIndex,1);
this.data.idCard = this.data.resultNumber.join('');
}
},
finish(){
if(!checkIdcard(this.data.idCard)){
api.confirm({
title: '提示',
msg: '您输入的身份证号码不符合规则,是否继续使用?',
buttons: ['确定', '取消']
}, (ret, err)=> {
var index = ret.buttonIndex;
if(index==1){
this.fire('setNumber',this.data.idCard);
}
});
}
else{
this.fire('setNumber',this.data.idCard);
}
}
}
}
</script>
<style>
.id-card-keyboard_container {
position: absolute;
height: 100%;
width: 100%;
background-color: rgba(0,0,0,0);
}
.id-card-keyboard_box{
align-items: center;
position: absolute;
bottom: 0;
width: 100%;
background-color: #f0f0f0;
border-top-left-radius: 30px;
border-top-right-radius: 30px;
}
.id-card-keyboard_box-item-container{
flex-flow: row wrap;
justify-content: space-around;
align-items: center;
padding: 10px;
box-sizing: border-box;
}
.id-card-keyboard_box-item{
flex-basis: 33%;
box-sizing: border-box;
padding: 5px;
}
.id-card-keyboard_box-item-label{
display: flex;
background-color: #ffffff;
padding: 5px;
border-radius: 5px;
width: 100%;
height: 48px;
align-items: center;
justify-content: center;
box-sizing: border-box;
}
.id-card-keyboard_box-item-ico{
width: 60px;
}
.id-card-keyboard_box-header{
width: 100%;
flex-flow: row nowrap;
justify-content: space-between;
align-items: center;
padding: 10px 15px 0 15px;
}
.id-card-keyboard_box-header-label{
font-size: 18px;
}
.id-card-keyboard_box-header-button{
font-size: 18px;
color: #327432;
}
</style>
评论