微信小程序之支付密码输入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 ...
随机推荐
- linux查看主板型号、CPU、显卡、硬盘等信息
系统 uname -a # 查看内核/操作系统/CPU信息 head -n 1 /etc/issue # 查看操作系统版本 cat /proc/cpuinfo # 查看CPU信息 hostname # ...
- java 打印空心菱形的两种实现
第一种实现方式: //打印给定行数的空心菱形 public static void draw(int size){ if (size % 2 == 0) //如果是偶数行变为奇数 { size++; ...
- python中的图像数据库PIL
from PIL import Image im = Image.open("图片路径") im.function() 常用的函数: 1.im.crop(x,y,x1,y1) 对图 ...
- dsp实验一 常见问题教程
1.选择合适阅读材料:卖油翁.将进酒,等. 2.录音设备三选一:某种电脑声卡+线上convert/楼月mp3录音软件+格式工厂(我选的)/Matlab (注:这是目前已知的方法,我只用了第二个) 3. ...
- Django unittest 单元测试
这里就不再介绍单元测试的作用了. 首先单元测试的创建方式有两种,一种是app下面的test文件,另一种是自定义方式创建 方法一.使用test.py文件测试 from django.test impor ...
- Java基础11-List;Set;Map
作业解析: remove(int index); //删除指定位置的元素 List list = new ArrayList(); list.add("s1"); list.add ...
- 基于WebGL/Threejs技术的BIM模型轻量化之图元合并
伴随着互联网的发展,从桌面端走向Web端.移动端必然的趋势.互联网技术的兴起极大地改变了我们的娱乐.生活和生产方式.尤其是HTML5/WebGL技术的发展更是在各个行业内引起颠覆性的变化.随着WebG ...
- ABP core学习之二 IIS部署.NET CORE
本文是关于IIS部署.NET CORE的总结,以后有碰到问题将陆续添加 IIS部署.NET CORE总结 一.服务器环境 首先确定自己项目的core版本,然后下载对应的包在服务器上安装 下载地址: h ...
- Allowed memory size of 134217728 bytes exhausted
错误信息: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65015808 bytes) 由于报错信息和数据库 ...
- 快速搭建Docker Registry私有仓库
前提条件: 服务器已经安装Docker(我的服务器是CentOS 7) 服务器已经安装Docker Compose 满足以上条件时就可以开始搭建了: 1. 生成用户密码文件:(运行下面命令后会在当前目 ...