小程序 车牌输入
admin
2024-01-22 22:04:38
0

html

{show?'show':'hide'}}">

  

  

    完成

  

  

  

    {keyboard}}" wx:for-item="rows" wx:for-index="rowIndex" wx:key="rowIndex">

      {rows}}" wx:for-item="col" wx:key="col">

        {col.disabled}}" class="col disabled">{{col.value}}

        {col.empty}}" class="col empty">{{col.value}}

        {col.backspace}}" class="col backspace" bindtap="delete">

          

        

        {col}}">{{col}}

      

    

  

  

  

js

Component({

  properties: {

    /**

     * 键盘类型 

     * 1:省份简称

     * 2:蓝牌普通车牌:车牌号数字+字母

     * 3:新能源车牌

     */

    keyboardType: {

      type: Number,

      value: 1

    },

  },

  data: {

    keyboard: [],

    show: false,

    provinces: [

      ['京', '津', '沪', '渝', '冀', '豫', '云', '辽', '黑'],

      ['湘', '皖', '鲁', '新', '苏', '浙', '赣', '鄂', '桂'],

      ['甘', '晋', '蒙', '陕', '吉', '闽', '贵', '粤', '青'],

      ['藏', '川', '宁', '琼', '使', '无', {

        value: '',

        empty: true

      }, {

        value: '',

        empty: true

      }, {

        value: '',

        backspace: true

      }],

    ],

    nomals: [

      ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'],

      ['Q', 'W', 'E', 'R', 'T', 'Y', 'U', {

        value: 'O',

        disabled: true

      }, 'P', '港'],

      ['A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', '澳'],

      ['Z', 'X', 'C', 'V', 'B', 'N', 'M', '学', '领', {

        value: '',

        backspace: true

      }],

    ],

    ecos: [

      ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'],

      ['Q', 'W', 'E', 'R', 'T', 'Y', 'U', {

        value: 'O',

        disabled: true

      }, 'P', {

        value: '港',

        disabled: true

      }],

      ['A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', {

        value: '澳',

        disabled: true

      }],

      ['Z', 'X', 'C', 'V', 'B', 'N', 'M', {

        value: '学',

        disabled: true

      }, {

        value: '领',

        disabled: true

      }, {

        value: '',

        backspace: true

      }],

    ]

  },

  lifetimes: {

    created() {},

    attached() {

      this.change(this.properties.keyboardType);

    },

    detached() {}

  },

  methods: {

    change(keyboardType) {

      switch (parseInt(keyboardType)) {

        case 1:

          this.setData({

            keyboard: this.data.provinces

          });

          break;

        case 2:

          this.setData({

            keyboard: this.data.nomals

          });

          break;

        case 3:

          this.setData({

            keyboard: this.data.ecos

          });

          break;

      }

    },

    show() {

      if (!this.data.show) {

        this.setData({

          show: true

        });

      }

    },

    hide(e) {

      this.setData({

        show: false

      });

    },

    delete(e) {

      this.triggerEvent('delete');

    },

    click(e) {

      this.triggerEvent('click', e.target.dataset.value);

    }

  }

})

css

.custom-keyboard {

  display: flex;

  flex-direction: column;

  border-top: 1rpx solid #e6e6e6;

  position: absolute;

  bottom: 0;

  width: 100%;

  transform: translateY(100%);

  transition: all .5s cubic-bezier(0, 1, 0.5, 1);

}

.custom-keyboard.show {

  transform: translateY(0%);

}

.custom-keyboard.hide {

  transform: translateY(100%);

}

.custom-keyboard .toolbar {

  display: flex;

  flex-direction: row;

  align-items: center;

  justify-content: flex-end;

  padding: 15rpx 10rpx;

  color: #05aeff;

  background-color: #ffffff;

}

.custom-keyboard .keyboard {

  background-color: #d1d4db;

  display: flex;

  flex-direction: column;

  padding: 40rpx 10rpx;

}

.custom-keyboard .keyboard .row {

  display: flex;

  flex-direction: row;

  align-items: center;

  justify-content: space-around;

  margin-bottom: 20rpx;

}

