设计支付密码的输入框

效果如下:

源码:github地址:https://github.com/fiveTree/-_-

干货:

<view class="pay">
<view class="title">支付方式</view>
<view catchtap="wx_pay" class="wx_pay">
<i class="icon {{payment_mode==1?'active':''}}" type="String"></i>
<text>微信支付</text>
</view>
<view catchtap="offline_pay" class="offline_pay">
<i class="icon {{payment_mode==0?'active':''}}" type="String"></i>
<text>对公打款</text>
</view>
<block wx:if="{{balance!=0}}">
<view catchtap="wallet_pay" class="wallet_pay">
<i class="icon {{payment_mode==2?'active':''}}" type="String"></i>
<text>钱包支付(余额:{{balance/100}}元)</text>
</view>
</block>
<block wx:if="{{balance==0}}">
<view class="wallet_pay">
<i class="icon" type="String" style="background:#e8e8e8;border:none;"></i>
<text style="color:#999">钱包支付(余额不足)</text>
</view>
</block>
</view>
<view catchtap="pay" class="save">确定</view>
<!--输入钱包密码-->
<view wx:if="{{wallets_password_flag}}" class="wallets-password">
<view class="input-content-wrap">
<view class="top">
<view catchtap="close_wallets_password" class="close">×</view>
<view class="txt">请输入支付密码</view>
<view catchtap="modify_password" class="forget">忘记密码</view>
</view>
<view class="actual_fee">
<span>¥</span>
<text>{{actual_fee/100}}</text>
</view>
<view catchtap="set_Focus" class="input-password-wrap">
<view class="password_dot">
<i wx:if="{{wallets_password.length>=1}}"></i>
</view>
<view class="password_dot">
<i wx:if="{{wallets_password.length>=2}}"></i>
</view>
<view class="password_dot">
<i wx:if="{{wallets_password.length>=3}}"></i>
</view>
<view class="password_dot">
<i wx:if="{{wallets_password.length>=4}}"></i>
</view>
<view class="password_dot">
<i wx:if="{{wallets_password.length>=5}}"></i>
</view>
<view class="password_dot">
<i wx:if="{{wallets_password.length>=6}}"></i>
</view>
</view>
</view>
<input bindinput="set_wallets_password" class="input-content" password type="number" focus="{{isFocus}}" maxlength="6" />
</view>

  1. //index.js
  2.  
  3. Page({
  4. data: {
  5. payment_mode: 1,//默认支付方式 微信支付
  6. isFocus: false,//控制input 聚焦
  7. balance:100,//余额
  8. actual_fee:20,//待支付
  9. wallets_password_flag:false//密码输入遮罩
  10. },
  11. //事件处理函数
  12.  
  13. onLoad: function () {
  14.  
  15. },
  16. wx_pay() {//转换为微信支付
  17. this.setData({
  18. payment_mode: 1
  19. })
  20. },
  21. offline_pay() {//转换为转账支付
  22. this.setData({
  23. payment_mode: 0
  24. })
  25. },
  26. wallet_pay() {
  27. this.setData({//转换为钱包支付
  28. payment_mode: 2
  29. })
  30. },
  31. set_wallets_password(e) {//获取钱包密码
  32. this.setData({
  33. wallets_password: e.detail.value
  34. });
  35. if (this.data.wallets_password.length == 6) {//密码长度6位时,自动验证钱包支付结果
  36. wallet_pay(this)
  37. }
  38. },
  39. set_Focus() {//聚焦input
  40. console.log('isFocus', this.data.isFocus)
  41. this.setData({
  42. isFocus: true
  43. })
  44. },
  45. set_notFocus() {//失去焦点
  46. this.setData({
  47. isFocus: false
  48. })
  49. },
  50. close_wallets_password () {//关闭钱包输入密码遮罩
  51. this.setData({
  52. isFocus: false,//失去焦点
  53. wallets_password_flag: false,
  54. })
  55. },
  56. pay() {//去支付
  57. pay(this)
  58. }
  59. })
  60. /*-----------------------------------------------*/
  61. /*支付*/
  62. function pay(_this) {
  63. let apikey = _this.data.apikey;
  64. let id = _this.data.id;
  65. let payment_mode = _this.data.payment_mode
  66. if (payment_mode == 1) {
  67. // 微信支付
  68. // 微信自带密码输入框
  69. console.log('微信支付')
  70. } else if (payment_mode == 0) {
  71. // 转账支付 后续跳转至传转账单照片
  72. console.log('转账支付')
  73. } else if (payment_mode == 2) {
  74. // 钱包支付 输入密码
  75. console.log('钱包支付')
  76. _this.setData({
  77. wallets_password_flag: true,
  78. isFocus: true
  79. })
  80. }
  81.  
  82. }
  83. // 钱包支付
  84. function wallet_pay(_this) {
  85. console.log('钱包支付请求函数')
  86. /*
  87. 1.支付成功
  88. 2.支付失败:提示;清空密码;自动聚焦isFocus:true,拉起键盘再次输入
  89. */
  90. }

