微信小程序 密码键盘 - 密码页面组件 (原生小程序代码)

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方 ...
随机推荐
- xcode代码提示没了
defaults write com.apple.dt.XCode IDEIndexDisable 0 https://www.jianshu.com/p/57a14bed9d1b
- 图->有向无环图->求关键路径
文字描述 与AOV-网相对应的是AOE-网(Activity on Edge)即边表示活动的网.AOE-网是一个带权的有向无环图.其中,顶点表示事件Event,弧表示活动,权表示活动持续的时间.通常, ...
- 常见web UI 元素操作 及API使用
1. 链接(Link) // 找到链接元素,这个方法比较直接,即通过超文本链接上的文字信息来定位元素,这种方式一般专门用于定位页面上的超文本链接 WebElement link1 = driver.f ...
- pandas 拆分groupby 应用某个函数apply 和聚合结果aggregate
https://www.jianshu.com/p/2d49cb87626b df.groupby('A').size()
- outlook2016用Exchange轻松绑定腾讯企业邮箱
系统版本:Win10 X64 1709 英文版 邮箱:Outlook2016 背景知识: 1.发送邮件均使用SMTP协议(SMTP 全称“Simple Mail Transfer Protocol”, ...
- 020-Json结构数据序列化异步传递
C#中将.Net对象序列化为Json字符串的方法: JavaScriptSerializer().Serialize(p),JavaScriptSerializer在System.Web.Extens ...
- Go 初体验 - 令人惊叹的语法 - defer.3 - defer 函数参数计算时机
defer 函数的参数计算时机 定义一个 defer 函数,接收参数 n: 调用: 输出: 有点惊讶,为什么不是 100 200 200? go 语言里,defer 函数的参数是在定义位置被计算的,也 ...
- Linux文件系统的硬连接和软连接
title: Linux文件系统的硬连接和软连接 date: 2018-02-06T20:26:25+08:00 tags: ["文件系统"] categories: [" ...
- 把vim插入状态的光标改为竖线
和终端有关系,如果是Konsole的终端,把下面两行加到.vimrc文件里就可以 let &t_SI = "\<Esc>]50;CursorShape=1\x7" ...
- k-means算法 - 数据挖掘算法(5)
(2017-05-02 银河统计) k-means算法,也被称为k-平均或k-均值,是数据挖掘技术中一种广泛使用的聚类算法. 它是将各个聚类子集内的所有数据样本的均值作为该聚类的代表点,算法的主要思想 ...