.custom-keyboard .keyboard .row:last-child {

  margin-bottom: 0;

}

.custom-keyboard .keyboard .row .col {

  width: 65rpx;

  height: 84rpx;

  line-height: 84rpx;

  text-align: center;

  background-color: #ffffff;

  border-radius: 10rpx;

  margin-right: 15rpx;

  box-shadow: 0rpx 6rpx 5rpx #888888;

}

.custom-keyboard .keyboard .row .col:last-child {

  margin-right: 0;

}

.custom-keyboard .keyboard .row .col:active {

  box-shadow: 0rpx 0rpx 0rpx #888888;

}


 

.custom-keyboard .keyboard .row .col.disabled {

  color: #c6c6c8;

}

.custom-keyboard .keyboard .row .col.empty {

  background-color: transparent;

  box-shadow: unset;

}

.custom-keyboard .keyboard .row .col.backspace {

  display: flex;

  flex-direction: column;

  align-items: center;

  justify-content: center;

}

.custom-keyboard .keyboard .row .col.backspace .icon {

  width: 42rpx;

  height: 28rpx;

}

.custom-keyboard .footer {

  height: env(safe-area-inset-bottom);

  background-color: #d1d4db;

}

html2

  {item.focus?'focus':''}} {{item.eco?'eco':''}}" wx:for="{{numbers}}" wx:key="index" data-index="{{index}}" bindtap="click">

    {index}}" bindtap="click">{{item.value}}

    {item.focus&&item.value==''}}">

  

js2

Component({

  properties: {

  },

  data: {

    numbers: [{

      value: '',

      focus: true

    }, {

      value: '',

      focus: false

    }, {

      value: '',

      focus: false

    }, {

      value: '',

      focus: false

    }, {

      value: '',

      focus: false

    }, {

      value: '',

      focus: false

    }, {

      value: '',

      focus: false

    }, {

      value: '',

      focus: false,

      eco: true

    }]

  },

  lifetimes: {

    created() {},

    attached() {},

    detached() {}

  },

  methods: {

    click(e) {

      const _index = e.target.dataset.index;

      const _nums = this.data.numbers;

      _nums.forEach((item, index) => {

        item.focus = index == _index;

      });

      this.setData({

        numbers: _nums

      });

      this.triggerEvent('focus', _index);

    },

    /**

     * {

     *    index: Number,

     *    value: String,

     *    remove: Boolean

     * }

     */

    change(data) {

      const {

        index,

        value,

        remove

      } = data;

      const _nums = this.data.numbers;

      _nums[index].value = remove ? '' : value;

      const len = _nums.length;

      let nextIndex = remove ? index - 1 : index + 1;

      if (remove && nextIndex < 0) {

        nextIndex = len - 1;

      }

      if (!remove && nextIndex >= len)

        nextIndex = 0;

      _nums.forEach((item, idx) => {

        item.focus = idx == nextIndex;

      });

      this.setData({

        numbers: _nums

      });

      this.triggerEvent('focus', nextIndex);

    }

  }

})

css2

.custom-car-number-input {

  display: flex;

  flex-direction: row;

  align-items: center;

  justify-content: space-around;

}

.custom-car-number-input .cell {

  width: 70rpx;

  height: 120rpx;

  display: flex;

  flex-direction: row;

  align-items: center;

  justify-content: center;

  font-size: 40rpx;

  background-color: #f7f7f7;

  border-radius: 10rpx;

  color: #333;

}

.custom-car-number-input .cell.focus {

  border: 1rpx solid #0099ff;

  box-shadow: 0rpx 0rpx 10rpx #0099ff;

}

.custom-car-number-input .cell .cursor {

  width: 2rpx;

  height: 30rpx;

  background-color: #0099ff;

  animation: flashing 1.2s infinite steps(1, start);

}

@keyframes flashing {

  0%,

  100% {

    background-color: #0099ff;

  }

  50% {

    background-color: transparent;

  }

}

.custom-car-number-input .cell.eco {

  background-color: rgba(54, 210, 146, .2);

}

