c语言如何自动填写验证码,小程序 自带样式的验证码自动填入

一、业务场景:像ios手机上的获取到验证码,,会在键盘上显示,点击,会自动填入到输入框里面;这时候输入框是一个input还好,,他会自动填入,但是现在要求是验证码的6位数字是分开的,原生的一个input不能实现,所以,数字用6个view来实现,这样验证码需要经过一些列处理,才会填入到6个view里面;

二、实现:

wxml:

{{code.length>=1?code[index]:""}}

js:

data:{

code: '', // 验证码

codeLength: 6, // 验证码的长度

type: 'number',

isPass: false, // input的属性password,没有用到吧

isFocus: true // 是否聚焦

}

方法:

focusBox() {

console.log("聚焦")

this.setData({

isFocus: true

})

},

blurFn() {

console.log("失焦")

this.setData({

isFocus: false

})

}

inputPhoneNum(e){

console.log(e.detail.value) // 输入的数字

}

css:光标闪烁的是模拟的光标,详见动画

.indentify-code{

display: flex;

justify-content: space-around;

border-bottom: 1px solid #999;

}

.indentify-code>block{

border: 1px solid #999;

}

.indentify-code .code-box{

width: 80rpx;

height: 80rpx;

line-height: 80rpx;

/* border: 1px solid #999;

border-radius: 20rpx; */

text-align: center;

}

.realCode{

width: 0rpx;

height: 0px;

}

.shining{

width: 2rpx;

/* border: 1rpx solid #588DED; */

background: #588DED;

height: 60rpx;

animation: shining 1s linear infinite;

margin: 0 auto;

margin-top: 10rpx;

}

@keyframes shining {

0%,100% {

opacity: 0

}

50% {

opacity: 1

}

}

效果这样:那个光标是闪烁的

556d16d1b45bea5c166b986cc1f19bec.png

发现这样有一个bug,就是聚焦之后,键盘弹起,然后自动灭屏之后,又打开屏幕,依然是聚焦状态,但是键盘调不起来,失焦也失焦不了,看了其他的这样的小程序也是有同样问题?????

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值