1.WXML页面

<view>
<!--<section class="mask" catchtap="canclePwd" wx:if="{{inputPwd}}"></section>-->
<section class="pwd-modal" catchtap="getFocus" >
<!-- <p class="close">X</p> -->
<!--<p class="title">输入查看密码</p>-->
<ul>
<li><i class="circle" wx:if="{{password.length >= 1}}"></i></li>
<li><i class="circle" wx:if="{{password.length >= 2}}"></i></li>
<li><i class="circle" wx:if="{{password.length >= 3}}"></i></li>
<li><i class="circle" wx:if="{{password.length >= 4}}"></i></li>
<li><i class="circle" wx:if="{{password.length >= 5}}"></i></li>
<li><i class="circle" wx:if="{{password.length >= 6}}"></i></li>
</ul>
<input ref="inputs" focus="{{isFocus}}" type="number" maxlength="6" bindinput="pwd" value="{{password}}"/>
</section> <view class="submit" bindtap="submit">确定</view>
</view>

2.WXSS

.mask {
position: fixed;
top: 0;
left: 0;
min-height: 100%;
width: 100%;
background: rgba(0, 0, 0, 0.5);
z-index: 10;
} .pwd-modal {
/*position: fixed;*/
/*top: 258rpx;*/
/*left: 54rpx;*/
/*right: 54rpx;*/
/*height: 504rpx;*/
padding-top: 50rpx;
background: white;
z-index: 99;
border-radius: 8rpx;
text-align: center;
} ul {
display: flex;
margin: 94rpx 38rpx 104rpx;
}
.submit{
position: fixed;
bottom: 0;
left: 0;
right: 0;
height:98rpx;
background:rgba(253,49,49,1);
box-shadow:0px -4px 6px 0px rgba(0,0,0,0.02);
color: #FFFFFF;
text-align: center;
line-height: 98rpx;
color: #FFFFFF;
font-size: 34rpx;
}
ul li {
width: 100%;
height: 96rpx;
line-height: 94rpx;
border: 1rpx solid #ececeb;
border-right: 0 none;
box-sizing: border-box;
text-align: center;
font-size: 0;
} ul li:last-of-type {
border-right: 1rpx solid #ececeb;
} ul li .circle {
display: inline-block;
vertical-align: middle;
width: 50rpx;
height: 50rpx;
border-radius: 50%;
background: black;
} input {
text-indent: -9999rpx;
margin-left: -9999rpx;
opacity: 0;
}

3.JS

//index.js
//获取应用实例
const app = getApp() Page({
data: {
password: '',
isFocus: false,
inputPwd: true,
inputNum: 0,
passwordFirst: '',
passwordTwo: '',
},
pwd(e) {
console.log(666)
console.log(e.detail.value)
console.log(666)
let reg = /[^\d]/g
let mobile = e.detail.value.replace(reg, '')
this.setData({
password: mobile
})
return mobile
},
getFocus() {
this.setData({
isFocus: true
})
},
onLoad: function () {
console.log(this.data.password.length)
},
submit(){
let that = this
if (that.data.password.length == 6) {
if (that.data.inputNum == 0) {
that.data.passwordFirst = that.data.password
that.data.inputNum = 1
wx.setNavigationBarTitle({
title: '再次输入密码',
})
that.setData({
password: '',
isFocus: false,
inputPwd: true,
})
} else if (that.data.inputNum == 1){
that.data.passwordTwo = that.data.password
if (that.data.passwordFirst == that.data.passwordTwo) {
// 传that.data.passwordTwo为支付密码
wx.showToast({
title: '设置成功',
icon: 'success',
success: function (res) {
wx.navigateBack({
delta: 1
})
}
}) } else {
wx.showToast({
title: '两次输入密码不同,请重新输入',
icon: 'none',
})
wx.setNavigationBarTitle({
title: '设置支付密码',
})
that.setData({
password: '',
isFocus: false,
inputPwd: true,
inputNum: 0,
passwordFirst: '',
passwordTwo: ''
})
return false
}
}
}
}, })