.custom-car-number-input .cell.eco.focus {

  border-color: #36d292;

  box-shadow: 0rpx 0rpx 10rpx #36d292;

}

.custom-car-number-input .cell.eco .cursor {

  background-color: #36d292;

  animation: flashing-eco 1.2s infinite steps(1, start);

}

@keyframes flashing-eco {

  0%,

  100% {

    background-color: #36d292;

  }

  50% {

    background-color: transparent;

  }

}

相关内容

热门资讯

1282列!石家庄国际陆港20... (来源:河北新闻网) 转自:河北新闻网 长城网·冀云客户端1月15日讯(记者 袁立朋 通讯员 余陈军...
原创 1... 周五早盘,沪深A股主要的大盘指数高开幅度明显,最终高开低走。盘面上看,多数个股下跌,人气一般。周五午...
康希诺生物:创新支撑盈利拐点已... 新年伊始,港股与A股市场迎来了一波“开门红”行情。步入2026年,多家头部外资机构在年度展望中释放积...
Omdia:AI推动半导体行业... 机构 Omdia 在英国伦敦当地时间昨日的新闻稿中表示,根据其最新市场分析,在人工智能市场的巨大需求...
OPPO总裁陈明永入选“202... 瑞财经1月13日,由瑞财经推出的“2025年度手机行业六大杰出人物”榜单揭晓,OPPO总裁陈明永入选...
国联民生证券董事长顾伟入选“2... 瑞财经1月15日,由瑞财经推出的“2025年度证券行业十大杰出人物”榜单揭晓,国联民生证券董事长顾伟...
南昌第五医院甲状腺科江辉科普:... 甲亢甲亢,作为一种生活中频发的疾病,已成为常见的病症之一。根据一项流行病学调查的数据显示,我国甲亢的...
A股异动丨年度预亏,昆仑万维午... 昆仑万维(300418.SZ)午间收跌8.6%报56.95元,总市值715亿元。消息上,昆仑万维昨日...
当千问能帮你“一句话出游”时,... 千问(房煜摄) 1月15日,在阿里巴巴西溪园区的会议大厅,当两名淘宝闪购配送员提着40杯霸王茶姬走进...
国家电网“十五五”计划投资4万... 国家电网1月15日宣布,“十五五”期间公司固定资产投资预计达到4万亿元,较“十四五”投资增长40%,...
乘联会:12月车市“减速蓄势”... 在政策调整与市场博弈的双重影响下,2025年12月全国乘用车市场迎来年末收官。尽管受以旧换新补贴退坡...
青岛国恩股份通过港交所聆讯,青... 齐鲁晚报·齐鲁壹点记者 尚青龙 日前,青岛国恩科技股份有限公司通过港交所聆讯,向港股上市迈出关键一步...
共商产权市场发展大计 常修泽建... ■ 中国经济时报记者 刘慧 2026年1月13日,“十五五”产权市场高质量发展研讨会在江苏省常州市举...
银行股年内跌幅居首,结构性降息... 开年以来,A股市场整体表现回暖,但银行板块却未能延续此前涨势,走势明显偏弱。Wind数据显示,截至1...
鸣鸣很忙上市背后:万店连锁告别... ▲这是灵兽第1748篇原创文章 万店之后拼的不是胆量,而是效率优势。 作者/十里 ID/lingsh...
以价代税,中欧电动汽车博弈新起... 中欧电动汽车案“软着陆”,以最低进口价格替代“反补贴”税;具体价格形成方式将成为后续磋商的关键点 文...
4万亿投资创纪录,国家电网布局... 国家电网于1月15日公布,“十五五”时期的固定资产投资预计将达4万亿元,较“十四五”期间投资规模增长...
黄金价格飙升,银行保管箱“一箱... 在黄金价格持续走高的背景下,黄金投资与储备需求加剧,银行保管箱租赁业务随之火爆。 据中国证券报,记者...
原创 年... “突然剧烈头痛,像被重锤击中!”“一侧肢体麻木无力,说话也含糊不清……”这些可能是大脑发出的求救信号...