微信小程序车牌号码模拟键盘输入功能的实现代(2)

Page({ data: { licensePlateShowHidden:true, licensePlate_provinces_Box:true, licensePlate_letter_Box: true, licensePlate_digital_Box: true, licensePlate_provinces: [ "京", "沪", "浙", "苏", "粤", "鲁", "晋", "冀", "豫", "川", "渝", "辽", "吉", "黑", "皖", "鄂", "津", "贵", "云", "桂", "琼", "青", "新", "藏", "蒙", "宁", "甘", "陕", "闽", "赣", "湘" ], licensePlate_letter: [ "A", "B", "C", "D", "E", "F", "G", "H", "L", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" ], licensePlate_digital: [ "", "", "", "", "", "", "", "", "", "" ], LicensePlateNumber:'', }, // 显示模拟键盘 LicensePlateNumber:function(){ var that = this; var LicensePlateNumber = this.data.LicensePlateNumber; var LicensePlateNumberLen = LicensePlateNumber.length; console.log(LicensePlateNumber, LicensePlateNumberLen) if (LicensePlateNumberLen == ){ this.setData({ licensePlateShowHidden: false, licensePlate_provinces_Box: false, }) } else if (LicensePlateNumberLen == ){ this.setData({ licensePlateShowHidden: false, licensePlate_letter_Box: false, }) }else{ this.setData({ licensePlateShowHidden: false, licensePlate_digital_Box: false, }) } }, // 切换成字母 licensePlate_switchLetter:function(){ this.setData({ licensePlate_provinces_Box:true, licensePlate_letter_Box:false, licensePlate_digital_Box: true, }) }, // 切换成数字 licensePlate_switchDigital: function () { var LicensePlateNumber = this.data.LicensePlateNumber; var LicensePlateNumberLen = LicensePlateNumber.length; if (LicensePlateNumberLen == ){ wx.showToast({ title: '车牌号码第二位必须是字母', icon: 'none', duration: , }) }else{ this.setData({ licensePlate_provinces_Box: true, licensePlate_letter_Box: true, licensePlate_digital_Box: false, }) } }, // 删除 licensePlate_delete: function (e) { var LicensePlateNumber = this.data.LicensePlateNumber; var LicensePlateNumberLen = LicensePlateNumber.length; var LicensePlateNumberDelete = LicensePlateNumber.split(''); var NewLicensePlateNumber = LicensePlateNumberDelete.join('').slice(,-) if (LicensePlateNumberDelete.slice(,-).length == ){ this.setData({ licensePlate_provinces_Box: true, licensePlate_letter_Box: false, licensePlate_digital_Box: true, }) } else if (LicensePlateNumberLen == || LicensePlateNumber == '' || LicensePlateNumberDelete.slice(, -).length == ){ this.setData({ licensePlate_provinces_Box: false, licensePlate_letter_Box: true, licensePlate_digital_Box: true, }) } this.setData({ LicensePlateNumber: NewLicensePlateNumber }) }, // 清空 licensePlate_empty: function (e) { this.setData({ LicensePlateNumber:'', licensePlate_provinces_Box: false, licensePlate_letter_Box: true, licensePlate_digital_Box: true, }) }, // 关闭模拟键盘 licensePlate_close:function(){ this.setData({ licensePlateShowHidden: true }) }, // 点击获取省份 licensePlate_provinces: function (e) { this.setData({ LicensePlateNumber: e.target.dataset.licenseplateprovinces, licensePlate_letter_Box: false, licensePlate_digital_Box: true, }) console.log(e.target.dataset.licenseplateprovinces) }, // 点击获取字母 licensePlate_letter: function (e) { var LicensePlateNumber = this.data.LicensePlateNumber; var LicensePlateNumberLen = LicensePlateNumber.length; if (LicensePlateNumberLen != ) { this.setData({ LicensePlateNumber: LicensePlateNumber + e.target.dataset.licenseplateprovinces }) console.log(e.target.dataset.licenseplateprovinces) } else { wx.showToast({ title: '车牌号码最多不能超过位', icon: 'none', duration: , }) } }, // 点击获取数字 licensePlate_digital: function (e) { var LicensePlateNumber = this.data.LicensePlateNumber; var LicensePlateNumberLen = LicensePlateNumber.length; if (LicensePlateNumberLen != ){ this.setData({ LicensePlateNumber: LicensePlateNumber + e.target.dataset.licenseplateprovinces }) console.log(e.target.dataset.licenseplateprovinces) }else{ wx.showToast({ title: '车牌号码最多不能超过位', icon:'none', duration:, }) } }, })

总结

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/79a6c3d9ed82c96b86676f696271cfe8.html