小程序 车牌输入
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;

  }

}

相关内容

热门资讯

28家企业排队,美妆IPO迎来... 沉寂三年后,美妆IPO重新热了起来。 2020年至2021年,是中国美妆企业上市的“黄金窗口”。贝泰...
原创 套... #格力第一大股东套现近 15.9 亿 #,格力电器正式发布减持结果公告,公司第一大股东珠海明骏(高瓴...
原创 昆... 6月23日,昆仑行机器人宣布,公司自2026年3月注册成立不足90天内,接连完成三轮融资,累计规模达...
心智观察所:从磷化铟的故事看中... 【文/观察者网 心智观察所 】 云南锗业的股价在2026年4月跑出了一波让人困惑的行情。 这家以锗为...
马云带着一群阿里合伙人,下田插... “马云带着一群阿里合伙人下田插秧,此次插秧团建的“同事们”阵容强大,吴泳铭、邵晓锋、蒋凡、吴泽明、蒋...
胖东来近半年累计销售额超139... 上证报中国证券网讯 6月22日晚,胖东来创始人于东来通过社交平台分享了集团近半年的经营情况。数据显示...
原创 帮... 达沃斯开幕+长川/卫星中报开门红:今天A股走“业绩提纯”,别蹭概念刀口舔血 老铁们,今天的早观察关键...
原创 腾... 原创首发 | 金角财经(ID: F-Jinjiao) 作者 | 田羽 “中国AMD”准备登陆A股了。...
于东来:胖东来拟制定夫妻或孩子... 来源:快科技 6月22日晚,胖东来创始人于东来通过个人账号“傻坏蛋于东来”透露多项员工福利升级计划。...
原创 纸... 作者 | 林洛栩 编辑 | 魏樊曦 6月18日,纸尿裤甲酰胺风波突然冲上热搜。 据《经济参考报》报道...
女子去世房贷逾期,银行起诉其子... 女子不幸去世,生前贷款57万元购买的房产开始逾期。银行将其儿子起诉至法院,提出在继承遗产范围内偿还贷...
4球-2球-4球-3球!姆巴佩... 姆巴佩距离“GOAT”还有多远?这是一个美加墨世界杯上无可避免的话题,有趣的是,这一距离似乎随着比赛...
原创 特... 文|两分钟 本文为深度观点解读,仅供交流学习 6月19日,美国总统特朗普在安德鲁斯联合基地的记者会公...
六旬老汉抱孙胳膊疼,庞继军不拍... 现代保健报讯:六十来岁的老汉,干了一辈子体力活。进了新城扶华诊所,见着庞继军就说:“我这脖子、肩膀、...
2026成都企业迎审融资:短期... 近期成都不少制造、工贸企业都卡在同一个关键节点:第三方验厂审核、银行授信、投资方现场尽调扎堆到来。但...
不断升级链博会“找朋友”模式 当“脱钩断链”的杂音不时泛起之际,第四届中国国际供应链促进博览会汇聚85个国家、地区及国际组织的67...
拼多多罕见买楼 活跃的自用型买... 观点网 全球总部也是靠租的拼多多,近期在雄安新区买了一栋办公楼。 6月21日消息,拼多多与中国电建旗...
SpaceX首发投资级债券,强... ,正在为市场对美国长端实际利率走高的判断提供新的佐证。这笔融资不仅折射出美国资本市场对超长期增长项目...