index.wxss

  1. page {
  2. height: 100%;
  3. width: 100%;
  4. background: #e8e8e8;
  5. }
  6.  
  7. page .pay {
  8. display: flex;
  9. flex-direction: column;
  10. background: #fff;
  11. }
  12.  
  13. page .pay .title {
  14. height: 90rpx;
  15. line-height: 90rpx;
  16. font-size: 28rpx;
  17. color: #353535;
  18. padding: 0 23rpx;
  19. border-bottom: 1rpx solid #ddd;
  20. box-sizing: border-box;
  21. }
  22.  
  23. page .pay .wx_pay, page .pay .offline_pay, page .pay .wallet_pay {
  24. margin: 0 26rpx;
  25. height: 90rpx;
  26. line-height: 90rpx;
  27. border-bottom: 2rpx solid #ddd;
  28. box-sizing: border-box;
  29. display: flex;
  30. align-items: center;
  31. justify-content: flex-start;
  32. }
  33.  
  34. page .pay .wx_pay .icon, page .pay .offline_pay .icon,
  35. page .pay .wallet_pay .icon {
  36. width: 34rpx;
  37. height: 34rpx;
  38. border: 2rpx solid #ddd;
  39. box-sizing: border-box;
  40. border-radius: 50%;
  41. }
  42.  
  43. page .pay .wx_pay .icon.active, page .pay .offline_pay .icon.active,
  44. page .pay .wallet_pay .icon.active {
  45. border: 10rpx solid #00a2ff;
  46. }
  47.  
  48. page .pay .wx_pay text, page .pay .offline_pay text, page .pay .wallet_pay text {
  49. margin-left: 20rpx;
  50. color: #353535;
  51. font-size: 26rpx;
  52. }
  53.  
  54. page .pay .wallet_pay {
  55. border:;
  56. border-top: 2rpx solid #ddd;
  57. }
  58.  
  59. page .pay .offline_pay {
  60. border: 0 none;
  61. }
  62.  
  63. page .save {
  64. margin: 80rpx 23rpx;
  65. color: #fff;
  66. background: #00a2ff;
  67. height: 88rpx;
  68. line-height: 88rpx;
  69. text-align: center;
  70. font-size: 30rpx;
  71. border-radius: 10rpx;
  72. }
  73.  
  74. page .wallets-password {
  75. position: absolute;
  76. left:;
  77. top:;
  78. width: 100%;
  79. height: 100%;
  80. background: rgba(0, 0, 0, 0.6);
  81. }
  82.  
  83. page .wallets-password .input-content-wrap {
  84. position: absolute;
  85. top: 200rpx;
  86. left: 50%;
  87. display: flex;
  88. flex-direction: column;
  89. width: 600rpx;
  90. margin-left: -300rpx;
  91. background: #fff;
  92. border-radius: 20rpx;
  93. }
  94.  
  95. page .wallets-password .input-content-wrap .top {
  96. display: flex;
  97. align-items: center;
  98. height: 90rpx;
  99. border-bottom: 2rpx solid #ddd;
  100. justify-content: space-around;
  101. }
  102.  
  103. page .wallets-password .input-content-wrap .top .close {
  104. font-size: 44rpx;
  105. color: #999;
  106. font-weight:;
  107. }
  108.  
  109. page .wallets-password .input-content-wrap .top .forget {
  110. color: #00a2ff;
  111. font-size: 22rpx;
  112. }
  113.  
  114. page .wallets-password .input-content-wrap .actual_fee {
  115. display: flex;
  116. align-items: center;
  117. justify-content: center;
  118. color: #000;
  119. height: 100rpx;
  120. margin: 0 23rpx;
  121. border-bottom: 2rpx solid #ddd;
  122. }
  123.  
  124. page .wallets-password .input-content-wrap .actual_fee span {
  125. font-size: 24rpx;
  126. }
  127.  
  128. page .wallets-password .input-content-wrap .actual_fee text {
  129. font-size: 36rpx;
  130. }
  131.  
  132. page .wallets-password .input-content-wrap .input-password-wrap {
  133. display: flex;
  134. align-items: center;
  135. justify-content: center;
  136. height: 150rpx;
  137. }
  138.  
  139. page .wallets-password .input-content-wrap .input-password-wrap .password_dot {
  140. display: flex;
  141. align-items: center;
  142. justify-content: center;
  143. text-align: center;
  144. color: #000;
  145. box-sizing: border-box;
  146. width: 90rpx;
  147. height: 90rpx;
  148. border: 2rpx solid #ddd;
  149. border-left: none 0;
  150. }
  151.  
  152. page .wallets-password .input-content-wrap .input-password-wrap .password_dot:nth-child(1) {
  153. border-left: 2rpx solid #ddd;
  154. }
  155.  
  156. page .wallets-password .input-content-wrap .input-password-wrap .password_dot i {
  157. background: #000;
  158. border-radius: 50%;
  159. width: 20rpx;
  160. height: 20rpx;
  161. }
  162.  
  163. page .wallets-password .input-content {
  164. position: absolute;
  165. opacity:;
  166. left: -100%;
  167. top: 600rpx;
  168. background: #f56;
  169. z-index: -999;
  170. }
  171.  
  172. page .wallets-password .input-content.active {
  173. z-index: -99;
  174. }