微信小程序 密码键盘 - 密码页面组件 (原生小程序代码)的更多相关文章

  1. 微信小程序富文本渲染组件html2wxml及html2wxml代码块格式化在ios下字体过大问题

    1.组件使用: 之前微信小程序的富文本渲染组件用的wxParse,对普通富文本确实可以,但是对于代码格式pre标签则无法使用. 下面这个html2wxml很不错,可以支持代码高亮. 详细文档:http ...

  2. 微信小程序开发 [02] 页面注册和基本组件

    1.页面注册 既然我们希望跳转到新的页面,那自然要新建页面相关的文件才行.在开篇已经讲过,一个小程序页面由四个文件组成,假如我们的页面名为welcome,那么这四个文件则是: welcome.js w ...

  3. 微信小程序 基本介绍及组件

    创建项目 微信开发工具深入介绍 https://developers.weixin.qq.com/miniprogram/dev/devtools/devtools.html 基本项目目录 1. 配置 ...

  4. 微信小程序自定义导航栏组件,完美适配所有手机,可实现各种功能和情况

    背景 在做小程序时,关于默认导航栏,我们遇到了以下的问题: Android.IOS 手机对于页面 title 的展示不一致,安卓 title 的显示不居中 页面的 title 只支持纯文本级别的样式控 ...

  5. 微信小程序开发—快速掌握组件及API的方法

    微信小程序框架为开发者提供了一系列的组件和API接口. 组件主要完成小程序的视图部分,例如文字.图片显示.API主要完成逻辑功能,例如网络请求.数据存储.音视频播放控制,以及微信开放的微信登录.微信支 ...

  6. 微信小程序开发—快速掌握组件及API的方法---转载

    微信小程序框架为开发者提供了一系列的组件和API接口. 组件主要完成小程序的视图部分,例如文字.图片显示.API主要完成逻辑功能,例如网络请求.数据存储.音视频播放控制,以及微信开放的微信登录.微信支 ...

  7. [小程序开发] 微信小程序audio音频播放组件+api_wx.createAudioContext

    引言: audio是微信小程序中的音频组件,可以轻松实现小程序中播放/停止音频等自定义动作. 附上微信小程序audio组件的相关属性说明:https://mp.weixin.qq.com/debug/ ...

  8. 微信小程序详解——页面之间的跳转方式【路由】和参数传递

    微信小程序拥有web网页和Application共同的特征,我们的页面都不是孤立存在的,而是通过和其他页面进行交互,来共同完成系统的功能.今天我们来研究小程序页面之间的跳转方式. 1.先导 在Andr ...

  9. 完整微信小程序授权登录页面教程

    完整微信小程序授权登录页面教程 1.前言 微信官方对getUserInfo接口做了修改,授权窗口无法直接弹出,而取而代之是需要创建一个button,将其open-type属性绑定getUseInfo方 ...

随机推荐

  1. UCloud首尔机房整体热迁移是这样炼成的

    小结: 1.把两个机房在逻辑上变成一个机房: 2.新老机房的后端服务使用同一套 ZooKeeper,但是配置的却是不同的 IP: 3.UCloud内部服务所使用的数据库服务为MySQL, 内部MySQ ...

  2. tomcat配置内存

    windows: Create a new script named as setenv.bat under TOMCAT_HOME/bin folder holding the following ...

  3. WebDriver API--元素定位

    WebDriver属于Selenium体系中设计出来操作浏览器的一套API, 站在WebDriver的角度, 因为它针对多种编程语言都实现了一遍这套API,所以它可以支持多种编程语言: 站在编程语言的 ...

  4. 3、jeecg 笔记之 模糊查询

    1.前言 jeecg 考虑到默认模糊查询的话,会增加系统压力,导致查询慢,本来系统就挺那啥的... 2.方式一之实体赋值 实体重新赋值查询,用 * %% * 实现,我们知道 sql 中通常使用 % 去 ...

  5. Python3学习之路~5.11 configparser模块

    用于生成和修改常见配置文档,当前模块的名称在 python 2.x 版本中为 ConfigParser, python 3.x 版本中变更为 configparser. 来看一个好多软件的常见文档格式 ...

  6. vue -about

    j基于webpack4 搭建vue 环境:https://juejin.im/post/5bc30d5fe51d450ea1328877

  7. Kafka实践1--Producer

    一.Kafka设计原理参考: http://blog.csdn.net/suifeng3051/article/details/48053965?locationNum=2 http://www.cn ...

  8. 原生JavaScript写select下拉选择后跳转页面

    <select name="molsel_oprate" onchange="javascript:var obj = event.target; var inde ...

  9. Hive为什么要启用Metastore?

    转载来自: https://blog.csdn.net/qq_40990732/article/details/80914873 https://blog.csdn.net/tp15868352616 ...

  10. 69A

    #include <stdio.h> int main() { int n; int sum1=0, sum2=0, sum3=0; int x, y, z; scanf("%d ...