小程序模板平台_vue完成键盘输入支付密码功用

日期:2021-01-08 类型:科技新闻 

关键词:微信公众号平台小程序,微信打分小程序,小程序发布,小程序大全,微信小程序编程

vue实现键盘输入支付密码功能       这篇文章主要为大家详细介绍了vue实现键盘输入支付密码功能,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文实例为大家分享了vue实现键盘输入支付密码功能的具体代码,供大家参考,具体内容如下

支付密码功能界面如下图:

主要代码如下:

 template 
 div 
 div 
 span @click="backHandle" /span strong 请输入交易密码 /strong 
 /div 
 div 
 div 
 div v-for="i in items" span v-if="password[i]" /span /div 
 /div 
 div router-link to="/getP" 忘记密码? /router-link /div 
 /div 
 div 
 li @click="keyUpHandle($event)" v-for="val in keys" 
 {{ val }}
 /li 
 li @click="delHandle" span /span /li 
 /ul 
 /div 
 /div 
 /template 
 script 
 const keys = () = [1, 2, 3, 4, 5, 6, 7, 8, 9, '', 0]
 // let sendFlag = true // 防止重复发送密码
 export default {
 data () {
 return {
 items: [0, 1, 2, 3, 4, 5],
 keys: keys(),
 password: []
 methods: {
 backHandle () {
 this.clearPasswordHandle() // 返回时清除password
 this.$emit('backFnc') // 返回上级
 keyUpHandle (e) {
 let text = e.currentTarget.innerText
 let len = this.password.length
 if (!text || len = 6) return
 this.password.push(text)
 this.ajaxData()
 delHandle () {
 if (this.password.length = 0) return false
 this.password.shift()
 ajaxData () {
 if (this.password.length = 6) {
 console.log(parseInt(this.password.join(' ').replace(/\s/g, '')))
 return false
 clearPasswordHandle: function () {
 this.password = []
 /script 
 style lang="less" scoped 
 .pay-tool {
 position: relative;
 height: 18.rem;
 background-color: #fff;
 overflow: hidden;
 -title {
 width: 100%;
 height: 2.rem;
 padding: 0 0.8rem;
 line-height: 2.rem;
 text-align: center;
 overflow: hidden;
 .icon {
 float: left;
 margin-top: 0.rem;
 strong {
 font-size: 0.8rem;
 -content {
 .pay-tool-inputs {
 width: 14.rem;
 height: 2.rem;
 margin: 1.rem auto 0;
 border: 1px solid #b9b9b9;
 border-radius: 0.rem;
 box-shadow: 0 0 1px #e6e6e6;
 display: flex;
 .item {
 width: 16.%;
 height: 2.rem;
 border-right: 1px solid #b9b9b9;
 line-height: 2.rem;
 text-align: center;
 :last-child {
 border-right: none;
 .icon_dot {
 display: inline-block;
 width: 0.rem;
 height: 0.rem;
 background: url("../../assets/images/icon_dot.png") no-repeat;
 background-size: cover;
 .pay-tool-link {
 padding: 0.rem 0.8rem 0;
 text-align: right;
 .link {
 font-size: 0.rem;
 color: #3c8cfb;
 .pay-tool-keyboard {
 position: absolute;
 left: 0;
 bottom: 0;
 width: 100%;
 ul {
 width: 100%;
 display: flex;
 flex-wrap: wrap;
 li {
 width: 33.3333%;
 height: 2.rem;
 line-height: 2.rem;
 text-align: center;
 border-right: 1px solid #aeaeae;
 border-bottom: 1px solid #aeaeae;
 font-size: 0.8rem;
 font-weight: bold;
 :nth-child(1), :nth-child(2), :nth-child(3) {
 border-top: 1px solid #eee;
 :nth-child(3), :nth-child(6), :nth-child(9), :nth-child(12) {
 border-right: none;
 :nth-child(10), :nth-child(11), :nth-child(12) {
 border-bottom: none;
 :nth-child(10), :nth-child(12), :active {
 background-color: #d1d4dd;
 :nth-child(12):active {
 background-color: #fff;
 /style 

注意:页面使用rem布局,根html的font-size为45px。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持凡科。