input-password.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <view class="page">
  3. <view>
  4. <view class="pay-title">
  5. <text>{{$t('enter.b3')}}</text>
  6. </view>
  7. <view class="pay-password">
  8. <view class="list" v-for="item in 6">
  9. <text v-show="passwordArr.length >= item">●</text>
  10. </view>
  11. </view>
  12. <navigator url="/pages/user/set/transaction">
  13. <view class="hint">
  14. <text>忘记支付密码?</text>
  15. </view>
  16. </navigator>
  17. </view>
  18. <cc-defineKeyboard ref="CodeKeyboard" passwrdType="pay" @KeyInfo="KeyInfo" :viewShow="true"></cc-defineKeyboard>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. data() {
  24. return {
  25. passwordArr: []
  26. };
  27. },
  28. mounted() {
  29. this.$refs.CodeKeyboard.show();
  30. },
  31. // 关闭循环
  32. methods: {
  33. // 点击触发支付事件
  34. KeyInfo(val) {
  35. console.log(val);
  36. let arr = this.passwordArr;
  37. if (val.index >= 6) {
  38. return;
  39. }
  40. // 判断是否输入的是删除键
  41. if (val.keyCode === 8) {
  42. // 删除最后一位
  43. arr.splice(val.index + 1, 1)
  44. }
  45. // 判断是否输入的是取消案件
  46. else if (val.keyCode == 190) {
  47. this.colsePayPassword();
  48. // 输入.无效
  49. } else {
  50. arr.push(val.key);
  51. }
  52. // 开始交易
  53. if (arr.length == 6) {
  54. this.$emit('commit',this.passwordArr.join(''))
  55. //初始化对象
  56. this.passwordArr = [];
  57. }
  58. },
  59. },
  60. };
  61. </script>
  62. <style lang="scss">
  63. $base: orangered; // 基础颜色
  64. .page {
  65. width: 100%;
  66. background-color: #FFFFFF;
  67. .pay-title {
  68. display: flex;
  69. align-items: center;
  70. justify-content: center;
  71. width: 100%;
  72. height: 200rpx;
  73. text {
  74. font-size: 28rpx;
  75. color: #555555;
  76. }
  77. }
  78. .pay-password {
  79. display: flex;
  80. align-items: center;
  81. width: 90%;
  82. height: 80rpx;
  83. margin: 20rpx auto;
  84. border: 2rpx solid $base;
  85. .list {
  86. display: flex;
  87. align-items: center;
  88. justify-content: center;
  89. width: 16.666%;
  90. height: 100%;
  91. border-right: 2rpx solid #EEEEEE;
  92. text {
  93. font-size: 32rpx;
  94. }
  95. }
  96. .list:nth-child(6) {
  97. border-right: none;
  98. }
  99. }
  100. .hint {
  101. display: flex;
  102. align-items: center;
  103. justify-content: center;
  104. width: 100%;
  105. height: 100rpx;
  106. text {
  107. font-size: 28rpx;
  108. color: $base;
  109. }
  110. }
  111. }
  112. </style>