github地址:https://github.com/fiveTree/-_-

微信小程序---密码输入的更多相关文章

  1. Taro -- 微信小程序密码弹窗

    记录一个类似支付密码的弹窗写法,实现是否免密功能.如图: index.js   import Taro, { Component } from '@tarojs/taro'   import { Vi ...

  2. 微信小程序-输入框输入文字后,将光标移到文字中间,接着输入文字后光标又自动跳到最后

    问题描述: input输入框输入一段文字后,将光标移到文字中间,接着输入文字后光标又自动跳到最后去了. 原因: input事件中,给input框绑定任何事件后,在处理事件时 setData之后就会让光 ...

  3. WordPress版微信小程序2.1.5版发布

    WordPress版微信小程序功能已经基本完善,利用这套程序,搭配WordPress提供的rest api,WordPress网站的站长可以快速搭建属于自己的网站微信小程序 . WordPress版微 ...

  4. 微信小程序-form表单-获取用户输入文本框的值

    微信小程序-form表单-获取用户输入文本框的值 <input name='formnickname' class="textarea" placeholder=" ...

  5. 微信小程序tips集合:无法输入文字/随时查看页面/元素审查/点击事件/数据绑定

    1:编辑文档无法输入文字 出现这种情况一般是因为之前编辑的文档未保存,所有在其他文档输入的时候会自动输入到未保存的文档中,在文档暂时编辑完毕后要ctrl+s随手保存,不然会出现无法打字情况 2: 随时 ...

  6. 微信小程序 获得用户输入内容

    在微信小程序里,如何获得用户输入的内容?? js: document.getElementById("Content").value jq:$("#Content&quo ...

  7. 微信小程序车牌号码模拟键盘输入

    微信小程序车牌号码模拟键盘输入练习, 未经允许,禁止转载,抄袭,如需借鉴参考等,请附上该文章连接. 相关资料参考:https://blog.csdn.net/littlerboss/article/d ...

  8. 微信小程序怎么获取用户输入

    能够获取用户输入的组件,需要使用组件的属性bindchange将用户的输入内容同步到 AppService. <input id="myInput" bindchange=& ...

  9. 微信小程序开发系列五:微信小程序中如何响应用户输入事件

    微信小程序开发系列教程 微信小程序开发系列一:微信小程序的申请和开发环境的搭建 微信小程序开发系列二:微信小程序的视图设计 微信小程序开发系列三:微信小程序的调试方法 微信小程序开发系列四:微信小程序 ...

随机推荐

  1. Mac下安装SecureCRT客户端并激活

    1. 先下载SecureCRT和破解文件 默认下载到了当前用户的”下载”目录中 2. 在”Finder”中 打开 “scrt-7.3.0-657.osx_x64.dmg” 并将 SecureCRT复制 ...

  2. 【转帖】linux下的各个目录的含义

    linux下的各个目录的含义 http://embeddedlinux.org.cn/emb-linux/entry-level/200809/22-85.html/bin/usr/local/bin ...

  3. oracle:archiver error. Connect internal only, until freed 原因以及错误的处理方法

    今天小编遇到这个数据原因,通过查找资料解决了,问题原因就是数据默认存储日志的文件夹满了 1.首先通过cmd命令窗口连接超级管理员,sqlplus / as sysdba; 2.查询db_recover ...

  4. 第十三章 字符串 (四)之Scanner类

    一.Scanner简述 Scanner扫描器类本质上是由正则表达式实现的,可以接受任何能产生数据的数据源对象,默认以空白符进行分词(包括\n等),使用各种next方法进行扫描匹配,获取匹配的数据. 二 ...

  5. 我的第一个Java博客

    1.2019 11.23 Alone in Beijing;

  6. 今天测试大商创,遇到了 upstream sent too big header while reading response header from upstream

    今天在测试大商创后台系统时,打开店铺结算,查看店铺对应的订单列表时,该列表自动跳转到502,查看线上和测试环境都能正常打开,唯独我的电脑上打开是502, 查询nginx的error.log日志,记录了 ...

  7. Springboot导出Excel并下载

    引入相关依赖 <!--数据导出excel--> <!-- https://mvnrepository.com/artifact/org.apache.poi/poi --> & ...

  8. 【IntelliJ IDEA】快捷键

    1.System.out.println();的快捷方法 sout然后Alt+Enter或者直接点 2.idea上 重写父类方法的快捷键 Ctrl+O之后,在弹出的上面选择要重写的方法 3.idea ...

  9. C#实现鼠标滚筒缩放界面的效果

    elementCanvas继承UserControl 声明属性: #region 缩放属性添加 float ratio = 1.0f; public float Ratio { set { ratio ...

  10. 手把手教你搭建FastDFS集群(上)

    手把手教你搭建FastDFS集群(上) 本文链接:https://blog.csdn.net/u012453843/article/details/68957209        FastDFS是一个 ...