微信小程序 密码键盘 - 密码页面组件 (原生小程序代码)
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
- }
- }
- }
- },
- })
微信小程序 密码键盘 - 密码页面组件 (原生小程序代码)的更多相关文章
- 微信小程序富文本渲染组件html2wxml及html2wxml代码块格式化在ios下字体过大问题
1.组件使用: 之前微信小程序的富文本渲染组件用的wxParse,对普通富文本确实可以,但是对于代码格式pre标签则无法使用. 下面这个html2wxml很不错,可以支持代码高亮. 详细文档:http ...
- 微信小程序开发 [02] 页面注册和基本组件
1.页面注册 既然我们希望跳转到新的页面,那自然要新建页面相关的文件才行.在开篇已经讲过,一个小程序页面由四个文件组成,假如我们的页面名为welcome,那么这四个文件则是: welcome.js w ...
- 微信小程序 基本介绍及组件
创建项目 微信开发工具深入介绍 https://developers.weixin.qq.com/miniprogram/dev/devtools/devtools.html 基本项目目录 1. 配置 ...
- 微信小程序自定义导航栏组件,完美适配所有手机,可实现各种功能和情况
背景 在做小程序时,关于默认导航栏,我们遇到了以下的问题: Android.IOS 手机对于页面 title 的展示不一致,安卓 title 的显示不居中 页面的 title 只支持纯文本级别的样式控 ...
- 微信小程序开发—快速掌握组件及API的方法
微信小程序框架为开发者提供了一系列的组件和API接口. 组件主要完成小程序的视图部分,例如文字.图片显示.API主要完成逻辑功能,例如网络请求.数据存储.音视频播放控制,以及微信开放的微信登录.微信支 ...
- 微信小程序开发—快速掌握组件及API的方法---转载
微信小程序框架为开发者提供了一系列的组件和API接口. 组件主要完成小程序的视图部分,例如文字.图片显示.API主要完成逻辑功能,例如网络请求.数据存储.音视频播放控制,以及微信开放的微信登录.微信支 ...
- [小程序开发] 微信小程序audio音频播放组件+api_wx.createAudioContext
引言: audio是微信小程序中的音频组件,可以轻松实现小程序中播放/停止音频等自定义动作. 附上微信小程序audio组件的相关属性说明:https://mp.weixin.qq.com/debug/ ...
- 微信小程序详解——页面之间的跳转方式【路由】和参数传递
微信小程序拥有web网页和Application共同的特征,我们的页面都不是孤立存在的,而是通过和其他页面进行交互,来共同完成系统的功能.今天我们来研究小程序页面之间的跳转方式. 1.先导 在Andr ...
- 完整微信小程序授权登录页面教程
完整微信小程序授权登录页面教程 1.前言 微信官方对getUserInfo接口做了修改,授权窗口无法直接弹出,而取而代之是需要创建一个button,将其open-type属性绑定getUseInfo方 ...
随机推荐
- JavaScript面向对象之get和set设置读写属性
之前我们通过this和prototype申明的属性都是可读写的属性,如果想实现单独控制,就必须使用get和set存取期. 基本方法的 步骤一般包含两个步骤,1,使用var关键字定义一个私有属性作为中间 ...
- kickstart ---无人值守安装
kickstart 实战 http://man.linuxde.net/download/CentOS_6_9镜像 安装: 关闭防火墙 且在编辑虚拟网络的vnet8中要取消使用本地dhcp项 1.yu ...
- Win10部署IIS 10.0
win10自带IIS10.0 控制面板 >> 程序 >>启用或关闭Windows功能 勾选完之后会安装IIS,安装完成后 计算机管理 >> 服务和应用程序 > ...
- 浅谈Java中的关键字
谈到final关键字,想必很多人都不陌生,在使用匿名内部类的时候可能会经常用到final关键字.另外,Java中的String类就是一个final类,那么今天我们就来了解final这个关键字的用法. ...
- docker+httpd的安装
docker pull docker.io/httpd //直接这么运行会报“没有conf/httpd.cong这个文件” docker run -d --name httpd2. -p : -p : ...
- java框架之SpringCloud(6)-Zuul路由网关
介绍 Zuul 包含了对请求的路由和过滤两个最重要的功能: 其中路由功能服务将外部请求转发到具体的微服务实例上,是实现外部访问统一入口的基础.而过滤的功能则负责对请求的处理过程进行干预,是实现请求校验 ...
- vue-cli 搭建的项目,无法用本地IP访问
项目是用vue-cli搭建的,是基于移动端的,需要在手机上测试的时候发现用ip访问不了,用localhost是可以访问的,网上查资料的解决办法(此为Mac机子的解决办法): 在config文件里面的i ...
- VC++运行库 集32位/64位整合版
运行程序时,win7/win10(x86和x64)常会遇到缺少什么缺少msvc***.dll问题 安装下面链接提供的程序,安装后,便可解决. [2016-10-10]Microsoft Visual ...
- C#中的装箱(inboxing)和拆箱(unboxing)(简单理解)
装箱和拆箱是值类型和引用类型之间相互转换是要执行的操作. 装箱:将一个值类型隐式地转换成一个object类型,或把这个值类型转换成一个被该值类型应用的接口类型,把一个值类型的值装箱,就是创建一个ob ...
- configparser配置文件处理
创建一个configparser格式的文档: import configparser config = configparser.ConfigParser()config["DEFAULT& ...