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. [daily][python2] int型IP地址与string型IP地址互转

    使用python2,类似如下操作. >>> import socket >>> import struct >>> socket.ntohl(]) ...

  2. TP框架中分页类的使用

    public function test(){ $m=M('Message'); import('ORG.Util.Page');// 导入分页类 $count = $m->count();// ...

  3. ios dispatch_async使用

    一般这样使用: dispatch_async(dispatch_get_global_queue(0, 0),^{ //进入另一个线程 dispatch_async(dispatch_get_main ...

  4. Py之set操作【转载】

    转自:https://blog.csdn.net/business122/article/details/7541486 1.python的set和其他语言类似, 是一个无序不重复元素集, 基本功能包 ...

  5. 非CI执行Allure2 trends空白问题

    问题描述 未使用CI工具集成Aluure运行测试用例并生成Allure报告,多次执行后,trends是空白的,未展示出期望的趋势图 问题原因非CI工具,是通过命令 allure serve 展示报告 ...

  6. 微信OpenID获取

    用户要求在微信端登录一次后,以后不需要再登录.  我的系统是单独的一个网站. 使用MVC的记住密码功能, 如果用户重启,就还是要输入密码,所以需要有一个唯一不变的用来标示用户的ID.  OpenID就 ...

  7. pageresponse.min.js自动缩放页面改写

    /* * 名称 :移动端响应式框架 * 作者 :白树 http://peunzhang.cnblogs.com * 版本 :v2.1 * 日期 :2015.10.13 * 兼容 :ios 5+.and ...

  8. python assert断言函数

    python assert断言是声明布尔值必须为真的判定,如果发生异常就说明表达式为假. 可以理解assert断言语句为raise-if-not,用来测试表示式,其返回值为假,就会触发异常. self ...

  9. ltp-ddt makefile的思考

    ltp-ddt env.sh export PATH=/opt/gcc-linaro--2018.05-x86_64_arm-linux-gnueabihf/bin:$PATH export CROS ...

  10. TPS54331 TPS54332 3.5V to 28V Input, 3A, 570kHz Step-Down Converter with Eco-mode

    The TPS54331 is a 28-V, 3-A non-synchronous buck converter that integrates a low RDS(on) high side M ...