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

  }

}

相关内容

热门资讯

蜻蜓订购APP贵金属订购非法期...   蜻蜓订购APP以"投资平台"名义对外宣传,主打贵金属期货(订购)交易。该平台一方面强调自身"正规...
悟空订购APP非法期货交易欺骗...   近期,有投资者反映,“悟空订购APP”等平台以白银、贵金属订购为名,宣传所谓“高收益”“低门槛”...
小赢淘金APP期货投资骗局,平...   “小赢淘金”之流,最擅长的就是用“注册送现金”、“充值返券”的糖衣炮弹来引流。别天真地以为那是福...
八方淘金APP非法期货交易欺骗...   警惕!八方生财、每日淘金、小赢淘金、悟空订购、蜻蜓订购、斗金订购等APP均涉嫌非法期货交易!  ...
智易购APP贵金属订购交易骗局...   很多人看到“3元起投”“充值送福利”“操作简单”“随时提现”这类宣传,很容易把智易购APP当成普...
喜玛银庄APP商品订购投资骗局...   喜玛银庄APP白银、铂金“现货订购”骗局警示:无资质平台涉嫌非法期货交易,投资者爆仓后如何维权?...
吉鑫乐享APP炒贵金属订购交易...   近期,多名投资者反映在“吉鑫乐享APP”进行贵金属投资时遭遇严重亏损,甚至血本无归。看似正规的“...
易掘金APP虚假期货投资骗局,...   “易掘金”的APP它打着“高收益、灵活投资”的旗号,宣称通过“商品订购”就能轻松赚钱,吸引了不少...
在大吉订购APP订购交易亏损被...   近期,不少投资者反映在“大吉订购App”上投资白银、铂金等商品遭遇严重亏损。该平台宣称提供现货订...
铂银壹号APP商品订购交易亏损...   许多中小投资者误以为网上的“商品现货订购”是合规合法的理财渠道,殊不知这背后隐藏着巨大的合规风险...
兴鑫淘金APP贵金属订购交易亏...   白银、贵金属或其他商品类投资,除国家批准的正规期货交易场所及持牌期货公司外,市面上大量第三方交易...
铂银掘金APP无资质的违规平台...   铂银掘金等平台的投资者,往往是被“注册送现金”“充值返现券”“首单免亏”等广告话术吸引,进而下载...
八方淘金APP订购交易不合规,...   “八方淘金APP”“铂银掘金APP”“铂银壹号APP”等软件被指以“现货订购”为名,实际采用高杠...
在指尖订购APP订购商品亏损被...   指尖订购APP这类平台,表面是“订购交易”,实则是披着电商外衣的非法期货陷阱。绝大多数投资者被蒙...
在犀贝易购APP做商品订购交易...   市面上打着“现货投资”“贵金属交易”旗号的APP并不少,但真正合规、受监管的平台并不多。犀贝易购...
易达淘金APP虚假商品订购交易...   易达淘金APP存在严重的虚假宣传与违规交易行为。该平台打着“商品订购”的旗号,实则通过不合规的交...
大浪淘金APP白银订购亏损被骗...   大浪淘金APP最隐蔽的套路,在于其完全封闭的内盘交易系统。表面上,它宣称与国际贵金属市场接轨;实...
一品好购APP上订购白银出现亏...   一品好购APP原名“一品订购”,运营方为上海宝智未来信息技术有限公司。近期不少投资者反映在该平台...
九州订购APP贵金属订购投资骗...   九州订购APP正通过抖.音、快手、今日头条等平台大量投放投资广告,用“5元起投”“充值返现”“0...
坚锅淘金APP交易软件并不正规...   当前,市面上大量所谓的“现货商城订购”交易软件,早已偏离了正常的实物商品买卖,演变为高杠杆、高手...