您现在的位置是:网站首页> 编程资料编程资料

微信小程序实现车牌键盘_javascript技巧_

2023-05-24 335人已围观

简介 微信小程序实现车牌键盘_javascript技巧_

本文实例为大家分享了微信小程序实现车牌键盘的具体代码,供大家参考,具体内容如下

一、效果图

二、代码

plateNumKeyboard.wxml

               请输入车牌号:                                       {{inputPlates.index0}}                             {{inputPlates.index1}}                                                          {{inputPlates.index2}}                             {{inputPlates.index3}}                             {{inputPlates.index4}}                             {{inputPlates.index5}}                             {{inputPlates.index6}}                             +                             {{inputPlates.index7}}                                             关闭                                     {{itemName}}                                           {{itemName}}                                           {{itemName}}                                           {{itemName}}                                删除                                                    {{itemName}}                                           {{itemName}}                                           {{itemName}}                                           {{itemName}}                                           {{itemName}}                             {{itemName}}                             {{itemName}}                                删除                       

plateNumKeyboard.js

Page({   data: {     isKeyboard: 1,     isNumberKB: !1,     tapNum: !1,     disableKey: "1234567890港澳学",     keyboardNumber: "1234567890ABCDEFGHJKLMNPQRSTUVWXYZ港澳学",     keyboard1: "京沪粤津冀晋蒙辽吉黑苏浙皖闽赣鲁豫鄂湘桂琼渝川贵云藏陕甘青宁新",     inputPlates: {       index0: "",       index1: "",       index2: "",       index3: "",       index4: "",       index5: "",       index6: "",       index7: ""     },     inputOnFocusIndex: "0",     flag: true   },   onLoad: function () {     },     /**    * 生命周期函数--监听页面显示    */   onShow: function () {     this.getHistoryList();   },     getHistoryList: function () {     let that = this;     let data = {       unionid: app.globalData.unionid,     }       wxRequest({       url: app.globalData.url + '/car/history/getByOpenId',       method: 'get',       header: {         "Authorization": app.globalData.token,       },       data: data,     })       .then((res) => {         let historyList = res.data.data;         that.setData({           historyList,         })       })       .catch((err) => {         console.log(err);       });   },     showLast: function () {     this.setData({       flag: false,     })   },     setText: function (e) {     let text = e.currentTarget.dataset.text;       if (text.length == 8) {       this.setData({         flag: false,         'inputPlates.index7': text[7],       })     } else {       this.setData({         flag: true,         'inputPlates.index7': "",       })     }     this.setData({       'inputPlates.index0': text[0],       'inputPlates.index1': text[1],       'inputPlates.index2': text[2],       'inputPlates.index3': text[3],       'inputPlates.index4': text[4],       'inputPlates.index5': text[5],       'inputPlates.index6': text[6],     })   },     inputClick: function (t) {     var that = this;     that.setData({       inputOnFocusIndex: t.target.dataset.id,       isKeyboard: !0     })     "0" == this.data.inputOnFocusIndex ? that.setData({       tapNum: !1,       isNumberKB: !1     }) : "1" == this.data.inputOnFocusIndex ? that.setData({       tapNum: !1,       isNumberKB: !0     }) : that.setData({       tapNum: !0,       isNumberKB: !0     });     },     //键盘点击事件   tapKeyboard: function (t) {     t.target.dataset.index;     var a = t.target.dataset.val;       switch (this.data.inputOnFocusIndex) {       case "0":         this.setData({           "inputPlates.index0": a,           inputOnFocusIndex: "1"         });         break;       case "1":         this.setData({           "inputPlates.index1": a,  
                
                

-六神源码网