微信小程序之支付密码输入demo
在小程序中实现支付密码的输入,要解决几个问题:
1、小程序要想唤起键盘,必须要借助input控件。通过input控件和其属性focus来唤起和隐藏输入键盘。
2、要让input控件不可见。让光标和输入的字符都不可见,这里是把input控件定位到左边不可见范围。
先看实现后的效果图:

实现demo代码:
1、页面代码
<view catchtap='showInputLayer' class="btn_pay">立即支付</view>
<!-- 密码输入框 -->
<view wx:if='{{showPayPwdInput}}'>
<view class='bg_layer'></view>
<view class='input_main'>
<view class='input_title'>
<view class='input_back' catchtap='hidePayLayer'><text></text></view>
<text>输入支付密码</text>
</view>
<view class='input_tip'><text>使用会员卡余额支付需要验证身份,验证通过后才可进行支付。</text></view>
<view class='input_row' catchtap='getFocus'>
<view class='pwd_item' wx:for='{{6}}' wx:key='item' wx:for-index='i'>
<text wx:if='{{pwdVal.length>i}}'></text>
</view>
</view>
<view class='forget_pwd' catchtap='hidePayLayer'>忘记密码</view>
<input class='input_control' password type='number' focus='{{payFocus}}' bindinput='inputPwd' maxlength='6'/>
</view>
</view>
2、js代码
//index.js
//获取应用实例
const app = getApp() Page({
data: {
showPayPwdInput: false, //是否展示密码输入层
pwdVal: '', //输入的密码
payFocus: true, //文本框焦点
},
onLoad: function () {
this.showInputLayer();
},
/**
* 显示支付密码输入层
*/
showInputLayer: function(){
this.setData({ showPayPwdInput: true, payFocus: true });
},
/**
* 隐藏支付密码输入层
*/
hidePayLayer: function(){ var val = this.data.pwdVal; this.setData({ showPayPwdInput: false, payFocus: false, pwdVal: '' }, function(){
wx.showToast({
title: val,
})
}); },
/**
* 获取焦点
*/
getFocus: function(){
this.setData({ payFocus: true });
},
/**
* 输入密码监听
*/
inputPwd: function(e){
this.setData({ pwdVal: e.detail.value }); if (e.detail.value.length >= 6){
this.hidePayLayer();
}
}
})
3、样式
.btn_pay{
margin: 100rpx auto; width: 600rpx; height: 100rpx; line-height: 100rpx; border-radius: 100rpx;
background-color: #d3a95a; color: #fff; font-size: 36rpx; text-align: center;
}
/* 支付密码css start */
.bg_layer{
position: fixed; left:; top:; bottom:; right:;
background-color: rgba(0, 0, 0, 0.6); z-index:;
}
.input_main{
position: fixed; left:; bottom: 500rpx; width: 100%; height: 394rpx;
background-color: #fff; z-index:;
}
.input_title{
width: 100%; height: 90rpx; line-height: 90rpx; text-align: center;
font-size: 32rpx; border-bottom: 1rpx solid #e2e2e2;
}
.input_back{
position: absolute; left:; top:;
width: 80rpx; height: 90rpx; display: flex; justify-content: center; align-items: center;
}
.input_back text{
width: 20rpx;
height: 20rpx;
background-color: white;
border: 1rpx solid #aaa;
border-width: 5rpx 0 0 5rpx;
transform: rotate(-45deg);
}
.input_tip{ margin: 30rpx; font-size: 24rpx; color: #888; }
/* 密码掩码模拟 */
.input_row{
width: 690rpx; margin: 0 auto; height: 98rpx; position: relative;
display: flex; align-items: center; border: 1rpx solid #e2e2e2; border-radius: 20rpx;
}
.input_row .pwd_item{
flex:; display: flex; align-items: center; justify-content: center;
height: 100%; border-right: 1rpx solid #e2e2e2; position: relative;
}
.pwd_item:nth-last-of-type(1) { border-right:; }
.pwd_item text {
width: 30rpx; height: 30rpx; border-radius: 30rpx; background-color: #555;
}
.forget_pwd{
float: right; margin: 30rpx; width: 100rpx; text-align: right; font-size: 24rpx; color: #ff7800;
}
/* 文本输入框位置: 设置到左边隐藏 */
.input_control {
position: relative; left: -300rpx; bottom:; width: 100rpx; height: 100rpx;
}
DEMO地址:https://github.com/xiaotanit/Tan_PayPwdInput
微信小程序之支付密码输入demo的更多相关文章
- 【微信小程序】支付过程详解
一.介绍 今天跟大家分享微信小程序集成支付. 二.分析 1.小程序支付API 地址:https://mp.weixin.qq.com/debug/wxadoc/dev/api/api-pay.html ...
- 微信小程序篇(微信小程序的支付)
微信小程序的支付和微信公众号的支付是类似的,对比起来还比公众号支付简单了一些,我们只需要调用微信的统一下单接口获取prepay_id之后我们在调用微信的支付即可. 今天我们来封装一般node的支付接口 ...
- 微信小程序在线支付功能使用总结
最近需要在微信小程序中用到在线支付功能,于是看了一下官方的文档,发现要在小程序里实现微信支付还是很方便的,如果你以前开发过服务号下的微信支付,那么你会发现其实小程序里的微信支付和服务号里的开发过程如出 ...
- 微信小程序的支付流程
一.前言 微信小程序为电商类小程序,提供了非常完善.优秀.安全的支付功能 在小程序内可调用微信的API完成支付功能,方便.快捷 场景如下图所示: 用户通过分享或扫描二维码进入商户小程序,用户选择购买, ...
- 微信小程序发起支付流程
小程序调起支付API 需要参数 邮件中参数 API参数名 详细说明 APPID appid appid是微信小程序后台APP的唯一标识,在小程序后台申请小程序账号后,微信会自动分配对应的appid,用 ...
- 微信小程序tips集合:无法输入文字/随时查看页面/元素审查/点击事件/数据绑定
1:编辑文档无法输入文字 出现这种情况一般是因为之前编辑的文档未保存,所有在其他文档输入的时候会自动输入到未保存的文档中,在文档暂时编辑完毕后要ctrl+s随手保存,不然会出现无法打字情况 2: 随时 ...
- 微信小程序之最简单的Demo设计使用
这个小Demo,代码量不多:导航样式.View.Text.点击.JS交互的使用,主要是理解每个后缀文件的功能,然后才能更好的使用开发.......(下面代码和源代码没差别,实在想要的请留言,谢谢... ...
- 微信小程序实现支付功能
小程序支付,没有封装支付代码:直接上一段可用的流程代码吧:微信小程序支付官网文档有详细的说明,这里我就不再赘述啦:客户端js: wx.request({ url:'https://www.xxxx.c ...
- java微信小程序调用支付接口(转)
简介:微信小程序支付这里的坑还是有的,所以提醒各位在编写的一定要注意!!! 1.首先呢,你需要准备openid,appid,还有申请微信支付后要设置一个32位的密钥,需要先生成一个sign,得到pre ...
随机推荐
- 使用Excel VBA编程将网点的百度坐标转换后标注到高德地图上
公司网点表存储的坐标是百度坐标,现需要将网点位置标注到高德地图上,研究了一下高德地图的云图数据模版 http://lbs.amap.com/yuntu/reference/cloudstorage和坐 ...
- hello1源代码分析
hello.java: package javaeetutorial.hello1; //这是一个java包 import javax.enterprise.context.RequestScoped ...
- java容器-Map
Map:基本思想是映射表(维护键-值对),HashMap,TreeMap,LinkedHashMap,ConcurrentHashMap等都是基于Map接口实现的map容器,他们特性不同,表现在效率, ...
- 分布式协调服务Zookeeper集群搭建
分布式协调服务Zookeeper集群搭建 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.安装jdk环境 1>.操作环境 [root@node101.yinzhengjie ...
- PLSQL Developer安装与配置
前言 PLSQL Developer软件以及需要的配置 链接:https://pan.baidu.com/s/1xHdAl1RAgtQb-oDHPah19w 密码:x41k 1 安装 解压这两个压缩包 ...
- PMP知识点(二)——三点估算的两种方法对活动持续时间估算的影响和如何取舍
一.准备工作 活动持续时间的估算属于PMBOK中第六章项目时间管理中第五节6.6估算活动持续时间的内容. 三点估算是6.5和7.2(估算成本)中应用到的一种工具和技术.数据流向图参考如下: 其应用到的 ...
- MySql的Communications link failure解决办法
在使用JDBC连接mysql时可能会遇到以下错误: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications li ...
- Java JPS找不到正在执行的java进程 jps cannot see running java process
最近磁盘进展,把临时目录/tmp给全删了,结果发现jps的输出为空,找不到正在运行的jvm进程. 但是新建的进程没有问题,能够正常查看: [root@node-master ~]# ps -e|gre ...
- 背景上实现阴影——linear-gradient
/*从元素顶部有条阴影,两种方式,第二种更好,能控制阴影的宽度*/background-image: linear-gradient(0deg, rgba(226, 226, 226, 0) 97%, ...
- SpringMVC+Apache Shiro+JPA(hibernate)案例教学(四)基于Shiro验证用户权限,且给用户授权
最新项目比较忙,写文章的精力就相对减少了,但看到邮箱里的几个催更,还是厚颜把剩下的文档补上. 一.修改ShiroDbRealm类,实现它的doGetAuthorizationInfo方法 packag ...